- ASE loader alpha
- MDL loader stable - 3ds bugfixes, - API extensions - New viewer features - WIP - Support for C git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@11 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
14abdcbbed
commit
db9c5fef2b
5
README
5
README
|
@ -1,5 +0,0 @@
|
||||||
AssetImporter
|
|
||||||
---------------
|
|
||||||
To use the asset importer lbrary just compile it with visual-c++ 8.0 (at this
|
|
||||||
moment no other build enviroments are supported).
|
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the 3ds importer class */
|
/** @file Implementation of the 3ds importer class */
|
||||||
#include "3DSLoader.h"
|
#include "3DSLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
|
@ -207,48 +248,67 @@ void Dot3DSImporter::ConvertMaterial(Dot3DS::Material& oldMat,
|
||||||
}
|
}
|
||||||
mat.AddProperty<int>( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL);
|
mat.AddProperty<int>( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
||||||
|
if (Dot3DS::Dot3DSFile::Wire == oldMat.mShading)
|
||||||
|
{
|
||||||
|
// set the wireframe flag
|
||||||
|
unsigned int iWire = 1;
|
||||||
|
mat.AddProperty<int>( (int*)&iWire,1,AI_MATKEY_ENABLE_WIREFRAME);
|
||||||
|
}
|
||||||
|
|
||||||
// texture, if there is one
|
// texture, if there is one
|
||||||
if( oldMat.sTexDiffuse.mMapName.length() > 0)
|
if( oldMat.sTexDiffuse.mMapName.length() > 0)
|
||||||
{
|
{
|
||||||
aiString tex;
|
aiString tex;
|
||||||
tex.Set( oldMat.sTexDiffuse.mMapName);
|
tex.Set( oldMat.sTexDiffuse.mMapName);
|
||||||
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
mat.AddProperty<float>( &oldMat.sTexDiffuse.mTextureBlend, 1, AI_MATKEY_TEXBLEND_DIFFUSE(0));
|
|
||||||
|
if (is_not_qnan(oldMat.sTexDiffuse.mTextureBlend))
|
||||||
|
mat.AddProperty<float>( &oldMat.sTexDiffuse.mTextureBlend, 1, AI_MATKEY_TEXBLEND_DIFFUSE(0));
|
||||||
}
|
}
|
||||||
if( oldMat.sTexSpecular.mMapName.length() > 0)
|
if( oldMat.sTexSpecular.mMapName.length() > 0)
|
||||||
{
|
{
|
||||||
aiString tex;
|
aiString tex;
|
||||||
tex.Set( oldMat.sTexSpecular.mMapName);
|
tex.Set( oldMat.sTexSpecular.mMapName);
|
||||||
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_SPECULAR(0));
|
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_SPECULAR(0));
|
||||||
mat.AddProperty<float>( &oldMat.sTexSpecular.mTextureBlend, 1, AI_MATKEY_TEXBLEND_SPECULAR(0));
|
|
||||||
|
if (is_not_qnan(oldMat.sTexSpecular.mTextureBlend))
|
||||||
|
mat.AddProperty<float>( &oldMat.sTexSpecular.mTextureBlend, 1, AI_MATKEY_TEXBLEND_SPECULAR(0));
|
||||||
}
|
}
|
||||||
if( oldMat.sTexOpacity.mMapName.length() > 0)
|
if( oldMat.sTexOpacity.mMapName.length() > 0)
|
||||||
{
|
{
|
||||||
aiString tex;
|
aiString tex;
|
||||||
tex.Set( oldMat.sTexOpacity.mMapName);
|
tex.Set( oldMat.sTexOpacity.mMapName);
|
||||||
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_OPACITY(0));
|
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_OPACITY(0));
|
||||||
mat.AddProperty<float>( &oldMat.sTexOpacity.mTextureBlend, 1,AI_MATKEY_TEXBLEND_OPACITY(0));
|
|
||||||
|
if (is_not_qnan(oldMat.sTexOpacity.mTextureBlend))
|
||||||
|
mat.AddProperty<float>( &oldMat.sTexOpacity.mTextureBlend, 1,AI_MATKEY_TEXBLEND_OPACITY(0));
|
||||||
}
|
}
|
||||||
if( oldMat.sTexEmissive.mMapName.length() > 0)
|
if( oldMat.sTexEmissive.mMapName.length() > 0)
|
||||||
{
|
{
|
||||||
aiString tex;
|
aiString tex;
|
||||||
tex.Set( oldMat.sTexEmissive.mMapName);
|
tex.Set( oldMat.sTexEmissive.mMapName);
|
||||||
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_EMISSIVE(0));
|
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_EMISSIVE(0));
|
||||||
mat.AddProperty<float>( &oldMat.sTexEmissive.mTextureBlend, 1, AI_MATKEY_TEXBLEND_EMISSIVE(0));
|
|
||||||
|
if (is_not_qnan(oldMat.sTexEmissive.mTextureBlend))
|
||||||
|
mat.AddProperty<float>( &oldMat.sTexEmissive.mTextureBlend, 1, AI_MATKEY_TEXBLEND_EMISSIVE(0));
|
||||||
}
|
}
|
||||||
if( oldMat.sTexBump.mMapName.length() > 0)
|
if( oldMat.sTexBump.mMapName.length() > 0)
|
||||||
{
|
{
|
||||||
aiString tex;
|
aiString tex;
|
||||||
tex.Set( oldMat.sTexBump.mMapName);
|
tex.Set( oldMat.sTexBump.mMapName);
|
||||||
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_BUMP(0));
|
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_HEIGHT(0));
|
||||||
mat.AddProperty<float>( &oldMat.sTexBump.mTextureBlend, 1, AI_MATKEY_TEXBLEND_BUMP(0));
|
|
||||||
|
if (is_not_qnan(oldMat.sTexBump.mTextureBlend))
|
||||||
|
mat.AddProperty<float>( &oldMat.sTexBump.mTextureBlend, 1, AI_MATKEY_TEXBLEND_HEIGHT(0));
|
||||||
}
|
}
|
||||||
if( oldMat.sTexShininess.mMapName.length() > 0)
|
if( oldMat.sTexShininess.mMapName.length() > 0)
|
||||||
{
|
{
|
||||||
aiString tex;
|
aiString tex;
|
||||||
tex.Set( oldMat.sTexShininess.mMapName);
|
tex.Set( oldMat.sTexShininess.mMapName);
|
||||||
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_SHININESS(0));
|
mat.AddProperty( &tex, AI_MATKEY_TEXTURE_SHININESS(0));
|
||||||
mat.AddProperty<float>( &oldMat.sTexBump.mTextureBlend, 1, AI_MATKEY_TEXBLEND_SHININESS(0));
|
|
||||||
|
if (is_not_qnan(oldMat.sTexShininess.mTextureBlend))
|
||||||
|
mat.AddProperty<float>( &oldMat.sTexShininess.mTextureBlend, 1, AI_MATKEY_TEXBLEND_SHININESS(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the name of the material itself, too
|
// store the name of the material itself, too
|
||||||
|
@ -267,7 +327,7 @@ void SetupMatUVSrc (aiMaterial* pcMat, const Dot3DS::Material* pcMatIn)
|
||||||
pcHelper->AddProperty<int>(&pcMatIn->sTexDiffuse.iUVSrc,1,AI_MATKEY_UVWSRC_DIFFUSE(0));
|
pcHelper->AddProperty<int>(&pcMatIn->sTexDiffuse.iUVSrc,1,AI_MATKEY_UVWSRC_DIFFUSE(0));
|
||||||
pcHelper->AddProperty<int>(&pcMatIn->sTexSpecular.iUVSrc,1,AI_MATKEY_UVWSRC_SPECULAR(0));
|
pcHelper->AddProperty<int>(&pcMatIn->sTexSpecular.iUVSrc,1,AI_MATKEY_UVWSRC_SPECULAR(0));
|
||||||
pcHelper->AddProperty<int>(&pcMatIn->sTexEmissive.iUVSrc,1,AI_MATKEY_UVWSRC_EMISSIVE(0));
|
pcHelper->AddProperty<int>(&pcMatIn->sTexEmissive.iUVSrc,1,AI_MATKEY_UVWSRC_EMISSIVE(0));
|
||||||
pcHelper->AddProperty<int>(&pcMatIn->sTexBump.iUVSrc,1,AI_MATKEY_UVWSRC_BUMP(0));
|
pcHelper->AddProperty<int>(&pcMatIn->sTexBump.iUVSrc,1,AI_MATKEY_UVWSRC_HEIGHT(0));
|
||||||
pcHelper->AddProperty<int>(&pcMatIn->sTexShininess.iUVSrc,1,AI_MATKEY_UVWSRC_SHININESS(0));
|
pcHelper->AddProperty<int>(&pcMatIn->sTexShininess.iUVSrc,1,AI_MATKEY_UVWSRC_SHININESS(0));
|
||||||
pcHelper->AddProperty<int>(&pcMatIn->sTexOpacity.iUVSrc,1,AI_MATKEY_UVWSRC_OPACITY(0));
|
pcHelper->AddProperty<int>(&pcMatIn->sTexOpacity.iUVSrc,1,AI_MATKEY_UVWSRC_OPACITY(0));
|
||||||
}
|
}
|
||||||
|
@ -331,14 +391,16 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
|
||||||
p_pcOut->mNumVertices = aiSplit[p].size()*3;
|
p_pcOut->mNumVertices = aiSplit[p].size()*3;
|
||||||
p_pcOut->mNumFaces = aiSplit[p].size();
|
p_pcOut->mNumFaces = aiSplit[p].size();
|
||||||
|
|
||||||
|
// allocate enough storage for faces
|
||||||
|
p_pcOut->mFaces = new aiFace[p_pcOut->mNumFaces];
|
||||||
iFaceCnt += p_pcOut->mNumFaces;
|
iFaceCnt += p_pcOut->mNumFaces;
|
||||||
|
|
||||||
if (p_pcOut->mNumVertices != 0)
|
if (p_pcOut->mNumVertices != 0)
|
||||||
{
|
{
|
||||||
p_pcOut->mVertices = new aiVector3D[p_pcOut->mNumVertices];
|
p_pcOut->mVertices = new aiVector3D[p_pcOut->mNumVertices];
|
||||||
p_pcOut->mNormals = new aiVector3D[p_pcOut->mNumVertices];
|
p_pcOut->mNormals = new aiVector3D[p_pcOut->mNumVertices];
|
||||||
unsigned int iBase = 0;
|
unsigned int iBase = 0;
|
||||||
|
|
||||||
p_pcOut->mFaces = new aiFace[p_pcOut->mNumFaces];
|
|
||||||
for (unsigned int q = 0; q < aiSplit[p].size();++q)
|
for (unsigned int q = 0; q < aiSplit[p].size();++q)
|
||||||
{
|
{
|
||||||
unsigned int iIndex = aiSplit[p][q];
|
unsigned int iIndex = aiSplit[p][q];
|
||||||
|
@ -617,8 +679,8 @@ void Dot3DSImporter::BakeScaleNOffset(
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
||||||
{
|
{
|
||||||
pcMesh->mTextureCoords[0][i].x *= pcSrc->pcSingleTexture->mScaleU;
|
pcMesh->mTextureCoords[0][i].x /= pcSrc->pcSingleTexture->mScaleU;
|
||||||
pcMesh->mTextureCoords[0][i].y *= pcSrc->pcSingleTexture->mScaleV;
|
pcMesh->mTextureCoords[0][i].y /= pcSrc->pcSingleTexture->mScaleV;
|
||||||
|
|
||||||
pcMesh->mTextureCoords[0][i].x += pcSrc->pcSingleTexture->mOffsetU;
|
pcMesh->mTextureCoords[0][i].x += pcSrc->pcSingleTexture->mOffsetU;
|
||||||
pcMesh->mTextureCoords[0][i].y += pcSrc->pcSingleTexture->mOffsetV;
|
pcMesh->mTextureCoords[0][i].y += pcSrc->pcSingleTexture->mOffsetV;
|
||||||
|
@ -630,8 +692,8 @@ void Dot3DSImporter::BakeScaleNOffset(
|
||||||
const float fCos = cosf(pcSrc->pcSingleTexture->mRotation);
|
const float fCos = cosf(pcSrc->pcSingleTexture->mRotation);
|
||||||
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
||||||
{
|
{
|
||||||
pcMesh->mTextureCoords[0][i].x *= pcSrc->pcSingleTexture->mScaleU;
|
pcMesh->mTextureCoords[0][i].x /= pcSrc->pcSingleTexture->mScaleU;
|
||||||
pcMesh->mTextureCoords[0][i].y *= pcSrc->pcSingleTexture->mScaleV;
|
pcMesh->mTextureCoords[0][i].y /= pcSrc->pcSingleTexture->mScaleV;
|
||||||
|
|
||||||
pcMesh->mTextureCoords[0][i].x *= fCos;
|
pcMesh->mTextureCoords[0][i].x *= fCos;
|
||||||
pcMesh->mTextureCoords[0][i].y *= fSin;
|
pcMesh->mTextureCoords[0][i].y *= fSin;
|
||||||
|
@ -694,8 +756,8 @@ void Dot3DSImporter::BakeScaleNOffset(
|
||||||
{
|
{
|
||||||
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n)
|
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n)
|
||||||
{
|
{
|
||||||
pcMesh->mTextureCoords[iCnt][n].x = pvBase->x * (*i).fScaleU;
|
pcMesh->mTextureCoords[iCnt][n].x = pvBase->x / (*i).fScaleU;
|
||||||
pcMesh->mTextureCoords[iCnt][n].y = pvBase->y * (*i).fScaleV;
|
pcMesh->mTextureCoords[iCnt][n].y = pvBase->y / (*i).fScaleV;
|
||||||
|
|
||||||
pcMesh->mTextureCoords[iCnt][n].x += (*i).fOffsetU;
|
pcMesh->mTextureCoords[iCnt][n].x += (*i).fOffsetU;
|
||||||
pcMesh->mTextureCoords[iCnt][n].y += (*i).fOffsetV;
|
pcMesh->mTextureCoords[iCnt][n].y += (*i).fOffsetV;
|
||||||
|
@ -709,8 +771,8 @@ void Dot3DSImporter::BakeScaleNOffset(
|
||||||
const float fCos = cosf((*i).fRotation);
|
const float fCos = cosf((*i).fRotation);
|
||||||
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n)
|
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n)
|
||||||
{
|
{
|
||||||
pcMesh->mTextureCoords[iCnt][n].x = pvBase->x * (*i).fScaleU;
|
pcMesh->mTextureCoords[iCnt][n].x = pvBase->x / (*i).fScaleU;
|
||||||
pcMesh->mTextureCoords[iCnt][n].y = pvBase->y * (*i).fScaleV;
|
pcMesh->mTextureCoords[iCnt][n].y = pvBase->y / (*i).fScaleV;
|
||||||
|
|
||||||
pcMesh->mTextureCoords[iCnt][n].x *= fCos;
|
pcMesh->mTextureCoords[iCnt][n].x *= fCos;
|
||||||
pcMesh->mTextureCoords[iCnt][n].y *= fSin;
|
pcMesh->mTextureCoords[iCnt][n].y *= fSin;
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the 3ds importer class */
|
/** @file Implementation of the 3ds importer class */
|
||||||
#include "3DSLoader.h"
|
#include "3DSLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
|
@ -14,7 +55,6 @@ using namespace Assimp;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
|
void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
|
||||||
{
|
{
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
// First generate face normals
|
// First generate face normals
|
||||||
sMesh->mNormals.resize(sMesh->mPositions.size(),aiVector3D());
|
sMesh->mNormals.resize(sMesh->mPositions.size(),aiVector3D());
|
||||||
for( unsigned int a = 0; a < sMesh->mFaces.size(); a++)
|
for( unsigned int a = 0; a < sMesh->mFaces.size(); a++)
|
||||||
|
@ -29,17 +69,12 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
|
||||||
aiVector3D pDelta1 = *pV2 - *pV1;
|
aiVector3D pDelta1 = *pV2 - *pV1;
|
||||||
aiVector3D pDelta2 = *pV3 - *pV1;
|
aiVector3D pDelta2 = *pV3 - *pV1;
|
||||||
aiVector3D vNor = pDelta1 ^ pDelta2;
|
aiVector3D vNor = pDelta1 ^ pDelta2;
|
||||||
|
|
||||||
//float fLength = vNor.Length();
|
|
||||||
//if (0.0f != fLength)vNor /= fLength;
|
|
||||||
|
|
||||||
|
|
||||||
sMesh->mNormals[face.i1] = vNor;
|
sMesh->mNormals[face.i1] = vNor;
|
||||||
sMesh->mNormals[face.i2] = vNor;
|
sMesh->mNormals[face.i2] = vNor;
|
||||||
sMesh->mNormals[face.i3] = vNor;
|
sMesh->mNormals[face.i3] = vNor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
// calculate the position bounds so we have a reliable epsilon to
|
// calculate the position bounds so we have a reliable epsilon to
|
||||||
// check position differences against
|
// check position differences against
|
||||||
// @Schrompf: This is the 6th time this snippet is repeated!
|
// @Schrompf: This is the 6th time this snippet is repeated!
|
||||||
|
@ -54,81 +89,48 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
|
||||||
maxVec.z = std::max( maxVec.z, sMesh->mPositions[a].z);
|
maxVec.z = std::max( maxVec.z, sMesh->mPositions[a].z);
|
||||||
}
|
}
|
||||||
const float posEpsilon = (maxVec - minVec).Length() * 1e-5f;
|
const float posEpsilon = (maxVec - minVec).Length() * 1e-5f;
|
||||||
|
|
||||||
|
|
||||||
std::vector<aiVector3D> avNormals;
|
std::vector<aiVector3D> avNormals;
|
||||||
avNormals.resize(sMesh->mNormals.size());
|
avNormals.resize(sMesh->mNormals.size());
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
// now generate the spatial sort tree
|
// now generate the spatial sort tree
|
||||||
D3DSSpatialSorter sSort(sMesh);
|
D3DSSpatialSorter sSort;
|
||||||
|
for( std::vector<Dot3DS::Face>::iterator
|
||||||
|
i = sMesh->mFaces.begin();
|
||||||
|
i != sMesh->mFaces.end();++i)
|
||||||
|
{
|
||||||
|
sSort.AddFace(&(*i),sMesh->mPositions);
|
||||||
|
}
|
||||||
|
sSort.Prepare();
|
||||||
|
|
||||||
for( std::vector<Dot3DS::Face>::iterator
|
for( std::vector<Dot3DS::Face>::iterator
|
||||||
i = sMesh->mFaces.begin();
|
i = sMesh->mFaces.begin();
|
||||||
i != sMesh->mFaces.end();++i)
|
i != sMesh->mFaces.end();++i)
|
||||||
{
|
{
|
||||||
std::vector<unsigned int> poResult;
|
std::vector<unsigned int> poResult;
|
||||||
// need to repeat the code for all three vertices of the triangle
|
|
||||||
|
|
||||||
// vertex 1
|
for (unsigned int c = 0; c < 3;++c)
|
||||||
sSort.FindPositions(sMesh->mPositions[(*i).i1],(*i).iSmoothGroup,
|
{
|
||||||
posEpsilon,poResult);
|
|
||||||
|
|
||||||
aiVector3D vNormals;
|
sSort.FindPositions(sMesh->mPositions[(*i).mIndices[c]],(*i).iSmoothGroup,
|
||||||
float fDiv = 0.0f;
|
posEpsilon,poResult);
|
||||||
for (std::vector<unsigned int>::const_iterator
|
|
||||||
a = poResult.begin();
|
aiVector3D vNormals;
|
||||||
a != poResult.end();++a)
|
float fDiv = 0.0f;
|
||||||
|
for (std::vector<unsigned int>::const_iterator
|
||||||
|
a = poResult.begin();
|
||||||
|
a != poResult.end();++a)
|
||||||
{
|
{
|
||||||
vNormals += sMesh->mNormals[(*a)];
|
vNormals += sMesh->mNormals[(*a)];
|
||||||
fDiv += 1.0f;
|
fDiv += 1.0f;
|
||||||
}
|
}
|
||||||
vNormals.x /= fDiv;
|
vNormals.x /= fDiv;
|
||||||
vNormals.y /= fDiv;
|
vNormals.y /= fDiv;
|
||||||
vNormals.z /= fDiv;
|
vNormals.z /= fDiv;
|
||||||
vNormals.Normalize();
|
vNormals.Normalize();
|
||||||
avNormals[(*i).i1] = vNormals;
|
avNormals[(*i).mIndices[c]] = vNormals;
|
||||||
poResult.clear();
|
poResult.clear();
|
||||||
|
|
||||||
// vertex 2
|
|
||||||
sSort.FindPositions(sMesh->mPositions[(*i).i2],(*i).iSmoothGroup,
|
|
||||||
posEpsilon,poResult);
|
|
||||||
|
|
||||||
vNormals = aiVector3D();
|
|
||||||
fDiv = 0.0f;
|
|
||||||
for (std::vector<unsigned int>::const_iterator
|
|
||||||
a = poResult.begin();
|
|
||||||
a != poResult.end();++a)
|
|
||||||
{
|
|
||||||
vNormals += sMesh->mNormals[(*a)];
|
|
||||||
fDiv += 1.0f;
|
|
||||||
}
|
|
||||||
vNormals.x /= fDiv;
|
|
||||||
vNormals.y /= fDiv;
|
|
||||||
vNormals.z /= fDiv;
|
|
||||||
vNormals.Normalize();
|
|
||||||
avNormals[(*i).i2] = vNormals;
|
|
||||||
poResult.clear();
|
|
||||||
|
|
||||||
// vertex 3
|
|
||||||
sSort.FindPositions(sMesh->mPositions[(*i).i3],(*i).iSmoothGroup,
|
|
||||||
posEpsilon ,poResult);
|
|
||||||
|
|
||||||
vNormals = aiVector3D();
|
|
||||||
fDiv = 0.0f;
|
|
||||||
for (std::vector<unsigned int>::const_iterator
|
|
||||||
a = poResult.begin();
|
|
||||||
a != poResult.end();++a)
|
|
||||||
{
|
|
||||||
vNormals += sMesh->mNormals[(*a)];
|
|
||||||
fDiv += 1.0f;
|
|
||||||
}
|
|
||||||
vNormals.x /= fDiv;
|
|
||||||
vNormals.y /= fDiv;
|
|
||||||
vNormals.z /= fDiv;
|
|
||||||
vNormals.Normalize();
|
|
||||||
avNormals[(*i).i3] = vNormals;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sMesh->mNormals = avNormals;
|
sMesh->mNormals = avNormals;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
155
code/3DSHelper.h
155
code/3DSHelper.h
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the helper data structures for importing XFiles */
|
/** @file Defines the helper data structures for importing XFiles */
|
||||||
#ifndef AI_3DSFILEHELPER_H_INC
|
#ifndef AI_3DSFILEHELPER_H_INC
|
||||||
#define AI_3DSFILEHELPER_H_INC
|
#define AI_3DSFILEHELPER_H_INC
|
||||||
|
@ -35,27 +75,30 @@ class Dot3DSFile
|
||||||
public:
|
public:
|
||||||
inline Dot3DSFile() {}
|
inline Dot3DSFile() {}
|
||||||
|
|
||||||
// data structure for a single chunk in a .3ds file
|
//! data structure for a single chunk in a .3ds file
|
||||||
struct Chunk
|
struct Chunk
|
||||||
{
|
{
|
||||||
unsigned short Flag;
|
unsigned short Flag;
|
||||||
long Size;
|
long Size;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
// source for this used own structures,
|
//! source for this used own structures,
|
||||||
// replaced it with out standard math helpers
|
//! replaced it with out standard math helpers
|
||||||
typedef aiMatrix3x3 MatTransform;
|
typedef aiMatrix3x3 MatTransform;
|
||||||
typedef aiVector3D MatTranslate;
|
typedef aiVector3D MatTranslate;
|
||||||
|
|
||||||
// Used for shading field in material3ds structure
|
//! Used for shading field in material3ds structure
|
||||||
// From AutoDesk 3ds SDK
|
//! From AutoDesk 3ds SDK
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Wire = 0,
|
Wire = 0,
|
||||||
Flat = 1,
|
Flat = 1,
|
||||||
Gouraud = 2,
|
Gouraud = 2,
|
||||||
Phong = 3,
|
Phong = 3,
|
||||||
Metal = 4
|
Metal = 4,
|
||||||
|
|
||||||
|
// required by the ASE loader
|
||||||
|
Blinn = 5
|
||||||
} shadetype3ds;
|
} shadetype3ds;
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -261,30 +304,38 @@ public:
|
||||||
/** Helper structure representing a 3ds mesh face */
|
/** Helper structure representing a 3ds mesh face */
|
||||||
struct Face
|
struct Face
|
||||||
{
|
{
|
||||||
Face() : iSmoothGroup(0), bDirection(true)
|
Face() : iSmoothGroup(0), bDirection(true), i1(0), i2(0), i3(0)
|
||||||
{
|
{
|
||||||
// let the rest uninitialized for performance
|
// let the rest uninitialized for performance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Indices. .3ds is using uint16. However, after
|
//! Indices. .3ds is using uint16. However, after
|
||||||
// an unique vrtex set has been geneerated it might
|
//! an unique vrtex set has been geneerated it might
|
||||||
// be an index becomes > 2^16
|
//! be an index becomes > 2^16
|
||||||
uint32_t i1;
|
union
|
||||||
uint32_t i2;
|
{
|
||||||
uint32_t i3;
|
struct
|
||||||
|
{
|
||||||
|
uint32_t i1;
|
||||||
|
uint32_t i2;
|
||||||
|
uint32_t i3;
|
||||||
|
};
|
||||||
|
uint32_t mIndices[3];
|
||||||
|
};
|
||||||
|
|
||||||
// specifies to which smoothing group the face belongs to
|
//! specifies to which smoothing group the face belongs to
|
||||||
uint32_t iSmoothGroup;
|
uint32_t iSmoothGroup;
|
||||||
|
|
||||||
// Direction the normal vector of the face
|
//! Direction the normal vector of the face
|
||||||
// will be pointing to
|
//! will be pointing to
|
||||||
bool bDirection;
|
bool bDirection;
|
||||||
};
|
};
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a texture */
|
/** Helper structure representing a texture */
|
||||||
struct Texture
|
struct Texture
|
||||||
{
|
{
|
||||||
|
//! Default constructor
|
||||||
Texture()
|
Texture()
|
||||||
:
|
:
|
||||||
mScaleU(1.0f),
|
mScaleU(1.0f),
|
||||||
|
@ -296,20 +347,20 @@ struct Texture
|
||||||
{
|
{
|
||||||
mTextureBlend = std::numeric_limits<float>::quiet_NaN();
|
mTextureBlend = std::numeric_limits<float>::quiet_NaN();
|
||||||
}
|
}
|
||||||
// Specifies the blending factor for the texture
|
//! Specifies the blending factor for the texture
|
||||||
float mTextureBlend;
|
float mTextureBlend;
|
||||||
|
|
||||||
// Specifies the filename of the texture
|
//! Specifies the filename of the texture
|
||||||
std::string mMapName;
|
std::string mMapName;
|
||||||
|
|
||||||
// Specifies texture coordinate offsets/scaling/rotations
|
//! Specifies texture coordinate offsets/scaling/rotations
|
||||||
float mScaleU;
|
float mScaleU;
|
||||||
float mScaleV;
|
float mScaleV;
|
||||||
float mOffsetU;
|
float mOffsetU;
|
||||||
float mOffsetV;
|
float mOffsetV;
|
||||||
float mRotation;
|
float mRotation;
|
||||||
|
|
||||||
// Used internally
|
//! Used internally
|
||||||
bool bPrivate;
|
bool bPrivate;
|
||||||
int iUVSrc;
|
int iUVSrc;
|
||||||
};
|
};
|
||||||
|
@ -317,6 +368,7 @@ struct Texture
|
||||||
/** Helper structure representing a 3ds material */
|
/** Helper structure representing a 3ds material */
|
||||||
struct Material
|
struct Material
|
||||||
{
|
{
|
||||||
|
//! Default constructor. Builds a default name for the material
|
||||||
Material()
|
Material()
|
||||||
:
|
:
|
||||||
mSpecularExponent (0.0f),
|
mSpecularExponent (0.0f),
|
||||||
|
@ -331,27 +383,32 @@ struct Material
|
||||||
ss << "%%_UNNAMED_" << iCnt++ << "_%%";
|
ss << "%%_UNNAMED_" << iCnt++ << "_%%";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name of the material
|
//! Name of the material
|
||||||
std::string mName;
|
std::string mName;
|
||||||
// Diffuse color of the material
|
//! Diffuse color of the material
|
||||||
aiColor3D mDiffuse;
|
aiColor3D mDiffuse;
|
||||||
// Specular exponent
|
//! Specular exponent
|
||||||
float mSpecularExponent;
|
float mSpecularExponent;
|
||||||
// Specular color of the material
|
//! Specular color of the material
|
||||||
aiColor3D mSpecular;
|
aiColor3D mSpecular;
|
||||||
// Ambient color of the material
|
//! Ambient color of the material
|
||||||
aiColor3D mAmbient;
|
aiColor3D mAmbient;
|
||||||
// Shading type to be used
|
//! Shading type to be used
|
||||||
Dot3DSFile::shadetype3ds mShading;
|
Dot3DSFile::shadetype3ds mShading;
|
||||||
// Opacity of the material
|
//! Opacity of the material
|
||||||
float mTransparency;
|
float mTransparency;
|
||||||
|
|
||||||
// Different texture channels
|
//! Diffuse texture channel
|
||||||
Texture sTexDiffuse;
|
Texture sTexDiffuse;
|
||||||
|
//! Opacity texture channel
|
||||||
Texture sTexOpacity;
|
Texture sTexOpacity;
|
||||||
|
//! Specular texture channel
|
||||||
Texture sTexSpecular;
|
Texture sTexSpecular;
|
||||||
|
//! Bump texture channel
|
||||||
Texture sTexBump;
|
Texture sTexBump;
|
||||||
|
//! Emissive texture channel
|
||||||
Texture sTexEmissive;
|
Texture sTexEmissive;
|
||||||
|
//! Shininess texture channel
|
||||||
Texture sTexShininess;
|
Texture sTexShininess;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -360,10 +417,10 @@ struct Material
|
||||||
*/
|
*/
|
||||||
float mBumpHeight;
|
float mBumpHeight;
|
||||||
|
|
||||||
// Emissive color
|
//! Emissive color
|
||||||
aiColor3D mEmissive;
|
aiColor3D mEmissive;
|
||||||
|
|
||||||
// Used internally
|
//! Used internally
|
||||||
unsigned int iBakeUVTransform;
|
unsigned int iBakeUVTransform;
|
||||||
Texture* pcSingleTexture;
|
Texture* pcSingleTexture;
|
||||||
};
|
};
|
||||||
|
@ -371,28 +428,33 @@ struct Material
|
||||||
/** Helper structure to represent a 3ds file mesh */
|
/** Helper structure to represent a 3ds file mesh */
|
||||||
struct Mesh
|
struct Mesh
|
||||||
{
|
{
|
||||||
|
//! Default constructor
|
||||||
Mesh()
|
Mesh()
|
||||||
{
|
{
|
||||||
static int iCnt = 0;
|
static int iCnt = 0;
|
||||||
std::stringstream ss(mName);
|
std::stringstream ss(mName);
|
||||||
ss << "%%_UNNAMED_" << iCnt++ << "_%%";
|
ss << "%%_UNNAMED_" << iCnt++ << "_%%";
|
||||||
#if 0
|
|
||||||
for (unsigned int i = 0; i < 32;++i)
|
|
||||||
bSmoothGroupRequired[i] = false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Name of the mesh
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
|
//! Vertex positions
|
||||||
std::vector<aiVector3D> mPositions;
|
std::vector<aiVector3D> mPositions;
|
||||||
|
|
||||||
|
//! Face lists
|
||||||
std::vector<Face> mFaces;
|
std::vector<Face> mFaces;
|
||||||
|
|
||||||
|
//! Texture coordinates
|
||||||
std::vector<aiVector2D> mTexCoords;
|
std::vector<aiVector2D> mTexCoords;
|
||||||
|
|
||||||
|
//! Face materials
|
||||||
std::vector<unsigned int> mFaceMaterials;
|
std::vector<unsigned int> mFaceMaterials;
|
||||||
|
|
||||||
|
//! Normal vectors
|
||||||
std::vector<aiVector3D> mNormals;
|
std::vector<aiVector3D> mNormals;
|
||||||
|
|
||||||
#if 0
|
//! Local transformation matrix
|
||||||
bool bSmoothGroupRequired[32];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
aiMatrix4x4 mMat;
|
aiMatrix4x4 mMat;
|
||||||
};
|
};
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -412,10 +474,19 @@ struct Node
|
||||||
mHierarchyIndex = 0;
|
mHierarchyIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Pointer to the parent node
|
||||||
Node* mParent;
|
Node* mParent;
|
||||||
|
|
||||||
|
//! Holds all child nodes
|
||||||
std::vector<Node*> mChildren;
|
std::vector<Node*> mChildren;
|
||||||
|
|
||||||
|
//! Name of the node
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
|
//! Position of the node in the hierarchy (tree depth)
|
||||||
int16_t mHierarchyPos;
|
int16_t mHierarchyPos;
|
||||||
|
|
||||||
|
//! Index of the node
|
||||||
int16_t mHierarchyIndex;
|
int16_t mHierarchyIndex;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -425,6 +496,8 @@ struct Node
|
||||||
aiVector3D vPosition;
|
aiVector3D vPosition;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//! Add a child node, setup the right parent node for it
|
||||||
|
//! \param pc Node to be 'adopted'
|
||||||
inline Node& push_back(Node* pc)
|
inline Node& push_back(Node* pc)
|
||||||
{
|
{
|
||||||
mChildren.push_back(pc);
|
mChildren.push_back(pc);
|
||||||
|
@ -438,10 +511,14 @@ struct Node
|
||||||
struct Scene
|
struct Scene
|
||||||
{
|
{
|
||||||
|
|
||||||
// NOTE: 3ds references materials globally
|
//! List of all materials loaded
|
||||||
|
//! NOTE: 3ds references materials globally
|
||||||
std::vector<Material> mMaterials;
|
std::vector<Material> mMaterials;
|
||||||
|
|
||||||
|
//! List of all meshes loaded
|
||||||
std::vector<Mesh> mMeshes;
|
std::vector<Mesh> mMeshes;
|
||||||
|
|
||||||
|
//! Pointer to the root node of the scene
|
||||||
Node* pcRootNode;
|
Node* pcRootNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the 3ds importer class */
|
/** @file Implementation of the 3ds importer class */
|
||||||
#include "3DSLoader.h"
|
#include "3DSLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
|
|
429
code/3DSLoader.h
429
code/3DSLoader.h
|
@ -1,3 +1,44 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definition of the .3ds importer class. */
|
/** @file Definition of the .3ds importer class. */
|
||||||
#ifndef AI_3DSIMPORTER_H_INC
|
#ifndef AI_3DSIMPORTER_H_INC
|
||||||
#define AI_3DSIMPORTER_H_INC
|
#define AI_3DSIMPORTER_H_INC
|
||||||
|
@ -5,230 +46,238 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
|
|
||||||
#include "../include/aiTypes.h"
|
#include "../include/aiTypes.h"
|
||||||
|
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
|
||||||
#include "3DSHelper.h"
|
#include "3DSHelper.h"
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
class MaterialHelper;
|
class MaterialHelper;
|
||||||
|
|
||||||
using namespace Dot3DS;
|
using namespace Dot3DS;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** The Dot3DSImporter is a worker class capable of importing a scene from a
|
/** The Dot3DSImporter is a worker class capable of importing a scene from a
|
||||||
* 3ds Max 4/5 File (.3ds)
|
* 3ds Max 4/5 Files (.3ds)
|
||||||
*/
|
*/
|
||||||
class Dot3DSImporter : public BaseImporter
|
class Dot3DSImporter : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
Dot3DSImporter();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~Dot3DSImporter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
{
|
{
|
||||||
friend class Importer;
|
append.append("*.3ds");
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
// -------------------------------------------------------------------
|
||||||
/** Constructor to be privately used by Importer */
|
/** Imports the given file into the given scene structure.
|
||||||
Dot3DSImporter();
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
/** Destructor, private as well */
|
// -------------------------------------------------------------------
|
||||||
~Dot3DSImporter();
|
/** Converts a temporary material to the outer representation
|
||||||
|
*/
|
||||||
|
void ConvertMaterial(Dot3DS::Material& p_cMat,
|
||||||
|
MaterialHelper& p_pcOut);
|
||||||
|
|
||||||
public:
|
// -------------------------------------------------------------------
|
||||||
// -------------------------------------------------------------------
|
/** Read a chunk, get a pointer to it
|
||||||
/** Returns whether the class can handle the format of the given file.
|
* The mCurrent pointer will be increased by sizeof(Dot3DSFile::Chunk),
|
||||||
* See BaseImporter::CanRead() for details. */
|
* thus pointing directly to the data of the chunk
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
*/
|
||||||
|
void ReadChunk(const Dot3DSFile::Chunk** p_ppcOut);
|
||||||
|
|
||||||
protected:
|
// -------------------------------------------------------------------
|
||||||
// -------------------------------------------------------------------
|
/** Parse a percentage chunk. mCurrent will point to the next
|
||||||
/** Imports the given file into the given scene structure.
|
* chunk behind afterwards. If no percentage chunk is found
|
||||||
* See BaseImporter::InternReadFile() for details
|
* QNAN is returned.
|
||||||
*/
|
*/
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
float ParsePercentageChunk();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a color chunk. mCurrent will point to the next
|
||||||
|
* chunk behind afterwards. If no color chunk is found
|
||||||
|
* QNAN is returned in all members.
|
||||||
|
*/
|
||||||
|
void ParseColorChunk(aiColor3D* p_pcOut,
|
||||||
|
bool p_bAcceptPercent = true);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Converts a temporary material to the outer representation
|
/** Skip a chunk in the file
|
||||||
*/
|
*/
|
||||||
void ConvertMaterial(Dot3DS::Material& p_cMat,
|
void SkipChunk();
|
||||||
MaterialHelper& p_pcOut);
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Generate the nodegraph
|
||||||
|
*/
|
||||||
|
void GenerateNodeGraph(aiScene* pcOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a main top-level chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseMainChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a top-level chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a top-level editor chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseEditorChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a top-level object chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseObjectChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a material chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseMaterialChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Apply texture coordinate offsets
|
||||||
|
*/
|
||||||
|
void ApplyScaleNOffset();
|
||||||
|
void BakeScaleNOffset(aiMesh* pcMesh, Dot3DS::Material* pcSrc);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a mesh chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseMeshChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a face list chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseFaceChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a keyframe chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseKeyframeChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a hierarchy chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseHierarchyChunk(int* piRemaining);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a texture chunk in the file
|
||||||
|
*/
|
||||||
|
void ParseTextureChunk(int* piRemaining,Dot3DS::Texture* pcOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Convert the meshes in the file
|
||||||
|
*/
|
||||||
|
void ConvertMeshes(aiScene* pcOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Replace the default material in the scene
|
||||||
|
*/
|
||||||
|
void ReplaceDefaultMaterial();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Convert the whole scene
|
||||||
|
*/
|
||||||
|
void ConvertScene(aiScene* pcOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** U/V Scaling/Offset handling
|
||||||
|
*/
|
||||||
|
void GenTexCoord (Dot3DS::Texture* pcTexture,
|
||||||
|
const std::vector<aiVector2D>& p_vIn,
|
||||||
|
std::vector<aiVector2D>& p_vOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** generate normal vectors for a given mesh
|
||||||
|
*/
|
||||||
|
void GenNormals(Dot3DS::Mesh* sMesh);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Read a chunk, get a pointer to it
|
/** generate unique vertices for a mesh
|
||||||
* The mCurrent pointer will be increased by sizeof(Dot3DSFile::Chunk),
|
*/
|
||||||
* thus pointing directly to the data of the chunk
|
void MakeUnique(Dot3DS::Mesh* sMesh);
|
||||||
*/
|
|
||||||
void ReadChunk(const Dot3DSFile::Chunk** p_ppcOut);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a percentage chunk. mCurrent will point to the next
|
|
||||||
* chunk behind afterwards. If no percentage chunk is found
|
|
||||||
* QNAN is returned.
|
|
||||||
*/
|
|
||||||
float ParsePercentageChunk();
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a color chunk. mCurrent will point to the next
|
|
||||||
* chunk behind afterwards. If no color chunk is found
|
|
||||||
* QNAN is returned in all members.
|
|
||||||
*/
|
|
||||||
void ParseColorChunk(aiColor3D* p_pcOut,
|
|
||||||
bool p_bAcceptPercent = true);
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Skip a chunk in the file
|
/** Add a node to the node graph
|
||||||
*/
|
*/
|
||||||
void SkipChunk();
|
void AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,Dot3DS::Node* pcIn);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Generate the nodegraph
|
/** Search for a node in the graph.
|
||||||
*/
|
* Called recursively
|
||||||
void GenerateNodeGraph(aiScene* pcOut);
|
*/
|
||||||
|
void InverseNodeSearch(Dot3DS::Node* pcNode,Dot3DS::Node* pcCurrent);
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a main top-level chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseMainChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a top-level chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a top-level editor chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseEditorChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a top-level object chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseObjectChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a material chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseMaterialChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Apply texture coordinate offsets
|
|
||||||
*/
|
|
||||||
void ApplyScaleNOffset();
|
|
||||||
void BakeScaleNOffset(aiMesh* pcMesh, Dot3DS::Material* pcSrc);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a mesh chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseMeshChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a face list chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseFaceChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a keyframe chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseKeyframeChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a hierarchy chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseHierarchyChunk(int* piRemaining);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Parse a texture chunk in the file
|
|
||||||
*/
|
|
||||||
void ParseTextureChunk(int* piRemaining,Dot3DS::Texture* pcOut);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Convert the meshes in the file
|
|
||||||
*/
|
|
||||||
void ConvertMeshes(aiScene* pcOut);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Replace the default material in the scene
|
|
||||||
*/
|
|
||||||
void ReplaceDefaultMaterial();
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Convert the whole scene
|
|
||||||
*/
|
|
||||||
void ConvertScene(aiScene* pcOut);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** U/V Scaling/Offset handling
|
|
||||||
*/
|
|
||||||
void GenTexCoord (Dot3DS::Texture* pcTexture,
|
|
||||||
const std::vector<aiVector2D>& p_vIn,
|
|
||||||
std::vector<aiVector2D>& p_vOut);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** generate normal vectors for a given mesh
|
|
||||||
*/
|
|
||||||
void GenNormals(Dot3DS::Mesh* sMesh);
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** generate unique vertices for a mesh
|
/** Apply the master scaling factor to the mesh
|
||||||
*/
|
*/
|
||||||
void MakeUnique(Dot3DS::Mesh* sMesh);
|
void ApplyMasterScale(aiScene* pScene);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Add a node to the node graph
|
/** Clamp all indices in the file to a valid range
|
||||||
*/
|
*/
|
||||||
void AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,Dot3DS::Node* pcIn);
|
void Dot3DSImporter::CheckIndices(Dot3DS::Mesh* sMesh);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Search for a node in the graph.
|
|
||||||
* Called recursively
|
|
||||||
*/
|
|
||||||
void InverseNodeSearch(Dot3DS::Node* pcNode,Dot3DS::Node* pcCurrent);
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
protected:
|
||||||
/** Apply the master scaling factor to the mesh
|
/** Buffer to hold the loaded file */
|
||||||
*/
|
unsigned char* mBuffer;
|
||||||
void ApplyMasterScale(aiScene* pScene);
|
|
||||||
|
|
||||||
|
/** Pointer to the current read position */
|
||||||
|
const unsigned char* mCurrent;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
/** Used to store old chunk addresses to jump back in the file*/
|
||||||
/** Clamp all indices in the file to a valid range
|
const unsigned char* mLast;
|
||||||
*/
|
|
||||||
void Dot3DSImporter::CheckIndices(Dot3DS::Mesh* sMesh);
|
|
||||||
|
|
||||||
|
/** Last touched node index */
|
||||||
|
short mLastNodeIndex;
|
||||||
|
|
||||||
protected:
|
/** Current node, root node */
|
||||||
/** Buffer to hold the loaded file */
|
Dot3DS::Node* mCurrentNode, *mRootNode;
|
||||||
unsigned char* mBuffer;
|
|
||||||
|
|
||||||
/** Pointer to the current read position */
|
/** Scene under construction */
|
||||||
const unsigned char* mCurrent;
|
Dot3DS::Scene* mScene;
|
||||||
|
|
||||||
/** Used to store old chunk addresses to jump back in the file*/
|
/** Ambient base color of the scene */
|
||||||
const unsigned char* mLast;
|
aiColor3D mClrAmbient;
|
||||||
|
|
||||||
/** Last touched node index */
|
/** Master scaling factor of the scene */
|
||||||
short mLastNodeIndex;
|
float mMasterScale;
|
||||||
|
|
||||||
/** Current node, root node */
|
/** Path to the background image of the scene */
|
||||||
Dot3DS::Node* mCurrentNode, *mRootNode;
|
std::string mBackgroundImage;
|
||||||
|
bool bHasBG;
|
||||||
/** Scene under construction */
|
};
|
||||||
Dot3DS::Scene* mScene;
|
|
||||||
|
|
||||||
/** Ambient base color of the scene */
|
|
||||||
aiColor3D mClrAmbient;
|
|
||||||
|
|
||||||
/** Master scaling factor of the scene */
|
|
||||||
float mMasterScale;
|
|
||||||
|
|
||||||
/** Path to the background image of the scene */
|
|
||||||
std::string mBackgroundImage;
|
|
||||||
bool bHasBG;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -1,67 +1,64 @@
|
||||||
/** @file Implementation of the helper class to quickly find vertices close to a given position */
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Implementation of the helper class to quickly find
|
||||||
|
vertices close to a given position. Special implementation for
|
||||||
|
the 3ds loader handling smooth groups correctly */
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "3DSSpatialSort.h"
|
#include "3DSSpatialSort.h"
|
||||||
|
|
||||||
|
#include "aiAssert.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace Assimp::Dot3DS;
|
using namespace Assimp::Dot3DS;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructs a spatially sorted representation from the given position array.
|
D3DSSpatialSorter::D3DSSpatialSorter()
|
||||||
D3DSSpatialSorter::D3DSSpatialSorter( const aiVector3D* pPositions,
|
|
||||||
unsigned int pNumPositions, unsigned int pElementOffset)
|
|
||||||
{
|
{
|
||||||
// define the reference plane. We choose some arbitrary vector away from all basic axises
|
// define the reference plane. We choose some arbitrary vector away from all basic axises
|
||||||
// in the hope that no model spreads all its vertices along this plane.
|
// in the hope that no model spreads all its vertices along this plane.
|
||||||
mPlaneNormal.Set( 0.8523f, 0.34321f, 0.5736f);
|
mPlaneNormal.Set( 0.8523f, 0.34321f, 0.5736f);
|
||||||
mPlaneNormal.Normalize();
|
mPlaneNormal.Normalize();
|
||||||
|
|
||||||
// store references to all given positions along with their distance to the reference plane
|
|
||||||
mPositions.reserve( pNumPositions);
|
|
||||||
for( unsigned int a = 0; a < pNumPositions; a++)
|
|
||||||
{
|
|
||||||
const char* tempPointer = reinterpret_cast<const char*> (pPositions);
|
|
||||||
const aiVector3D* vec = reinterpret_cast<const aiVector3D*> (tempPointer + a * pElementOffset);
|
|
||||||
|
|
||||||
// store position by index and distance
|
|
||||||
float distance = *vec * mPlaneNormal;
|
|
||||||
mPositions.push_back( Entry( a, *vec, distance,0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// now sort the array ascending by distance.
|
|
||||||
std::sort( mPositions.begin(), mPositions.end());
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
D3DSSpatialSorter::D3DSSpatialSorter( const Dot3DS::Mesh* p_pcMesh)
|
|
||||||
{
|
|
||||||
// define the reference plane. We choose some arbitrary vector away from all basic axises
|
|
||||||
// in the hope that no model spreads all its vertices along this plane.
|
|
||||||
mPlaneNormal.Set( 0.8523f, 0.34321f, 0.5736f);
|
|
||||||
mPlaneNormal.Normalize();
|
|
||||||
|
|
||||||
// store references to all given positions along with their distance to the reference plane
|
|
||||||
mPositions.reserve( p_pcMesh->mPositions.size());
|
|
||||||
for( std::vector<Dot3DS::Face>::const_iterator
|
|
||||||
i = p_pcMesh->mFaces.begin();
|
|
||||||
i != p_pcMesh->mFaces.end();++i)
|
|
||||||
{
|
|
||||||
// store position by index and distance
|
|
||||||
float distance = p_pcMesh->mPositions[(*i).i1] * mPlaneNormal;
|
|
||||||
mPositions.push_back( Entry( (*i).i1, p_pcMesh->mPositions[(*i).i1],
|
|
||||||
distance, (*i).iSmoothGroup));
|
|
||||||
|
|
||||||
// triangle vertex 2
|
|
||||||
distance = p_pcMesh->mPositions[(*i).i2] * mPlaneNormal;
|
|
||||||
mPositions.push_back( Entry( (*i).i2, p_pcMesh->mPositions[(*i).i2],
|
|
||||||
distance, (*i).iSmoothGroup));
|
|
||||||
|
|
||||||
// triangle vertex 3
|
|
||||||
distance = p_pcMesh->mPositions[(*i).i3] * mPlaneNormal;
|
|
||||||
mPositions.push_back( Entry( (*i).i3, p_pcMesh->mPositions[(*i).i3],
|
|
||||||
distance, (*i).iSmoothGroup));
|
|
||||||
}
|
|
||||||
|
|
||||||
// now sort the array ascending by distance.
|
|
||||||
std::sort( this->mPositions.begin(), this->mPositions.end());
|
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor
|
// Destructor
|
||||||
|
@ -69,11 +66,39 @@ D3DSSpatialSorter::~D3DSSpatialSorter()
|
||||||
{
|
{
|
||||||
// nothing to do here, everything destructs automatically
|
// nothing to do here, everything destructs automatically
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void D3DSSpatialSorter::AddFace(const Dot3DS::Face* pcFace,
|
||||||
|
const std::vector<aiVector3D>& vPositions)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcFace);
|
||||||
|
|
||||||
|
// store position by index and distance
|
||||||
|
float distance = vPositions[pcFace->i1] * mPlaneNormal;
|
||||||
|
mPositions.push_back( Entry( pcFace->i1, vPositions[pcFace->i1],
|
||||||
|
distance, pcFace->iSmoothGroup));
|
||||||
|
|
||||||
|
// triangle vertex 2
|
||||||
|
distance = vPositions[pcFace->i2] * mPlaneNormal;
|
||||||
|
mPositions.push_back( Entry( pcFace->i2, vPositions[pcFace->i2],
|
||||||
|
distance, pcFace->iSmoothGroup));
|
||||||
|
|
||||||
|
// triangle vertex 3
|
||||||
|
distance = vPositions[pcFace->i3] * mPlaneNormal;
|
||||||
|
mPositions.push_back( Entry( pcFace->i3, vPositions[pcFace->i3],
|
||||||
|
distance, pcFace->iSmoothGroup));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void D3DSSpatialSorter::Prepare()
|
||||||
|
{
|
||||||
|
// now sort the array ascending by distance.
|
||||||
|
std::sort( this->mPositions.begin(), this->mPositions.end());
|
||||||
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns an iterator for all positions close to the given position.
|
// Returns an iterator for all positions close to the given position.
|
||||||
void D3DSSpatialSorter::FindPositions( const aiVector3D& pPosition,
|
void D3DSSpatialSorter::FindPositions( const aiVector3D& pPosition,
|
||||||
uint32_t pSG,float pRadius, std::vector<unsigned int>& poResults) const
|
uint32_t pSG,
|
||||||
|
float pRadius,
|
||||||
|
std::vector<unsigned int>& poResults) const
|
||||||
{
|
{
|
||||||
float dist = pPosition * mPlaneNormal;
|
float dist = pPosition * mPlaneNormal;
|
||||||
float minDist = dist - pRadius, maxDist = dist + pRadius;
|
float minDist = dist - pRadius, maxDist = dist + pRadius;
|
||||||
|
@ -113,10 +138,10 @@ void D3DSSpatialSorter::FindPositions( const aiVector3D& pPosition,
|
||||||
// Mow start iterating from there until the first position lays outside of the distance range.
|
// Mow start iterating from there until the first position lays outside of the distance range.
|
||||||
// Add all positions inside the distance range within the given radius to the result aray
|
// Add all positions inside the distance range within the given radius to the result aray
|
||||||
|
|
||||||
|
float squareEpsilon = pRadius * pRadius;
|
||||||
|
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
|
||||||
if (0 == pSG)
|
if (0 == pSG)
|
||||||
{
|
{
|
||||||
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
|
|
||||||
float squareEpsilon = pRadius * pRadius;
|
|
||||||
while( it->mDistance < maxDist)
|
while( it->mDistance < maxDist)
|
||||||
{
|
{
|
||||||
if((it->mPosition - pPosition).SquareLength() < squareEpsilon)
|
if((it->mPosition - pPosition).SquareLength() < squareEpsilon)
|
||||||
|
@ -130,8 +155,6 @@ void D3DSSpatialSorter::FindPositions( const aiVector3D& pPosition,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
|
|
||||||
float squareEpsilon = pRadius * pRadius;
|
|
||||||
while( it->mDistance < maxDist)
|
while( it->mDistance < maxDist)
|
||||||
{
|
{
|
||||||
if((it->mPosition - pPosition).SquareLength() < squareEpsilon &&
|
if((it->mPosition - pPosition).SquareLength() < squareEpsilon &&
|
||||||
|
@ -144,5 +167,6 @@ void D3DSSpatialSorter::FindPositions( const aiVector3D& pPosition,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,55 @@
|
||||||
/** Small helper classes to optimise finding vertizes close to a given location */
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Small helper classes to optimise finding vertizes close to a given location
|
||||||
|
*/
|
||||||
#ifndef AI_D3DSSPATIALSORT_H_INC
|
#ifndef AI_D3DSSPATIALSORT_H_INC
|
||||||
#define AI_D3DSSPATIALSORT_H_INC
|
#define AI_D3DSSPATIALSORT_H_INC
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../include/aiVector3D.h"
|
#include "../include/aiVector3D.h"
|
||||||
#include "3DSHelper.h"
|
|
||||||
|
|
||||||
|
#if (!defined AI_BUILD_NO_ASE_IMPORTER)
|
||||||
|
# include "3DSHelper.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
@ -19,28 +64,30 @@ class D3DSSpatialSorter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
D3DSSpatialSorter() {/* This is unintialized. This is evil. This is OK. */}
|
D3DSSpatialSorter();
|
||||||
|
|
||||||
/** Constructs a spatially sorted representation from the given position array.
|
|
||||||
* Supply the positions in its layout in memory, the class will only refer to them
|
|
||||||
* by index.
|
|
||||||
* @param pPositions Pointer to the first position vector of the array.
|
|
||||||
* @param pNumPositions Number of vectors to expect in that array.
|
|
||||||
* @param pElementOffset Offset in bytes from the beginning of one vector in memory to the beginning of the next vector.
|
|
||||||
* @note Smoothing groups are ignored
|
|
||||||
*/
|
|
||||||
D3DSSpatialSorter( const aiVector3D* pPositions,
|
|
||||||
unsigned int pNumPositions, unsigned int pElementOffset);
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
/** Construction from a given face array, handling smoothing groups properly
|
/** Construction from a given face array, handling smoothing groups properly
|
||||||
* @param p_pcMesh Input mesh.
|
|
||||||
*/
|
*/
|
||||||
D3DSSpatialSorter( const Dot3DS::Mesh* p_pcMesh);
|
D3DSSpatialSorter(const std::vector<aiVector3D>& vPositions);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Add a face to the spatial sorter
|
||||||
|
* @param pcFace Face to be added
|
||||||
|
* @param vPositions Input position list
|
||||||
|
*/
|
||||||
|
void AddFace(const Dot3DS::Face* pcFace,
|
||||||
|
const std::vector<aiVector3D>& vPositions);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Prepare the spatial sorter for use
|
||||||
|
*/
|
||||||
|
void Prepare();
|
||||||
|
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
~D3DSSpatialSorter();
|
~D3DSSpatialSorter();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
/** Returns an iterator for all positions close to the given position.
|
/** Returns an iterator for all positions close to the given position.
|
||||||
* @param pPosition The position to look for vertices.
|
* @param pPosition The position to look for vertices.
|
||||||
* @param pSG Only included vertices with at least one shared smooth group
|
* @param pSG Only included vertices with at least one shared smooth group
|
||||||
|
@ -56,6 +103,7 @@ protected:
|
||||||
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
||||||
aiVector3D mPlaneNormal;
|
aiVector3D mPlaneNormal;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
/** An entry in a spatially sorted position array. Consists of a vertex index,
|
/** An entry in a spatially sorted position array. Consists of a vertex index,
|
||||||
* its position and its precalculated distance from the reference plane */
|
* its position and its precalculated distance from the reference plane */
|
||||||
struct Entry
|
struct Entry
|
||||||
|
|
|
@ -0,0 +1,720 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Implementation of the ASE importer class */
|
||||||
|
#include "ASELoader.h"
|
||||||
|
#include "3DSSpatialSort.h"
|
||||||
|
#include "MaterialSystem.h"
|
||||||
|
|
||||||
|
#include "../include/IOStream.h"
|
||||||
|
#include "../include/IOSystem.h"
|
||||||
|
#include "../include/aiMesh.h"
|
||||||
|
#include "../include/aiScene.h"
|
||||||
|
#include "../include/aiAssert.h"
|
||||||
|
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
using namespace Assimp::ASE;
|
||||||
|
|
||||||
|
#define LOGOUT_WARN(x)
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Constructor to be privately used by Importer
|
||||||
|
ASEImporter::ASEImporter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Destructor, private as well
|
||||||
|
ASEImporter::~ASEImporter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Returns whether the class can handle the format of the given file.
|
||||||
|
bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
|
||||||
|
{
|
||||||
|
// simple check of file extension is enough for the moment
|
||||||
|
std::string::size_type pos = pFile.find_last_of('.');
|
||||||
|
// no file extension - can't read
|
||||||
|
if( pos == std::string::npos)
|
||||||
|
return false;
|
||||||
|
std::string extension = pFile.substr( pos);
|
||||||
|
|
||||||
|
if (extension.length() < 4)return false;
|
||||||
|
if (extension[0] != '.')return false;
|
||||||
|
|
||||||
|
if (extension[1] != 'a' && extension[1] != 'A')return false;
|
||||||
|
if (extension[2] != 's' && extension[2] != 'S')return false;
|
||||||
|
|
||||||
|
// NOTE: Sometimes the extension .ASK is also used
|
||||||
|
if (extension[3] != 'e' && extension[3] != 'E' &&
|
||||||
|
extension[3] != 'k' && extension[3] != 'K')return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Imports the given file into the given scene structure.
|
||||||
|
void ASEImporter::InternReadFile(
|
||||||
|
const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
|
||||||
|
{
|
||||||
|
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||||
|
|
||||||
|
// Check whether we can read from the file
|
||||||
|
if( file.get() == NULL)
|
||||||
|
{
|
||||||
|
throw new ImportErrorException( "Failed to open ASE file " + pFile + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t fileSize = file->FileSize();
|
||||||
|
|
||||||
|
// allocate storage and copy the contents of the file to a memory buffer
|
||||||
|
// (terminate it with zero)
|
||||||
|
this->mBuffer = new unsigned char[fileSize+1];
|
||||||
|
file->Read( (void*)mBuffer, 1, fileSize);
|
||||||
|
this->mBuffer[fileSize] = '\0';
|
||||||
|
|
||||||
|
// construct an ASE parser and parse the file
|
||||||
|
this->mParser = new ASE::Parser((const char*)this->mBuffer);
|
||||||
|
this->mParser->Parse();
|
||||||
|
|
||||||
|
// process all meshes
|
||||||
|
for (std::vector<ASE::Mesh>::iterator
|
||||||
|
i = this->mParser->m_vMeshes.begin();
|
||||||
|
i != this->mParser->m_vMeshes.end();++i)
|
||||||
|
{
|
||||||
|
// need to generate proper vertex normals if necessary
|
||||||
|
this->GenerateNormals(*i);
|
||||||
|
|
||||||
|
// now we need to create proper meshes from the import
|
||||||
|
// we need to split them by materials, build valid vertex/face lists ...
|
||||||
|
this->BuildUniqueRepresentation(*i);
|
||||||
|
this->ConvertMeshes(*i,pScene);
|
||||||
|
}
|
||||||
|
// buil final material indices (remove submaterials and make the final list)
|
||||||
|
this->BuildMaterialIndices(pScene);
|
||||||
|
|
||||||
|
// build the final node graph
|
||||||
|
this->BuildNodes(pScene);
|
||||||
|
|
||||||
|
// delete the ASE parser
|
||||||
|
delete this->mParser;
|
||||||
|
this->mParser = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ASEImporter::BuildNodes(aiScene* pcScene)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcScene);
|
||||||
|
|
||||||
|
pcScene->mRootNode = new aiNode();
|
||||||
|
pcScene->mRootNode->mNumMeshes = pcScene->mNumMeshes;
|
||||||
|
pcScene->mRootNode->mMeshes = new unsigned int[pcScene->mRootNode->mNumMeshes];
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < pcScene->mRootNode->mNumMeshes;++i)
|
||||||
|
pcScene->mRootNode->mMeshes[i] = i;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ASEImporter::BuildUniqueRepresentation(ASE::Mesh& mesh)
|
||||||
|
{
|
||||||
|
// allocate output storage
|
||||||
|
std::vector<aiVector3D> mPositions;
|
||||||
|
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
std::vector<aiColor4D> mVertexColors;
|
||||||
|
std::vector<aiVector3D> mNormals;
|
||||||
|
|
||||||
|
unsigned int iSize = mesh.mFaces.size() * 3;
|
||||||
|
mPositions.resize(iSize);
|
||||||
|
|
||||||
|
// optional texture coordinates
|
||||||
|
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
||||||
|
{
|
||||||
|
if (!mesh.amTexCoords[i].empty())
|
||||||
|
{
|
||||||
|
amTexCoords[i].resize(iSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// optional vertex colors
|
||||||
|
if (!mesh.mVertexColors.empty())
|
||||||
|
{
|
||||||
|
mVertexColors.resize(iSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional vertex normals (vertex normals can simply be copied)
|
||||||
|
if (!mesh.mNormals.empty())
|
||||||
|
{
|
||||||
|
mNormals.resize(iSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate through all faces in the mesh
|
||||||
|
unsigned int iCurrent = 0;
|
||||||
|
for (std::vector<ASE::Face>::iterator
|
||||||
|
i = mesh.mFaces.begin();
|
||||||
|
i != mesh.mFaces.end();++i)
|
||||||
|
{
|
||||||
|
for (unsigned int n = 0; n < 3;++n,++iCurrent)
|
||||||
|
{
|
||||||
|
mPositions[iCurrent] = mesh.mPositions[(*i).mIndices[n]];
|
||||||
|
|
||||||
|
// add texture coordinates
|
||||||
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
|
{
|
||||||
|
if (!mesh.amTexCoords[c].empty())
|
||||||
|
{
|
||||||
|
amTexCoords[c][iCurrent] = mesh.amTexCoords[c][(*i).amUVIndices[c][n]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add vertex colors
|
||||||
|
if (!mesh.mVertexColors.empty())
|
||||||
|
{
|
||||||
|
mVertexColors[iCurrent] = mesh.mVertexColors[(*i).mColorIndices[n]];
|
||||||
|
}
|
||||||
|
// add normal vectors
|
||||||
|
if (!mesh.mNormals.empty())
|
||||||
|
{
|
||||||
|
mNormals[iCurrent] = mesh.mNormals[(*i).mIndices[n]];
|
||||||
|
}
|
||||||
|
// assign a new valid index to the face
|
||||||
|
(*i).mIndices[n] = iCurrent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// replace the old arrays
|
||||||
|
mesh.mNormals = mNormals;
|
||||||
|
mesh.mPositions = mPositions;
|
||||||
|
mesh.mVertexColors = mVertexColors;
|
||||||
|
|
||||||
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
|
mesh.amTexCoords[c] = amTexCoords[c];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ASEImporter::ConvertMaterial(ASE::Material& mat)
|
||||||
|
{
|
||||||
|
// allocate the output material
|
||||||
|
mat.pcInstance = new MaterialHelper();
|
||||||
|
|
||||||
|
// At first add the base ambient color of the
|
||||||
|
// scene to the material
|
||||||
|
mat.mAmbient.r += this->mParser->m_clrAmbient.r;
|
||||||
|
mat.mAmbient.g += this->mParser->m_clrAmbient.g;
|
||||||
|
mat.mAmbient.b += this->mParser->m_clrAmbient.b;
|
||||||
|
|
||||||
|
aiString name;
|
||||||
|
name.Set( mat.mName);
|
||||||
|
mat.pcInstance->AddProperty( &name, AI_MATKEY_NAME);
|
||||||
|
|
||||||
|
// material colors
|
||||||
|
mat.pcInstance->AddProperty( &mat.mAmbient, 1, AI_MATKEY_COLOR_AMBIENT);
|
||||||
|
mat.pcInstance->AddProperty( &mat.mDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
|
mat.pcInstance->AddProperty( &mat.mSpecular, 1, AI_MATKEY_COLOR_SPECULAR);
|
||||||
|
mat.pcInstance->AddProperty( &mat.mSpecularExponent, 1, AI_MATKEY_SHININESS);
|
||||||
|
mat.pcInstance->AddProperty( &mat.mEmissive, 1, AI_MATKEY_COLOR_EMISSIVE);
|
||||||
|
|
||||||
|
// opacity
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.mTransparency,1,AI_MATKEY_OPACITY);
|
||||||
|
|
||||||
|
|
||||||
|
// shading mode
|
||||||
|
aiShadingMode eShading = aiShadingMode_NoShading;
|
||||||
|
switch (mat.mShading)
|
||||||
|
{
|
||||||
|
case Dot3DS::Dot3DSFile::Flat:
|
||||||
|
eShading = aiShadingMode_Flat; break;
|
||||||
|
case Dot3DS::Dot3DSFile::Phong :
|
||||||
|
eShading = aiShadingMode_Phong; break;
|
||||||
|
|
||||||
|
// I don't know what "Wire" shading should be,
|
||||||
|
// assume it is simple lambertian diffuse (L dot N) shading
|
||||||
|
case Dot3DS::Dot3DSFile::Wire:
|
||||||
|
case Dot3DS::Dot3DSFile::Gouraud:
|
||||||
|
eShading = aiShadingMode_Gouraud; break;
|
||||||
|
case Dot3DS::Dot3DSFile::Metal :
|
||||||
|
eShading = aiShadingMode_CookTorrance; break;
|
||||||
|
}
|
||||||
|
mat.pcInstance->AddProperty<int>( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
||||||
|
if (Dot3DS::Dot3DSFile::Wire == mat.mShading)
|
||||||
|
{
|
||||||
|
// set the wireframe flag
|
||||||
|
unsigned int iWire = 1;
|
||||||
|
mat.pcInstance->AddProperty<int>( (int*)&iWire,1,AI_MATKEY_ENABLE_WIREFRAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
// texture, if there is one
|
||||||
|
if( mat.sTexDiffuse.mMapName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.sTexDiffuse.mMapName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
|
|
||||||
|
if (is_not_qnan(mat.sTexDiffuse.mTextureBlend))
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.sTexDiffuse.mTextureBlend, 1,
|
||||||
|
AI_MATKEY_TEXBLEND_DIFFUSE(0));
|
||||||
|
}
|
||||||
|
if( mat.sTexSpecular.mMapName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.sTexSpecular.mMapName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_TEXTURE_SPECULAR(0));
|
||||||
|
|
||||||
|
if (is_not_qnan(mat.sTexSpecular.mTextureBlend))
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.sTexSpecular.mTextureBlend, 1,
|
||||||
|
AI_MATKEY_TEXBLEND_SPECULAR(0));
|
||||||
|
}
|
||||||
|
if( mat.sTexOpacity.mMapName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.sTexOpacity.mMapName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_TEXTURE_OPACITY(0));
|
||||||
|
|
||||||
|
if (is_not_qnan(mat.sTexOpacity.mTextureBlend))
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.sTexOpacity.mTextureBlend, 1,
|
||||||
|
AI_MATKEY_TEXBLEND_OPACITY(0));
|
||||||
|
}
|
||||||
|
if( mat.sTexEmissive.mMapName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.sTexEmissive.mMapName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_TEXTURE_EMISSIVE(0));
|
||||||
|
|
||||||
|
if (is_not_qnan(mat.sTexEmissive.mTextureBlend))
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.sTexEmissive.mTextureBlend, 1,
|
||||||
|
AI_MATKEY_TEXBLEND_EMISSIVE(0));
|
||||||
|
}
|
||||||
|
if( mat.sTexAmbient.mMapName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.sTexAmbient.mMapName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_TEXTURE_AMBIENT(0));
|
||||||
|
|
||||||
|
if (is_not_qnan(mat.sTexAmbient.mTextureBlend))
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.sTexAmbient.mTextureBlend, 1,
|
||||||
|
AI_MATKEY_TEXBLEND_AMBIENT(0));
|
||||||
|
}
|
||||||
|
if( mat.sTexBump.mMapName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.sTexBump.mMapName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_TEXTURE_HEIGHT(0));
|
||||||
|
|
||||||
|
if (is_not_qnan(mat.sTexBump.mTextureBlend))
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.sTexBump.mTextureBlend, 1,
|
||||||
|
AI_MATKEY_TEXBLEND_HEIGHT(0));
|
||||||
|
}
|
||||||
|
if( mat.sTexShininess.mMapName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.sTexShininess.mMapName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_TEXTURE_SHININESS(0));
|
||||||
|
|
||||||
|
if (is_not_qnan(mat.sTexShininess.mTextureBlend))
|
||||||
|
mat.pcInstance->AddProperty<float>( &mat.sTexBump.mTextureBlend, 1,
|
||||||
|
AI_MATKEY_TEXBLEND_SHININESS(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// store the name of the material itself, too
|
||||||
|
if( mat.mName.length() > 0)
|
||||||
|
{
|
||||||
|
aiString tex;
|
||||||
|
tex.Set( mat.mName);
|
||||||
|
mat.pcInstance->AddProperty( &tex, AI_MATKEY_NAME);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcScene);
|
||||||
|
|
||||||
|
// validate the material index of the mesh
|
||||||
|
if (mesh.iMaterialIndex >= this->mParser->m_vMaterials.size())
|
||||||
|
{
|
||||||
|
mesh.iMaterialIndex = this->mParser->m_vMaterials.size()-1;
|
||||||
|
LOGOUT_WARN("Material index is out of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of all output meshes
|
||||||
|
std::vector<aiMesh*> avOutMeshes;
|
||||||
|
|
||||||
|
// if the material the mesh is assigned to is consisting of submeshes
|
||||||
|
// we'll need to split it ... Quak.
|
||||||
|
if (!this->mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials.empty())
|
||||||
|
{
|
||||||
|
std::vector<ASE::Material> vSubMaterials = this->mParser->
|
||||||
|
m_vMaterials[mesh.iMaterialIndex].avSubMaterials;
|
||||||
|
|
||||||
|
std::vector<unsigned int>* aiSplit = new std::vector<unsigned int>[
|
||||||
|
vSubMaterials.size()];
|
||||||
|
|
||||||
|
// build a list of all faces per submaterial
|
||||||
|
unsigned int iNum = 0;
|
||||||
|
for (unsigned int i = 0; i < mesh.mFaces.size();++i)
|
||||||
|
{
|
||||||
|
// check range
|
||||||
|
if (mesh.mFaces[i].iMaterial >= vSubMaterials.size())
|
||||||
|
{
|
||||||
|
LOGOUT_WARN("Submaterial index is out of range");
|
||||||
|
|
||||||
|
// use the last material instead
|
||||||
|
aiSplit[vSubMaterials.size()-1].push_back(i);
|
||||||
|
}
|
||||||
|
else aiSplit[mesh.mFaces[i].iMaterial].push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now generate submeshes
|
||||||
|
for (unsigned int p = 0; p < vSubMaterials.size();++p)
|
||||||
|
{
|
||||||
|
if (aiSplit[p].size() != 0)
|
||||||
|
{
|
||||||
|
aiMesh* p_pcOut = new aiMesh();
|
||||||
|
|
||||||
|
// let the sub material index
|
||||||
|
p_pcOut->mMaterialIndex = p;
|
||||||
|
|
||||||
|
// we will need this material
|
||||||
|
this->mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials[p].bNeed = true;
|
||||||
|
|
||||||
|
// store the real index here ...
|
||||||
|
p_pcOut->mColors[3] = (aiColor4D*)(uintptr_t)mesh.iMaterialIndex;
|
||||||
|
avOutMeshes.push_back(p_pcOut);
|
||||||
|
|
||||||
|
// convert vertices
|
||||||
|
p_pcOut->mNumVertices = aiSplit[p].size()*3;
|
||||||
|
p_pcOut->mNumFaces = aiSplit[p].size();
|
||||||
|
|
||||||
|
// allocate enough storage for faces
|
||||||
|
p_pcOut->mFaces = new aiFace[p_pcOut->mNumFaces];
|
||||||
|
|
||||||
|
if (p_pcOut->mNumVertices != 0)
|
||||||
|
{
|
||||||
|
p_pcOut->mVertices = new aiVector3D[p_pcOut->mNumVertices];
|
||||||
|
p_pcOut->mNormals = new aiVector3D[p_pcOut->mNumVertices];
|
||||||
|
unsigned int iBase = 0;
|
||||||
|
|
||||||
|
for (unsigned int q = 0; q < aiSplit[p].size();++q)
|
||||||
|
{
|
||||||
|
unsigned int iIndex = aiSplit[p][q];
|
||||||
|
|
||||||
|
p_pcOut->mFaces[q].mIndices = new unsigned int[3];
|
||||||
|
p_pcOut->mFaces[q].mNumIndices = 3;
|
||||||
|
|
||||||
|
for (unsigned int t = 0; t < 3;++t)
|
||||||
|
{
|
||||||
|
p_pcOut->mFaces[q].mIndices[t] = iBase;
|
||||||
|
p_pcOut->mVertices[iBase] = mesh.mPositions[mesh.mFaces[iIndex].mIndices[t]];
|
||||||
|
p_pcOut->mNormals[iBase++] = mesh.mNormals[mesh.mFaces[iIndex].mIndices[t]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// convert texture coordinates
|
||||||
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
|
{
|
||||||
|
if (!mesh.amTexCoords[c].empty())
|
||||||
|
{
|
||||||
|
p_pcOut->mTextureCoords[c] = new aiVector3D[p_pcOut->mNumVertices];
|
||||||
|
unsigned int iBase = 0;
|
||||||
|
for (unsigned int q = 0; q < aiSplit[p].size();++q)
|
||||||
|
{
|
||||||
|
unsigned int iIndex = aiSplit[p][q];
|
||||||
|
for (unsigned int t = 0; t < 3;++t)
|
||||||
|
{
|
||||||
|
p_pcOut->mTextureCoords[c][iBase++] = mesh.amTexCoords[c][mesh.mFaces[iIndex].mIndices[t]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// setup the number of valid vertex components
|
||||||
|
p_pcOut->mNumUVComponents[c] = mesh.mNumUVComponents[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert vertex colors (only one set supported)
|
||||||
|
if (!mesh.mVertexColors.empty())
|
||||||
|
{
|
||||||
|
p_pcOut->mColors[0] = new aiColor4D[p_pcOut->mNumVertices];
|
||||||
|
unsigned int iBase = 0;
|
||||||
|
for (unsigned int q = 0; q < aiSplit[p].size();++q)
|
||||||
|
{
|
||||||
|
unsigned int iIndex = aiSplit[p][q];
|
||||||
|
for (unsigned int t = 0; t < 3;++t)
|
||||||
|
{
|
||||||
|
p_pcOut->mColors[0][iBase++] = mesh.mVertexColors[mesh.mFaces[iIndex].mIndices[t]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// delete storage
|
||||||
|
delete[] aiSplit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// otherwise we can simply copy the data to one output mesh
|
||||||
|
aiMesh* p_pcOut = new aiMesh();
|
||||||
|
|
||||||
|
// set an empty sub material index
|
||||||
|
p_pcOut->mMaterialIndex = ASE::Face::DEFAULT_MATINDEX;
|
||||||
|
this->mParser->m_vMaterials[mesh.iMaterialIndex].bNeed = true;
|
||||||
|
|
||||||
|
// store the real index here ...
|
||||||
|
p_pcOut->mColors[3] = (aiColor4D*)(uintptr_t)mesh.iMaterialIndex;
|
||||||
|
avOutMeshes.push_back(p_pcOut);
|
||||||
|
|
||||||
|
// convert vertices
|
||||||
|
p_pcOut->mNumVertices = mesh.mPositions.size();
|
||||||
|
p_pcOut->mNumFaces = mesh.mFaces.size();
|
||||||
|
|
||||||
|
// allocate enough storage for faces
|
||||||
|
p_pcOut->mFaces = new aiFace[p_pcOut->mNumFaces];
|
||||||
|
|
||||||
|
// copy vertices
|
||||||
|
p_pcOut->mVertices = new aiVector3D[mesh.mPositions.size()];
|
||||||
|
memcpy(p_pcOut->mVertices,&mesh.mPositions[0],
|
||||||
|
mesh.mPositions.size() * sizeof(aiVector3D));
|
||||||
|
|
||||||
|
// copy normals
|
||||||
|
p_pcOut->mNormals = new aiVector3D[mesh.mNormals.size()];
|
||||||
|
memcpy(p_pcOut->mNormals,&mesh.mNormals[0],
|
||||||
|
mesh.mNormals.size() * sizeof(aiVector3D));
|
||||||
|
|
||||||
|
// copy texture coordinates
|
||||||
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
|
{
|
||||||
|
if (!mesh.amTexCoords[c].empty())
|
||||||
|
{
|
||||||
|
p_pcOut->mTextureCoords[c] = new aiVector3D[mesh.amTexCoords[c].size()];
|
||||||
|
memcpy(p_pcOut->mTextureCoords[c],&mesh.amTexCoords[c][0],
|
||||||
|
mesh.amTexCoords[c].size() * sizeof(aiVector3D));
|
||||||
|
|
||||||
|
// setup the number of valid vertex components
|
||||||
|
p_pcOut->mNumUVComponents[c] = mesh.mNumUVComponents[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy vertex colors
|
||||||
|
if (!mesh.mVertexColors.empty())
|
||||||
|
{
|
||||||
|
p_pcOut->mColors[0] = new aiColor4D[mesh.mVertexColors.size()];
|
||||||
|
memcpy(p_pcOut->mColors[0],&mesh.mVertexColors[0],
|
||||||
|
mesh.mVertexColors.size() * sizeof(aiColor4D));
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy faces
|
||||||
|
for (unsigned int iFace = 0; iFace < p_pcOut->mNumFaces;++iFace)
|
||||||
|
{
|
||||||
|
p_pcOut->mFaces[iFace].mNumIndices = 3;
|
||||||
|
p_pcOut->mFaces[iFace].mIndices = new unsigned int[3];
|
||||||
|
|
||||||
|
// copy indices
|
||||||
|
p_pcOut->mFaces[iFace].mIndices[0] = mesh.mFaces[iFace].mIndices[0];
|
||||||
|
p_pcOut->mFaces[iFace].mIndices[1] = mesh.mFaces[iFace].mIndices[1];
|
||||||
|
p_pcOut->mFaces[iFace].mIndices[2] = mesh.mFaces[iFace].mIndices[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// now build the output mesh list
|
||||||
|
pcScene->mNumMeshes = avOutMeshes.size();
|
||||||
|
pcScene->mMeshes = new aiMesh*[pcScene->mNumMeshes];
|
||||||
|
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||||
|
pcScene->mMeshes[i] = avOutMeshes[i];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ASEImporter::BuildMaterialIndices(aiScene* pcScene)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcScene);
|
||||||
|
|
||||||
|
// iterate through all materials and check whether we need them
|
||||||
|
unsigned int iNum = 0;
|
||||||
|
for (unsigned int iMat = 0; iMat < this->mParser->m_vMaterials.size();++iMat)
|
||||||
|
{
|
||||||
|
if (this->mParser->m_vMaterials[iMat].bNeed)
|
||||||
|
{
|
||||||
|
// convert it to the aiMaterial layout
|
||||||
|
this->ConvertMaterial(this->mParser->m_vMaterials[iMat]);
|
||||||
|
iNum++;
|
||||||
|
}
|
||||||
|
for (unsigned int iSubMat = 0; iSubMat < this->mParser->m_vMaterials[
|
||||||
|
iMat].avSubMaterials.size();++iSubMat)
|
||||||
|
{
|
||||||
|
if (this->mParser->m_vMaterials[iMat].avSubMaterials[iSubMat].bNeed)
|
||||||
|
{
|
||||||
|
// convert it to the aiMaterial layout
|
||||||
|
this->ConvertMaterial(this->mParser->m_vMaterials[iMat].avSubMaterials[iSubMat]);
|
||||||
|
iNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate the output material array
|
||||||
|
pcScene->mNumMaterials = iNum;
|
||||||
|
pcScene->mMaterials = new aiMaterial*[pcScene->mNumMaterials];
|
||||||
|
|
||||||
|
iNum = 0;
|
||||||
|
for (unsigned int iMat = 0; iMat < this->mParser->m_vMaterials.size();++iMat)
|
||||||
|
{
|
||||||
|
if (this->mParser->m_vMaterials[iMat].bNeed)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != this->mParser->m_vMaterials[iMat].pcInstance);
|
||||||
|
pcScene->mMaterials[iNum] = this->mParser->m_vMaterials[iMat].pcInstance;
|
||||||
|
|
||||||
|
// iterate through all meshes and search for one which is using
|
||||||
|
// this top-level material index
|
||||||
|
for (unsigned int iMesh = 0; iMesh < pcScene->mNumMeshes;++iMesh)
|
||||||
|
{
|
||||||
|
if (ASE::Face::DEFAULT_MATINDEX == pcScene->mMeshes[iMesh]->mMaterialIndex &&
|
||||||
|
iMat == (uintptr_t)pcScene->mMeshes[iMesh]->mColors[3])
|
||||||
|
{
|
||||||
|
pcScene->mMeshes[iMesh]->mMaterialIndex = iNum;
|
||||||
|
pcScene->mMeshes[iMesh]->mColors[3] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iNum++;
|
||||||
|
}
|
||||||
|
for (unsigned int iSubMat = 0; iSubMat < this->mParser->m_vMaterials[iMat].avSubMaterials.size();++iSubMat)
|
||||||
|
{
|
||||||
|
if (this->mParser->m_vMaterials[iMat].avSubMaterials[iSubMat].bNeed)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != this->mParser->m_vMaterials[iMat].avSubMaterials[iSubMat].pcInstance);
|
||||||
|
pcScene->mMaterials[iNum] = this->mParser->m_vMaterials[iMat].
|
||||||
|
avSubMaterials[iSubMat].pcInstance;
|
||||||
|
|
||||||
|
// iterate through all meshes and search for one which is using
|
||||||
|
// this sub-level material index
|
||||||
|
for (unsigned int iMesh = 0; iMesh < pcScene->mNumMeshes;++iMesh)
|
||||||
|
{
|
||||||
|
if (iSubMat == pcScene->mMeshes[iMesh]->mMaterialIndex &&
|
||||||
|
iMat == (uintptr_t)pcScene->mMeshes[iMesh]->mColors[3])
|
||||||
|
{
|
||||||
|
pcScene->mMeshes[iMesh]->mMaterialIndex = iNum;
|
||||||
|
pcScene->mMeshes[iMesh]->mColors[3] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// finished!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Generate normal vectors basing on smoothing groups
|
||||||
|
void ASEImporter::GenerateNormals(ASE::Mesh& mesh)
|
||||||
|
{
|
||||||
|
if (mesh.mNormals.empty())
|
||||||
|
{
|
||||||
|
// need to calculate normals ...
|
||||||
|
// TODO: Find a way to merge this with the code in 3DSGenNormals.cpp
|
||||||
|
mesh.mNormals.resize(mesh.mPositions.size(),aiVector3D());
|
||||||
|
for( unsigned int a = 0; a < mesh.mFaces.size(); a++)
|
||||||
|
{
|
||||||
|
const ASE::Face& face = mesh.mFaces[a];
|
||||||
|
|
||||||
|
// assume it is a triangle
|
||||||
|
aiVector3D* pV1 = &mesh.mPositions[face.i1];
|
||||||
|
aiVector3D* pV2 = &mesh.mPositions[face.i2];
|
||||||
|
aiVector3D* pV3 = &mesh.mPositions[face.i3];
|
||||||
|
|
||||||
|
aiVector3D pDelta1 = *pV2 - *pV1;
|
||||||
|
aiVector3D pDelta2 = *pV3 - *pV1;
|
||||||
|
aiVector3D vNor = pDelta1 ^ pDelta2;
|
||||||
|
|
||||||
|
mesh.mNormals[face.i1] = vNor;
|
||||||
|
mesh.mNormals[face.i2] = vNor;
|
||||||
|
mesh.mNormals[face.i3] = vNor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the position bounds so we have a reliable epsilon to
|
||||||
|
// check position differences against
|
||||||
|
// @Schrompf: This is the 7th time this snippet is repeated!
|
||||||
|
aiVector3D minVec( 1e10f, 1e10f, 1e10f), maxVec( -1e10f, -1e10f, -1e10f);
|
||||||
|
for( unsigned int a = 0; a < mesh.mPositions.size(); a++)
|
||||||
|
{
|
||||||
|
minVec.x = std::min( minVec.x, mesh.mPositions[a].x);
|
||||||
|
minVec.y = std::min( minVec.y, mesh.mPositions[a].y);
|
||||||
|
minVec.z = std::min( minVec.z, mesh.mPositions[a].z);
|
||||||
|
maxVec.x = std::max( maxVec.x, mesh.mPositions[a].x);
|
||||||
|
maxVec.y = std::max( maxVec.y, mesh.mPositions[a].y);
|
||||||
|
maxVec.z = std::max( maxVec.z, mesh.mPositions[a].z);
|
||||||
|
}
|
||||||
|
const float posEpsilon = (maxVec - minVec).Length() * 1e-5f;
|
||||||
|
|
||||||
|
std::vector<aiVector3D> avNormals;
|
||||||
|
avNormals.resize(mesh.mNormals.size());
|
||||||
|
|
||||||
|
// now generate the spatial sort tree
|
||||||
|
D3DSSpatialSorter sSort;
|
||||||
|
for( std::vector<ASE::Face>::iterator
|
||||||
|
i = mesh.mFaces.begin();
|
||||||
|
i != mesh.mFaces.end();++i){sSort.AddFace(&(*i),mesh.mPositions);}
|
||||||
|
sSort.Prepare();
|
||||||
|
|
||||||
|
for( std::vector<ASE::Face>::iterator
|
||||||
|
i = mesh.mFaces.begin();
|
||||||
|
i != mesh.mFaces.end();++i)
|
||||||
|
{
|
||||||
|
std::vector<unsigned int> poResult;
|
||||||
|
for (unsigned int c = 0; c < 3;++c)
|
||||||
|
{
|
||||||
|
sSort.FindPositions(mesh.mPositions[(*i).mIndices[c]],(*i).iSmoothGroup,
|
||||||
|
posEpsilon,poResult);
|
||||||
|
|
||||||
|
aiVector3D vNormals;
|
||||||
|
float fDiv = 0.0f;
|
||||||
|
for (std::vector<unsigned int>::const_iterator
|
||||||
|
a = poResult.begin();
|
||||||
|
a != poResult.end();++a)
|
||||||
|
{
|
||||||
|
vNormals += mesh.mNormals[(*a)];
|
||||||
|
fDiv += 1.0f;
|
||||||
|
}
|
||||||
|
vNormals.x /= fDiv;vNormals.y /= fDiv;vNormals.z /= fDiv;
|
||||||
|
vNormals.Normalize();
|
||||||
|
avNormals[(*i).mIndices[c]] = vNormals;
|
||||||
|
poResult.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mesh.mNormals = avNormals;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,147 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Definition of the .ASE importer class. */
|
||||||
|
#ifndef AI_ASELOADER_H_INCLUDED
|
||||||
|
#define AI_ASELOADER_H_INCLUDED
|
||||||
|
|
||||||
|
#include "BaseImporter.h"
|
||||||
|
#include "../include/aiTypes.h"
|
||||||
|
|
||||||
|
struct aiNode;
|
||||||
|
#include "ASEParser.h"
|
||||||
|
|
||||||
|
namespace Assimp
|
||||||
|
{
|
||||||
|
class MaterialHelper;
|
||||||
|
|
||||||
|
using namespace ASE;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Used to load ASE files
|
||||||
|
*/
|
||||||
|
class ASEImporter : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
ASEImporter();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~ASEImporter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
|
{
|
||||||
|
append.append("*.ase;*.ask");
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Imports the given file into the given scene structure.
|
||||||
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Generate normal vectors basing on smoothing groups
|
||||||
|
* (in some cases the normal are already contained in the file)
|
||||||
|
* \param mesh Mesh to work on
|
||||||
|
*/
|
||||||
|
void GenerateNormals(ASE::Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Create valid vertex/normal/UV/color/face lists.
|
||||||
|
* All elements are unique, faces have only one set of indices
|
||||||
|
* after this step occurs.
|
||||||
|
* \param mesh Mesh to work on
|
||||||
|
*/
|
||||||
|
void BuildUniqueRepresentation(ASE::Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Create one-material-per-mesh meshes ;-)
|
||||||
|
* \param mesh Mesh to work with
|
||||||
|
* \param pcScene Scene object to be filled
|
||||||
|
*/
|
||||||
|
void ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Convert a material to a MaterialHelper object
|
||||||
|
* \param mat Input material
|
||||||
|
*/
|
||||||
|
void ConvertMaterial(ASE::Material& mat);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Setup the final material indices for each mesh
|
||||||
|
* \param pcScene Scene object to be filled
|
||||||
|
*/
|
||||||
|
void BuildMaterialIndices(aiScene* pcScene);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Build the node graph
|
||||||
|
* \param pcScene Scene object to be filled
|
||||||
|
*/
|
||||||
|
void BuildNodes(aiScene* pcScene);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/** Parser instance */
|
||||||
|
ASE::Parser* mParser;
|
||||||
|
|
||||||
|
/** Buffer to hold the loaded file */
|
||||||
|
unsigned char* mBuffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
#endif // AI_3DSIMPORTER_H_INC
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,387 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @file Defines the helper data structures for importing ASE files */
|
||||||
|
#ifndef AI_ASEFILEHELPER_H_INC
|
||||||
|
#define AI_ASEFILEHELPER_H_INC
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "../include/aiTypes.h"
|
||||||
|
#include "../include/aiMesh.h"
|
||||||
|
#include "../include/aiAnim.h"
|
||||||
|
|
||||||
|
// for some helper routines like IsSpace()
|
||||||
|
#include "PlyParser.h"
|
||||||
|
|
||||||
|
// ASE is quite similar to 3ds. We can reuse some structures
|
||||||
|
#include "3DSLoader.h"
|
||||||
|
|
||||||
|
namespace Assimp
|
||||||
|
{
|
||||||
|
|
||||||
|
// http://wiki.beyondunreal.com/Legacy:ASE_File_Format
|
||||||
|
namespace ASE
|
||||||
|
{
|
||||||
|
using namespace Dot3DS;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Helper structure representing an ASE material */
|
||||||
|
struct Material : public Dot3DS::Material
|
||||||
|
{
|
||||||
|
//! Default constructor
|
||||||
|
Material() : pcInstance(NULL), bNeed (false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! Ambient texture channel
|
||||||
|
Texture sTexAmbient;
|
||||||
|
|
||||||
|
//! Contains all sub materials of this material
|
||||||
|
std::vector<Material> avSubMaterials;
|
||||||
|
|
||||||
|
//! MaterialHelper object
|
||||||
|
MaterialHelper* pcInstance;
|
||||||
|
|
||||||
|
//! Can we remove this material?
|
||||||
|
bool bNeed;
|
||||||
|
};
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Helper structure to represent an ASE file face */
|
||||||
|
struct Face : public Dot3DS::Face
|
||||||
|
{
|
||||||
|
//! Default constructor. Initializes everything with 0
|
||||||
|
Face()
|
||||||
|
{
|
||||||
|
mColorIndices[0] = mColorIndices[1] = mColorIndices[2] = 0;
|
||||||
|
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
||||||
|
{
|
||||||
|
amUVIndices[i][0] = amUVIndices[i][1] = amUVIndices[i][2] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
iMaterial = DEFAULT_MATINDEX;
|
||||||
|
iFace = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! special value to indicate that no material index has
|
||||||
|
//! been assigned to a face. The default material index
|
||||||
|
//! will replace this value later.
|
||||||
|
static const unsigned int DEFAULT_MATINDEX = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
|
||||||
|
//! Indices into the list of vertices
|
||||||
|
unsigned int mIndices[3];
|
||||||
|
|
||||||
|
//! Indices into each list of texture coordinates
|
||||||
|
unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3];
|
||||||
|
|
||||||
|
//! Index into the list of vertex colors
|
||||||
|
unsigned int mColorIndices[3];
|
||||||
|
|
||||||
|
//! (Sub)Material index to be assigned to this face
|
||||||
|
unsigned int iMaterial;
|
||||||
|
|
||||||
|
//! Index of the face. It is not specified whether it is
|
||||||
|
//! a requirement of the file format that all faces are
|
||||||
|
//! written in sequential order, so we have to expect this case
|
||||||
|
unsigned int iFace;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Helper structure to represent an ASE file mesh */
|
||||||
|
struct Mesh
|
||||||
|
{
|
||||||
|
//! Constructor. Creates a default name for the mesh
|
||||||
|
Mesh()
|
||||||
|
{
|
||||||
|
static int iCnt = 0;
|
||||||
|
std::stringstream ss(mName);
|
||||||
|
ss << "%%_UNNAMED_" << iCnt++ << "_%%";
|
||||||
|
|
||||||
|
// use 2 texture vertex components by default
|
||||||
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
|
this->mNumUVComponents[c] = 2;
|
||||||
|
}
|
||||||
|
std::string mName;
|
||||||
|
|
||||||
|
//! vertex positions
|
||||||
|
std::vector<aiVector3D> mPositions;
|
||||||
|
|
||||||
|
//! List of all faces loaded
|
||||||
|
std::vector<ASE::Face> mFaces;
|
||||||
|
|
||||||
|
//! List of all texture coordinate sets
|
||||||
|
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
|
||||||
|
//! List of all vertex color sets.
|
||||||
|
std::vector<aiColor4D> mVertexColors;
|
||||||
|
|
||||||
|
//! List of normal vectors
|
||||||
|
std::vector<aiVector3D> mNormals;
|
||||||
|
|
||||||
|
//! Transformation matrix of the mesh
|
||||||
|
aiMatrix4x4 mTransform;
|
||||||
|
|
||||||
|
//! Material index of the mesh
|
||||||
|
unsigned int iMaterialIndex;
|
||||||
|
|
||||||
|
//! Number of vertex components for each UVW set
|
||||||
|
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------
|
||||||
|
/** \brief Class to parse ASE files
|
||||||
|
*/
|
||||||
|
class Parser
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Parser() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Construct a parser from a given input file which is
|
||||||
|
//! guaranted to be terminated with zero.
|
||||||
|
Parser (const char* szFile);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parses the file into the parsers internal representation
|
||||||
|
void Parse();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse the *SCENE block in a file
|
||||||
|
void ParseLV1SceneBlock();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse the *MATERIAL_LIST block in a file
|
||||||
|
void ParseLV1MaterialListBlock();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *GEOMOBJECT block in a file
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV1GeometryObjectBlock(Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MATERIAL blocks in a material list
|
||||||
|
//! \param mat Material structure to be filled
|
||||||
|
void ParseLV2MaterialBlock(Material& mat);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *NODE_TM block in a file
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV2NodeTransformBlock(Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH block in a file
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV2MeshBlock(Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse the *MAP_XXXXXX blocks in a material
|
||||||
|
//! \param map Texture structure to be filled
|
||||||
|
void ParseLV3MapBlock(Texture& map);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_VERTEX_LIST block in a file
|
||||||
|
//! \param iNumVertices Value of *MESH_NUMVERTEX, if present.
|
||||||
|
//! Otherwise zero. This is used to check the consistency of the file.
|
||||||
|
//! A warning is sent to the logger if the validations fails.
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV3MeshVertexListBlock(
|
||||||
|
unsigned int iNumVertices,Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_FACE_LIST block in a file
|
||||||
|
//! \param iNumFaces Value of *MESH_NUMFACES, if present.
|
||||||
|
//! Otherwise zero. This is used to check the consistency of the file.
|
||||||
|
//! A warning is sent to the logger if the validations fails.
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV3MeshFaceListBlock(
|
||||||
|
unsigned int iNumFaces,Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_TVERT_LIST block in a file
|
||||||
|
//! \param iNumVertices Value of *MESH_NUMTVERTEX, if present.
|
||||||
|
//! Otherwise zero. This is used to check the consistency of the file.
|
||||||
|
//! A warning is sent to the logger if the validations fails.
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
//! \param iChannel Output UVW channel
|
||||||
|
void ParseLV3MeshTListBlock(
|
||||||
|
unsigned int iNumVertices,Mesh& mesh, unsigned int iChannel = 0);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_TFACELIST block in a file
|
||||||
|
//! \param iNumFaces Value of *MESH_NUMTVFACES, if present.
|
||||||
|
//! Otherwise zero. This is used to check the consistency of the file.
|
||||||
|
//! A warning is sent to the logger if the validations fails.
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
//! \param iChannel Output UVW channel
|
||||||
|
void ParseLV3MeshTFaceListBlock(
|
||||||
|
unsigned int iNumFaces,Mesh& mesh, unsigned int iChannel = 0);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse an additional mapping channel
|
||||||
|
//! (specified via *MESH_MAPPINGCHANNEL)
|
||||||
|
//! \param iChannel Channel index to be filled
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV3MappingChannel(
|
||||||
|
unsigned int iChannel, Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_CVERTLIST block in a file
|
||||||
|
//! \param iNumVertices Value of *MESH_NUMCVERTEX, if present.
|
||||||
|
//! Otherwise zero. This is used to check the consistency of the file.
|
||||||
|
//! A warning is sent to the logger if the validations fails.
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV3MeshCListBlock(
|
||||||
|
unsigned int iNumVertices, Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_CFACELIST block in a file
|
||||||
|
//! \param iNumFaces Value of *MESH_NUMCVFACES, if present.
|
||||||
|
//! Otherwise zero. This is used to check the consistency of the file.
|
||||||
|
//! A warning is sent to the logger if the validations fails.
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV3MeshCFaceListBlock(
|
||||||
|
unsigned int iNumFaces, Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_NORMALS block in a file
|
||||||
|
//! \param mesh Mesh object to be filled
|
||||||
|
void ParseLV3MeshNormalListBlock(Mesh& mesh);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_FACE block in a file
|
||||||
|
//! \param out receive the face data
|
||||||
|
void ParseLV4MeshFace(ASE::Face& out);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_VERT block in a file
|
||||||
|
//! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...)
|
||||||
|
//! \param apOut Output buffer (3 floats)
|
||||||
|
//! \param rIndexOut Output index
|
||||||
|
void ParseLV4MeshFloatTriple(float* apOut, unsigned int& rIndexOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_VERT block in a file
|
||||||
|
//! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...)
|
||||||
|
//! \param apOut Output buffer (3 floats)
|
||||||
|
void ParseLV4MeshFloatTriple(float* apOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_TFACE block in a file
|
||||||
|
//! (also works for MESH_CFACE)
|
||||||
|
//! \param apOut Output buffer (3 ints)
|
||||||
|
//! \param rIndexOut Output index
|
||||||
|
void ParseLV4MeshLongTriple(unsigned int* apOut, unsigned int& rIndexOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a *MESH_TFACE block in a file
|
||||||
|
//! (also works for MESH_CFACE)
|
||||||
|
//! \param apOut Output buffer (3 ints)
|
||||||
|
void ParseLV4MeshLongTriple(unsigned int* apOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a single float element
|
||||||
|
//! \param fOut Output float
|
||||||
|
void ParseLV4MeshFloat(float& fOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Parse a single int element
|
||||||
|
//! \param iOut Output integer
|
||||||
|
void ParseLV4MeshLong(unsigned int& iOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Skip the opening bracket at the beginning of a complex statement
|
||||||
|
bool SkipOpeningBracket();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Skip everything to the next: '*' or '\0'
|
||||||
|
bool SkipToNextToken();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Skip the current section until the token after the closing }.
|
||||||
|
//! This function handles embedded subsections correctly
|
||||||
|
bool SkipSection();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Output a warning to the logger
|
||||||
|
//! \param szWarn Warn message
|
||||||
|
void LogWarning(const char* szWarn);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
//! Output an error to the logger
|
||||||
|
//! \param szWarn Error message
|
||||||
|
void LogError(const char* szWarn);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Pointer to current data
|
||||||
|
const char* m_szFile;
|
||||||
|
|
||||||
|
//! background color to be passed to the viewer
|
||||||
|
//! QNAN if none was found
|
||||||
|
aiColor3D m_clrBackground;
|
||||||
|
|
||||||
|
//! Base ambient color to be passed to all materials
|
||||||
|
//! QNAN if none was found
|
||||||
|
aiColor3D m_clrAmbient;
|
||||||
|
|
||||||
|
//! List of all materials found in the file
|
||||||
|
std::vector<Material> m_vMaterials;
|
||||||
|
|
||||||
|
//! List of all meshes found in the file
|
||||||
|
std::vector<Mesh> m_vMeshes;
|
||||||
|
|
||||||
|
//! Current line in the file
|
||||||
|
unsigned int iLineNumber;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};};
|
||||||
|
|
||||||
|
#endif // !! include guard
|
114
code/Assimp.cpp
114
code/Assimp.cpp
|
@ -1,22 +1,77 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
/** @file Implementation of the Plain-C API */
|
/** @file Implementation of the Plain-C API */
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "../include/assimp.h"
|
#include "../include/assimp.h"
|
||||||
#include "../include/assimp.hpp"
|
#include "../include/assimp.hpp"
|
||||||
|
|
||||||
|
#include "../include/aiassert.h"
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
#if (defined AI_C_THREADSAFE)
|
||||||
|
# include <boost/thread/thread.hpp>
|
||||||
|
# include <boost/thread/mutex.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Stores the importer objects for all active import processes */
|
/** Stores the importer objects for all active import processes */
|
||||||
typedef std::map< const aiScene*, Assimp::Importer* > ImporterMap;
|
typedef std::map< const aiScene*, Assimp::Importer* > ImporterMap;
|
||||||
|
|
||||||
/** Local storage of all active import processes */
|
/** Local storage of all active import processes */
|
||||||
static ImporterMap gActiveImports;
|
static ImporterMap gActiveImports;
|
||||||
|
|
||||||
/** Error message of the last failed import process */
|
/** Error message of the last failed import process */
|
||||||
static std::string gLastErrorString;
|
static std::string gLastErrorString;
|
||||||
|
|
||||||
|
#if (defined AI_C_THREADSAFE)
|
||||||
|
/** Global mutex to manage the access to the importer map */
|
||||||
|
static boost::mutex gMutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads the given file and returns its content.
|
// Reads the given file and returns its content.
|
||||||
const aiScene* aiImportFile( const char* pFile, unsigned int pFlags)
|
const aiScene* aiImportFile( const char* pFile, unsigned int pFlags)
|
||||||
{
|
{
|
||||||
|
ai_assert(NULL != pFile);
|
||||||
|
|
||||||
// create an Importer for this file
|
// create an Importer for this file
|
||||||
Assimp::Importer* imp = new Assimp::Importer;
|
Assimp::Importer* imp = new Assimp::Importer;
|
||||||
// and have it read the file
|
// and have it read the file
|
||||||
|
@ -25,6 +80,9 @@ const aiScene* aiImportFile( const char* pFile, unsigned int pFlags)
|
||||||
// if succeeded, place it in the collection of active processes
|
// if succeeded, place it in the collection of active processes
|
||||||
if( scene)
|
if( scene)
|
||||||
{
|
{
|
||||||
|
#if (defined AI_C_THREADSAFE)
|
||||||
|
boost::mutex::scoped_lock lock(gMutex);
|
||||||
|
#endif
|
||||||
gActiveImports[scene] = imp;
|
gActiveImports[scene] = imp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -42,6 +100,13 @@ const aiScene* aiImportFile( const char* pFile, unsigned int pFlags)
|
||||||
// Releases all resources associated with the given import process.
|
// Releases all resources associated with the given import process.
|
||||||
void aiReleaseImport( const aiScene* pScene)
|
void aiReleaseImport( const aiScene* pScene)
|
||||||
{
|
{
|
||||||
|
if (!pScene)return;
|
||||||
|
|
||||||
|
// lock the mutex
|
||||||
|
#if (defined AI_C_THREADSAFE)
|
||||||
|
boost::mutex::scoped_lock lock(gMutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
// find the importer associated with this data
|
// find the importer associated with this data
|
||||||
ImporterMap::iterator it = gActiveImports.find( pScene);
|
ImporterMap::iterator it = gActiveImports.find( pScene);
|
||||||
// it should be there... else the user is playing fools with us
|
// it should be there... else the user is playing fools with us
|
||||||
|
@ -59,3 +124,52 @@ const char* aiGetErrorString()
|
||||||
{
|
{
|
||||||
return gLastErrorString.c_str();
|
return gLastErrorString.c_str();
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Returns the error text of the last failed import process.
|
||||||
|
int aiIsExtensionSupported(const char* szExtension)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != szExtension);
|
||||||
|
|
||||||
|
// lock the mutex
|
||||||
|
#if (defined AI_C_THREADSAFE)
|
||||||
|
boost::mutex::scoped_lock lock(gMutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!gActiveImports.empty())
|
||||||
|
{
|
||||||
|
return (int)((*(gActiveImports.begin())).second->IsExtensionSupported(
|
||||||
|
std::string ( szExtension )));
|
||||||
|
}
|
||||||
|
// need to create a temporary Importer instance.
|
||||||
|
// TODO: Find a better solution ...
|
||||||
|
Assimp::Importer* pcTemp = new Assimp::Importer();
|
||||||
|
int i = (int)pcTemp->IsExtensionSupported(std::string ( szExtension ));
|
||||||
|
delete pcTemp;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Get a list of all file extensions supported by ASSIMP
|
||||||
|
void aiGetExtensionList(aiString* szOut)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != szOut);
|
||||||
|
|
||||||
|
// lock the mutex
|
||||||
|
#if (defined AI_C_THREADSAFE)
|
||||||
|
boost::mutex::scoped_lock lock(gMutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::string szTemp;
|
||||||
|
if (!gActiveImports.empty())
|
||||||
|
{
|
||||||
|
(*(gActiveImports.begin())).second->GetExtensionList(szTemp);
|
||||||
|
szOut->Set ( szTemp );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// need to create a temporary Importer instance.
|
||||||
|
// TODO: Find a better solution ...
|
||||||
|
Assimp::Importer* pcTemp = new Assimp::Importer();
|
||||||
|
pcTemp->GetExtensionList(szTemp);
|
||||||
|
szOut->Set ( szTemp );
|
||||||
|
delete pcTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,47 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the few default functions of the base importer class */
|
/** @file Implementation of the few default functions of the base importer class */
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
|
#include "DefaultLogger.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
#include "aiAssert.h"
|
#include "aiAssert.h"
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
@ -33,6 +75,9 @@ aiScene* BaseImporter::ReadFile( const std::string& pFile, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
// extract error description
|
// extract error description
|
||||||
mErrorText = exception->GetErrorText();
|
mErrorText = exception->GetErrorText();
|
||||||
|
|
||||||
|
DefaultLogger::get()->error(mErrorText);
|
||||||
|
|
||||||
delete exception;
|
delete exception;
|
||||||
|
|
||||||
// and kill the partially imported data
|
// and kill the partially imported data
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definition of the base class for all importer worker classes. */
|
/** @file Definition of the base class for all importer worker classes. */
|
||||||
#ifndef AI_BASEIMPORTER_H_INC
|
#ifndef AI_BASEIMPORTER_H_INC
|
||||||
#define AI_BASEIMPORTER_H_INC
|
#define AI_BASEIMPORTER_H_INC
|
||||||
|
@ -22,8 +62,10 @@ public:
|
||||||
mErrorText = pErrorText;
|
mErrorText = pErrorText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
/** Returns the error text provided when throwing the exception */
|
/** Returns the error text provided when throwing the exception */
|
||||||
const std::string& GetErrorText() const { return mErrorText; }
|
inline const std::string& GetErrorText() const
|
||||||
|
{ return mErrorText; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mErrorText;
|
std::string mErrorText;
|
||||||
|
@ -36,15 +78,16 @@ private:
|
||||||
* The interface defines two functions: CanRead() is used to check if the
|
* The interface defines two functions: CanRead() is used to check if the
|
||||||
* importer can handle the format of the given file. If an implementation of
|
* importer can handle the format of the given file. If an implementation of
|
||||||
* this function returns true, the importer then calls ReadFile() which
|
* this function returns true, the importer then calls ReadFile() which
|
||||||
* imports the given file. ReadFile is not overridable, it just calls InternReadFile()
|
* imports the given file. ReadFile is not overridable, it just calls
|
||||||
* and catches any ImportErrorException that might occur.
|
* InternReadFile() and catches any ImportErrorException that might occur.
|
||||||
*/
|
*/
|
||||||
class BaseImporter
|
class BaseImporter
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Constructor to be privately used by Importer */
|
|
||||||
|
/** Constructor to be privately used by #Importer */
|
||||||
BaseImporter();
|
BaseImporter();
|
||||||
|
|
||||||
/** Destructor, private as well */
|
/** Destructor, private as well */
|
||||||
|
@ -56,46 +99,73 @@ public:
|
||||||
* @param pFile Path and file name of the file to be examined.
|
* @param pFile Path and file name of the file to be examined.
|
||||||
* @param pIOHandler The IO handler to use for accessing any file.
|
* @param pIOHandler The IO handler to use for accessing any file.
|
||||||
* @return true if the class can read this file, false if not.
|
* @return true if the class can read this file, false if not.
|
||||||
|
*
|
||||||
|
* @note Sometimes ASSIMP uses this method to determine whether a
|
||||||
|
* a given file extension is generally supported. In this case the
|
||||||
|
* file extension is passed in the pFile parameter, pIOHandler is NULL
|
||||||
*/
|
*/
|
||||||
virtual bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const = 0;
|
virtual bool CanRead( const std::string& pFile,
|
||||||
|
IOSystem* pIOHandler) const = 0;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Imports the given file and returns the imported data.
|
/** Imports the given file and returns the imported data.
|
||||||
* If the import succeeds, ownership of the data is transferred to the caller.
|
* If the import succeeds, ownership of the data is transferred to
|
||||||
* If the import failes, NULL is returned. The function takes care that any
|
* the caller. If the import failes, NULL is returned. The function
|
||||||
* partially constructed data is destroyed beforehand.
|
* takes care that any partially constructed data is destroyed
|
||||||
|
* beforehand.
|
||||||
*
|
*
|
||||||
* @param pFile Path of the file to be imported.
|
* @param pFile Path of the file to be imported.
|
||||||
* @param pIOHandler IO-Handler used to open this and possible other files.
|
* @param pIOHandler IO-Handler used to open this and possible other files.
|
||||||
* @return The imported data or NULL if failed. If it failed a human-readable
|
* @return The imported data or NULL if failed. If it failed a
|
||||||
* error description can be retrieved by calling GetErrorText()
|
* human-readable error description can be retrieved by calling
|
||||||
|
* GetErrorText()
|
||||||
*
|
*
|
||||||
* @note This function is not intended to be overridden. Implement InternReadFile()
|
* @note This function is not intended to be overridden. Implement
|
||||||
* to do the import. If an exception is thrown somewhere in InternReadFile(),
|
* InternReadFile() to do the import. If an exception is thrown somewhere
|
||||||
* this function will catch it and transform it into a suitable response to the caller.
|
* in InternReadFile(), this function will catch it and transform it into
|
||||||
|
* a suitable response to the caller.
|
||||||
*/
|
*/
|
||||||
aiScene* ReadFile( const std::string& pFile, IOSystem* pIOHandler);
|
aiScene* ReadFile( const std::string& pFile, IOSystem* pIOHandler);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns the error description of the last error that occured.
|
/** Returns the error description of the last error that occured.
|
||||||
* @return A description of the last error that occured. An empty string if no error.
|
* @return A description of the last error that occured. An empty
|
||||||
|
* string if there was no error.
|
||||||
*/
|
*/
|
||||||
const std::string& GetErrorText() const { return mErrorText; }
|
inline const std::string& GetErrorText() const
|
||||||
|
{ return mErrorText; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Imports the given file into the given scene structure. The function is
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
* expected to throw an ImportErrorException if there is an error. If it
|
* Importer implementations should append all file extensions
|
||||||
* terminates normally, the data in aiScene is expected to be correct.
|
* which they supported to the passed string.
|
||||||
* Override this function to implement the actual importing.
|
* Example: "*.blabb;*.quak;*.gug;*.foo" (no comma after the last!)
|
||||||
|
* @param append Output string
|
||||||
|
*/
|
||||||
|
virtual void GetExtensionList(std::string& append) = 0;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Imports the given file into the given scene structure. The
|
||||||
|
* function is expected to throw an ImportErrorException if there is
|
||||||
|
* an error. If it terminates normally, the data in aiScene is
|
||||||
|
* expected to be correct. Override this function to implement the
|
||||||
|
* actual importing.
|
||||||
*
|
*
|
||||||
* @param pFile Path of the file to be imported.
|
* @param pFile Path of the file to be imported.
|
||||||
* @param pScene The scene object to hold the imported data.
|
* @param pScene The scene object to hold the imported data.
|
||||||
|
* NULL is not a valid parameter.
|
||||||
* @param pIOHandler The IO handler to use for any file access.
|
* @param pIOHandler The IO handler to use for any file access.
|
||||||
|
* NULL is not a valid parameter.
|
||||||
*/
|
*/
|
||||||
virtual void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) = 0;
|
virtual void InternReadFile( const std::string& pFile,
|
||||||
|
aiScene* pScene, IOSystem* pIOHandler) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** Error description in case there was one. */
|
/** Error description in case there was one. */
|
||||||
std::string mErrorText;
|
std::string mErrorText;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Base class of all import post processing steps */
|
/** @file Base class of all import post processing steps */
|
||||||
#ifndef AI_BASEPROCESS_H_INC
|
#ifndef AI_BASEPROCESS_H_INC
|
||||||
#define AI_BASEPROCESS_H_INC
|
#define AI_BASEPROCESS_H_INC
|
||||||
|
|
|
@ -1,5 +1,46 @@
|
||||||
/** @file Implementation of the post processing step to calculate tangents and bitangents
|
/*
|
||||||
* for all imported meshes
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Implementation of the post processing step to calculate
|
||||||
|
* tangents and bitangents for all imported meshes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @file Defines a post processing step to calculate tangents and bitangents on all imported meshes.*/
|
/** @file Defines a post processing step to calculate tangents and bitangents on all imported meshes.*/
|
||||||
#ifndef AI_CALCTANGENTSPROCESS_H_INC
|
#ifndef AI_CALCTANGENTSPROCESS_H_INC
|
||||||
#define AI_CALCTANGENTSPROCESS_H_INC
|
#define AI_CALCTANGENTSPROCESS_H_INC
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines a post processing step to convert all data to a left-handed coordinate system.*/
|
/** @file Defines a post processing step to convert all data to a left-handed coordinate system.*/
|
||||||
#ifndef AI_CONVERTTOLHPROCESS_H_INC
|
#ifndef AI_CONVERTTOLHPROCESS_H_INC
|
||||||
#define AI_CONVERTTOLHPROCESS_H_INC
|
#define AI_CONVERTTOLHPROCESS_H_INC
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
/** @file Default File I/O implementation for #Importer */
|
/** @file Default File I/O implementation for #Importer */
|
||||||
|
|
||||||
#include "DefaultIOStream.h"
|
#include "DefaultIOStream.h"
|
||||||
|
@ -8,7 +48,6 @@
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
DefaultIOStream::~DefaultIOStream()
|
DefaultIOStream::~DefaultIOStream()
|
||||||
{
|
{
|
||||||
|
@ -17,8 +56,6 @@ DefaultIOStream::~DefaultIOStream()
|
||||||
fclose(this->mFile);
|
fclose(this->mFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
size_t DefaultIOStream::Read(void* pvBuffer,
|
size_t DefaultIOStream::Read(void* pvBuffer,
|
||||||
size_t pSize,
|
size_t pSize,
|
||||||
|
@ -29,9 +66,6 @@ size_t DefaultIOStream::Read(void* pvBuffer,
|
||||||
|
|
||||||
return fread(pvBuffer, pSize, pCount, this->mFile);
|
return fread(pvBuffer, pSize, pCount, this->mFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
size_t DefaultIOStream::Write(const void* pvBuffer,
|
size_t DefaultIOStream::Write(const void* pvBuffer,
|
||||||
size_t pSize,
|
size_t pSize,
|
||||||
|
@ -42,9 +76,6 @@ size_t DefaultIOStream::Write(const void* pvBuffer,
|
||||||
fseek(mFile, 0, SEEK_SET);
|
fseek(mFile, 0, SEEK_SET);
|
||||||
return fwrite(pvBuffer, pSize, pCount, this->mFile);
|
return fwrite(pvBuffer, pSize, pCount, this->mFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
aiReturn DefaultIOStream::Seek(size_t pOffset,
|
aiReturn DefaultIOStream::Seek(size_t pOffset,
|
||||||
aiOrigin pOrigin)
|
aiOrigin pOrigin)
|
||||||
|
@ -56,9 +87,6 @@ aiReturn DefaultIOStream::Seek(size_t pOffset,
|
||||||
(aiOrigin_END == pOrigin ? SEEK_END : SEEK_SET)))
|
(aiOrigin_END == pOrigin ? SEEK_END : SEEK_SET)))
|
||||||
? AI_SUCCESS : AI_FAILURE);
|
? AI_SUCCESS : AI_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
size_t DefaultIOStream::Tell() const
|
size_t DefaultIOStream::Tell() const
|
||||||
{
|
{
|
||||||
|
@ -66,8 +94,6 @@ size_t DefaultIOStream::Tell() const
|
||||||
|
|
||||||
return ftell(this->mFile);
|
return ftell(this->mFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
size_t DefaultIOStream::FileSize() const
|
size_t DefaultIOStream::FileSize() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Default file I/O using fXXX()-family of functions */
|
/** @file Default file I/O using fXXX()-family of functions */
|
||||||
#ifndef AI_DEFAULTIOSTREAM_H_INC
|
#ifndef AI_DEFAULTIOSTREAM_H_INC
|
||||||
#define AI_DEFAULTIOSTREAM_H_INC
|
#define AI_DEFAULTIOSTREAM_H_INC
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
/** @file Default implementation of IOSystem using the standard C file functions */
|
/** @file Default implementation of IOSystem using the standard C file functions */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Default implementation of IOSystem using the standard C file functions */
|
/** @file Default implementation of IOSystem using the standard C file functions */
|
||||||
#ifndef AI_DEFAULTIOSYSTEM_H_INC
|
#ifndef AI_DEFAULTIOSYSTEM_H_INC
|
||||||
#define AI_DEFAULTIOSYSTEM_H_INC
|
#define AI_DEFAULTIOSYSTEM_H_INC
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the post processing step to generate face
|
/** @file Implementation of the post processing step to generate face
|
||||||
* normals for all imported faces.
|
* normals for all imported faces.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines a post processing step to compute face normals for all loaded faces*/
|
/** @file Defines a post processing step to compute face normals for all loaded faces*/
|
||||||
#ifndef AI_GENFACENORMALPROCESS_H_INC
|
#ifndef AI_GENFACENORMALPROCESS_H_INC
|
||||||
#define AI_GENFACENORMALPROCESS_H_INC
|
#define AI_GENFACENORMALPROCESS_H_INC
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the post processing step to generate face
|
/** @file Implementation of the post processing step to generate face
|
||||||
* normals for all imported faces.
|
* normals for all imported faces.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines a post processing step to compute vertex normals for all loaded vertizes */
|
/** @file Defines a post processing step to compute vertex normals for all loaded vertizes */
|
||||||
#ifndef AI_GENVERTEXNORMALPROCESS_H_INC
|
#ifndef AI_GENVERTEXNORMALPROCESS_H_INC
|
||||||
#define AI_GENVERTEXNORMALPROCESS_H_INC
|
#define AI_GENVERTEXNORMALPROCESS_H_INC
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the CPP-API class #Importer */
|
/** @file Implementation of the CPP-API class #Importer */
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -8,12 +49,35 @@
|
||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
#include "DefaultIOStream.h"
|
#include "DefaultIOStream.h"
|
||||||
#include "DefaultIOSystem.h"
|
#include "DefaultIOSystem.h"
|
||||||
#include "XFileImporter.h"
|
|
||||||
#include "3DSLoader.h"
|
#if (!defined AI_BUILD_NO_X_IMPORTER)
|
||||||
#include "MD3Loader.h"
|
# include "XFileImporter.h"
|
||||||
#include "MD2Loader.h"
|
#endif
|
||||||
#include "PlyLoader.h"
|
#if (!defined AI_BUILD_NO_3DS_IMPORTER)
|
||||||
#include "ObjFileImporter.h"
|
# include "3DSLoader.h"
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MD3_IMPORTER)
|
||||||
|
# include "MD3Loader.h"
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MD4_IMPORTER)
|
||||||
|
# include "MD4Loader.h"
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MDL_IMPORTER)
|
||||||
|
# include "MDLLoader.h"
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MD2_IMPORTER)
|
||||||
|
# include "MD2Loader.h"
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_PLY_IMPORTER)
|
||||||
|
# include "PlyLoader.h"
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_ASE_IMPORTER)
|
||||||
|
# include "ASELoader.h"
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_OBJ_IMPORTER)
|
||||||
|
# include "ObjFileImporter.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "CalcTangentsProcess.h"
|
#include "CalcTangentsProcess.h"
|
||||||
#include "JoinVerticesProcess.h"
|
#include "JoinVerticesProcess.h"
|
||||||
#include "ConvertToLHProcess.h"
|
#include "ConvertToLHProcess.h"
|
||||||
|
@ -32,25 +96,47 @@ Importer::Importer() :
|
||||||
mScene(NULL),
|
mScene(NULL),
|
||||||
mErrorString("")
|
mErrorString("")
|
||||||
{
|
{
|
||||||
// default IO handler
|
// allocate a default IO handler
|
||||||
mIOHandler = new DefaultIOSystem;
|
mIOHandler = new DefaultIOSystem;
|
||||||
|
|
||||||
// add an instance of each worker class here
|
// add an instance of each worker class here
|
||||||
|
#if (!defined AI_BUILD_NO_X_IMPORTER)
|
||||||
mImporter.push_back( new XFileImporter());
|
mImporter.push_back( new XFileImporter());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_OBJ_IMPORTER)
|
||||||
mImporter.push_back( new ObjFileImporter());
|
mImporter.push_back( new ObjFileImporter());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_3DS_IMPORTER)
|
||||||
mImporter.push_back( new Dot3DSImporter());
|
mImporter.push_back( new Dot3DSImporter());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MD3_IMPORTER)
|
||||||
mImporter.push_back( new MD3Importer());
|
mImporter.push_back( new MD3Importer());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MD2_IMPORTER)
|
||||||
mImporter.push_back( new MD2Importer());
|
mImporter.push_back( new MD2Importer());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_PLY_IMPORTER)
|
||||||
mImporter.push_back( new PLYImporter());
|
mImporter.push_back( new PLYImporter());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MDL_IMPORTER)
|
||||||
|
mImporter.push_back( new MDLImporter());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_MD4_IMPORTER)
|
||||||
|
mImporter.push_back( new MD4Importer());
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_BUILD_NO_ASE_IMPORTER)
|
||||||
|
mImporter.push_back( new ASEImporter());
|
||||||
|
#endif
|
||||||
|
|
||||||
// add an instance of each post processing step here in the order of sequence it is executed
|
// add an instance of each post processing step here in the order of sequence it is executed
|
||||||
mPostProcessingSteps.push_back( new TriangulateProcess());
|
mPostProcessingSteps.push_back( new TriangulateProcess());
|
||||||
mPostProcessingSteps.push_back( new SplitLargeMeshesProcess());
|
mPostProcessingSteps.push_back( new SplitLargeMeshesProcess_Triangle());
|
||||||
mPostProcessingSteps.push_back( new KillNormalsProcess());
|
mPostProcessingSteps.push_back( new KillNormalsProcess());
|
||||||
mPostProcessingSteps.push_back( new GenFaceNormalsProcess());
|
mPostProcessingSteps.push_back( new GenFaceNormalsProcess());
|
||||||
mPostProcessingSteps.push_back( new GenVertexNormalsProcess());
|
mPostProcessingSteps.push_back( new GenVertexNormalsProcess());
|
||||||
mPostProcessingSteps.push_back( new CalcTangentsProcess());
|
mPostProcessingSteps.push_back( new CalcTangentsProcess());
|
||||||
mPostProcessingSteps.push_back( new JoinVerticesProcess());
|
mPostProcessingSteps.push_back( new JoinVerticesProcess());
|
||||||
|
mPostProcessingSteps.push_back( new SplitLargeMeshesProcess_Vertex());
|
||||||
mPostProcessingSteps.push_back( new ConvertToLHProcess());
|
mPostProcessingSteps.push_back( new ConvertToLHProcess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +149,7 @@ Importer::~Importer()
|
||||||
for( unsigned int a = 0; a < mPostProcessingSteps.size(); a++)
|
for( unsigned int a = 0; a < mPostProcessingSteps.size(); a++)
|
||||||
delete mPostProcessingSteps[a];
|
delete mPostProcessingSteps[a];
|
||||||
|
|
||||||
|
// delete the assigned IO handler
|
||||||
delete mIOHandler;
|
delete mIOHandler;
|
||||||
|
|
||||||
// kill imported scene. Destructors should do that recursivly
|
// kill imported scene. Destructors should do that recursivly
|
||||||
|
@ -73,8 +160,17 @@ Importer::~Importer()
|
||||||
// Supplies a custom IO handler to the importer to open and access files.
|
// Supplies a custom IO handler to the importer to open and access files.
|
||||||
void Importer::SetIOHandler( IOSystem* pIOHandler)
|
void Importer::SetIOHandler( IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
delete mIOHandler;
|
if (NULL == pIOHandler)
|
||||||
mIOHandler = pIOHandler;
|
{
|
||||||
|
delete mIOHandler;
|
||||||
|
mIOHandler = new DefaultIOSystem();
|
||||||
|
}
|
||||||
|
else if (mIOHandler != pIOHandler)
|
||||||
|
{
|
||||||
|
delete mIOHandler;
|
||||||
|
mIOHandler = pIOHandler;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -128,9 +224,40 @@ const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Empty and rpivate copy constructor
|
// Empty and private copy constructor
|
||||||
Importer::Importer(const Importer &other)
|
Importer::Importer(const Importer &other)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Helper function to check whether an extension is supported by ASSIMP
|
||||||
|
bool Importer::IsExtensionSupported(const std::string& szExtension)
|
||||||
|
{
|
||||||
|
for (std::vector<BaseImporter*>::const_iterator
|
||||||
|
i = this->mImporter.begin();
|
||||||
|
i != this->mImporter.end();++i)
|
||||||
|
{
|
||||||
|
// pass the file extension to the CanRead(..,NULL)-method
|
||||||
|
if ((*i)->CanRead(szExtension,NULL))return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Helper function to build a list of all file extensions supported by ASSIMP
|
||||||
|
void Importer::GetExtensionList(std::string& szOut)
|
||||||
|
{
|
||||||
|
unsigned int iNum = 0;
|
||||||
|
for (std::vector<BaseImporter*>::const_iterator
|
||||||
|
i = this->mImporter.begin();
|
||||||
|
i != this->mImporter.end();++i,++iNum)
|
||||||
|
{
|
||||||
|
// insert a comma as delimiter character
|
||||||
|
if (0 != iNum)
|
||||||
|
szOut.append(";");
|
||||||
|
|
||||||
|
(*i)->GetExtensionList(szOut);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the post processing step to join identical vertices
|
/** @file Implementation of the post processing step to join identical vertices
|
||||||
* for all imported meshes
|
* for all imported meshes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines a post processing step to join identical vertices on all imported meshes.*/
|
/** @file Defines a post processing step to join identical vertices on all imported meshes.*/
|
||||||
#ifndef AI_JOINVERTICESPROCESS_H_INC
|
#ifndef AI_JOINVERTICESPROCESS_H_INC
|
||||||
#define AI_CALCTANGENTSPROCESS_H_INC
|
#define AI_CALCTANGENTSPROCESS_H_INC
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
/** @file Implementation of the post processing step tokill mesh normals
|
/** @file Implementation of the post processing step tokill mesh normals
|
||||||
*/
|
*/
|
||||||
#include "KillNormalsProcess.h"
|
#include "KillNormalsProcess.h"
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines a post processing step to kill all loaded normals */
|
/** @file Defines a post processing step to kill all loaded normals */
|
||||||
#ifndef AI_KILLNORMALPROCESS_H_INC
|
#ifndef AI_KILLNORMALPROCESS_H_INC
|
||||||
#define AI_KILLNORMALPROCESS_H_INC
|
#define AI_KILLNORMALPROCESS_H_INC
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the helper data structures for importing MD2 files */
|
/** @file Defines the helper data structures for importing MD2 files */
|
||||||
#ifndef AI_MD2FILEHELPER_H_INC
|
#ifndef AI_MD2FILEHELPER_H_INC
|
||||||
#define AI_MD2FILEHELPER_H_INC
|
#define AI_MD2FILEHELPER_H_INC
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the MD2 importer class */
|
/** @file Implementation of the MD2 importer class */
|
||||||
#include "MD2Loader.h"
|
#include "MD2Loader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
|
@ -150,11 +191,11 @@ void MD2Importer::InternReadFile(
|
||||||
std::vector<aiVector3D> vTexCoords;
|
std::vector<aiVector3D> vTexCoords;
|
||||||
std::vector<aiVector3D> vNormals;
|
std::vector<aiVector3D> vNormals;
|
||||||
|
|
||||||
vPositions.resize(this->m_pcHeader->numVertices,aiVector3D());
|
vPositions.resize(pScene->mMeshes[0]->mNumFaces*3,aiVector3D());
|
||||||
vTexCoords.resize(this->m_pcHeader->numVertices,aiVector3D(
|
vTexCoords.resize(pScene->mMeshes[0]->mNumFaces*3,aiVector3D(
|
||||||
std::numeric_limits<float>::quiet_NaN(),
|
std::numeric_limits<float>::quiet_NaN(),
|
||||||
std::numeric_limits<float>::quiet_NaN(),0.0f));
|
std::numeric_limits<float>::quiet_NaN(),0.0f));
|
||||||
vNormals.resize(this->m_pcHeader->numVertices,aiVector3D());
|
vNormals.resize(pScene->mMeshes[0]->mNumFaces*3,aiVector3D());
|
||||||
|
|
||||||
// not sure whether there are MD2 files without texture coordinates
|
// not sure whether there are MD2 files without texture coordinates
|
||||||
if (0 != this->m_pcHeader->numTexCoords && 0 != this->m_pcHeader->numSkins)
|
if (0 != this->m_pcHeader->numTexCoords && 0 != this->m_pcHeader->numSkins)
|
||||||
|
@ -198,32 +239,9 @@ void MD2Importer::InternReadFile(
|
||||||
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_AMBIENT);
|
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now read all vertices of the frame
|
|
||||||
for (unsigned int i = 0; i < (unsigned int)this->m_pcHeader->numVertices;++i)
|
|
||||||
{
|
|
||||||
// read x,y, and z component of the vertex
|
|
||||||
|
|
||||||
aiVector3D& vec = vPositions[i];
|
|
||||||
|
|
||||||
vec.x = (float)pcVerts[i].vertex[0] * pcFrame->scale[0];
|
|
||||||
vec.x += pcFrame->translate[0];
|
|
||||||
|
|
||||||
// (flip z and y component)
|
|
||||||
vec.z = (float)pcVerts[i].vertex[1] * pcFrame->scale[1];
|
|
||||||
vec.z += pcFrame->translate[1];
|
|
||||||
|
|
||||||
vec.y = (float)pcVerts[i].vertex[2] * pcFrame->scale[2];
|
|
||||||
vec.y += pcFrame->translate[2];
|
|
||||||
|
|
||||||
// read the normal vector from the precalculated normal table
|
|
||||||
vNormals[i] = *((const aiVector3D*)(&g_avNormals[std::min(
|
|
||||||
int(pcVerts[i].lightNormalIndex),
|
|
||||||
int(sizeof(g_avNormals) / sizeof(g_avNormals[0]))-1)]));
|
|
||||||
|
|
||||||
std::swap ( vNormals[i].y,vNormals[i].z );
|
|
||||||
}
|
|
||||||
|
|
||||||
// now read all triangles of the first frame, apply scaling and translation
|
// now read all triangles of the first frame, apply scaling and translation
|
||||||
|
unsigned int iCurrent = 0;
|
||||||
if (0 != this->m_pcHeader->numTexCoords)
|
if (0 != this->m_pcHeader->numTexCoords)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < (unsigned int)this->m_pcHeader->numTriangles;++i)
|
for (unsigned int i = 0; i < (unsigned int)this->m_pcHeader->numTriangles;++i)
|
||||||
|
@ -235,40 +253,47 @@ void MD2Importer::InternReadFile(
|
||||||
// copy texture coordinates
|
// copy texture coordinates
|
||||||
// check whether they are different from the previous value at this index.
|
// check whether they are different from the previous value at this index.
|
||||||
// In this case, create a full separate set of vertices/normals/texcoords
|
// In this case, create a full separate set of vertices/normals/texcoords
|
||||||
for (unsigned int c = 0; c < 3;++c)
|
for (unsigned int c = 0; c < 3;++c,++iCurrent)
|
||||||
{
|
{
|
||||||
|
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
|
||||||
|
|
||||||
// validate vertex indices
|
// validate vertex indices
|
||||||
if (pcTriangles[i].vertexIndices[c] >= this->m_pcHeader->numVertices)
|
if (pcTriangles[i].vertexIndices[c] >= this->m_pcHeader->numVertices)
|
||||||
pcTriangles[i].vertexIndices[c] = this->m_pcHeader->numVertices-1;
|
pcTriangles[i].vertexIndices[c] = this->m_pcHeader->numVertices-1;
|
||||||
|
|
||||||
// copy face indices
|
// copy face indices
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[c] = (unsigned int)pcTriangles[i].vertexIndices[c];
|
unsigned int iIndex = (unsigned int)pcTriangles[i].vertexIndices[c];
|
||||||
|
|
||||||
|
// read x,y, and z component of the vertex
|
||||||
|
aiVector3D& vec = vPositions[iCurrent];
|
||||||
|
|
||||||
|
vec.x = (float)pcVerts[iIndex].vertex[0] * pcFrame->scale[0];
|
||||||
|
vec.x += pcFrame->translate[0];
|
||||||
|
|
||||||
|
// (flip z and y component)
|
||||||
|
vec.z = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
|
||||||
|
vec.z += pcFrame->translate[1];
|
||||||
|
|
||||||
|
vec.y = (float)pcVerts[iIndex].vertex[2] * pcFrame->scale[2];
|
||||||
|
vec.y += pcFrame->translate[2];
|
||||||
|
|
||||||
|
// read the normal vector from the precalculated normal table
|
||||||
|
vNormals[iCurrent] = *((const aiVector3D*)(&g_avNormals[std::min(
|
||||||
|
int(pcVerts[iIndex].lightNormalIndex),
|
||||||
|
int(sizeof(g_avNormals) / sizeof(g_avNormals[0]))-1)]));
|
||||||
|
|
||||||
|
std::swap ( vNormals[iCurrent].y,vNormals[iCurrent].z );
|
||||||
|
|
||||||
// validate texture coordinates
|
// validate texture coordinates
|
||||||
if (pcTriangles[i].textureIndices[c] >= this->m_pcHeader->numTexCoords)
|
if (pcTriangles[iIndex].textureIndices[c] >= this->m_pcHeader->numTexCoords)
|
||||||
pcTriangles[i].textureIndices[c] = this->m_pcHeader->numTexCoords-1;
|
pcTriangles[iIndex].textureIndices[c] = this->m_pcHeader->numTexCoords-1;
|
||||||
|
|
||||||
aiVector3D* pcOut = &vTexCoords[pScene->mMeshes[0]->mFaces[i].mIndices[c]];
|
aiVector3D* pcOut = &vTexCoords[iCurrent];
|
||||||
float u,v;
|
float u,v;
|
||||||
u = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].s / this->m_pcHeader->skinWidth;
|
u = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].s / this->m_pcHeader->skinWidth;
|
||||||
v = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].t / this->m_pcHeader->skinHeight;
|
v = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].t / this->m_pcHeader->skinHeight;
|
||||||
|
pcOut->x = u;
|
||||||
if ( is_not_qnan ( pcOut->x ) && (pcOut->x != u || pcOut->y != v))
|
pcOut->y = v;
|
||||||
{
|
|
||||||
// generate a separate vertex/index set
|
|
||||||
vTexCoords.push_back(aiVector3D(u,v,0.0f));
|
|
||||||
vPositions.push_back(vPositions[pcTriangles[i].vertexIndices[c]]);
|
|
||||||
vNormals.push_back(vPositions[pcTriangles[i].vertexIndices[c]]);
|
|
||||||
unsigned int iPos = vTexCoords.size()-1;
|
|
||||||
|
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iPos;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pcOut->x = u;
|
|
||||||
pcOut->y = v;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,18 +305,44 @@ void MD2Importer::InternReadFile(
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices = new unsigned int[3];
|
pScene->mMeshes[0]->mFaces[i].mIndices = new unsigned int[3];
|
||||||
pScene->mMeshes[0]->mFaces[i].mNumIndices = 3;
|
pScene->mMeshes[0]->mFaces[i].mNumIndices = 3;
|
||||||
|
|
||||||
// validate vertex indices
|
// copy texture coordinates
|
||||||
if (pcTriangles[i].vertexIndices[0] >= this->m_pcHeader->numVertices)
|
// check whether they are different from the previous value at this index.
|
||||||
pcTriangles[i].vertexIndices[0] = this->m_pcHeader->numVertices-1;
|
// In this case, create a full separate set of vertices/normals/texcoords
|
||||||
if (pcTriangles[i].vertexIndices[1] >= this->m_pcHeader->numVertices)
|
for (unsigned int c = 0; c < 3;++c,++iCurrent)
|
||||||
pcTriangles[i].vertexIndices[1] = this->m_pcHeader->numVertices-1;
|
{
|
||||||
if (pcTriangles[i].vertexIndices[2] >= this->m_pcHeader->numVertices)
|
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
|
||||||
pcTriangles[i].vertexIndices[2] = this->m_pcHeader->numVertices-1;
|
|
||||||
|
|
||||||
// copy face indices
|
// validate vertex indices
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[0] = (unsigned int)pcTriangles[i].vertexIndices[0];
|
if (pcTriangles[i].vertexIndices[c] >= this->m_pcHeader->numVertices)
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[1] = (unsigned int)pcTriangles[i].vertexIndices[1];
|
pcTriangles[i].vertexIndices[c] = this->m_pcHeader->numVertices-1;
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[2] = (unsigned int)pcTriangles[i].vertexIndices[2];
|
|
||||||
|
// copy face indices
|
||||||
|
unsigned int iIndex = (unsigned int)pcTriangles[i].vertexIndices[c];
|
||||||
|
|
||||||
|
// read x,y, and z component of the vertex
|
||||||
|
aiVector3D& vec = vPositions[iCurrent];
|
||||||
|
|
||||||
|
vec.x = (float)pcVerts[iIndex].vertex[0] * pcFrame->scale[0];
|
||||||
|
vec.x += pcFrame->translate[0];
|
||||||
|
|
||||||
|
// (flip z and y component)
|
||||||
|
vec.z = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
|
||||||
|
vec.z += pcFrame->translate[1];
|
||||||
|
|
||||||
|
vec.y = (float)pcVerts[iIndex].vertex[2] * pcFrame->scale[2];
|
||||||
|
vec.y += pcFrame->translate[2];
|
||||||
|
|
||||||
|
// read the normal vector from the precalculated normal table
|
||||||
|
vNormals[iCurrent] = *((const aiVector3D*)(&g_avNormals[std::min(
|
||||||
|
int(pcVerts[iIndex].lightNormalIndex),
|
||||||
|
int(sizeof(g_avNormals) / sizeof(g_avNormals[0]))-1)]));
|
||||||
|
|
||||||
|
std::swap ( vNormals[iCurrent].y,vNormals[iCurrent].z );
|
||||||
|
|
||||||
|
aiVector3D* pcOut = &vTexCoords[iCurrent];
|
||||||
|
pcOut->x = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].s / this->m_pcHeader->skinWidth;
|
||||||
|
pcOut->y = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].t / this->m_pcHeader->skinHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,9 +353,16 @@ void MD2Importer::InternReadFile(
|
||||||
pScene->mMeshes[0]->mTextureCoords[0] = new aiVector3D[vPositions.size()];
|
pScene->mMeshes[0]->mTextureCoords[0] = new aiVector3D[vPositions.size()];
|
||||||
|
|
||||||
// memcpy() the data to the c-syle arrays
|
// memcpy() the data to the c-syle arrays
|
||||||
memcpy(pScene->mMeshes[0]->mVertices, &vPositions[0], vPositions.size() * sizeof(aiVector3D));
|
memcpy(pScene->mMeshes[0]->mVertices, &vPositions[0],
|
||||||
memcpy(pScene->mMeshes[0]->mNormals, &vNormals[0], vPositions.size() * sizeof(aiVector3D));
|
vPositions.size() * sizeof(aiVector3D));
|
||||||
memcpy(pScene->mMeshes[0]->mTextureCoords[0], &vTexCoords[0], vPositions.size() * sizeof(aiVector3D));
|
memcpy(pScene->mMeshes[0]->mNormals, &vNormals[0],
|
||||||
|
vPositions.size() * sizeof(aiVector3D));
|
||||||
|
|
||||||
|
if (0 != this->m_pcHeader->numTexCoords)
|
||||||
|
{
|
||||||
|
memcpy(pScene->mMeshes[0]->mTextureCoords[0], &vTexCoords[0],
|
||||||
|
vPositions.size() * sizeof(aiVector3D));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
118
code/MD2Loader.h
118
code/MD2Loader.h
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definition of the .MD2 importer class. */
|
/** @file Definition of the .MD2 importer class. */
|
||||||
#ifndef AI_MD2LOADER_H_INCLUDED
|
#ifndef AI_MD2LOADER_H_INCLUDED
|
||||||
#define AI_MD2LOADER_H_INCLUDED
|
#define AI_MD2LOADER_H_INCLUDED
|
||||||
|
@ -10,47 +50,57 @@ struct aiNode;
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
class MaterialHelper;
|
class MaterialHelper;
|
||||||
|
|
||||||
using namespace MD2;
|
using namespace MD2;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Used to load MD2 files
|
/** Used to load MD2 files
|
||||||
*/
|
*/
|
||||||
class MD2Importer : public BaseImporter
|
class MD2Importer : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
MD2Importer();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~MD2Importer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
{
|
{
|
||||||
friend class Importer;
|
append.append("*.md2");
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
// -------------------------------------------------------------------
|
||||||
/** Constructor to be privately used by Importer */
|
/** Imports the given file into the given scene structure.
|
||||||
MD2Importer();
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
/** Destructor, private as well */
|
protected:
|
||||||
~MD2Importer();
|
|
||||||
|
|
||||||
public:
|
/** Header of the MD2 file */
|
||||||
|
const MD2::Header* m_pcHeader;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
/** Buffer to hold the loaded file */
|
||||||
/** Returns whether the class can handle the format of the given file.
|
const unsigned char* mBuffer;
|
||||||
* See BaseImporter::CanRead() for details. */
|
};
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Imports the given file into the given scene structure.
|
|
||||||
* See BaseImporter::InternReadFile() for details
|
|
||||||
*/
|
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/** Header of the MD2 file */
|
|
||||||
const MD2::Header* m_pcHeader;
|
|
||||||
|
|
||||||
/** Buffer to hold the loaded file */
|
|
||||||
const unsigned char* mBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,55 @@
|
||||||
/*
|
/*
|
||||||
* Slightly modified version of the anorms.h header file released by
|
Free Asset Import Library (ASSIMP)
|
||||||
* ID software with the Quake 2 source code.
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @file Slightly modified version of the anorms.h header file
|
||||||
|
* released by ID software with the Quake 2 source code.
|
||||||
*
|
*
|
||||||
* Table of normals used by MD2 models
|
* Table of normals used by MD2 models
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float g_avNormals[][3] = {
|
#ifndef AI_MDL_NORMALTABLE_H_INC
|
||||||
|
#define AI_MDL_NORMALTABLE_H_INC
|
||||||
|
|
||||||
|
|
||||||
|
float g_avNormals[162][3] = {
|
||||||
{ -0.525731f, 0.000000f, 0.850651f },
|
{ -0.525731f, 0.000000f, 0.850651f },
|
||||||
{ -0.442863f, 0.238856f, 0.864188f },
|
{ -0.442863f, 0.238856f, 0.864188f },
|
||||||
{ -0.295242f, 0.000000f, 0.955423f },
|
{ -0.295242f, 0.000000f, 0.955423f },
|
||||||
|
@ -169,3 +213,5 @@ float g_avNormals[][3] = {
|
||||||
{ -0.587785f, -0.425325f, -0.688191f },
|
{ -0.587785f, -0.425325f, -0.688191f },
|
||||||
{ -0.688191f, -0.587785f, -0.425325f }
|
{ -0.688191f, -0.587785f, -0.425325f }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // !! include guard
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the helper data structures for importing MD3 files */
|
/** @file Defines the helper data structures for importing MD3 files */
|
||||||
#ifndef AI_MD3FILEHELPER_H_INC
|
#ifndef AI_MD3FILEHELPER_H_INC
|
||||||
#define AI_MD3FILEHELPER_H_INC
|
#define AI_MD3FILEHELPER_H_INC
|
||||||
|
@ -43,51 +83,51 @@ namespace MD3
|
||||||
#define AI_MD3_XYZ_SCALE (1.0f/64.0f)
|
#define AI_MD3_XYZ_SCALE (1.0f/64.0f)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for the MD3 main header
|
/** \brief Data structure for the MD3 main header
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct Header
|
struct Header
|
||||||
{
|
{
|
||||||
// magic number
|
//! magic number
|
||||||
int32_t IDENT;
|
int32_t IDENT;
|
||||||
|
|
||||||
// file format version
|
//! file format version
|
||||||
int32_t VERSION;
|
int32_t VERSION;
|
||||||
|
|
||||||
// original name in .pak archive
|
//! original name in .pak archive
|
||||||
unsigned char NAME[ AI_MD3_MAXQPATH ];
|
unsigned char NAME[ AI_MD3_MAXQPATH ];
|
||||||
|
|
||||||
// unknown
|
//! unknown
|
||||||
int32_t FLAGS;
|
int32_t FLAGS;
|
||||||
|
|
||||||
// number of frames in the file
|
//! number of frames in the file
|
||||||
int32_t NUM_FRAMES;
|
int32_t NUM_FRAMES;
|
||||||
|
|
||||||
// number of tags in the file
|
//! number of tags in the file
|
||||||
int32_t NUM_TAGS;
|
int32_t NUM_TAGS;
|
||||||
|
|
||||||
// number of surfaces in the file
|
//! number of surfaces in the file
|
||||||
int32_t NUM_SURFACES;
|
int32_t NUM_SURFACES;
|
||||||
|
|
||||||
// number of skins in the file
|
//! number of skins in the file
|
||||||
int32_t NUM_SKINS;
|
int32_t NUM_SKINS;
|
||||||
|
|
||||||
// offset of the first frame
|
//! offset of the first frame
|
||||||
int32_t OFS_FRAMES;
|
int32_t OFS_FRAMES;
|
||||||
|
|
||||||
// offset of the first tag
|
//! offset of the first tag
|
||||||
int32_t OFS_TAGS;
|
int32_t OFS_TAGS;
|
||||||
|
|
||||||
// offset of the first surface
|
//! offset of the first surface
|
||||||
int32_t OFS_SURFACES;
|
int32_t OFS_SURFACES;
|
||||||
|
|
||||||
// end of file
|
//! end of file
|
||||||
int32_t OFS_EOF;
|
int32_t OFS_EOF;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for the frame header
|
/** \brief Data structure for the frame header
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct Frame
|
struct Frame
|
||||||
|
@ -97,7 +137,7 @@ struct Frame
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for the tag header
|
/** \brief Data structure for the tag header
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct Tag
|
struct Tag
|
||||||
|
@ -107,95 +147,95 @@ struct Tag
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for the surface header
|
/** \brief Data structure for the surface header
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct Surface
|
struct Surface
|
||||||
{
|
{
|
||||||
// magic number
|
//! magic number
|
||||||
int32_t IDENT;
|
int32_t IDENT;
|
||||||
|
|
||||||
// original name of the surface
|
//! original name of the surface
|
||||||
unsigned char NAME[ AI_MD3_MAXQPATH ];
|
unsigned char NAME[ AI_MD3_MAXQPATH ];
|
||||||
|
|
||||||
// unknown
|
//! unknown
|
||||||
int32_t FLAGS;
|
int32_t FLAGS;
|
||||||
|
|
||||||
// number of frames in the surface
|
//! number of frames in the surface
|
||||||
int32_t NUM_FRAMES;
|
int32_t NUM_FRAMES;
|
||||||
|
|
||||||
// number of shaders in the surface
|
//! number of shaders in the surface
|
||||||
int32_t NUM_SHADER;
|
int32_t NUM_SHADER;
|
||||||
|
|
||||||
// number of vertices in the surface
|
//! number of vertices in the surface
|
||||||
int32_t NUM_VERTICES;
|
int32_t NUM_VERTICES;
|
||||||
|
|
||||||
// number of triangles in the surface
|
//! number of triangles in the surface
|
||||||
int32_t NUM_TRIANGLES;
|
int32_t NUM_TRIANGLES;
|
||||||
|
|
||||||
|
|
||||||
// offset to the triangle data
|
//! offset to the triangle data
|
||||||
int32_t OFS_TRIANGLES;
|
int32_t OFS_TRIANGLES;
|
||||||
|
|
||||||
// offset to the shader data
|
//! offset to the shader data
|
||||||
int32_t OFS_SHADERS;
|
int32_t OFS_SHADERS;
|
||||||
|
|
||||||
// offset to the texture coordinate data
|
//! offset to the texture coordinate data
|
||||||
int32_t OFS_ST;
|
int32_t OFS_ST;
|
||||||
|
|
||||||
// offset to the vertex/normal data
|
//! offset to the vertex/normal data
|
||||||
int32_t OFS_XYZNORMAL;
|
int32_t OFS_XYZNORMAL;
|
||||||
|
|
||||||
// offset to the end of the Surface object
|
//! offset to the end of the Surface object
|
||||||
int32_t OFS_END;
|
int32_t OFS_END;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a shader
|
/** \brief Data structure for a shader
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct Shader
|
struct Shader
|
||||||
{
|
{
|
||||||
// filename of the shader
|
//! filename of the shader
|
||||||
unsigned char NAME[ AI_MD3_MAXQPATH ];
|
unsigned char NAME[ AI_MD3_MAXQPATH ];
|
||||||
|
|
||||||
// index of the shader
|
//! index of the shader
|
||||||
int32_t SHADER_INDEX;
|
int32_t SHADER_INDEX;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a triangle
|
/** \brief Data structure for a triangle
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct Triangle
|
struct Triangle
|
||||||
{
|
{
|
||||||
// triangle indices
|
//! triangle indices
|
||||||
int32_t INDEXES[3];
|
int32_t INDEXES[3];
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for an UV coord
|
/** \brief Data structure for an UV coord
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct TexCoord
|
struct TexCoord
|
||||||
{
|
{
|
||||||
// UV coordinates
|
//! UV coordinates
|
||||||
float U,V;
|
float U,V;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** \brief Data structure for a vertex
|
/** \brief Data structure for a vertex
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct Vertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
// X/Y/Z coordinates
|
//! X/Y/Z coordinates
|
||||||
int16_t X,Y,Z;
|
int16_t X,Y,Z;
|
||||||
|
|
||||||
// encoded normal vector
|
//! encoded normal vector
|
||||||
int16_t NORMAL;
|
int16_t NORMAL;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the MD3 importer class */
|
/** @file Implementation of the MD3 importer class */
|
||||||
#include "MD3Loader.h"
|
#include "MD3Loader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
|
@ -142,7 +183,7 @@ void MD3Importer::InternReadFile(
|
||||||
pScene->mMeshes[iNum] = new aiMesh();
|
pScene->mMeshes[iNum] = new aiMesh();
|
||||||
aiMesh* pcMesh = pScene->mMeshes[iNum];
|
aiMesh* pcMesh = pScene->mMeshes[iNum];
|
||||||
|
|
||||||
pcMesh->mNumVertices = pcSurfaces->NUM_VERTICES;
|
pcMesh->mNumVertices = pcSurfaces->NUM_TRIANGLES*3;
|
||||||
pcMesh->mNumBones = 0;
|
pcMesh->mNumBones = 0;
|
||||||
pcMesh->mColors[0] = pcMesh->mColors[1] = pcMesh->mColors[2] = pcMesh->mColors[3] = NULL;
|
pcMesh->mColors[0] = pcMesh->mColors[1] = pcMesh->mColors[2] = pcMesh->mColors[3] = NULL;
|
||||||
pcMesh->mNumFaces = pcSurfaces->NUM_TRIANGLES;
|
pcMesh->mNumFaces = pcSurfaces->NUM_TRIANGLES;
|
||||||
|
@ -153,35 +194,32 @@ void MD3Importer::InternReadFile(
|
||||||
pcMesh->mTextureCoords[1] = pcMesh->mTextureCoords[2] = pcMesh->mTextureCoords[3] = NULL;
|
pcMesh->mTextureCoords[1] = pcMesh->mTextureCoords[2] = pcMesh->mTextureCoords[3] = NULL;
|
||||||
pcMesh->mNumUVComponents[0] = 2;
|
pcMesh->mNumUVComponents[0] = 2;
|
||||||
|
|
||||||
// fill in all vertices and normals
|
|
||||||
// fill in all texture coordinates
|
|
||||||
for (unsigned int i = 0; i < (unsigned int)pcSurfaces->NUM_VERTICES;++i)
|
|
||||||
{
|
|
||||||
pcMesh->mVertices[i].x = pcVertices->X;
|
|
||||||
pcMesh->mVertices[i].y = pcVertices->Y;
|
|
||||||
pcMesh->mVertices[i].z = -1.0f*pcVertices->Z;
|
|
||||||
|
|
||||||
// convert the normal vector to uncompressed float3 format
|
|
||||||
LatLngNormalToVec3(pcVertices->NORMAL,(float*)&pcMesh->mNormals[i]);
|
|
||||||
|
|
||||||
// read texture coordinates
|
|
||||||
pcMesh->mTextureCoords[0][i].x = pcUVs->U;
|
|
||||||
pcMesh->mTextureCoords[0][i].y = 1.0f - pcUVs->V;
|
|
||||||
|
|
||||||
pcVertices++;
|
|
||||||
pcUVs++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill in all triangles
|
// fill in all triangles
|
||||||
|
unsigned int iCurrent = 0;
|
||||||
for (unsigned int i = 0; i < (unsigned int)pcSurfaces->NUM_TRIANGLES;++i)
|
for (unsigned int i = 0; i < (unsigned int)pcSurfaces->NUM_TRIANGLES;++i)
|
||||||
{
|
{
|
||||||
pcMesh->mFaces[i].mIndices = new unsigned int[3];
|
pcMesh->mFaces[i].mIndices = new unsigned int[3];
|
||||||
pcMesh->mFaces[i].mNumIndices = 3;
|
pcMesh->mFaces[i].mNumIndices = 3;
|
||||||
|
|
||||||
pcMesh->mFaces[i].mIndices[0] = pcTriangles->INDEXES[0];
|
for (unsigned int c = 0; c < 3;++c,++iCurrent)
|
||||||
pcMesh->mFaces[i].mIndices[1] = pcTriangles->INDEXES[1];
|
{
|
||||||
pcMesh->mFaces[i].mIndices[2] = pcTriangles->INDEXES[2];
|
pcMesh->mFaces[i].mIndices[c] = iCurrent;
|
||||||
|
|
||||||
|
// read vertices
|
||||||
|
pcMesh->mVertices[iCurrent].x = pcVertices[ pcTriangles->INDEXES[c]].X;
|
||||||
|
pcMesh->mVertices[iCurrent].y = pcVertices[ pcTriangles->INDEXES[c]].Y;
|
||||||
|
pcMesh->mVertices[iCurrent].z = pcVertices[ pcTriangles->INDEXES[c]].Z * -1.0f;
|
||||||
|
|
||||||
|
// convert the normal vector to uncompressed float3 format
|
||||||
|
LatLngNormalToVec3(pcVertices[pcTriangles->INDEXES[c]].NORMAL,
|
||||||
|
(float*)&pcMesh->mNormals[iCurrent]);
|
||||||
|
|
||||||
|
std::swap ( pcMesh->mNormals[iCurrent].y,pcMesh->mNormals[iCurrent].z );
|
||||||
|
|
||||||
|
// read texture coordinates
|
||||||
|
pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[ pcTriangles->INDEXES[c]].U;
|
||||||
|
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[ pcTriangles->INDEXES[c]].V;
|
||||||
|
}
|
||||||
pcTriangles++;
|
pcTriangles++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,12 +288,15 @@ void MD3Importer::InternReadFile(
|
||||||
{
|
{
|
||||||
MaterialHelper* pcHelper = new MaterialHelper();
|
MaterialHelper* pcHelper = new MaterialHelper();
|
||||||
|
|
||||||
aiString szString;
|
if (szEndDir2)
|
||||||
const size_t iLen = strlen(szEndDir2);
|
{
|
||||||
memcpy(szString.data,szEndDir2,iLen+1);
|
aiString szString;
|
||||||
szString.length = iLen-1;
|
const size_t iLen = strlen(szEndDir2);
|
||||||
|
memcpy(szString.data,szEndDir2,iLen+1);
|
||||||
|
szString.length = iLen-1;
|
||||||
|
|
||||||
pcHelper->AddProperty(&szString,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
pcHelper->AddProperty(&szString,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
|
}
|
||||||
|
|
||||||
int iMode = (int)aiShadingMode_Gouraud;
|
int iMode = (int)aiShadingMode_Gouraud;
|
||||||
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
116
code/MD3Loader.h
116
code/MD3Loader.h
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definition of the .MD3 importer class. */
|
/** @file Definition of the .MD3 importer class. */
|
||||||
#ifndef AI_MD3LOADER_H_INCLUDED
|
#ifndef AI_MD3LOADER_H_INCLUDED
|
||||||
#define AI_MD3LOADER_H_INCLUDED
|
#define AI_MD3LOADER_H_INCLUDED
|
||||||
|
@ -13,46 +53,56 @@ struct aiNode;
|
||||||
#include "MD3FileData.h"
|
#include "MD3FileData.h"
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
class MaterialHelper;
|
class MaterialHelper;
|
||||||
|
|
||||||
using namespace MD3;
|
using namespace MD3;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Used to load MD3 files
|
/** Used to load MD3 files
|
||||||
*/
|
*/
|
||||||
class MD3Importer : public BaseImporter
|
class MD3Importer : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
MD3Importer();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~MD3Importer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
{
|
{
|
||||||
friend class Importer;
|
append.append("*.md3");
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
// -------------------------------------------------------------------
|
||||||
/** Constructor to be privately used by Importer */
|
/** Imports the given file into the given scene structure.
|
||||||
MD3Importer();
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
/** Destructor, private as well */
|
protected:
|
||||||
~MD3Importer();
|
|
||||||
|
|
||||||
public:
|
/** Header of the MD3 file */
|
||||||
|
const MD3::Header* m_pcHeader;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
/** Buffer to hold the loaded file */
|
||||||
/** Returns whether the class can handle the format of the given file.
|
const unsigned char* mBuffer;
|
||||||
* See BaseImporter::CanRead() for details. */
|
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Imports the given file into the given scene structure.
|
|
||||||
* See BaseImporter::InternReadFile() for details
|
|
||||||
*/
|
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/** Header of the MD3 file */
|
|
||||||
const MD3::Header* m_pcHeader;
|
|
||||||
|
|
||||||
/** Buffer to hold the loaded file */
|
|
||||||
const unsigned char* mBuffer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Defines the helper data structures for importing MD4 files */
|
||||||
|
#ifndef AI_MD4FILEHELPER_H_INC
|
||||||
|
#define AI_MD4FILEHELPER_H_INC
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "../include/aiTypes.h"
|
||||||
|
#include "../include/aiMesh.h"
|
||||||
|
#include "../include/aiAnim.h"
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||||
|
# pragma pack(push,1)
|
||||||
|
# define PACK_STRUCT
|
||||||
|
#elif defined( __GNUC__ )
|
||||||
|
# define PACK_STRUCT __attribute__((packed))
|
||||||
|
#else
|
||||||
|
# error Compiler not supported
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace Assimp
|
||||||
|
{
|
||||||
|
// http://gongo.quakedev.com/md4.html
|
||||||
|
namespace MD4
|
||||||
|
{
|
||||||
|
|
||||||
|
#define AI_MD4_MAGIC_NUMBER_BE 'IDP4'
|
||||||
|
#define AI_MD4_MAGIC_NUMBER_LE '4PDI'
|
||||||
|
|
||||||
|
// common limitations
|
||||||
|
#define AI_MD4_VERSION 4
|
||||||
|
#define AI_MD4_MAXQPATH 64
|
||||||
|
#define AI_MD4_MAX_FRAMES 2028
|
||||||
|
#define AI_MD4_MAX_SURFACES 32
|
||||||
|
#define AI_MD4_MAX_BONES 256
|
||||||
|
#define AI_MD4_MAX_VERTS 4096
|
||||||
|
#define AI_MD4_MAX_TRIANGLES 8192
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Data structure for the MD4 main header
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Header
|
||||||
|
{
|
||||||
|
//! magic number
|
||||||
|
int32_t magic;
|
||||||
|
|
||||||
|
//! file format version
|
||||||
|
int32_t version;
|
||||||
|
|
||||||
|
//! original name in .pak archive
|
||||||
|
unsigned char name[ AI_MD4_MAXQPATH ];
|
||||||
|
|
||||||
|
//! number of frames in the file
|
||||||
|
int32_t NUM_FRAMES;
|
||||||
|
|
||||||
|
//! number of bones in the file
|
||||||
|
int32_t NUM_BONES;
|
||||||
|
|
||||||
|
//! number of surfaces in the file
|
||||||
|
int32_t NUM_SURFACES;
|
||||||
|
|
||||||
|
//! offset of the first frame
|
||||||
|
int32_t OFS_FRAMES;
|
||||||
|
|
||||||
|
//! offset of the first bone
|
||||||
|
int32_t OFS_BONES;
|
||||||
|
|
||||||
|
//! offset of the first surface
|
||||||
|
int32_t OFS_SURFACES;
|
||||||
|
|
||||||
|
//! end of file
|
||||||
|
int32_t OFS_EOF;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Stores the local transformation matrix of a bone
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct BoneFrame
|
||||||
|
{
|
||||||
|
float matrix[3][4];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Stores the name / parent index / flag of a node
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct BoneName
|
||||||
|
{
|
||||||
|
char name[32] ;
|
||||||
|
int parent ;
|
||||||
|
int flags ;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Data structure for a surface in a MD4 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Surface
|
||||||
|
{
|
||||||
|
int32_t ident;
|
||||||
|
char name[64];
|
||||||
|
char shader[64];
|
||||||
|
int32_t shaderIndex;
|
||||||
|
int32_t lodBias;
|
||||||
|
int32_t minLod;
|
||||||
|
int32_t ofsHeader;
|
||||||
|
int32_t numVerts;
|
||||||
|
int32_t ofsVerts;
|
||||||
|
int32_t numTris;
|
||||||
|
int32_t ofsTris;
|
||||||
|
int32_t numBoneRefs;
|
||||||
|
int32_t ofsBoneRefs;
|
||||||
|
int32_t ofsCollapseMap;
|
||||||
|
int32_t ofsEnd;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Data structure for a MD4 vertex' weight
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Weight
|
||||||
|
{
|
||||||
|
int32_t boneIndex;
|
||||||
|
float boneWeight;
|
||||||
|
float offset[3];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Data structure for a vertex in a MD4 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Vertex
|
||||||
|
{
|
||||||
|
float vertex[3];
|
||||||
|
float normal[3];
|
||||||
|
float texCoords[2];
|
||||||
|
int32_t numWeights;
|
||||||
|
Weight weights[1];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Data structure for a triangle in a MD4 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Triangle
|
||||||
|
{
|
||||||
|
int32_t indexes[3];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Data structure for a MD4 frame
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Frame
|
||||||
|
{
|
||||||
|
float bounds[3][2];
|
||||||
|
float localOrigin[3];
|
||||||
|
float radius;
|
||||||
|
BoneFrame bones[1];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
// reset packing to the original value
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||||
|
# pragma pack( pop )
|
||||||
|
#endif
|
||||||
|
#undef PACK_STRUCT
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !! AI_MD4FILEHELPER_H_INC
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Implementation of the MD4 importer class */
|
||||||
|
#include "MD4Loader.h"
|
||||||
|
#include "MaterialSystem.h"
|
||||||
|
|
||||||
|
#include "../include/IOStream.h"
|
||||||
|
#include "../include/IOSystem.h"
|
||||||
|
#include "../include/aiMesh.h"
|
||||||
|
#include "../include/aiScene.h"
|
||||||
|
#include "../include/aiAssert.h"
|
||||||
|
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Constructor to be privately used by Importer
|
||||||
|
MD4Importer::MD4Importer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Destructor, private as well
|
||||||
|
MD4Importer::~MD4Importer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Returns whether the class can handle the format of the given file.
|
||||||
|
bool MD4Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
|
||||||
|
{
|
||||||
|
// simple check of file extension is enough for the moment
|
||||||
|
std::string::size_type pos = pFile.find_last_of('.');
|
||||||
|
// no file extension - can't read
|
||||||
|
if( pos == std::string::npos)
|
||||||
|
return false;
|
||||||
|
std::string extension = pFile.substr( pos);
|
||||||
|
|
||||||
|
if (extension.length() < 4)return false;
|
||||||
|
if (extension[0] != '.')return false;
|
||||||
|
|
||||||
|
// not brilliant but working ;-)
|
||||||
|
if( extension == ".md4" || extension == ".MD4" ||
|
||||||
|
extension == ".mD4" || extension == ".Md4")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#if (!defined AI_MD4_DONT_SUPPORT_RAVENSOFT_MDR)
|
||||||
|
if (extension[1] != 'm' && extension[1] != 'M')return false;
|
||||||
|
if (extension[2] != 'd' && extension[2] != 'D')return false;
|
||||||
|
if (extension[3] != 'r' && extension[3] != 'R')return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Imports the given file into the given scene structure.
|
||||||
|
void MD4Importer::InternReadFile(
|
||||||
|
const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
|
||||||
|
{
|
||||||
|
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||||
|
|
||||||
|
// Check whether we can read from the file
|
||||||
|
if( file.get() == NULL)
|
||||||
|
{
|
||||||
|
throw new ImportErrorException( "Failed to open md4/mdr file " + pFile + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check whether the md4 file is large enough to contain
|
||||||
|
// at least the file header
|
||||||
|
size_t fileSize = file->FileSize();
|
||||||
|
if( fileSize < sizeof(MD4::Header))
|
||||||
|
{
|
||||||
|
throw new ImportErrorException( ".mdd File is too small.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
118
code/MD4Loader.h
118
code/MD4Loader.h
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definition of the .MD4 importer class. */
|
/** @file Definition of the .MD4 importer class. */
|
||||||
#ifndef AI_MD4LOADER_H_INCLUDED
|
#ifndef AI_MD4LOADER_H_INCLUDED
|
||||||
#define AI_MD4LOADER_H_INCLUDED
|
#define AI_MD4LOADER_H_INCLUDED
|
||||||
|
@ -10,47 +50,57 @@ struct aiNode;
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
class MaterialHelper;
|
class MaterialHelper;
|
||||||
|
|
||||||
using namespace MD4;
|
using namespace MD4;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Used to load MD4 files
|
/** Used to load MD4 files
|
||||||
*/
|
*/
|
||||||
class MD4Importer : public BaseImporter
|
class MD4Importer : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
MD4Importer();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~MD4Importer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
{
|
{
|
||||||
friend class Importer;
|
append.append("*.md4;*.mdr");
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
// -------------------------------------------------------------------
|
||||||
/** Constructor to be privately used by Importer */
|
/** Imports the given file into the given scene structure.
|
||||||
MD4Importer();
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
/** Destructor, private as well */
|
protected:
|
||||||
~MD4Importer();
|
|
||||||
|
|
||||||
public:
|
/** Header of the MD4 file */
|
||||||
|
const MD4::Header* m_pcHeader;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
/** Buffer to hold the loaded file */
|
||||||
/** Returns whether the class can handle the format of the given file.
|
const unsigned char* mBuffer;
|
||||||
* See BaseImporter::CanRead() for details. */
|
};
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Imports the given file into the given scene structure.
|
|
||||||
* See BaseImporter::InternReadFile() for details
|
|
||||||
*/
|
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/** Header of the MD4 file */
|
|
||||||
const MD4::Header* m_pcHeader;
|
|
||||||
|
|
||||||
/** Buffer to hold the loaded file */
|
|
||||||
const unsigned char* mBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
119
code/MD5Loader.h
119
code/MD5Loader.h
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @file Definition of the .MD5 importer class. */
|
/** @file Definition of the .MD5 importer class. */
|
||||||
#ifndef AI_MD5LOADER_H_INCLUDED
|
#ifndef AI_MD5LOADER_H_INCLUDED
|
||||||
#define AI_MD5LOADER_H_INCLUDED
|
#define AI_MD5LOADER_H_INCLUDED
|
||||||
|
@ -10,47 +51,57 @@ struct aiNode;
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
class MaterialHelper;
|
class MaterialHelper;
|
||||||
|
|
||||||
using namespace MD5;
|
using namespace MD5;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Used to load MD5 files
|
/** Used to load MD5 files
|
||||||
*/
|
*/
|
||||||
class MD5Importer : public BaseImporter
|
class MD5Importer : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
MD5Importer();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~MD5Importer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
{
|
{
|
||||||
friend class Importer;
|
append.append("*.md5");
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
// -------------------------------------------------------------------
|
||||||
/** Constructor to be privately used by Importer */
|
/** Imports the given file into the given scene structure.
|
||||||
MD5Importer();
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
/** Destructor, private as well */
|
protected:
|
||||||
~MD5Importer();
|
|
||||||
|
|
||||||
public:
|
/** Header of the MD5 file */
|
||||||
|
const MD5::Header* m_pcHeader;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
/** Buffer to hold the loaded file */
|
||||||
/** Returns whether the class can handle the format of the given file.
|
const unsigned char* mBuffer;
|
||||||
* See BaseImporter::CanRead() for details. */
|
};
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Imports the given file into the given scene structure.
|
|
||||||
* See BaseImporter::InternReadFile() for details
|
|
||||||
*/
|
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/** Header of the MD5 file */
|
|
||||||
const MD5::Header* m_pcHeader;
|
|
||||||
|
|
||||||
/** Buffer to hold the loaded file */
|
|
||||||
const unsigned char* mBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @file Defines the default color map used for Quake 1 model textures
|
||||||
|
*
|
||||||
|
* The lib tries to load colormap.lmp from the model's directory.
|
||||||
|
* This table is only used when required.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AI_MDL_DEFAULTLMP_H_INC
|
||||||
|
#define AI_MDL_DEFAULTLMP_H_INC
|
||||||
|
|
||||||
|
const unsigned char g_aclrDefaultColorMap[256][3] = {
|
||||||
|
{ 0, 0, 0}, { 15, 15, 15}, { 31, 31, 31}, { 47, 47, 47},
|
||||||
|
{ 63, 63, 63}, { 75, 75, 75}, { 91, 91, 91}, {107, 107, 107},
|
||||||
|
{123, 123, 123}, {139, 139, 139}, {155, 155, 155}, {171, 171, 171},
|
||||||
|
{187, 187, 187}, {203, 203, 203}, {219, 219, 219}, {235, 235, 235},
|
||||||
|
{ 15, 11, 7}, { 23, 15, 11}, { 31, 23, 11}, { 39, 27, 15},
|
||||||
|
{ 47, 35, 19}, { 55, 43, 23}, { 63, 47, 23}, { 75, 55, 27},
|
||||||
|
{ 83, 59, 27}, { 91, 67, 31}, { 99, 75, 31}, {107, 83, 31},
|
||||||
|
{115, 87, 31}, {123, 95, 35}, {131, 103, 35}, {143, 111, 35},
|
||||||
|
{ 11, 11, 15}, { 19, 19, 27}, { 27, 27, 39}, { 39, 39, 51},
|
||||||
|
{ 47, 47, 63}, { 55, 55, 75}, { 63, 63, 87}, { 71, 71, 103},
|
||||||
|
{ 79, 79, 115}, { 91, 91, 127}, { 99, 99, 139}, {107, 107, 151},
|
||||||
|
{115, 115, 163}, {123, 123, 175}, {131, 131, 187}, {139, 139, 203},
|
||||||
|
{ 0, 0, 0}, { 7, 7, 0}, { 11, 11, 0}, { 19, 19, 0},
|
||||||
|
{ 27, 27, 0}, { 35, 35, 0}, { 43, 43, 7}, { 47, 47, 7},
|
||||||
|
{ 55, 55, 7}, { 63, 63, 7}, { 71, 71, 7}, { 75, 75, 11},
|
||||||
|
{ 83, 83, 11}, { 91, 91, 11}, { 99, 99, 11}, {107, 107, 15},
|
||||||
|
{ 7, 0, 0}, { 15, 0, 0}, { 23, 0, 0}, { 31, 0, 0},
|
||||||
|
{ 39, 0, 0}, { 47, 0, 0}, { 55, 0, 0}, { 63, 0, 0},
|
||||||
|
{ 71, 0, 0}, { 79, 0, 0}, { 87, 0, 0}, { 95, 0, 0},
|
||||||
|
{103, 0, 0}, {111, 0, 0}, {119, 0, 0}, {127, 0, 0},
|
||||||
|
{ 19, 19, 0}, { 27, 27, 0}, { 35, 35, 0}, { 47, 43, 0},
|
||||||
|
{ 55, 47, 0}, { 67, 55, 0}, { 75, 59, 7}, { 87, 67, 7},
|
||||||
|
{ 95, 71, 7}, {107, 75, 11}, {119, 83, 15}, {131, 87, 19},
|
||||||
|
{139, 91, 19}, {151, 95, 27}, {163, 99, 31}, {175, 103, 35},
|
||||||
|
{ 35, 19, 7}, { 47, 23, 11}, { 59, 31, 15}, { 75, 35, 19},
|
||||||
|
{ 87, 43, 23}, { 99, 47, 31}, {115, 55, 35}, {127, 59, 43},
|
||||||
|
{143, 67, 51}, {159, 79, 51}, {175, 99, 47}, {191, 119, 47},
|
||||||
|
{207, 143, 43}, {223, 171, 39}, {239, 203, 31}, {255, 243, 27},
|
||||||
|
{ 11, 7, 0}, { 27, 19, 0}, { 43, 35, 15}, { 55, 43, 19},
|
||||||
|
{ 71, 51, 27}, { 83, 55, 35}, { 99, 63, 43}, {111, 71, 51},
|
||||||
|
{127, 83, 63}, {139, 95, 71}, {155, 107, 83}, {167, 123, 95},
|
||||||
|
{183, 135, 107}, {195, 147, 123}, {211, 163, 139}, {227, 179, 151},
|
||||||
|
{171, 139, 163}, {159, 127, 151}, {147, 115, 135}, {139, 103, 123},
|
||||||
|
{127, 91, 111}, {119, 83, 99}, {107, 75, 87}, { 95, 63, 75},
|
||||||
|
{ 87, 55, 67}, { 75, 47, 55}, { 67, 39, 47}, { 55, 31, 35},
|
||||||
|
{ 43, 23, 27}, { 35, 19, 19}, { 23, 11, 11}, { 15, 7, 7},
|
||||||
|
{187, 115, 159}, {175, 107, 143}, {163, 95, 131}, {151, 87, 119},
|
||||||
|
{139, 79, 107}, {127, 75, 95}, {115, 67, 83}, {107, 59, 75},
|
||||||
|
{ 95, 51, 63}, { 83, 43, 55}, { 71, 35, 43}, { 59, 31, 35},
|
||||||
|
{ 47, 23, 27}, { 35, 19, 19}, { 23, 11, 11}, { 15, 7, 7},
|
||||||
|
{219, 195, 187}, {203, 179, 167}, {191, 163, 155}, {175, 151, 139},
|
||||||
|
{163, 135, 123}, {151, 123, 111}, {135, 111, 95}, {123, 99, 83},
|
||||||
|
{107, 87, 71}, { 95, 75, 59}, { 83, 63, 51}, { 67, 51, 39},
|
||||||
|
{ 55, 43, 31}, { 39, 31, 23}, { 27, 19, 15}, { 15, 11, 7},
|
||||||
|
{111, 131, 123}, {103, 123, 111}, { 95, 115, 103}, { 87, 107, 95},
|
||||||
|
{ 79, 99, 87}, { 71, 91, 79}, { 63, 83, 71}, { 55, 75, 63},
|
||||||
|
{ 47, 67, 55}, { 43, 59, 47}, { 35, 51, 39}, { 31, 43, 31},
|
||||||
|
{ 23, 35, 23}, { 15, 27, 19}, { 11, 19, 11}, { 7, 11, 7},
|
||||||
|
{255, 243, 27}, {239, 223, 23}, {219, 203, 19}, {203, 183, 15},
|
||||||
|
{187, 167, 15}, {171, 151, 11}, {155, 131, 7}, {139, 115, 7},
|
||||||
|
{123, 99, 7}, {107, 83, 0}, { 91, 71, 0}, { 75, 55, 0},
|
||||||
|
{ 59, 43, 0}, { 43, 31, 0}, { 27, 15, 0}, { 11, 7, 0},
|
||||||
|
{ 0, 0, 255}, { 11, 11, 239}, { 19, 19, 223}, { 27, 27, 207},
|
||||||
|
{ 35, 35, 191}, { 43, 43, 175}, { 47, 47, 159}, { 47, 47, 143},
|
||||||
|
{ 47, 47, 127}, { 47, 47, 111}, { 47, 47, 95}, { 43, 43, 79},
|
||||||
|
{ 35, 35, 63}, { 27, 27, 47}, { 19, 19, 31}, { 11, 11, 15},
|
||||||
|
{ 43, 0, 0}, { 59, 0, 0}, { 75, 7, 0}, { 95, 7, 0},
|
||||||
|
{111, 15, 0}, {127, 23, 7}, {147, 31, 7}, {163, 39, 11},
|
||||||
|
{183, 51, 15}, {195, 75, 27}, {207, 99, 43}, {219, 127, 59},
|
||||||
|
{227, 151, 79}, {231, 171, 95}, {239, 191, 119}, {247, 211, 139},
|
||||||
|
{167, 123, 59}, {183, 155, 55}, {199, 195, 55}, {231, 227, 87},
|
||||||
|
{127, 191, 255}, {171, 231, 255}, {215, 255, 255}, {103, 0, 0},
|
||||||
|
{139, 0, 0}, {179, 0, 0}, {215, 0, 0}, {255, 0, 0},
|
||||||
|
{255, 243, 147}, {255, 247, 199}, {255, 255, 255}, {159, 91, 83} };
|
||||||
|
|
||||||
|
|
||||||
|
#endif // !! AI_MDL_DEFAULTLMP_H_INC
|
|
@ -0,0 +1,706 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//! @file Definition of in-memory structures for the MDL file format.
|
||||||
|
//
|
||||||
|
// The specification has been taken from various sources on the internet.
|
||||||
|
// http://tfc.duke.free.fr/coding/mdl-specs-en.html
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef AI_MDLFILEHELPER_H_INC
|
||||||
|
#define AI_MDLFILEHELPER_H_INC
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../include/aiTypes.h"
|
||||||
|
#include "../include/aiMesh.h"
|
||||||
|
#include "../include/aiAnim.h"
|
||||||
|
#include "../include/aiMaterial.h"
|
||||||
|
|
||||||
|
// ugly compiler dependent packing stuff
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||||
|
# pragma pack(push,1)
|
||||||
|
# define PACK_STRUCT
|
||||||
|
#elif defined( __GNUC__ )
|
||||||
|
# define PACK_STRUCT __attribute__((packed))
|
||||||
|
#else
|
||||||
|
# error Compiler not supported. Never do this again.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace Assimp
|
||||||
|
{
|
||||||
|
namespace MDL
|
||||||
|
{
|
||||||
|
|
||||||
|
// magic bytes used in Quake 1 MDL meshes
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_BE 'IDPO'
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_LE 'OPDI'
|
||||||
|
|
||||||
|
// magic bytes used in GameStudio A4 MDL meshes
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_BE_GS4 'MDL3'
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_LE_GS4 '3LDM'
|
||||||
|
|
||||||
|
// magic bytes used in GameStudio A5+ MDL meshes
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_BE_GS5a 'MDL4'
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_LE_GS5a '4LDM'
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_BE_GS5b 'MDL5'
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_LE_GS5b '5LDM'
|
||||||
|
|
||||||
|
// magic bytes used in GameStudio A6+ MDL meshes
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_BE_GS6 'MDL6'
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_LE_GS6 '6LDM'
|
||||||
|
|
||||||
|
// magic bytes used in GameStudio A7+ MDL meshes
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_BE_GS7 'MDL7'
|
||||||
|
#define AI_MDL_MAGIC_NUMBER_LE_GS7 '7LDM'
|
||||||
|
|
||||||
|
// common limitations for Quake1 meshes. The loader does not check them,
|
||||||
|
// but models should not exceed these limits.
|
||||||
|
#if (!defined AI_MDL_VERSION)
|
||||||
|
# define AI_MDL_VERSION 6
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_MDL_MAX_FRAMES)
|
||||||
|
# define AI_MDL_MAX_FRAMES 256
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_MDL_MAX_UVS)
|
||||||
|
# define AI_MDL_MAX_UVS 1024
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_MDL_MAX_VERTS)
|
||||||
|
# define AI_MDL_MAX_VERTS 1024
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_MDL_MAX_TRIANGLES)
|
||||||
|
# define AI_MDL_MAX_TRIANGLES 2048
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Header
|
||||||
|
* \brief Data structure for the MDL main header
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Header
|
||||||
|
{
|
||||||
|
//! magic number: "IDPO"
|
||||||
|
int32_t ident;
|
||||||
|
|
||||||
|
//! version number: 6
|
||||||
|
int32_t version;
|
||||||
|
|
||||||
|
//! scale factors for each axis
|
||||||
|
aiVector3D scale;
|
||||||
|
|
||||||
|
//! translation factors for each axis
|
||||||
|
aiVector3D translate;
|
||||||
|
|
||||||
|
//! bounding radius of the mesh
|
||||||
|
float boundingradius;
|
||||||
|
|
||||||
|
//! Position of the viewer's exe. Ignored
|
||||||
|
aiVector3D vEyePos;
|
||||||
|
|
||||||
|
//! Number of textures
|
||||||
|
int32_t num_skins;
|
||||||
|
|
||||||
|
//! Texture width in pixels
|
||||||
|
int32_t skinwidth;
|
||||||
|
|
||||||
|
//! Texture height in pixels
|
||||||
|
int32_t skinheight;
|
||||||
|
|
||||||
|
//! Number of vertices contained in the file
|
||||||
|
int32_t num_verts;
|
||||||
|
|
||||||
|
//! Number of triangles contained in the file
|
||||||
|
int32_t num_tris;
|
||||||
|
|
||||||
|
//! Number of frames contained in the file
|
||||||
|
int32_t num_frames;
|
||||||
|
|
||||||
|
//! 0 = synchron, 1 = random . Ignored
|
||||||
|
int32_t synctype;
|
||||||
|
|
||||||
|
//! State flag
|
||||||
|
int32_t flags;
|
||||||
|
|
||||||
|
//! ???
|
||||||
|
float size;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Header_MDL7
|
||||||
|
* \brief Data structure for the MDL 7 main header
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Header_MDL7
|
||||||
|
{
|
||||||
|
//! magic number: "MDL7"
|
||||||
|
char ident[4];
|
||||||
|
|
||||||
|
//! Version number. Ignored
|
||||||
|
int32_t version;
|
||||||
|
|
||||||
|
//! Number of bones in file
|
||||||
|
int32_t bones_num;
|
||||||
|
|
||||||
|
//! Number of groups in file
|
||||||
|
int32_t groups_num;
|
||||||
|
|
||||||
|
//! Size of data in the file
|
||||||
|
int32_t data_size;
|
||||||
|
|
||||||
|
//! Ignored. Used to store entity specific information
|
||||||
|
int32_t entlump_size;
|
||||||
|
|
||||||
|
//! Ignored. Used to store MED related data
|
||||||
|
int32_t medlump_size;
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
|
// Sizes of some file parts
|
||||||
|
|
||||||
|
uint16_t bone_stc_size;
|
||||||
|
uint16_t skin_stc_size;
|
||||||
|
uint16_t colorvalue_stc_size;
|
||||||
|
uint16_t material_stc_size;
|
||||||
|
uint16_t skinpoint_stc_size;
|
||||||
|
uint16_t triangle_stc_size;
|
||||||
|
uint16_t mainvertex_stc_size;
|
||||||
|
uint16_t framevertex_stc_size;
|
||||||
|
uint16_t bonetrans_stc_size;
|
||||||
|
uint16_t frame_stc_size;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
#define AI_MDL7_MAX_BONENAMESIZE 20
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Bone_MDL7
|
||||||
|
* \brief Bone in a MDL7 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Bone_MDL7
|
||||||
|
{
|
||||||
|
uint16_t parent_index;
|
||||||
|
uint8_t _unused_[2]; //
|
||||||
|
float x,y,z;
|
||||||
|
|
||||||
|
char name[AI_MDL7_MAX_BONENAMESIZE];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define AI_MDL7_MAX_GROUPNAMESIZE 16
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Group_MDL7
|
||||||
|
* \brief Group in a MDL7 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Group_MDL7
|
||||||
|
{
|
||||||
|
//! = '1' -> triangle based Mesh
|
||||||
|
unsigned char typ;
|
||||||
|
|
||||||
|
int8_t deformers;
|
||||||
|
int8_t max_weights;
|
||||||
|
int8_t _unused_;
|
||||||
|
|
||||||
|
//! size of data for this group in bytes ( MD7_GROUP stc. included).
|
||||||
|
int32_t groupdata_size;
|
||||||
|
char name[AI_MDL7_MAX_GROUPNAMESIZE];
|
||||||
|
|
||||||
|
//! Number of skins
|
||||||
|
int32_t numskins;
|
||||||
|
|
||||||
|
//! Number of texture coordinates
|
||||||
|
int32_t num_stpts;
|
||||||
|
|
||||||
|
//! Number of triangles
|
||||||
|
int32_t numtris;
|
||||||
|
|
||||||
|
//! Number of vertices
|
||||||
|
int32_t numverts;
|
||||||
|
|
||||||
|
//! Number of frames
|
||||||
|
int32_t numframes;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
#define AI_MDL7_SKINTYPE_MIPFLAG 0x08
|
||||||
|
#define AI_MDL7_SKINTYPE_MATERIAL 0x10
|
||||||
|
#define AI_MDL7_SKINTYPE_MATERIAL_ASCDEF 0x20
|
||||||
|
#define AI_MDL7_SKINTYPE_RGBFLAG 0x80
|
||||||
|
|
||||||
|
|
||||||
|
#define AI_MDL7_MAX_BONENAMESIZE 20
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Deformer_MDL7
|
||||||
|
* \brief Deformer in a MDL7 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Deformer_MDL7
|
||||||
|
{
|
||||||
|
int8_t deformer_version; // 0
|
||||||
|
int8_t deformer_typ; // 0 - bones
|
||||||
|
int8_t _unused_[2];
|
||||||
|
int32_t group_index;
|
||||||
|
int32_t elements;
|
||||||
|
int32_t deformerdata_size;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct DeformerElement_MDL7
|
||||||
|
{
|
||||||
|
//! bei deformer_typ==0 (==bones) element_index == bone index
|
||||||
|
int32_t element_index;
|
||||||
|
char element_name[AI_MDL7_MAX_BONENAMESIZE];
|
||||||
|
int32_t weights;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct DeformerWeight_MDL7
|
||||||
|
{
|
||||||
|
//! for deformer_typ==0 (==bones) index == vertex index
|
||||||
|
int32_t index;
|
||||||
|
float weight;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
#define AI_MDL7_MAX_TEXNAMESIZE 0x10
|
||||||
|
|
||||||
|
typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Skin_MDL7
|
||||||
|
* \brief Skin in a MDL7 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Skin_MDL7
|
||||||
|
{
|
||||||
|
uint8_t typ;
|
||||||
|
int8_t _unused_[3];
|
||||||
|
int32_t width;
|
||||||
|
int32_t height;
|
||||||
|
char texture_name[AI_MDL7_MAX_TEXNAMESIZE];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct ColorValue_MDL7
|
||||||
|
{
|
||||||
|
float r,g,b,a;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Material_MDL7
|
||||||
|
* \brief Material in a MDL7 file
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Material_MDL7
|
||||||
|
{
|
||||||
|
//! Diffuse base color of the material
|
||||||
|
ColorValue_MDL7 Diffuse;
|
||||||
|
|
||||||
|
//! Ambient base color of the material
|
||||||
|
ColorValue_MDL7 Ambient;
|
||||||
|
|
||||||
|
//! Specular base color of the material
|
||||||
|
ColorValue_MDL7 Specular;
|
||||||
|
|
||||||
|
//! Emissive base color of the material
|
||||||
|
ColorValue_MDL7 Emissive;
|
||||||
|
|
||||||
|
//! Phong power
|
||||||
|
float Power;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Skin
|
||||||
|
* \brief Skin data structure #1
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Skin
|
||||||
|
{
|
||||||
|
//! 0 = single (Skin), 1 = group (GroupSkin)
|
||||||
|
//! For MDL3-5: Defines the type of the skin and there
|
||||||
|
//! fore the size of the data to skip:
|
||||||
|
//-------------------------------------------------------
|
||||||
|
//! 2 for 565 RGB,
|
||||||
|
//! 3 for 4444 ARGB,
|
||||||
|
//! 10 for 565 mipmapped,
|
||||||
|
//! 11 for 4444 mipmapped (bpp = 2),
|
||||||
|
//! 12 for 888 RGB mipmapped (bpp = 3),
|
||||||
|
//! 13 for 8888 ARGB mipmapped (bpp = 4)
|
||||||
|
//-------------------------------------------------------
|
||||||
|
int32_t group;
|
||||||
|
|
||||||
|
//! Texture data
|
||||||
|
uint8_t *data;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct Skin_MDL5
|
||||||
|
{
|
||||||
|
int32_t size, width, height;
|
||||||
|
uint8_t *data;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct RGB565
|
||||||
|
{
|
||||||
|
uint16_t r : 5;
|
||||||
|
uint16_t g : 6;
|
||||||
|
uint16_t b : 5;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct ARGB4
|
||||||
|
{
|
||||||
|
uint16_t a : 4;
|
||||||
|
uint16_t r : 4;
|
||||||
|
uint16_t g : 4;
|
||||||
|
uint16_t b : 4;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct GroupSkin
|
||||||
|
* \brief Skin data structure #2 (group of pictures)
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct GroupSkin
|
||||||
|
{
|
||||||
|
//! 0 = single (Skin), 1 = group (GroupSkin)
|
||||||
|
int32_t group;
|
||||||
|
|
||||||
|
//! Number of images
|
||||||
|
int32_t nb;
|
||||||
|
|
||||||
|
//! Time for each image
|
||||||
|
float *time;
|
||||||
|
|
||||||
|
//! Data of each image
|
||||||
|
uint8_t **data;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct TexCoord
|
||||||
|
* \brief Texture coordinate data structure
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct TexCoord
|
||||||
|
{
|
||||||
|
//! Is the vertex on the noundary between front and back piece?
|
||||||
|
int32_t onseam;
|
||||||
|
|
||||||
|
//! Texture coordinate in the tx direction
|
||||||
|
int32_t s;
|
||||||
|
|
||||||
|
//! Texture coordinate in the ty direction
|
||||||
|
int32_t t;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
struct TexCoord_MDL3
|
||||||
|
{
|
||||||
|
//! position, horizontally in range 0..skinwidth-1
|
||||||
|
int16_t u;
|
||||||
|
|
||||||
|
//! position, vertically in range 0..skinheight-1
|
||||||
|
int16_t v;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
struct TexCoord_MDL7
|
||||||
|
{
|
||||||
|
//! position, horizontally in range 0..1
|
||||||
|
float u;
|
||||||
|
|
||||||
|
//! position, vertically in range 0..1
|
||||||
|
float v;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Triangle
|
||||||
|
* \brief Triangle data structure
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Triangle
|
||||||
|
{
|
||||||
|
//! 0 = backface, 1 = frontface
|
||||||
|
int32_t facesfront;
|
||||||
|
|
||||||
|
//! Vertex indices
|
||||||
|
int32_t vertex[3];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
struct Triangle_MDL3
|
||||||
|
{
|
||||||
|
//! Index of 3 3D vertices in range 0..numverts
|
||||||
|
uint16_t index_xyz[3];
|
||||||
|
|
||||||
|
//! Index of 3 skin vertices in range 0..numskinverts
|
||||||
|
uint16_t index_uv[3];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
struct SkinSet_MDL7
|
||||||
|
{
|
||||||
|
//! Index into the UV coordinate list
|
||||||
|
uint16_t st_index[3]; // size 6
|
||||||
|
|
||||||
|
//! Material index
|
||||||
|
int32_t material; // size 4
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
struct Triangle_MDL7
|
||||||
|
{
|
||||||
|
//! Vertex indices
|
||||||
|
uint16_t v_index[3]; // size 6
|
||||||
|
|
||||||
|
//! Two skinsets. The second will be used for multi-texturing
|
||||||
|
SkinSet_MDL7 skinsets[2];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
// Helper constants for Triangle::facesfront
|
||||||
|
#if (!defined AI_MDL_BACKFACE)
|
||||||
|
# define AI_MDL_BACKFACE 0x0
|
||||||
|
#endif
|
||||||
|
#if (!defined AI_MDL_FRONTFACE)
|
||||||
|
# define AI_MDL_FRONTFACE 0x1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Vertex
|
||||||
|
* \brief Vertex data structure
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Vertex
|
||||||
|
{
|
||||||
|
uint8_t v[3];
|
||||||
|
uint8_t normalIndex;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
struct Vertex_MDL4
|
||||||
|
{
|
||||||
|
uint16_t v[3];
|
||||||
|
uint8_t normalIndex;
|
||||||
|
uint8_t unused;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
#define AI_MDL7_FRAMEVERTEX120503_STCSIZE 16
|
||||||
|
#define AI_MDL7_FRAMEVERTEX030305_STCSIZE 26
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Vertex_MDL7
|
||||||
|
* \brief Vertex data structure used in MDL7 files
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Vertex_MDL7
|
||||||
|
{
|
||||||
|
float x,y,z;
|
||||||
|
uint16_t vertindex;
|
||||||
|
union {
|
||||||
|
uint16_t norm162index;
|
||||||
|
float norm[3];
|
||||||
|
};
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct BoneTransform_MDL7
|
||||||
|
* \brief bone transformation matrix structure used in MDL7 files
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct BoneTransform_MDL7
|
||||||
|
{
|
||||||
|
//! 4*3
|
||||||
|
float m [4*4];
|
||||||
|
|
||||||
|
//! the index of this vertex, 0.. header::bones_num - 1
|
||||||
|
uint16_t bone_index;
|
||||||
|
|
||||||
|
//! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED
|
||||||
|
//! THIS STUPID FILE FORMAT!
|
||||||
|
int8_t _unused_[2];
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
#define AI_MDL7_MAX_FRAMENAMESIZE 16
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Frame_MDL7
|
||||||
|
* \brief Frame data structure used by MDL7 files
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Frame_MDL7
|
||||||
|
{
|
||||||
|
char frame_name[AI_MDL7_MAX_FRAMENAMESIZE];
|
||||||
|
uint32_t vertices_count;
|
||||||
|
uint32_t transmatrix_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct SimpleFrame
|
||||||
|
* \brief Data structure for a simple frame
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct SimpleFrame
|
||||||
|
{
|
||||||
|
//! Minimum vertex of the bounding box
|
||||||
|
Vertex bboxmin;
|
||||||
|
|
||||||
|
//! Maximum vertex of the bounding box
|
||||||
|
Vertex bboxmax;
|
||||||
|
|
||||||
|
//! Name of the frame
|
||||||
|
char name[16];
|
||||||
|
|
||||||
|
//! Vertex list of the frame
|
||||||
|
Vertex *verts;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct Frame
|
||||||
|
* \brief Model frame data structure
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct Frame
|
||||||
|
{
|
||||||
|
//! 0 = simple frame, !0 = group frame
|
||||||
|
int32_t type;
|
||||||
|
|
||||||
|
//! Frame data
|
||||||
|
SimpleFrame frame;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
struct SimpleFrame_MDLn_SP
|
||||||
|
{
|
||||||
|
//! Minimum vertex of the bounding box
|
||||||
|
Vertex_MDL4 bboxmin;
|
||||||
|
|
||||||
|
//! Maximum vertex of the bounding box
|
||||||
|
Vertex_MDL4 bboxmax;
|
||||||
|
|
||||||
|
//! Name of the frame
|
||||||
|
char name[16];
|
||||||
|
|
||||||
|
//! Vertex list of the frame
|
||||||
|
Vertex_MDL4 *verts;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct GroupFrame
|
||||||
|
* \brief Data structure for a group of frames
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct GroupFrame
|
||||||
|
{
|
||||||
|
//! 0 = simple frame, !0 = group frame
|
||||||
|
int32_t type;
|
||||||
|
|
||||||
|
//! Minimum vertex for all single frames
|
||||||
|
Vertex min;
|
||||||
|
|
||||||
|
//! Maximum vertex for all single frames
|
||||||
|
Vertex max;
|
||||||
|
|
||||||
|
//! Time for all single frames
|
||||||
|
float *time;
|
||||||
|
|
||||||
|
//! List of single frames
|
||||||
|
SimpleFrame *frames;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// reset packing to the original value
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||||
|
# pragma pack( pop )
|
||||||
|
#endif
|
||||||
|
#undef PACK_STRUCT
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct IntFace_MDL7
|
||||||
|
* \brief Internal data structure to temporarily represent a face
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct IntFace_MDL7
|
||||||
|
{
|
||||||
|
// provide a constructor for our own convenience
|
||||||
|
IntFace_MDL7()
|
||||||
|
{
|
||||||
|
// set everything to zero
|
||||||
|
mIndices[0] = mIndices[1] = mIndices[2] = 0;
|
||||||
|
iMatIndex[0] = iMatIndex[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Vertex indices
|
||||||
|
uint32_t mIndices[3];
|
||||||
|
|
||||||
|
//! Material index (maximally two channels, which are joined later)
|
||||||
|
unsigned int iMatIndex[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \struct IntMaterial_MDL7
|
||||||
|
* \brief Internal data structure to temporarily represent a material
|
||||||
|
* which has been created from two single materials along with the
|
||||||
|
* original material indices.
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct IntMaterial_MDL7
|
||||||
|
{
|
||||||
|
// provide a constructor for our own convenience
|
||||||
|
IntMaterial_MDL7()
|
||||||
|
{
|
||||||
|
pcMat = NULL;
|
||||||
|
iOldMatIndices[0] = iOldMatIndices[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Material instance
|
||||||
|
MaterialHelper* pcMat;
|
||||||
|
|
||||||
|
//! Old material indices
|
||||||
|
unsigned int iOldMatIndices[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
};}; // end namespaces
|
||||||
|
|
||||||
|
#endif // !! AI_MDLFILEHELPER_H_INC
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,241 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//!
|
||||||
|
//! @file Definition of MDL importer class
|
||||||
|
//!
|
||||||
|
|
||||||
|
#ifndef AI_MDLLOADER_H_INCLUDED
|
||||||
|
#define AI_MDLLOADER_H_INCLUDED
|
||||||
|
|
||||||
|
#include "BaseImporter.h"
|
||||||
|
#include "../include/aiTypes.h"
|
||||||
|
#include "../include/aiTexture.h"
|
||||||
|
#include "../include/aiMaterial.h"
|
||||||
|
|
||||||
|
struct aiNode;
|
||||||
|
#include "MDLFileData.h"
|
||||||
|
|
||||||
|
namespace Assimp
|
||||||
|
{
|
||||||
|
class MaterialHelper;
|
||||||
|
|
||||||
|
using namespace MDL;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Used to load MDL files
|
||||||
|
*/
|
||||||
|
class MDLImporter : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
MDLImporter();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~MDLImporter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
|
{
|
||||||
|
append.append("*.mdl");
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Imports the given file into the given scene structure.
|
||||||
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Import a quake 1 MDL file
|
||||||
|
*/
|
||||||
|
void InternReadFile_Quake1( );
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Import a GameStudio A4/A5 file
|
||||||
|
*/
|
||||||
|
void InternReadFile_GameStudio( );
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Import a GameStudio A7 file
|
||||||
|
*/
|
||||||
|
void InternReadFile_GameStudioA7( );
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Load a paletized texture from the file and convert it to 32bpp
|
||||||
|
*/
|
||||||
|
void CreateTextureARGB8(const unsigned char* szData);
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Used to load textures from MDL3/4
|
||||||
|
* \param szData Input data
|
||||||
|
* \param iType Color data type
|
||||||
|
* \param piSkip Receive: Size to skip
|
||||||
|
*/
|
||||||
|
void CreateTextureARGB8_GS4(const unsigned char* szData,
|
||||||
|
unsigned int iType,
|
||||||
|
unsigned int* piSkip);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Used to load textures from MDL5
|
||||||
|
* \param szData Input data
|
||||||
|
* \param iType Color data type
|
||||||
|
* \param piSkip Receive: Size to skip
|
||||||
|
*/
|
||||||
|
void CreateTextureARGB8_GS5(const unsigned char* szData,
|
||||||
|
unsigned int iType,
|
||||||
|
unsigned int* piSkip);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse a skin lump in a MDL7 file with all of its features
|
||||||
|
* \param szCurrent Current data pointer
|
||||||
|
* \param szCurrentOut Output data pointer
|
||||||
|
* \param pcMats Material list for this group. To be filled ...
|
||||||
|
*/
|
||||||
|
void ParseSkinLump_GameStudioA7(
|
||||||
|
const unsigned char* szCurrent,
|
||||||
|
const unsigned char** szCurrentOut,
|
||||||
|
std::vector<MaterialHelper*>& pcMats);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Parse texture color data for MDL5, MDL6 and MDL7 formats
|
||||||
|
* \param szData Current data pointer
|
||||||
|
* \param iType type of the texture data. No DDS or external
|
||||||
|
* \param piSkip Receive the number of bytes to skip
|
||||||
|
* \param pcNew Must point to fully initialized data. Width and
|
||||||
|
* height must be set.
|
||||||
|
*/
|
||||||
|
void ParseTextureColorData(const unsigned char* szData,
|
||||||
|
unsigned int iType,
|
||||||
|
unsigned int* piSkip,
|
||||||
|
aiTexture* pcNew);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Validate the header data structure of a game studio MDL7 file
|
||||||
|
* \param pcHeader Input header to be validated
|
||||||
|
*/
|
||||||
|
void ValidateHeader_GameStudioA7(const MDL::Header_MDL7* pcHeader);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Join two materials / skins. Setup UV source ... etc
|
||||||
|
* \param pcMat1 First input material
|
||||||
|
* \param pcMat2 Second input material
|
||||||
|
* \param pcMatOut Output material instance to be filled. Must be empty
|
||||||
|
*/
|
||||||
|
void JoinSkins_GameStudioA7(MaterialHelper* pcMat1,
|
||||||
|
MaterialHelper* pcMat2,
|
||||||
|
MaterialHelper* pcMatOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Generate the final output meshes for a7 models
|
||||||
|
* \param aiSplit Face-per-material list
|
||||||
|
* \param pcMats List of all materials
|
||||||
|
* \param avOutList Output: List of all meshes
|
||||||
|
* \param pcFaces List of all input faces
|
||||||
|
* \param vPositions List of all input vectors
|
||||||
|
* \param vNormals List of all input normal vectors
|
||||||
|
* \param vTextureCoords1 List of all input UV coords #1
|
||||||
|
* \param vTextureCoords2 List of all input UV coords #2
|
||||||
|
*/
|
||||||
|
void GenerateOutputMeshes_GameStudioA7(
|
||||||
|
const std::vector<unsigned int>** aiSplit,
|
||||||
|
const std::vector<MaterialHelper*>& pcMats,
|
||||||
|
std::vector<aiMesh*>& avOutList,
|
||||||
|
const MDL::IntFace_MDL7* pcFaces,
|
||||||
|
const std::vector<aiVector3D>& vPositions,
|
||||||
|
const std::vector<aiVector3D>& vNormals,
|
||||||
|
const std::vector<aiVector3D>& vTextureCoords1,
|
||||||
|
const std::vector<aiVector3D>& vTextureCoords2);
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Try to load a palette from the current directory (colormap.lmp)
|
||||||
|
* If it is not found the default palette of Quake1 is returned
|
||||||
|
*/
|
||||||
|
void SearchPalette(const unsigned char** pszColorMap);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Free a palette created with a previous call to SearchPalette()
|
||||||
|
*/
|
||||||
|
void FreePalette(const unsigned char* pszColorMap);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/** Header of the MDL file */
|
||||||
|
const MDL::Header* m_pcHeader;
|
||||||
|
|
||||||
|
/** Buffer to hold the loaded file */
|
||||||
|
unsigned char* mBuffer;
|
||||||
|
|
||||||
|
/** For GameStudio MDL files: The number in the magic
|
||||||
|
word, either 3,4 or 5*/
|
||||||
|
unsigned int iGSFileVersion;
|
||||||
|
|
||||||
|
/** Output I/O handler. used to load external lmp files
|
||||||
|
*/
|
||||||
|
IOSystem* pIOHandler;
|
||||||
|
|
||||||
|
/** Output scene to be filled
|
||||||
|
*/
|
||||||
|
aiScene* pScene;
|
||||||
|
};
|
||||||
|
}; // end of namespace Assimp
|
||||||
|
|
||||||
|
#endif // AI_3DSIMPORTER_H_INC
|
|
@ -1,4 +1,42 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
#include "assimp.h"
|
#include "assimp.h"
|
||||||
#include "aiMaterial.h"
|
#include "aiMaterial.h"
|
||||||
|
@ -11,20 +49,15 @@
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
|
aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
const aiMaterialProperty** pPropOut)
|
const aiMaterialProperty** pPropOut)
|
||||||
{
|
{
|
||||||
#if (defined DEBUG)
|
|
||||||
|
|
||||||
ai_assert (pMat != NULL);
|
ai_assert (pMat != NULL);
|
||||||
ai_assert (pKey != NULL);
|
ai_assert (pKey != NULL);
|
||||||
ai_assert (pPropOut != NULL);
|
ai_assert (pPropOut != NULL);
|
||||||
|
|
||||||
#endif // ASSIMP_DEBUG
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
||||||
{
|
{
|
||||||
if (NULL != pMat->mProperties[i])
|
if (NULL != pMat->mProperties[i])
|
||||||
|
@ -39,23 +72,16 @@ aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
|
||||||
*pPropOut = NULL;
|
*pPropOut = NULL;
|
||||||
return AI_FAILURE;
|
return AI_FAILURE;
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
|
aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
float* pOut,
|
float* pOut,
|
||||||
unsigned int* pMax)
|
unsigned int* pMax)
|
||||||
{
|
{
|
||||||
#if (defined DEBUG)
|
|
||||||
|
|
||||||
ai_assert (pMat != NULL);
|
ai_assert (pMat != NULL);
|
||||||
ai_assert (pKey != NULL);
|
ai_assert (pKey != NULL);
|
||||||
ai_assert (pOut != NULL);
|
ai_assert (pOut != NULL);
|
||||||
|
|
||||||
#endif // ASSIMP_DEBUG
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
||||||
{
|
{
|
||||||
if (NULL != pMat->mProperties[i])
|
if (NULL != pMat->mProperties[i])
|
||||||
|
@ -106,23 +132,15 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
|
||||||
}
|
}
|
||||||
return AI_FAILURE;
|
return AI_FAILURE;
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
|
aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
int* pOut,
|
int* pOut,
|
||||||
unsigned int* pMax)
|
unsigned int* pMax)
|
||||||
{
|
{
|
||||||
#if (defined DEBUG)
|
|
||||||
|
|
||||||
ai_assert (pMat != NULL);
|
ai_assert (pMat != NULL);
|
||||||
ai_assert (pKey != NULL);
|
ai_assert (pKey != NULL);
|
||||||
ai_assert (pOut != NULL);
|
ai_assert (pOut != NULL);
|
||||||
|
|
||||||
#endif // ASSIMP_DEBUG
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
||||||
{
|
{
|
||||||
if (NULL != pMat->mProperties[i])
|
if (NULL != pMat->mProperties[i])
|
||||||
|
@ -173,10 +191,7 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
|
||||||
}
|
}
|
||||||
return AI_FAILURE;
|
return AI_FAILURE;
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
aiReturn aiGetMaterialColor(const aiMaterial* pMat,
|
aiReturn aiGetMaterialColor(const aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
aiColor4D* pOut)
|
aiColor4D* pOut)
|
||||||
|
@ -188,22 +203,15 @@ aiReturn aiGetMaterialColor(const aiMaterial* pMat,
|
||||||
if (3 == iMax)pOut->a = 1.0f;
|
if (3 == iMax)pOut->a = 1.0f;
|
||||||
return eRet;
|
return eRet;
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
aiReturn aiGetMaterialString(const aiMaterial* pMat,
|
aiReturn aiGetMaterialString(const aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
aiString* pOut)
|
aiString* pOut)
|
||||||
{
|
{
|
||||||
#if (defined DEBUG)
|
|
||||||
|
|
||||||
ai_assert (pMat != NULL);
|
ai_assert (pMat != NULL);
|
||||||
ai_assert (pKey != NULL);
|
ai_assert (pKey != NULL);
|
||||||
ai_assert (pOut != NULL);
|
ai_assert (pOut != NULL);
|
||||||
|
|
||||||
#endif // ASSIMP_DEBUG
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
for (unsigned int i = 0; i < pMat->mNumProperties;++i)
|
||||||
{
|
{
|
||||||
if (NULL != pMat->mProperties[i])
|
if (NULL != pMat->mProperties[i])
|
||||||
|
@ -223,23 +231,16 @@ aiReturn aiGetMaterialString(const aiMaterial* pMat,
|
||||||
}
|
}
|
||||||
return AI_FAILURE;
|
return AI_FAILURE;
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
aiReturn MaterialHelper::AddBinaryProperty (const void* pInput,
|
aiReturn MaterialHelper::AddBinaryProperty (const void* pInput,
|
||||||
const unsigned int pSizeInBytes,
|
const unsigned int pSizeInBytes,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
aiPropertyTypeInfo pType)
|
aiPropertyTypeInfo pType)
|
||||||
{
|
{
|
||||||
#if (defined DEBUG)
|
|
||||||
|
|
||||||
ai_assert (pInput != NULL);
|
ai_assert (pInput != NULL);
|
||||||
ai_assert (pKey != NULL);
|
ai_assert (pKey != NULL);
|
||||||
ai_assert (0 != pSizeInBytes);
|
ai_assert (0 != pSizeInBytes);
|
||||||
|
|
||||||
#endif // ASSIMP_DEBUG
|
|
||||||
|
|
||||||
aiMaterialProperty* pcNew = new aiMaterialProperty();
|
aiMaterialProperty* pcNew = new aiMaterialProperty();
|
||||||
|
|
||||||
// fill this
|
// fill this
|
||||||
|
@ -273,13 +274,146 @@ aiReturn MaterialHelper::AddBinaryProperty (const void* pInput,
|
||||||
this->mProperties[this->mNumProperties++] = pcNew;
|
this->mProperties[this->mNumProperties++] = pcNew;
|
||||||
return AI_SUCCESS;
|
return AI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
aiReturn MaterialHelper::AddProperty (const aiString* pInput,
|
aiReturn MaterialHelper::AddProperty (const aiString* pInput,
|
||||||
const char* pKey)
|
const char* pKey)
|
||||||
{
|
{
|
||||||
return this->AddBinaryProperty(pInput,
|
return this->AddBinaryProperty(pInput,
|
||||||
sizeof(aiString),pKey,aiPTI_String);
|
sizeof(aiString),pKey,aiPTI_String);
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void MaterialHelper::CopyPropertyList(MaterialHelper* pcDest,
|
||||||
|
const MaterialHelper* pcSrc)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcDest);
|
||||||
|
ai_assert(NULL != pcSrc);
|
||||||
|
|
||||||
|
unsigned int iOldNum = pcDest->mNumProperties;
|
||||||
|
pcDest->mNumAllocated += pcSrc->mNumAllocated;
|
||||||
|
pcDest->mNumProperties += pcSrc->mNumProperties;
|
||||||
|
|
||||||
|
aiMaterialProperty** pcOld = pcDest->mProperties;
|
||||||
|
pcDest->mProperties = new aiMaterialProperty*[pcDest->mNumAllocated];
|
||||||
|
|
||||||
|
if (pcOld)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < iOldNum;++i)
|
||||||
|
pcDest->mProperties[i] = pcOld[i];
|
||||||
|
|
||||||
|
delete[] pcDest->mProperties;
|
||||||
|
}
|
||||||
|
for (unsigned int i = iOldNum; i< pcDest->mNumProperties;++i)
|
||||||
|
{
|
||||||
|
pcDest->mProperties[i]->mKey = new aiString(*pcSrc->mProperties[i]->mKey);
|
||||||
|
pcDest->mProperties[i]->mDataLength = pcSrc->mProperties[i]->mDataLength;
|
||||||
|
pcDest->mProperties[i]->mType = pcSrc->mProperties[i]->mType;
|
||||||
|
pcDest->mProperties[i]->mData = new char[pcDest->mProperties[i]->mDataLength];
|
||||||
|
memcpy(pcDest->mProperties[i]->mData,pcSrc->mProperties[i]->mData,
|
||||||
|
pcDest->mProperties[i]->mDataLength);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiReturn aiGetMaterialTexture(const aiMaterial* pcMat,
|
||||||
|
unsigned int iIndex,
|
||||||
|
unsigned int iTexType,
|
||||||
|
aiString* szOut,
|
||||||
|
unsigned int* piUVIndex,
|
||||||
|
float* pfBlendFactor,
|
||||||
|
aiTextureOp* peTextureOp)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcMat);
|
||||||
|
ai_assert(NULL != szOut);
|
||||||
|
|
||||||
|
const char* szPathBase;
|
||||||
|
const char* szUVBase;
|
||||||
|
const char* szBlendBase;
|
||||||
|
const char* szOpBase;
|
||||||
|
switch (iTexType)
|
||||||
|
{
|
||||||
|
case AI_TEXTYPE_DIFFUSE:
|
||||||
|
szPathBase = AI_MATKEY_TEXTURE_DIFFUSE_;
|
||||||
|
szUVBase = AI_MATKEY_UVWSRC_DIFFUSE_;
|
||||||
|
szBlendBase = AI_MATKEY_TEXBLEND_DIFFUSE_;
|
||||||
|
szOpBase = AI_MATKEY_TEXOP_DIFFUSE_;
|
||||||
|
break;
|
||||||
|
case AI_TEXTYPE_SPECULAR:
|
||||||
|
szPathBase = AI_MATKEY_TEXTURE_SPECULAR_;
|
||||||
|
szUVBase = AI_MATKEY_UVWSRC_SPECULAR_;
|
||||||
|
szBlendBase = AI_MATKEY_TEXBLEND_SPECULAR_;
|
||||||
|
szOpBase = AI_MATKEY_TEXOP_SPECULAR_;
|
||||||
|
break;
|
||||||
|
case AI_TEXTYPE_AMBIENT:
|
||||||
|
szPathBase = AI_MATKEY_TEXTURE_AMBIENT_;
|
||||||
|
szUVBase = AI_MATKEY_UVWSRC_AMBIENT_;
|
||||||
|
szBlendBase = AI_MATKEY_TEXBLEND_AMBIENT_;
|
||||||
|
szOpBase = AI_MATKEY_TEXOP_AMBIENT_;
|
||||||
|
break;
|
||||||
|
case AI_TEXTYPE_EMISSIVE:
|
||||||
|
szPathBase = AI_MATKEY_TEXTURE_EMISSIVE_;
|
||||||
|
szUVBase = AI_MATKEY_UVWSRC_EMISSIVE_;
|
||||||
|
szBlendBase = AI_MATKEY_TEXBLEND_EMISSIVE_;
|
||||||
|
szOpBase = AI_MATKEY_TEXOP_EMISSIVE_;
|
||||||
|
break;
|
||||||
|
case AI_TEXTYPE_HEIGHT:
|
||||||
|
szPathBase = AI_MATKEY_TEXTURE_HEIGHT_;
|
||||||
|
szUVBase = AI_MATKEY_UVWSRC_HEIGHT_;
|
||||||
|
szBlendBase = AI_MATKEY_TEXBLEND_HEIGHT_;
|
||||||
|
szOpBase = AI_MATKEY_TEXOP_HEIGHT_;
|
||||||
|
break;
|
||||||
|
case AI_TEXTYPE_NORMALS:
|
||||||
|
szPathBase = AI_MATKEY_TEXTURE_NORMALS_;
|
||||||
|
szUVBase = AI_MATKEY_UVWSRC_NORMALS_;
|
||||||
|
szBlendBase = AI_MATKEY_TEXBLEND_NORMALS_;
|
||||||
|
szOpBase = AI_MATKEY_TEXOP_NORMALS_;
|
||||||
|
break;
|
||||||
|
case AI_TEXTYPE_SHININESS:
|
||||||
|
szPathBase = AI_MATKEY_TEXTURE_SHININESS_;
|
||||||
|
szUVBase = AI_MATKEY_UVWSRC_SHININESS_;
|
||||||
|
szBlendBase = AI_MATKEY_TEXBLEND_SHININESS_;
|
||||||
|
szOpBase = AI_MATKEY_TEXOP_SHININESS_;
|
||||||
|
break;
|
||||||
|
default: return AI_FAILURE;
|
||||||
|
};
|
||||||
|
|
||||||
|
char szKey[256];
|
||||||
|
|
||||||
|
// get the path to the texture
|
||||||
|
sprintf(szKey,"%s[%i]",szPathBase,iIndex);
|
||||||
|
if (AI_SUCCESS != aiGetMaterialString(pcMat,szKey,szOut))
|
||||||
|
{
|
||||||
|
return AI_FAILURE;
|
||||||
|
}
|
||||||
|
// get the UV index of the texture
|
||||||
|
if (piUVIndex)
|
||||||
|
{
|
||||||
|
int iUV;
|
||||||
|
sprintf(szKey,"%s[%i]",szUVBase,iIndex);
|
||||||
|
if (AI_SUCCESS != aiGetMaterialInteger(pcMat,szKey,&iUV))
|
||||||
|
iUV = 0;
|
||||||
|
|
||||||
|
*piUVIndex = iUV;
|
||||||
|
}
|
||||||
|
// get the blend factor of the texture
|
||||||
|
if (pfBlendFactor)
|
||||||
|
{
|
||||||
|
float fBlend;
|
||||||
|
sprintf(szKey,"%s[%i]",szBlendBase,iIndex);
|
||||||
|
if (AI_SUCCESS != aiGetMaterialFloat(pcMat,szKey,&fBlend))
|
||||||
|
fBlend = 1.0f;
|
||||||
|
|
||||||
|
*pfBlendFactor = fBlend;
|
||||||
|
}
|
||||||
|
// get the texture operation of the texture
|
||||||
|
if (peTextureOp)
|
||||||
|
{
|
||||||
|
aiTextureOp op;
|
||||||
|
sprintf(szKey,"%s[%i]",szOpBase,iIndex);
|
||||||
|
if (AI_SUCCESS != aiGetMaterialInteger(pcMat,szKey,(int*)&op))
|
||||||
|
op = aiTextureOp_Multiply;
|
||||||
|
|
||||||
|
*peTextureOp = op;
|
||||||
|
}
|
||||||
|
return AI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definition of the base class for all importer worker classes. */
|
/** @file Definition of the base class for all importer worker classes. */
|
||||||
#ifndef AI_MATERIALSYSTEM_H_INC
|
#ifndef AI_MATERIALSYSTEM_H_INC
|
||||||
#define AI_MATERIALSYSTEM_H_INC
|
#define AI_MATERIALSYSTEM_H_INC
|
||||||
|
@ -8,6 +48,15 @@ namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Helper function to do platform independent string comparison.
|
||||||
|
*
|
||||||
|
* This is required since stricmp() is not consistently available on
|
||||||
|
* all platforms. Some platforms use the '_' prefix, others don't even
|
||||||
|
* have such a function. Yes, this is called an ISO standard.
|
||||||
|
*
|
||||||
|
* \param s1 First input string
|
||||||
|
* \param s2 Second input string
|
||||||
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
inline int ASSIMP_stricmp(const char *s1, const char *s2)
|
inline int ASSIMP_stricmp(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +77,16 @@ inline int ASSIMP_stricmp(const char *s1, const char *s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Helper function to do platform independent string comparison.
|
||||||
|
*
|
||||||
|
* This is required since strincmp() is not consistently available on
|
||||||
|
* all platforms. Some platforms use the '_' prefix, others don't even
|
||||||
|
* have such a function. Yes, this is called an ISO standard.
|
||||||
|
*
|
||||||
|
* \param s1 First input string
|
||||||
|
* \param s2 Second input string
|
||||||
|
* \param n Macimum number of characters to compare
|
||||||
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
inline int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n)
|
inline int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n)
|
||||||
{
|
{
|
||||||
|
@ -58,14 +117,20 @@ inline int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n)
|
||||||
structure easily. */
|
structure easily. */
|
||||||
class MaterialHelper : public ::aiMaterial
|
class MaterialHelper : public ::aiMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline MaterialHelper();
|
inline MaterialHelper();
|
||||||
inline ~MaterialHelper();
|
inline ~MaterialHelper();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Add a property with a given key and type info to the material
|
/** Add a property with a given key and type info to the material
|
||||||
structure */
|
* structure
|
||||||
|
*
|
||||||
|
* \param pInput Pointer to input data
|
||||||
|
* \param pSizeInBytes Size of input data
|
||||||
|
* \param pKey Key/Usage of the property (AI_MATKEY_XXX)
|
||||||
|
* \param pType Type information hint
|
||||||
|
*/
|
||||||
aiReturn AddBinaryProperty (const void* pInput,
|
aiReturn AddBinaryProperty (const void* pInput,
|
||||||
const unsigned int pSizeInBytes,
|
const unsigned int pSizeInBytes,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
|
@ -74,17 +139,33 @@ class MaterialHelper : public ::aiMaterial
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Add a string property with a given key and type info to the
|
/** Add a string property with a given key and type info to the
|
||||||
material structure */
|
* material structure
|
||||||
|
*
|
||||||
|
* \param pInput Input string
|
||||||
|
* \param pKey Key/Usage of the property (AI_MATKEY_XXX)
|
||||||
|
*/
|
||||||
aiReturn AddProperty (const aiString* pInput,
|
aiReturn AddProperty (const aiString* pInput,
|
||||||
const char* pKey);
|
const char* pKey);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Add a property with a given key to the material structure */
|
/** Add a property with a given key to the material structure
|
||||||
|
* \param pInput Pointer to the input data
|
||||||
|
* \param pNumValues Number of values in the array
|
||||||
|
* \param pKey Key/Usage of the property (AI_MATKEY_XXX)
|
||||||
|
*/
|
||||||
template<class TYPE>
|
template<class TYPE>
|
||||||
aiReturn AddProperty (const TYPE* pInput,
|
aiReturn AddProperty (const TYPE* pInput,
|
||||||
const unsigned int pNumValues,
|
const unsigned int pNumValues,
|
||||||
const char* pKey);
|
const char* pKey);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Copy the property list of a material
|
||||||
|
* \param pcDest Destination material
|
||||||
|
* \param pcSrc Source material
|
||||||
|
*/
|
||||||
|
static void CopyPropertyList(MaterialHelper* pcDest,
|
||||||
|
const MaterialHelper* pcSrc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef OBJ_FILEDATA_H_INC
|
#ifndef OBJ_FILEDATA_H_INC
|
||||||
#define OBJ_FILEDATA_H_INC
|
#define OBJ_FILEDATA_H_INC
|
||||||
|
|
||||||
|
@ -128,16 +169,16 @@ struct Model
|
||||||
//! Vector with all generated group
|
//! Vector with all generated group
|
||||||
std::vector<std::string> m_GroupLib;
|
std::vector<std::string> m_GroupLib;
|
||||||
//! Vector with all generated vertices
|
//! Vector with all generated vertices
|
||||||
std::vector<aiVector3D_t*> m_Vertices;
|
std::vector<aiVector3D*> m_Vertices;
|
||||||
//! vector with all generated normals
|
//! vector with all generated normals
|
||||||
std::vector<aiVector3D_t*> m_Normals;
|
std::vector<aiVector3D*> m_Normals;
|
||||||
//! Groupmap
|
//! Groupmap
|
||||||
GroupMap m_Groups;
|
GroupMap m_Groups;
|
||||||
std::vector<unsigned int> *m_pGroupFaceIDs;
|
std::vector<unsigned int> *m_pGroupFaceIDs;
|
||||||
//! Active group
|
//! Active group
|
||||||
std::string m_strActiveGroup;
|
std::string m_strActiveGroup;
|
||||||
//! Vector with generated texture coordinates
|
//! Vector with generated texture coordinates
|
||||||
std::vector<aiVector2D_t*> m_TextureCoord;
|
std::vector<aiVector2D*> m_TextureCoord;
|
||||||
//! Material map
|
//! Material map
|
||||||
std::map<std::string, Material*> m_MaterialMap;
|
std::map<std::string, Material*> m_MaterialMap;
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
||||||
|
|
||||||
// Copy all stored vertices, normals and so on
|
// Copy all stored vertices, normals and so on
|
||||||
pMesh->mNumVertices = pModel->m_Vertices.size();
|
pMesh->mNumVertices = pModel->m_Vertices.size();
|
||||||
pMesh->mVertices = new aiVector3D_t[pMesh->mNumVertices];
|
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
|
||||||
for (size_t index=0; index < pModel->m_Vertices.size(); index++)
|
for (size_t index=0; index < pModel->m_Vertices.size(); index++)
|
||||||
{
|
{
|
||||||
pMesh->mVertices[ index ] = *pModel->m_Vertices[ index ];
|
pMesh->mVertices[ index ] = *pModel->m_Vertices[ index ];
|
||||||
|
@ -268,7 +268,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
||||||
|
|
||||||
if (!pModel->m_Normals.empty())
|
if (!pModel->m_Normals.empty())
|
||||||
{
|
{
|
||||||
pMesh->mNormals = new aiVector3D_t[pModel->m_Normals.size()];
|
pMesh->mNormals = new aiVector3D[pModel->m_Normals.size()];
|
||||||
for (size_t index = 0; index < pModel->m_Normals.size(); index++)
|
for (size_t index = 0; index < pModel->m_Normals.size(); index++)
|
||||||
{
|
{
|
||||||
pMesh->mNormals[ index ] = *pModel->m_Normals[ index ];
|
pMesh->mNormals[ index ] = *pModel->m_Normals[ index ];
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef OBJ_FILE_IMPORTER_H_INC
|
#ifndef OBJ_FILE_IMPORTER_H_INC
|
||||||
#define OBJ_FILE_IMPORTER_H_INC
|
#define OBJ_FILE_IMPORTER_H_INC
|
||||||
|
|
||||||
|
@ -39,6 +80,13 @@ public:
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
//! brief
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
|
{
|
||||||
|
append.append("*.obj");
|
||||||
|
}
|
||||||
|
|
||||||
//! \brief
|
//! \brief
|
||||||
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef OBJFILEMTLIMPORTER_H_INC
|
#ifndef OBJFILEMTLIMPORTER_H_INC
|
||||||
#define OBJFILEMTLIMPORTER_H_INC
|
#define OBJFILEMTLIMPORTER_H_INC
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ void ObjFileParser::copyNextLine(char *pBuffer, size_t length)
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get values for a new 3D vector instance
|
// Get values for a new 3D vector instance
|
||||||
void ObjFileParser::getVector3(std::vector<aiVector3D_t*> &point3d_array)
|
void ObjFileParser::getVector3(std::vector<aiVector3D*> &point3d_array)
|
||||||
{
|
{
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
copyNextWord(m_buffer, BUFFERSIZE);
|
copyNextWord(m_buffer, BUFFERSIZE);
|
||||||
|
@ -179,7 +179,7 @@ void ObjFileParser::getVector3(std::vector<aiVector3D_t*> &point3d_array)
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get values for a new 2D vector instance
|
// Get values for a new 2D vector instance
|
||||||
void ObjFileParser::getVector2(std::vector<aiVector2D_t*> &point2d_array)
|
void ObjFileParser::getVector2(std::vector<aiVector2D*> &point2d_array)
|
||||||
{
|
{
|
||||||
float x, y;
|
float x, y;
|
||||||
copyNextWord(m_buffer, BUFFERSIZE);
|
copyNextWord(m_buffer, BUFFERSIZE);
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file ObjTools.h
|
/** @file ObjTools.h
|
||||||
* @brief Some helpful templates for text parsing
|
* @brief Some helpful templates for text parsing
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the PLY importer class */
|
/** @file Implementation of the PLY importer class */
|
||||||
#include "PLYLoader.h"
|
#include "PLYLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
|
@ -172,13 +213,17 @@ void PLYImporter::InternReadFile(
|
||||||
std::vector<aiColor4D> avColors;
|
std::vector<aiColor4D> avColors;
|
||||||
this->LoadVertexColor(&avColors);
|
this->LoadVertexColor(&avColors);
|
||||||
|
|
||||||
|
// now try to load texture coordinates
|
||||||
|
std::vector<aiVector2D> avTexCoords;
|
||||||
|
this->LoadTextureCoordinates(&avTexCoords);
|
||||||
|
|
||||||
// now replace the default material in all faces and validate all material indices
|
// now replace the default material in all faces and validate all material indices
|
||||||
this->ReplaceDefaultMaterial(&avFaces,&avMaterials);
|
this->ReplaceDefaultMaterial(&avFaces,&avMaterials);
|
||||||
|
|
||||||
// now convert this to a list of aiMesh instances
|
// now convert this to a list of aiMesh instances
|
||||||
std::vector<aiMesh*> avMeshes;
|
std::vector<aiMesh*> avMeshes;
|
||||||
this->ConvertMeshes(&avFaces,&avPositions,&avNormals,
|
this->ConvertMeshes(&avFaces,&avPositions,&avNormals,
|
||||||
&avColors,&avMaterials,&avMeshes);
|
&avColors,&avTexCoords,&avMaterials,&avMeshes);
|
||||||
|
|
||||||
if (avMeshes.empty())
|
if (avMeshes.empty())
|
||||||
{
|
{
|
||||||
|
@ -216,6 +261,7 @@ void PLYImporter::ConvertMeshes(std::vector<PLY::Face>* avFaces,
|
||||||
const std::vector<aiVector3D>* avPositions,
|
const std::vector<aiVector3D>* avPositions,
|
||||||
const std::vector<aiVector3D>* avNormals,
|
const std::vector<aiVector3D>* avNormals,
|
||||||
const std::vector<aiColor4D>* avColors,
|
const std::vector<aiColor4D>* avColors,
|
||||||
|
const std::vector<aiVector2D>* avTexCoords,
|
||||||
const std::vector<MaterialHelper*>* avMaterials,
|
const std::vector<MaterialHelper*>* avMaterials,
|
||||||
std::vector<aiMesh*>* avOut)
|
std::vector<aiMesh*>* avOut)
|
||||||
{
|
{
|
||||||
|
@ -258,6 +304,11 @@ void PLYImporter::ConvertMeshes(std::vector<PLY::Face>* avFaces,
|
||||||
|
|
||||||
if (!avColors->empty())
|
if (!avColors->empty())
|
||||||
p_pcOut->mColors[0] = new aiColor4D[iNum];
|
p_pcOut->mColors[0] = new aiColor4D[iNum];
|
||||||
|
if (!avTexCoords->empty())
|
||||||
|
{
|
||||||
|
p_pcOut->mNumUVComponents[0] = 2;
|
||||||
|
p_pcOut->mTextureCoords[0] = new aiVector3D[iNum];
|
||||||
|
}
|
||||||
if (!avNormals->empty())
|
if (!avNormals->empty())
|
||||||
p_pcOut->mNormals = new aiVector3D[iNum];
|
p_pcOut->mNormals = new aiVector3D[iNum];
|
||||||
|
|
||||||
|
@ -272,53 +323,26 @@ void PLYImporter::ConvertMeshes(std::vector<PLY::Face>* avFaces,
|
||||||
p_pcOut->mFaces[iNum].mIndices = new unsigned int[p_pcOut->mFaces[iNum].mNumIndices];
|
p_pcOut->mFaces[iNum].mIndices = new unsigned int[p_pcOut->mFaces[iNum].mNumIndices];
|
||||||
|
|
||||||
// build an unique set of vertices/colors for this face
|
// build an unique set of vertices/colors for this face
|
||||||
// hardcode all combinations to speedup this piece of code
|
for (unsigned int q = 0; q < p_pcOut->mFaces[iNum].mNumIndices;++q)
|
||||||
if (!avColors->empty())
|
|
||||||
{
|
{
|
||||||
|
p_pcOut->mFaces[iNum].mIndices[q] = iVertex;
|
||||||
|
p_pcOut->mVertices[iVertex] = (*avPositions)[(*avFaces)[*i].mIndices[q]];
|
||||||
|
|
||||||
|
if (!avColors->empty())
|
||||||
|
p_pcOut->mColors[0][iVertex] = (*avColors)[(*avFaces)[*i].mIndices[q]];
|
||||||
|
|
||||||
|
if (!avTexCoords->empty())
|
||||||
|
{
|
||||||
|
const aiVector2D& vec = (*avTexCoords)[(*avFaces)[*i].mIndices[q]];
|
||||||
|
p_pcOut->mTextureCoords[0][iVertex].x = vec.x;
|
||||||
|
p_pcOut->mTextureCoords[0][iVertex].y = vec.y;
|
||||||
|
}
|
||||||
|
|
||||||
if (!avNormals->empty())
|
if (!avNormals->empty())
|
||||||
{
|
p_pcOut->mNormals[iVertex] = (*avNormals)[(*avFaces)[*i].mIndices[q]];
|
||||||
for (unsigned int q = 0; q < p_pcOut->mFaces[iNum].mNumIndices;++q)
|
iVertex++;
|
||||||
{
|
|
||||||
p_pcOut->mFaces[iNum].mIndices[q] = iVertex;
|
|
||||||
p_pcOut->mVertices[iVertex] = (*avPositions)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
p_pcOut->mColors[0][iVertex] = (*avColors)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
p_pcOut->mNormals[iVertex] = (*avNormals)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
iVertex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int q = 0; q < p_pcOut->mFaces[iNum].mNumIndices;++q)
|
|
||||||
{
|
|
||||||
p_pcOut->mFaces[iNum].mIndices[q] = iVertex;
|
|
||||||
p_pcOut->mVertices[iVertex] = (*avPositions)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
p_pcOut->mColors[0][iVertex] = (*avColors)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
iVertex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!avNormals->empty())
|
|
||||||
{
|
|
||||||
for (unsigned int q = 0; q < p_pcOut->mFaces[iNum].mNumIndices;++q)
|
|
||||||
{
|
|
||||||
p_pcOut->mFaces[iNum].mIndices[q] = iVertex;
|
|
||||||
p_pcOut->mVertices[iVertex] = (*avPositions)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
p_pcOut->mNormals[iVertex] = (*avNormals)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
iVertex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int q = 0; q < p_pcOut->mFaces[iNum].mNumIndices;++q)
|
|
||||||
{
|
|
||||||
p_pcOut->mFaces[iNum].mIndices[q] = iVertex;
|
|
||||||
p_pcOut->mVertices[iVertex] = (*avPositions)[(*avFaces)[*i].mIndices[q]];
|
|
||||||
iVertex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// add the mesh to the output list
|
// add the mesh to the output list
|
||||||
avOut->push_back(p_pcOut);
|
avOut->push_back(p_pcOut);
|
||||||
|
@ -370,8 +394,79 @@ void PLYImporter::ReplaceDefaultMaterial(std::vector<PLY::Face>* avFaces,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void PLYImporter::LoadTextureCoordinates(std::vector<aiVector2D>* pvOut)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pvOut);
|
||||||
|
|
||||||
|
unsigned int aiPositions[2] = {0xFFFFFFFF,0xFFFFFFFF};
|
||||||
|
PLY::EDataType aiTypes[2];
|
||||||
|
PLY::ElementInstanceList* pcList = NULL;
|
||||||
|
unsigned int cnt = 0;
|
||||||
|
|
||||||
|
// serach in the DOM for a vertex entry
|
||||||
|
unsigned int _i = 0;
|
||||||
|
for (std::vector<PLY::Element*>::const_iterator
|
||||||
|
i = this->pcDOM->alElements.begin();
|
||||||
|
i != this->pcDOM->alElements.end();++i,++_i)
|
||||||
|
{
|
||||||
|
if (PLY::EEST_Vertex == (*i)->eSemantic)
|
||||||
|
{
|
||||||
|
pcList = this->pcDOM->alElementData[_i];
|
||||||
|
|
||||||
|
// now check whether which normal components are available
|
||||||
|
unsigned int _a = 0;
|
||||||
|
for (std::vector<PLY::Property*>::const_iterator
|
||||||
|
a = (*i)->alProperties.begin();
|
||||||
|
a != (*i)->alProperties.end();++a,++_a)
|
||||||
|
{
|
||||||
|
if ((*a)->bIsList)continue;
|
||||||
|
if (PLY::EST_UTextureCoord == (*a)->Semantic)
|
||||||
|
{
|
||||||
|
cnt++;
|
||||||
|
aiPositions[0] = _a;
|
||||||
|
aiTypes[0] = (*a)->eType;
|
||||||
|
}
|
||||||
|
else if (PLY::EST_VTextureCoord == (*a)->Semantic)
|
||||||
|
{
|
||||||
|
cnt++;
|
||||||
|
aiPositions[1] = _a;
|
||||||
|
aiTypes[1] = (*a)->eType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check whether we have a valid source for the texture coordinates data
|
||||||
|
if (NULL != pcList && 0 != cnt)
|
||||||
|
{
|
||||||
|
pvOut->reserve(pcList->alInstances.size());
|
||||||
|
for (std::vector<ElementInstance*>::const_iterator
|
||||||
|
i = pcList->alInstances.begin();
|
||||||
|
i != pcList->alInstances.end();++i)
|
||||||
|
{
|
||||||
|
// convert the vertices to sp floats
|
||||||
|
aiVector2D vOut;
|
||||||
|
|
||||||
|
if (0xFFFFFFFF != aiPositions[0])
|
||||||
|
{
|
||||||
|
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
|
||||||
|
(*i)->alProperties[aiPositions[0]].avList.front(),aiTypes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0xFFFFFFFF != aiPositions[1])
|
||||||
|
{
|
||||||
|
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
|
||||||
|
(*i)->alProperties[aiPositions[1]].avList.front(),aiTypes[1]);
|
||||||
|
}
|
||||||
|
// and add them to our nice list
|
||||||
|
pvOut->push_back(vOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
{
|
{
|
||||||
|
ai_assert(NULL != pvOut);
|
||||||
|
|
||||||
unsigned int aiPositions[3] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
|
unsigned int aiPositions[3] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
|
||||||
PLY::EDataType aiTypes[3];
|
PLY::EDataType aiTypes[3];
|
||||||
PLY::ElementInstanceList* pcList = NULL;
|
PLY::ElementInstanceList* pcList = NULL;
|
||||||
|
@ -379,43 +474,42 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
|
|
||||||
// serach in the DOM for a vertex entry
|
// serach in the DOM for a vertex entry
|
||||||
unsigned int _i = 0;
|
unsigned int _i = 0;
|
||||||
for (std::vector<PLY::Element>::const_iterator
|
for (std::vector<PLY::Element*>::const_iterator
|
||||||
i = this->pcDOM->alElements.begin();
|
i = this->pcDOM->alElements.begin();
|
||||||
i != this->pcDOM->alElements.end();++i,++_i)
|
i != this->pcDOM->alElements.end();++i,++_i)
|
||||||
{
|
{
|
||||||
if (PLY::EEST_Vertex == (*i).eSemantic)
|
if (PLY::EEST_Vertex == (*i)->eSemantic)
|
||||||
{
|
{
|
||||||
pcList = &this->pcDOM->alElementData[_i];
|
pcList = this->pcDOM->alElementData[_i];
|
||||||
|
|
||||||
// load normal vectors?
|
// load normal vectors?
|
||||||
if (p_bNormals)
|
if (p_bNormals)
|
||||||
{
|
{
|
||||||
// now check whether which normal components are available
|
// now check whether which normal components are available
|
||||||
unsigned int _a = 0;
|
unsigned int _a = 0;
|
||||||
for (std::vector<PLY::Property>::const_iterator
|
for (std::vector<PLY::Property*>::const_iterator
|
||||||
a = (*i).alProperties.begin();
|
a = (*i)->alProperties.begin();
|
||||||
a != (*i).alProperties.end();++a,++_a)
|
a != (*i)->alProperties.end();++a,++_a)
|
||||||
{
|
{
|
||||||
if ((*a).bIsList)continue;
|
if ((*a)->bIsList)continue;
|
||||||
if (PLY::EST_XNormal == (*a).Semantic)
|
if (PLY::EST_XNormal == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[0] = _a;
|
aiPositions[0] = _a;
|
||||||
aiTypes[0] = (*a).eType;
|
aiTypes[0] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_YNormal == (*a).Semantic)
|
else if (PLY::EST_YNormal == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[1] = _a;
|
aiPositions[1] = _a;
|
||||||
aiTypes[1] = (*a).eType;
|
aiTypes[1] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_ZNormal == (*a).Semantic)
|
else if (PLY::EST_ZNormal == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[2] = _a;
|
aiPositions[2] = _a;
|
||||||
aiTypes[2] = (*a).eType;
|
aiTypes[2] = (*a)->eType;
|
||||||
}
|
}
|
||||||
if (3 == cnt)break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// load vertex coordinates
|
// load vertex coordinates
|
||||||
|
@ -423,28 +517,28 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
{
|
{
|
||||||
// now check whether which coordinate sets are available
|
// now check whether which coordinate sets are available
|
||||||
unsigned int _a = 0;
|
unsigned int _a = 0;
|
||||||
for (std::vector<PLY::Property>::const_iterator
|
for (std::vector<PLY::Property*>::const_iterator
|
||||||
a = (*i).alProperties.begin();
|
a = (*i)->alProperties.begin();
|
||||||
a != (*i).alProperties.end();++a,++_a)
|
a != (*i)->alProperties.end();++a,++_a)
|
||||||
{
|
{
|
||||||
if ((*a).bIsList)continue;
|
if ((*a)->bIsList)continue;
|
||||||
if (PLY::EST_XCoord == (*a).Semantic)
|
if (PLY::EST_XCoord == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[0] = _a;
|
aiPositions[0] = _a;
|
||||||
aiTypes[0] = (*a).eType;
|
aiTypes[0] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_YCoord == (*a).Semantic)
|
else if (PLY::EST_YCoord == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[1] = _a;
|
aiPositions[1] = _a;
|
||||||
aiTypes[1] = (*a).eType;
|
aiTypes[1] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_ZCoord == (*a).Semantic)
|
else if (PLY::EST_ZCoord == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[2] = _a;
|
aiPositions[2] = _a;
|
||||||
aiTypes[2] = (*a).eType;
|
aiTypes[2] = (*a)->eType;
|
||||||
}
|
}
|
||||||
if (3 == cnt)break;
|
if (3 == cnt)break;
|
||||||
}
|
}
|
||||||
|
@ -456,32 +550,29 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
if (NULL != pcList && 0 != cnt)
|
if (NULL != pcList && 0 != cnt)
|
||||||
{
|
{
|
||||||
pvOut->reserve(pcList->alInstances.size());
|
pvOut->reserve(pcList->alInstances.size());
|
||||||
for (std::vector<ElementInstance>::const_iterator
|
for (std::vector<ElementInstance*>::const_iterator
|
||||||
i = pcList->alInstances.begin();
|
i = pcList->alInstances.begin();
|
||||||
i != pcList->alInstances.end();++i)
|
i != pcList->alInstances.end();++i)
|
||||||
{
|
{
|
||||||
// convert the vertices to sp floats
|
// convert the vertices to sp floats
|
||||||
aiVector3D vOut;
|
aiVector3D vOut;
|
||||||
|
|
||||||
if (0xFFFFFFFF == aiPositions[0])vOut.x = 0.0f;
|
if (0xFFFFFFFF != aiPositions[0])
|
||||||
else
|
|
||||||
{
|
{
|
||||||
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
|
||||||
(*i).alProperties[aiPositions[0]].avList.front(),aiTypes[0]);
|
(*i)->alProperties[aiPositions[0]].avList.front(),aiTypes[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xFFFFFFFF == aiPositions[1])vOut.y = 0.0f;
|
if (0xFFFFFFFF != aiPositions[1])
|
||||||
else
|
|
||||||
{
|
{
|
||||||
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
|
||||||
(*i).alProperties[aiPositions[1]].avList.front(),aiTypes[1]);
|
(*i)->alProperties[aiPositions[1]].avList.front(),aiTypes[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xFFFFFFFF == aiPositions[2])vOut.z = 0.0f;
|
if (0xFFFFFFFF != aiPositions[2])
|
||||||
else
|
|
||||||
{
|
{
|
||||||
vOut.z = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.z = PLY::PropertyInstance::ConvertTo<float>(
|
||||||
(*i).alProperties[aiPositions[2]].avList.front(),aiTypes[2]);
|
(*i)->alProperties[aiPositions[2]].avList.front(),aiTypes[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and add them to our nice list
|
// and add them to our nice list
|
||||||
|
@ -491,7 +582,8 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
float NormalizeColorValue (PLY::PropertyInstance::ValueUnion val,PLY::EDataType eType)
|
float PLYImporter::NormalizeColorValue (PLY::PropertyInstance::ValueUnion val,
|
||||||
|
PLY::EDataType eType)
|
||||||
{
|
{
|
||||||
switch (eType)
|
switch (eType)
|
||||||
{
|
{
|
||||||
|
@ -518,6 +610,8 @@ float NormalizeColorValue (PLY::PropertyInstance::ValueUnion val,PLY::EDataType
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
||||||
{
|
{
|
||||||
|
ai_assert(NULL != pvOut);
|
||||||
|
|
||||||
unsigned int aiPositions[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
|
unsigned int aiPositions[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
|
||||||
PLY::EDataType aiTypes[4];
|
PLY::EDataType aiTypes[4];
|
||||||
unsigned int cnt = 0;
|
unsigned int cnt = 0;
|
||||||
|
@ -525,44 +619,44 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
||||||
|
|
||||||
// serach in the DOM for a vertex entry
|
// serach in the DOM for a vertex entry
|
||||||
unsigned int _i = 0;
|
unsigned int _i = 0;
|
||||||
for (std::vector<PLY::Element>::const_iterator
|
for (std::vector<PLY::Element*>::const_iterator
|
||||||
i = this->pcDOM->alElements.begin();
|
i = this->pcDOM->alElements.begin();
|
||||||
i != this->pcDOM->alElements.end();++i,++_i)
|
i != this->pcDOM->alElements.end();++i,++_i)
|
||||||
{
|
{
|
||||||
if (PLY::EEST_Vertex == (*i).eSemantic)
|
if (PLY::EEST_Vertex == (*i)->eSemantic)
|
||||||
{
|
{
|
||||||
pcList = &this->pcDOM->alElementData[_i];
|
pcList = this->pcDOM->alElementData[_i];
|
||||||
|
|
||||||
// now check whether which coordinate sets are available
|
// now check whether which coordinate sets are available
|
||||||
unsigned int _a = 0;
|
unsigned int _a = 0;
|
||||||
for (std::vector<PLY::Property>::const_iterator
|
for (std::vector<PLY::Property*>::const_iterator
|
||||||
a = (*i).alProperties.begin();
|
a = (*i)->alProperties.begin();
|
||||||
a != (*i).alProperties.end();++a,++_a)
|
a != (*i)->alProperties.end();++a,++_a)
|
||||||
{
|
{
|
||||||
if ((*a).bIsList)continue;
|
if ((*a)->bIsList)continue;
|
||||||
if (PLY::EST_Red == (*a).Semantic)
|
if (PLY::EST_Red == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[0] = _a;
|
aiPositions[0] = _a;
|
||||||
aiTypes[0] = (*a).eType;
|
aiTypes[0] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_Green == (*a).Semantic)
|
else if (PLY::EST_Green == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[1] = _a;
|
aiPositions[1] = _a;
|
||||||
aiTypes[1] = (*a).eType;
|
aiTypes[1] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_Blue == (*a).Semantic)
|
else if (PLY::EST_Blue == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[2] = _a;
|
aiPositions[2] = _a;
|
||||||
aiTypes[2] = (*a).eType;
|
aiTypes[2] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_Alpha == (*a).Semantic)
|
else if (PLY::EST_Alpha == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
aiPositions[3] = _a;
|
aiPositions[3] = _a;
|
||||||
aiTypes[3] = (*a).eType;
|
aiTypes[3] = (*a)->eType;
|
||||||
}
|
}
|
||||||
if (4 == cnt)break;
|
if (4 == cnt)break;
|
||||||
}
|
}
|
||||||
|
@ -573,31 +667,28 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
||||||
if (NULL != pcList && 0 != cnt)
|
if (NULL != pcList && 0 != cnt)
|
||||||
{
|
{
|
||||||
pvOut->reserve(pcList->alInstances.size());
|
pvOut->reserve(pcList->alInstances.size());
|
||||||
for (std::vector<ElementInstance>::const_iterator
|
for (std::vector<ElementInstance*>::const_iterator
|
||||||
i = pcList->alInstances.begin();
|
i = pcList->alInstances.begin();
|
||||||
i != pcList->alInstances.end();++i)
|
i != pcList->alInstances.end();++i)
|
||||||
{
|
{
|
||||||
// convert the vertices to sp floats
|
// convert the vertices to sp floats
|
||||||
aiColor4D vOut;
|
aiColor4D vOut;
|
||||||
|
|
||||||
if (0xFFFFFFFF == aiPositions[0])vOut.r = 0.0f;
|
if (0xFFFFFFFF != aiPositions[0])
|
||||||
else
|
|
||||||
{
|
{
|
||||||
vOut.r = NormalizeColorValue((*i).alProperties[
|
vOut.r = NormalizeColorValue((*i)->alProperties[
|
||||||
aiPositions[0]].avList.front(),aiTypes[0]);
|
aiPositions[0]].avList.front(),aiTypes[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xFFFFFFFF == aiPositions[1])vOut.g = 0.0f;
|
if (0xFFFFFFFF != aiPositions[1])
|
||||||
else
|
|
||||||
{
|
{
|
||||||
vOut.g = NormalizeColorValue((*i).alProperties[
|
vOut.g = NormalizeColorValue((*i)->alProperties[
|
||||||
aiPositions[1]].avList.front(),aiTypes[1]);
|
aiPositions[1]].avList.front(),aiTypes[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xFFFFFFFF == aiPositions[2])vOut.b = 0.0f;
|
if (0xFFFFFFFF != aiPositions[2])
|
||||||
else
|
|
||||||
{
|
{
|
||||||
vOut.b = NormalizeColorValue((*i).alProperties[
|
vOut.b = NormalizeColorValue((*i)->alProperties[
|
||||||
aiPositions[2]].avList.front(),aiTypes[2]);
|
aiPositions[2]].avList.front(),aiTypes[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,7 +696,7 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
||||||
if (0xFFFFFFFF == aiPositions[3])vOut.a = 1.0f;
|
if (0xFFFFFFFF == aiPositions[3])vOut.a = 1.0f;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vOut.a = NormalizeColorValue((*i).alProperties[
|
vOut.a = NormalizeColorValue((*i)->alProperties[
|
||||||
aiPositions[3]].avList.front(),aiTypes[3]);
|
aiPositions[3]].avList.front(),aiTypes[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +710,8 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
||||||
{
|
{
|
||||||
|
ai_assert(NULL != pvOut);
|
||||||
|
|
||||||
PLY::ElementInstanceList* pcList = NULL;
|
PLY::ElementInstanceList* pcList = NULL;
|
||||||
bool bOne = false;
|
bool bOne = false;
|
||||||
|
|
||||||
|
@ -633,54 +726,54 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
||||||
|
|
||||||
// serach in the DOM for a face entry
|
// serach in the DOM for a face entry
|
||||||
unsigned int _i = 0;
|
unsigned int _i = 0;
|
||||||
for (std::vector<PLY::Element>::const_iterator
|
for (std::vector<PLY::Element*>::const_iterator
|
||||||
i = this->pcDOM->alElements.begin();
|
i = this->pcDOM->alElements.begin();
|
||||||
i != this->pcDOM->alElements.end();++i,++_i)
|
i != this->pcDOM->alElements.end();++i,++_i)
|
||||||
{
|
{
|
||||||
// face = unique number of vertex indices
|
// face = unique number of vertex indices
|
||||||
if (PLY::EEST_Face == (*i).eSemantic)
|
if (PLY::EEST_Face == (*i)->eSemantic)
|
||||||
{
|
{
|
||||||
pcList = &this->pcDOM->alElementData[_i];
|
pcList = this->pcDOM->alElementData[_i];
|
||||||
unsigned int _a = 0;
|
unsigned int _a = 0;
|
||||||
for (std::vector<PLY::Property>::const_iterator
|
for (std::vector<PLY::Property*>::const_iterator
|
||||||
a = (*i).alProperties.begin();
|
a = (*i)->alProperties.begin();
|
||||||
a != (*i).alProperties.end();++a,++_a)
|
a != (*i)->alProperties.end();++a,++_a)
|
||||||
{
|
{
|
||||||
if (PLY::EST_VertexIndex == (*a).Semantic)
|
if (PLY::EST_VertexIndex == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
// must be a dynamic list!
|
// must be a dynamic list!
|
||||||
if (!(*a).bIsList)continue;
|
if (!(*a)->bIsList)continue;
|
||||||
iProperty = _a;
|
iProperty = _a;
|
||||||
bOne = true;
|
bOne = true;
|
||||||
eType = (*a).eType;
|
eType = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_MaterialIndex == (*a).Semantic)
|
else if (PLY::EST_MaterialIndex == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
if ((*a).bIsList)continue;
|
if ((*a)->bIsList)continue;
|
||||||
iMaterialIndex = _a;
|
iMaterialIndex = _a;
|
||||||
bOne = true;
|
bOne = true;
|
||||||
eType2 = (*a).eType;
|
eType2 = (*a)->eType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// triangle strip
|
// triangle strip
|
||||||
// TODO: triangle strip and material index support???
|
// TODO: triangle strip and material index support???
|
||||||
else if (PLY::EEST_TriStrip == (*i).eSemantic)
|
else if (PLY::EEST_TriStrip == (*i)->eSemantic)
|
||||||
{
|
{
|
||||||
// find a list property in this ...
|
// find a list property in this ...
|
||||||
pcList = &this->pcDOM->alElementData[_i];
|
pcList = this->pcDOM->alElementData[_i];
|
||||||
unsigned int _a = 0;
|
unsigned int _a = 0;
|
||||||
for (std::vector<PLY::Property>::const_iterator
|
for (std::vector<PLY::Property*>::const_iterator
|
||||||
a = (*i).alProperties.begin();
|
a = (*i)->alProperties.begin();
|
||||||
a != (*i).alProperties.end();++a,++_a)
|
a != (*i)->alProperties.end();++a,++_a)
|
||||||
{
|
{
|
||||||
// must be a dynamic list!
|
// must be a dynamic list!
|
||||||
if (!(*a).bIsList)continue;
|
if (!(*a)->bIsList)continue;
|
||||||
iProperty = _a;
|
iProperty = _a;
|
||||||
bOne = true;
|
bOne = true;
|
||||||
bIsTristrip = true;
|
bIsTristrip = true;
|
||||||
eType = (*a).eType;
|
eType = (*a)->eType;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -692,7 +785,7 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
||||||
if (!bIsTristrip)
|
if (!bIsTristrip)
|
||||||
{
|
{
|
||||||
pvOut->reserve(pcList->alInstances.size());
|
pvOut->reserve(pcList->alInstances.size());
|
||||||
for (std::vector<ElementInstance>::const_iterator
|
for (std::vector<ElementInstance*>::const_iterator
|
||||||
i = pcList->alInstances.begin();
|
i = pcList->alInstances.begin();
|
||||||
i != pcList->alInstances.end();++i)
|
i != pcList->alInstances.end();++i)
|
||||||
{
|
{
|
||||||
|
@ -701,11 +794,19 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
||||||
// parse the list of vertex indices
|
// parse the list of vertex indices
|
||||||
if (0xFFFFFFFF != iProperty)
|
if (0xFFFFFFFF != iProperty)
|
||||||
{
|
{
|
||||||
const unsigned int iNum = (*i).alProperties[iProperty].avList.size();
|
const unsigned int iNum = (*i)->alProperties[iProperty].avList.size();
|
||||||
sFace.mIndices.resize(iNum);
|
sFace.mIndices.resize(iNum);
|
||||||
|
|
||||||
|
if (3 > iNum)
|
||||||
|
{
|
||||||
|
// We must filter out all degenerates. Leave a message
|
||||||
|
// in the log ...
|
||||||
|
// LOG
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::list<PLY::PropertyInstance::ValueUnion>::const_iterator p =
|
std::list<PLY::PropertyInstance::ValueUnion>::const_iterator p =
|
||||||
(*i).alProperties[iProperty].avList.begin();
|
(*i)->alProperties[iProperty].avList.begin();
|
||||||
|
|
||||||
for (unsigned int a = 0; a < iNum;++a,++p)
|
for (unsigned int a = 0; a < iNum;++a,++p)
|
||||||
{
|
{
|
||||||
|
@ -717,7 +818,7 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
||||||
if (0xFFFFFFFF != iMaterialIndex)
|
if (0xFFFFFFFF != iMaterialIndex)
|
||||||
{
|
{
|
||||||
sFace.iMaterialIndex = PLY::PropertyInstance::ConvertTo<unsigned int>(
|
sFace.iMaterialIndex = PLY::PropertyInstance::ConvertTo<unsigned int>(
|
||||||
(*i).alProperties[iMaterialIndex].avList.front(),eType2);
|
(*i)->alProperties[iMaterialIndex].avList.front(),eType2);
|
||||||
}
|
}
|
||||||
pvOut->push_back(sFace);
|
pvOut->push_back(sFace);
|
||||||
}
|
}
|
||||||
|
@ -726,14 +827,14 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
||||||
{
|
{
|
||||||
// normally we have only one triangle strip instance where
|
// normally we have only one triangle strip instance where
|
||||||
// a value of -1 indicates a restart of the strip
|
// a value of -1 indicates a restart of the strip
|
||||||
for (std::vector<ElementInstance>::const_iterator
|
for (std::vector<ElementInstance*>::const_iterator
|
||||||
i = pcList->alInstances.begin();
|
i = pcList->alInstances.begin();
|
||||||
i != pcList->alInstances.end();++i)
|
i != pcList->alInstances.end();++i)
|
||||||
{
|
{
|
||||||
int aiTable[2] = {-1,-1};
|
int aiTable[2] = {-1,-1};
|
||||||
for (std::list<PLY::PropertyInstance::ValueUnion>::const_iterator
|
for (std::list<PLY::PropertyInstance::ValueUnion>::const_iterator
|
||||||
a = (*i).alProperties[iProperty].avList.begin();
|
a = (*i)->alProperties[iProperty].avList.begin();
|
||||||
a != (*i).alProperties[iProperty].avList.end();++a)
|
a != (*i)->alProperties[iProperty].avList.end();++a)
|
||||||
{
|
{
|
||||||
int p = PLY::PropertyInstance::ConvertTo<int>(*a,eType);
|
int p = PLY::PropertyInstance::ConvertTo<int>(*a,eType);
|
||||||
if (-1 == p)
|
if (-1 == p)
|
||||||
|
@ -768,10 +869,10 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void GetMaterialColor(const std::vector<PLY::PropertyInstance>& avList,
|
void PLYImporter::GetMaterialColor(const std::vector<PLY::PropertyInstance>& avList,
|
||||||
unsigned int aiPositions[4],
|
unsigned int aiPositions[4],
|
||||||
PLY::EDataType aiTypes[4],
|
PLY::EDataType aiTypes[4],
|
||||||
aiColor4D* clrOut)
|
aiColor4D* clrOut)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != clrOut);
|
ai_assert(NULL != clrOut);
|
||||||
|
|
||||||
|
@ -809,6 +910,8 @@ void GetMaterialColor(const std::vector<PLY::PropertyInstance>& avList,
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
||||||
{
|
{
|
||||||
|
ai_assert(NULL != pvOut);
|
||||||
|
|
||||||
// diffuse[4], specular[4], ambient[4]
|
// diffuse[4], specular[4], ambient[4]
|
||||||
// rgba order
|
// rgba order
|
||||||
unsigned int aaiPositions[3][4] = {
|
unsigned int aaiPositions[3][4] = {
|
||||||
|
@ -830,98 +933,98 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
||||||
|
|
||||||
// serach in the DOM for a vertex entry
|
// serach in the DOM for a vertex entry
|
||||||
unsigned int _i = 0;
|
unsigned int _i = 0;
|
||||||
for (std::vector<PLY::Element>::const_iterator
|
for (std::vector<PLY::Element*>::const_iterator
|
||||||
i = this->pcDOM->alElements.begin();
|
i = this->pcDOM->alElements.begin();
|
||||||
i != this->pcDOM->alElements.end();++i,++_i)
|
i != this->pcDOM->alElements.end();++i,++_i)
|
||||||
{
|
{
|
||||||
if (PLY::EEST_Material == (*i).eSemantic)
|
if (PLY::EEST_Material == (*i)->eSemantic)
|
||||||
{
|
{
|
||||||
pcList = &this->pcDOM->alElementData[_i];
|
pcList = this->pcDOM->alElementData[_i];
|
||||||
|
|
||||||
// now check whether which coordinate sets are available
|
// now check whether which coordinate sets are available
|
||||||
unsigned int _a = 0;
|
unsigned int _a = 0;
|
||||||
for (std::vector<PLY::Property>::const_iterator
|
for (std::vector<PLY::Property*>::const_iterator
|
||||||
a = (*i).alProperties.begin();
|
a = (*i)->alProperties.begin();
|
||||||
a != (*i).alProperties.end();++a,++_a)
|
a != (*i)->alProperties.end();++a,++_a)
|
||||||
{
|
{
|
||||||
if ((*a).bIsList)continue;
|
if ((*a)->bIsList)continue;
|
||||||
|
|
||||||
// pohng specularity -----------------------------------
|
// pohng specularity -----------------------------------
|
||||||
if (PLY::EST_PhongPower == (*a).Semantic)
|
if (PLY::EST_PhongPower == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
iPhong = _a;
|
iPhong = _a;
|
||||||
ePhong = (*a).eType;
|
ePhong = (*a)->eType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// general opacity -----------------------------------
|
// general opacity -----------------------------------
|
||||||
if (PLY::EST_Opacity == (*a).Semantic)
|
if (PLY::EST_Opacity == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
iOpacity = _a;
|
iOpacity = _a;
|
||||||
eOpacity = (*a).eType;
|
eOpacity = (*a)->eType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// diffuse color channels -----------------------------------
|
// diffuse color channels -----------------------------------
|
||||||
if (PLY::EST_DiffuseRed == (*a).Semantic)
|
if (PLY::EST_DiffuseRed == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[0][0] = _a;
|
aaiPositions[0][0] = _a;
|
||||||
aaiTypes[0][0] = (*a).eType;
|
aaiTypes[0][0] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_DiffuseGreen == (*a).Semantic)
|
else if (PLY::EST_DiffuseGreen == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[0][1] = _a;
|
aaiPositions[0][1] = _a;
|
||||||
aaiTypes[0][1] = (*a).eType;
|
aaiTypes[0][1] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_DiffuseBlue == (*a).Semantic)
|
else if (PLY::EST_DiffuseBlue == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[0][2] = _a;
|
aaiPositions[0][2] = _a;
|
||||||
aaiTypes[0][2] = (*a).eType;
|
aaiTypes[0][2] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_DiffuseAlpha == (*a).Semantic)
|
else if (PLY::EST_DiffuseAlpha == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[0][3] = _a;
|
aaiPositions[0][3] = _a;
|
||||||
aaiTypes[0][3] = (*a).eType;
|
aaiTypes[0][3] = (*a)->eType;
|
||||||
}
|
}
|
||||||
// specular color channels -----------------------------------
|
// specular color channels -----------------------------------
|
||||||
else if (PLY::EST_SpecularRed == (*a).Semantic)
|
else if (PLY::EST_SpecularRed == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[1][0] = _a;
|
aaiPositions[1][0] = _a;
|
||||||
aaiTypes[1][0] = (*a).eType;
|
aaiTypes[1][0] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_SpecularGreen == (*a).Semantic)
|
else if (PLY::EST_SpecularGreen == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[1][1] = _a;
|
aaiPositions[1][1] = _a;
|
||||||
aaiTypes[1][1] = (*a).eType;
|
aaiTypes[1][1] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_SpecularBlue == (*a).Semantic)
|
else if (PLY::EST_SpecularBlue == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[1][2] = _a;
|
aaiPositions[1][2] = _a;
|
||||||
aaiTypes[1][2] = (*a).eType;
|
aaiTypes[1][2] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_SpecularAlpha == (*a).Semantic)
|
else if (PLY::EST_SpecularAlpha == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[1][3] = _a;
|
aaiPositions[1][3] = _a;
|
||||||
aaiTypes[1][3] = (*a).eType;
|
aaiTypes[1][3] = (*a)->eType;
|
||||||
}
|
}
|
||||||
// ambient color channels -----------------------------------
|
// ambient color channels -----------------------------------
|
||||||
else if (PLY::EST_AmbientRed == (*a).Semantic)
|
else if (PLY::EST_AmbientRed == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[2][0] = _a;
|
aaiPositions[2][0] = _a;
|
||||||
aaiTypes[2][0] = (*a).eType;
|
aaiTypes[2][0] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_AmbientGreen == (*a).Semantic)
|
else if (PLY::EST_AmbientGreen == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[2][1] = _a;
|
aaiPositions[2][1] = _a;
|
||||||
aaiTypes[2][1] = (*a).eType;
|
aaiTypes[2][1] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_AmbientBlue == (*a).Semantic)
|
else if (PLY::EST_AmbientBlue == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[22][2] = _a;
|
aaiPositions[22][2] = _a;
|
||||||
aaiTypes[2][2] = (*a).eType;
|
aaiTypes[2][2] = (*a)->eType;
|
||||||
}
|
}
|
||||||
else if (PLY::EST_AmbientAlpha == (*a).Semantic)
|
else if (PLY::EST_AmbientAlpha == (*a)->Semantic)
|
||||||
{
|
{
|
||||||
aaiPositions[2][3] = _a;
|
aaiPositions[2][3] = _a;
|
||||||
aaiTypes[2][3] = (*a).eType;
|
aaiTypes[2][3] = (*a)->eType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -930,7 +1033,7 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
||||||
// check whether we have a valid source for the material data
|
// check whether we have a valid source for the material data
|
||||||
if (NULL != pcList)
|
if (NULL != pcList)
|
||||||
{
|
{
|
||||||
for (std::vector<ElementInstance>::const_iterator
|
for (std::vector<ElementInstance*>::const_iterator
|
||||||
i = pcList->alInstances.begin();
|
i = pcList->alInstances.begin();
|
||||||
i != pcList->alInstances.end();++i)
|
i != pcList->alInstances.end();++i)
|
||||||
{
|
{
|
||||||
|
@ -938,15 +1041,15 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
||||||
MaterialHelper* pcHelper = new MaterialHelper();
|
MaterialHelper* pcHelper = new MaterialHelper();
|
||||||
|
|
||||||
// build the diffuse material color
|
// build the diffuse material color
|
||||||
GetMaterialColor((*i).alProperties,aaiPositions[0],aaiTypes[0],&clrOut);
|
GetMaterialColor((*i)->alProperties,aaiPositions[0],aaiTypes[0],&clrOut);
|
||||||
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_DIFFUSE);
|
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||||
|
|
||||||
// build the specular material color
|
// build the specular material color
|
||||||
GetMaterialColor((*i).alProperties,aaiPositions[1],aaiTypes[1],&clrOut);
|
GetMaterialColor((*i)->alProperties,aaiPositions[1],aaiTypes[1],&clrOut);
|
||||||
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_SPECULAR);
|
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_SPECULAR);
|
||||||
|
|
||||||
// build the ambient material color
|
// build the ambient material color
|
||||||
GetMaterialColor((*i).alProperties,aaiPositions[2],aaiTypes[2],&clrOut);
|
GetMaterialColor((*i)->alProperties,aaiPositions[2],aaiTypes[2],&clrOut);
|
||||||
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_AMBIENT);
|
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_AMBIENT);
|
||||||
|
|
||||||
// handle phong power and shading mode
|
// handle phong power and shading mode
|
||||||
|
@ -954,7 +1057,7 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
||||||
if (0xFFFFFFFF != iPhong)
|
if (0xFFFFFFFF != iPhong)
|
||||||
{
|
{
|
||||||
float fSpec = PLY::PropertyInstance::ConvertTo<float>(
|
float fSpec = PLY::PropertyInstance::ConvertTo<float>(
|
||||||
(*i).alProperties[iPhong].avList.front(),ePhong);
|
(*i)->alProperties[iPhong].avList.front(),ePhong);
|
||||||
|
|
||||||
// if shininess is 0 (and the pow() calculation would therefore always
|
// if shininess is 0 (and the pow() calculation would therefore always
|
||||||
// become 1, not depending on the angle) use gouraud lighting
|
// become 1, not depending on the angle) use gouraud lighting
|
||||||
|
@ -962,8 +1065,7 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
||||||
{
|
{
|
||||||
|
|
||||||
// scale this with 15 ... hopefully this is correct
|
// scale this with 15 ... hopefully this is correct
|
||||||
fSpec += 15;
|
fSpec *= 15;
|
||||||
|
|
||||||
pcHelper->AddProperty<float>(&fSpec, 1, AI_MATKEY_SHININESS);
|
pcHelper->AddProperty<float>(&fSpec, 1, AI_MATKEY_SHININESS);
|
||||||
|
|
||||||
iMode = (int)aiShadingMode_Phong;
|
iMode = (int)aiShadingMode_Phong;
|
||||||
|
@ -977,7 +1079,7 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
||||||
if (0xFFFFFFFF != iOpacity)
|
if (0xFFFFFFFF != iOpacity)
|
||||||
{
|
{
|
||||||
float fOpacity = PLY::PropertyInstance::ConvertTo<float>(
|
float fOpacity = PLY::PropertyInstance::ConvertTo<float>(
|
||||||
(*i).alProperties[iPhong].avList.front(),eOpacity);
|
(*i)->alProperties[iPhong].avList.front(),eOpacity);
|
||||||
|
|
||||||
pcHelper->AddProperty<float>(&fOpacity, 1, AI_MATKEY_OPACITY);
|
pcHelper->AddProperty<float>(&fOpacity, 1, AI_MATKEY_OPACITY);
|
||||||
}
|
}
|
||||||
|
|
207
code/PlyLoader.h
207
code/PlyLoader.h
|
@ -1,4 +1,45 @@
|
||||||
/** @file Definition of the .ply importer class. */
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @file Declaration of the .ply importer class. */
|
||||||
#ifndef AI_PLYLOADER_H_INCLUDED
|
#ifndef AI_PLYLOADER_H_INCLUDED
|
||||||
#define AI_PLYLOADER_H_INCLUDED
|
#define AI_PLYLOADER_H_INCLUDED
|
||||||
|
|
||||||
|
@ -11,88 +52,124 @@ struct aiNode;
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
class MaterialHelper;
|
class MaterialHelper;
|
||||||
|
|
||||||
|
|
||||||
using namespace PLY;
|
using namespace PLY;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Used to load PLY files
|
/** Used to load PLY files
|
||||||
*/
|
*/
|
||||||
class PLYImporter : public BaseImporter
|
class PLYImporter : public BaseImporter
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
PLYImporter();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~PLYImporter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
{
|
{
|
||||||
friend class Importer;
|
append.append("*.ply");
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
// -------------------------------------------------------------------
|
||||||
/** Constructor to be privately used by Importer */
|
/** Imports the given file into the given scene structure.
|
||||||
PLYImporter();
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
*/
|
||||||
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
/** Destructor, private as well */
|
protected:
|
||||||
~PLYImporter();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Returns whether the class can handle the format of the given file.
|
|
||||||
* See BaseImporter::CanRead() for details. */
|
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
/** Imports the given file into the given scene structure.
|
|
||||||
* See BaseImporter::InternReadFile() for details
|
|
||||||
*/
|
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Extract vertices from the DOM
|
/** Extract vertices from the DOM
|
||||||
*/
|
*/
|
||||||
void LoadVertices(std::vector<aiVector3D>* pvOut,bool p_bNormals = false);
|
void LoadVertices(std::vector<aiVector3D>* pvOut,
|
||||||
|
bool p_bNormals = false);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Extract vertex color channels
|
/** Extract vertex color channels from the DOM
|
||||||
*/
|
*/
|
||||||
void LoadVertexColor(std::vector<aiColor4D>* pvOut);
|
void LoadVertexColor(std::vector<aiColor4D>* pvOut);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Extract a face list from the DOM
|
/** Extract texture coordinate channels from the DOM
|
||||||
*/
|
*/
|
||||||
void LoadFaces(std::vector<PLY::Face>* pvOut);
|
void LoadTextureCoordinates(std::vector<aiVector2D>* pvOut);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Extract a material list from the DOM
|
/** Extract a face list from the DOM
|
||||||
*/
|
*/
|
||||||
void LoadMaterial(std::vector<MaterialHelper*>* pvOut);
|
void LoadFaces(std::vector<PLY::Face>* pvOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Extract a material list from the DOM
|
||||||
|
*/
|
||||||
|
void LoadMaterial(std::vector<MaterialHelper*>* pvOut);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Validate material indices, replace default material identifiers
|
/** Validate material indices, replace default material identifiers
|
||||||
*/
|
*/
|
||||||
void ReplaceDefaultMaterial(std::vector<PLY::Face>* avFaces,
|
void ReplaceDefaultMaterial(std::vector<PLY::Face>* avFaces,
|
||||||
std::vector<MaterialHelper*>* avMaterials);
|
std::vector<MaterialHelper*>* avMaterials);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Convert all meshes into our ourer representation
|
/** Convert all meshes into our ourer representation
|
||||||
*/
|
*/
|
||||||
void ConvertMeshes(std::vector<PLY::Face>* avFaces,
|
void ConvertMeshes(std::vector<PLY::Face>* avFaces,
|
||||||
const std::vector<aiVector3D>* avPositions,
|
const std::vector<aiVector3D>* avPositions,
|
||||||
const std::vector<aiVector3D>* avNormals,
|
const std::vector<aiVector3D>* avNormals,
|
||||||
const std::vector<aiColor4D>* avColors,
|
const std::vector<aiColor4D>* avColors,
|
||||||
const std::vector<MaterialHelper*>* avMaterials,
|
const std::vector<aiVector2D>* avTexCoords,
|
||||||
std::vector<aiMesh*>* avOut);
|
const std::vector<MaterialHelper*>* avMaterials,
|
||||||
|
std::vector<aiMesh*>* avOut);
|
||||||
|
|
||||||
|
|
||||||
/** Buffer to hold the loaded file */
|
// -------------------------------------------------------------------
|
||||||
unsigned char* mBuffer;
|
/** Static helper to parse a color from four single channels in
|
||||||
|
*/
|
||||||
|
static void GetMaterialColor(
|
||||||
|
const std::vector<PLY::PropertyInstance>& avList,
|
||||||
|
unsigned int aiPositions[4],
|
||||||
|
PLY::EDataType aiTypes[4],
|
||||||
|
aiColor4D* clrOut);
|
||||||
|
|
||||||
/** Document object model representation extracted from the file */
|
|
||||||
PLY::DOM* pcDOM;
|
// -------------------------------------------------------------------
|
||||||
};
|
/** Static helper to parse a color channel value. The input value
|
||||||
|
* is normalized to 0-1.
|
||||||
|
*/
|
||||||
|
static float NormalizeColorValue (
|
||||||
|
PLY::PropertyInstance::ValueUnion val,
|
||||||
|
PLY::EDataType eType);
|
||||||
|
|
||||||
|
|
||||||
|
/** Buffer to hold the loaded file */
|
||||||
|
unsigned char* mBuffer;
|
||||||
|
|
||||||
|
/** Document object model representation extracted from the file */
|
||||||
|
PLY::DOM* pcDOM;
|
||||||
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,46 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the PLY parser class */
|
/** @file Implementation of the PLY parser class */
|
||||||
|
|
||||||
#include "PLYLoader.h"
|
#include "PLYLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
|
@ -13,7 +55,6 @@
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
PLY::EDataType PLY::Property::ParseDataType(const char* p_szIn,const char** p_szOut)
|
PLY::EDataType PLY::Property::ParseDataType(const char* p_szIn,const char** p_szOut)
|
||||||
{
|
{
|
||||||
|
@ -100,22 +141,7 @@ PLY::EDataType PLY::Property::ParseDataType(const char* p_szIn,const char** p_sz
|
||||||
PLY::ESemantic PLY::Property::ParseSemantic(const char* p_szIn,const char** p_szOut)
|
PLY::ESemantic PLY::Property::ParseSemantic(const char* p_szIn,const char** p_szOut)
|
||||||
{
|
{
|
||||||
PLY::ESemantic eOut = PLY::EST_INVALID;
|
PLY::ESemantic eOut = PLY::EST_INVALID;
|
||||||
if (0 == ASSIMP_strincmp(p_szIn,"x",1))
|
if (0 == ASSIMP_strincmp(p_szIn,"red",3))
|
||||||
{
|
|
||||||
p_szIn++;
|
|
||||||
eOut = PLY::EST_XCoord;
|
|
||||||
}
|
|
||||||
else if (0 == ASSIMP_strincmp(p_szIn,"y",1))
|
|
||||||
{
|
|
||||||
p_szIn++;
|
|
||||||
eOut = PLY::EST_YCoord;
|
|
||||||
}
|
|
||||||
else if (0 == ASSIMP_strincmp(p_szIn,"z",1))
|
|
||||||
{
|
|
||||||
p_szIn++;
|
|
||||||
eOut = PLY::EST_ZCoord;
|
|
||||||
}
|
|
||||||
else if (0 == ASSIMP_strincmp(p_szIn,"red",3))
|
|
||||||
{
|
{
|
||||||
p_szIn+=3;
|
p_szIn+=3;
|
||||||
eOut = PLY::EST_Red;
|
eOut = PLY::EST_Red;
|
||||||
|
@ -235,6 +261,41 @@ PLY::ESemantic PLY::Property::ParseSemantic(const char* p_szIn,const char** p_sz
|
||||||
p_szIn++;
|
p_szIn++;
|
||||||
eOut = PLY::EST_Blue;
|
eOut = PLY::EST_Blue;
|
||||||
}
|
}
|
||||||
|
else if (0 == ASSIMP_strincmp(p_szIn,"tx",2))
|
||||||
|
{
|
||||||
|
p_szIn+=2;
|
||||||
|
eOut = PLY::EST_UTextureCoord;
|
||||||
|
}
|
||||||
|
else if (0 == ASSIMP_strincmp(p_szIn,"ty",2))
|
||||||
|
{
|
||||||
|
p_szIn+=2;
|
||||||
|
eOut = PLY::EST_VTextureCoord;
|
||||||
|
}
|
||||||
|
else if (0 == ASSIMP_strincmp(p_szIn,"u",1))
|
||||||
|
{
|
||||||
|
p_szIn++;
|
||||||
|
eOut = PLY::EST_UTextureCoord;
|
||||||
|
}
|
||||||
|
else if (0 == ASSIMP_strincmp(p_szIn,"v",1))
|
||||||
|
{
|
||||||
|
p_szIn++;
|
||||||
|
eOut = PLY::EST_VTextureCoord;
|
||||||
|
}
|
||||||
|
else if (0 == ASSIMP_strincmp(p_szIn,"x",1))
|
||||||
|
{
|
||||||
|
p_szIn++;
|
||||||
|
eOut = PLY::EST_XCoord;
|
||||||
|
}
|
||||||
|
else if (0 == ASSIMP_strincmp(p_szIn,"y",1))
|
||||||
|
{
|
||||||
|
p_szIn++;
|
||||||
|
eOut = PLY::EST_YCoord;
|
||||||
|
}
|
||||||
|
else if (0 == ASSIMP_strincmp(p_szIn,"z",1))
|
||||||
|
{
|
||||||
|
p_szIn++;
|
||||||
|
eOut = PLY::EST_ZCoord;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ... find the next space or new line
|
// ... find the next space or new line
|
||||||
|
@ -250,7 +311,9 @@ PLY::ESemantic PLY::Property::ParseSemantic(const char* p_szIn,const char** p_sz
|
||||||
return eOut;
|
return eOut;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::Property::ParseProperty (const char* p_szIn, const char** p_szOut, PLY::Property* pOut)
|
bool PLY::Property::ParseProperty (const char* p_szIn,
|
||||||
|
const char** p_szOut,
|
||||||
|
PLY::Property* pOut)
|
||||||
{
|
{
|
||||||
// Forms supported:
|
// Forms supported:
|
||||||
// "property float x"
|
// "property float x"
|
||||||
|
@ -320,7 +383,8 @@ bool PLY::Property::ParseProperty (const char* p_szIn, const char** p_szOut, PLY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
PLY::EElementSemantic PLY::Element::ParseSemantic(const char* p_szIn,const char** p_szOut)
|
PLY::EElementSemantic PLY::Element::ParseSemantic(const char* p_szIn,
|
||||||
|
const char** p_szOut)
|
||||||
{
|
{
|
||||||
PLY::EElementSemantic eOut = PLY::EEST_INVALID;
|
PLY::EElementSemantic eOut = PLY::EEST_INVALID;
|
||||||
if (0 == ASSIMP_strincmp(p_szIn,"vertex",6))
|
if (0 == ASSIMP_strincmp(p_szIn,"vertex",6))
|
||||||
|
@ -365,8 +429,9 @@ PLY::EElementSemantic PLY::Element::ParseSemantic(const char* p_szIn,const char*
|
||||||
return eOut;
|
return eOut;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::Element::ParseElement (const char* p_szIn, const char** p_szOut,
|
bool PLY::Element::ParseElement (const char* p_szIn,
|
||||||
PLY::Element* pOut)
|
const char** p_szOut,
|
||||||
|
PLY::Element* pOut)
|
||||||
{
|
{
|
||||||
// Example format: "element vertex 8"
|
// Example format: "element vertex 8"
|
||||||
*p_szOut = p_szIn;
|
*p_szOut = p_szIn;
|
||||||
|
@ -410,8 +475,8 @@ bool PLY::Element::ParseElement (const char* p_szIn, const char** p_szOut,
|
||||||
// skip all comments
|
// skip all comments
|
||||||
PLY::DOM::SkipComments(p_szIn,&p_szIn);
|
PLY::DOM::SkipComments(p_szIn,&p_szIn);
|
||||||
|
|
||||||
Property prop;
|
PLY::Property* prop = new PLY::Property();
|
||||||
if(!PLY::Property::ParseProperty(p_szIn,&p_szIn,&prop))break;
|
if(!PLY::Property::ParseProperty(p_szIn,&p_szIn,prop))break;
|
||||||
|
|
||||||
// add the property to the property list
|
// add the property to the property list
|
||||||
pOut->alProperties.push_back(prop);
|
pOut->alProperties.push_back(prop);
|
||||||
|
@ -420,7 +485,8 @@ bool PLY::Element::ParseElement (const char* p_szIn, const char** p_szOut,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::DOM::SkipComments (const char* p_szIn,const char** p_szOut)
|
bool PLY::DOM::SkipComments (const char* p_szIn,
|
||||||
|
const char** p_szOut)
|
||||||
{
|
{
|
||||||
*p_szOut = p_szIn;
|
*p_szOut = p_szIn;
|
||||||
|
|
||||||
|
@ -451,8 +517,8 @@ bool PLY::DOM::ParseHeader (const char* p_szIn,const char** p_szOut)
|
||||||
// skip all comments
|
// skip all comments
|
||||||
PLY::DOM::SkipComments(p_szIn,&p_szIn);
|
PLY::DOM::SkipComments(p_szIn,&p_szIn);
|
||||||
|
|
||||||
Element out;
|
PLY::Element* out = new PLY::Element();
|
||||||
if(PLY::Element::ParseElement(p_szIn,&p_szIn,&out))
|
if(PLY::Element::ParseElement(p_szIn,&p_szIn,out))
|
||||||
{
|
{
|
||||||
// add the element to the list of elements
|
// add the element to the list of elements
|
||||||
this->alElements.push_back(out);
|
this->alElements.push_back(out);
|
||||||
|
@ -470,34 +536,39 @@ bool PLY::DOM::ParseHeader (const char* p_szIn,const char** p_szOut)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::DOM::ParseElementInstanceLists (const char* p_szIn,const char** p_szOut)
|
bool PLY::DOM::ParseElementInstanceLists (
|
||||||
|
const char* p_szIn,
|
||||||
|
const char** p_szOut)
|
||||||
{
|
{
|
||||||
this->alElementData.resize(this->alElements.size());
|
this->alElementData.resize(this->alElements.size());
|
||||||
|
|
||||||
std::vector<PLY::Element>::const_iterator i = this->alElements.begin();
|
std::vector<PLY::Element*>::const_iterator i = this->alElements.begin();
|
||||||
std::vector<PLY::ElementInstanceList>::iterator a = this->alElementData.begin();
|
std::vector<PLY::ElementInstanceList*>::iterator a = this->alElementData.begin();
|
||||||
|
|
||||||
// parse all element instances
|
// parse all element instances
|
||||||
for (;i != this->alElements.end();++i,++a)
|
for (;i != this->alElements.end();++i,++a)
|
||||||
{
|
{
|
||||||
*a = PLY::ElementInstanceList(&(*i)); // reserve enough storage
|
*a = new PLY::ElementInstanceList((*i)); // reserve enough storage
|
||||||
PLY::ElementInstanceList::ParseInstanceList(p_szIn,&p_szIn,&(*i),&(*a));
|
PLY::ElementInstanceList::ParseInstanceList(p_szIn,&p_szIn,(*i),(*a));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::DOM::ParseElementInstanceListsBinary (const char* p_szIn,const char** p_szOut,bool p_bBE)
|
bool PLY::DOM::ParseElementInstanceListsBinary (
|
||||||
|
const char* p_szIn,
|
||||||
|
const char** p_szOut,
|
||||||
|
bool p_bBE)
|
||||||
{
|
{
|
||||||
this->alElementData.resize(this->alElements.size());
|
this->alElementData.resize(this->alElements.size());
|
||||||
|
|
||||||
std::vector<PLY::Element>::const_iterator i = this->alElements.begin();
|
std::vector<PLY::Element*>::const_iterator i = this->alElements.begin();
|
||||||
std::vector<PLY::ElementInstanceList>::iterator a = this->alElementData.begin();
|
std::vector<PLY::ElementInstanceList*>::iterator a = this->alElementData.begin();
|
||||||
|
|
||||||
// parse all element instances
|
// parse all element instances
|
||||||
for (;i != this->alElements.end();++i,++a)
|
for (;i != this->alElements.end();++i,++a)
|
||||||
{
|
{
|
||||||
*a = PLY::ElementInstanceList(&(*i)); // reserve enough storage
|
*a = new PLY::ElementInstanceList((*i)); // reserve enough storage
|
||||||
PLY::ElementInstanceList::ParseInstanceListBinary(p_szIn,&p_szIn,&(*i),&(*a),p_bBE);
|
PLY::ElementInstanceList::ParseInstanceListBinary(p_szIn,&p_szIn,(*i),(*a),p_bBE);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -549,8 +620,8 @@ bool PLY::ElementInstanceList::ParseInstanceList (const char* p_szIn,const char*
|
||||||
{
|
{
|
||||||
PLY::DOM::SkipComments(p_szIn,&p_szIn);
|
PLY::DOM::SkipComments(p_szIn,&p_szIn);
|
||||||
|
|
||||||
PLY::ElementInstance out;
|
PLY::ElementInstance* out = new PLY::ElementInstance();
|
||||||
PLY::ElementInstance::ParseInstance(p_szIn, &p_szIn,pcElement, &out);
|
PLY::ElementInstance::ParseInstance(p_szIn, &p_szIn,pcElement, out);
|
||||||
// add it to the list
|
// add it to the list
|
||||||
p_pcOut->alInstances[i] = out;
|
p_pcOut->alInstances[i] = out;
|
||||||
}
|
}
|
||||||
|
@ -559,8 +630,12 @@ bool PLY::ElementInstanceList::ParseInstanceList (const char* p_szIn,const char*
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::ElementInstanceList::ParseInstanceListBinary (const char* p_szIn,const char** p_szOut,
|
bool PLY::ElementInstanceList::ParseInstanceListBinary (
|
||||||
const PLY::Element* pcElement, PLY::ElementInstanceList* p_pcOut,bool p_bBE)
|
const char* p_szIn,
|
||||||
|
const char** p_szOut,
|
||||||
|
const PLY::Element* pcElement,
|
||||||
|
PLY::ElementInstanceList* p_pcOut,
|
||||||
|
bool p_bBE /* = false */)
|
||||||
{
|
{
|
||||||
// we can add special handling code for unknown element semantics since
|
// we can add special handling code for unknown element semantics since
|
||||||
// we can't skip it as a whole block (we don't know its exact size
|
// we can't skip it as a whole block (we don't know its exact size
|
||||||
|
@ -568,8 +643,8 @@ bool PLY::ElementInstanceList::ParseInstanceListBinary (const char* p_szIn,const
|
||||||
// of the unknown element)
|
// of the unknown element)
|
||||||
for (unsigned int i = 0; i < pcElement->NumOccur;++i)
|
for (unsigned int i = 0; i < pcElement->NumOccur;++i)
|
||||||
{
|
{
|
||||||
PLY::ElementInstance out;
|
PLY::ElementInstance* out = new PLY::ElementInstance();
|
||||||
PLY::ElementInstance::ParseInstanceBinary(p_szIn, &p_szIn,pcElement, &out, p_bBE);
|
PLY::ElementInstance::ParseInstanceBinary(p_szIn, &p_szIn,pcElement, out, p_bBE);
|
||||||
// add it to the list
|
// add it to the list
|
||||||
p_pcOut->alInstances[i] = out;
|
p_pcOut->alInstances[i] = out;
|
||||||
}
|
}
|
||||||
|
@ -577,24 +652,28 @@ bool PLY::ElementInstanceList::ParseInstanceListBinary (const char* p_szIn,const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::ElementInstance::ParseInstance (const char* p_szIn,const char** p_szOut,
|
bool PLY::ElementInstance::ParseInstance (
|
||||||
const PLY::Element* pcElement, PLY::ElementInstance* p_pcOut)
|
const char* p_szIn,
|
||||||
|
const char** p_szOut,
|
||||||
|
const PLY::Element* pcElement,
|
||||||
|
PLY::ElementInstance* p_pcOut)
|
||||||
{
|
{
|
||||||
if (!SkipSpaces(p_szIn, &p_szIn))return false;
|
if (!SkipSpaces(p_szIn, &p_szIn))return false;
|
||||||
|
|
||||||
|
// allocate enough storage
|
||||||
p_pcOut->alProperties.resize(pcElement->alProperties.size());
|
p_pcOut->alProperties.resize(pcElement->alProperties.size());
|
||||||
|
|
||||||
*p_szOut = p_szIn;
|
*p_szOut = p_szIn;
|
||||||
std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
|
std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
|
||||||
std::vector<PLY::Property>::const_iterator a = pcElement->alProperties.begin();
|
std::vector<PLY::Property*>::const_iterator a = pcElement->alProperties.begin();
|
||||||
for (;i != p_pcOut->alProperties.end();++i,++a)
|
for (;i != p_pcOut->alProperties.end();++i,++a)
|
||||||
{
|
{
|
||||||
if(!(PLY::PropertyInstance::ParseInstance(p_szIn, &p_szIn,&(*a),&(*i))))
|
if(!(PLY::PropertyInstance::ParseInstance(p_szIn, &p_szIn,(*a),&(*i))))
|
||||||
{
|
{
|
||||||
// skip the rest of the instance
|
// skip the rest of the instance
|
||||||
SkipLine(p_szIn, &p_szIn);
|
SkipLine(p_szIn, &p_szIn);
|
||||||
|
|
||||||
PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a).eType);
|
PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a)->eType);
|
||||||
(*i).avList.push_back(v);
|
(*i).avList.push_back(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,19 +681,24 @@ bool PLY::ElementInstance::ParseInstance (const char* p_szIn,const char** p_szOu
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool PLY::ElementInstance::ParseInstanceBinary (const char* p_szIn,const char** p_szOut,
|
bool PLY::ElementInstance::ParseInstanceBinary (
|
||||||
const PLY::Element* pcElement, PLY::ElementInstance* p_pcOut, bool p_bBE)
|
const char* p_szIn,
|
||||||
|
const char** p_szOut,
|
||||||
|
const PLY::Element* pcElement,
|
||||||
|
PLY::ElementInstance* p_pcOut,
|
||||||
|
bool p_bBE /* = false */)
|
||||||
{
|
{
|
||||||
|
// allocate enough storage
|
||||||
p_pcOut->alProperties.resize(pcElement->alProperties.size());
|
p_pcOut->alProperties.resize(pcElement->alProperties.size());
|
||||||
|
|
||||||
*p_szOut = p_szIn;
|
*p_szOut = p_szIn;
|
||||||
std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
|
std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
|
||||||
std::vector<PLY::Property>::const_iterator a = pcElement->alProperties.begin();
|
std::vector<PLY::Property*>::const_iterator a = pcElement->alProperties.begin();
|
||||||
for (;i != p_pcOut->alProperties.end();++i,++a)
|
for (;i != p_pcOut->alProperties.end();++i,++a)
|
||||||
{
|
{
|
||||||
if(!(PLY::PropertyInstance::ParseInstance(p_szIn, &p_szIn,&(*a),&(*i))))
|
if(!(PLY::PropertyInstance::ParseInstance(p_szIn, &p_szIn,(*a),&(*i))))
|
||||||
{
|
{
|
||||||
PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a).eType);
|
PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a)->eType);
|
||||||
(*i).avList.push_back(v);
|
(*i).avList.push_back(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
159
code/PlyParser.h
159
code/PlyParser.h
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @file Defines the helper data structures for importing PLY files */
|
/** @file Defines the helper data structures for importing PLY files */
|
||||||
#ifndef AI_PLYFILEHELPER_H_INC
|
#ifndef AI_PLYFILEHELPER_H_INC
|
||||||
#define AI_PLYFILEHELPER_H_INC
|
#define AI_PLYFILEHELPER_H_INC
|
||||||
|
@ -54,9 +95,9 @@ enum EDataType
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Specifies semantics for PLY element properties
|
/** \brief Specifies semantics for PLY element properties
|
||||||
*
|
*
|
||||||
* Semantics define the usage of a property, e.g. x coordinate
|
* Semantics define the usage of a property, e.g. x coordinate
|
||||||
*/
|
*/
|
||||||
enum ESemantic
|
enum ESemantic
|
||||||
{
|
{
|
||||||
|
@ -73,6 +114,11 @@ enum ESemantic
|
||||||
EST_YNormal,
|
EST_YNormal,
|
||||||
//! vertex normal z coordinate
|
//! vertex normal z coordinate
|
||||||
EST_ZNormal,
|
EST_ZNormal,
|
||||||
|
|
||||||
|
//! u texture coordinate
|
||||||
|
EST_UTextureCoord,
|
||||||
|
//! v texture coordinate
|
||||||
|
EST_VTextureCoord,
|
||||||
|
|
||||||
//! vertex colors, red channel
|
//! vertex colors, red channel
|
||||||
EST_Red,
|
EST_Red,
|
||||||
|
@ -133,9 +179,9 @@ enum ESemantic
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Specifies semantics for PLY elements
|
/** \brief Specifies semantics for PLY elements
|
||||||
*
|
*
|
||||||
* Semantics define the usage of an element, e.g. vertex or material
|
* Semantics define the usage of an element, e.g. vertex or material
|
||||||
*/
|
*/
|
||||||
enum EElementSemantic
|
enum EElementSemantic
|
||||||
{
|
{
|
||||||
|
@ -159,9 +205,9 @@ enum EElementSemantic
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Helper class for a property in a PLY file.
|
/** \brief Helper class for a property in a PLY file.
|
||||||
*
|
*
|
||||||
* This can e.g. be a part of the vertex declaration
|
* This can e.g. be a part of the vertex declaration
|
||||||
*/
|
*/
|
||||||
class Property
|
class Property
|
||||||
{
|
{
|
||||||
|
@ -187,6 +233,7 @@ public:
|
||||||
bool bIsList;
|
bool bIsList;
|
||||||
EDataType eFirstType;
|
EDataType eFirstType;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a property from a string. The end of the
|
//! Parse a property from a string. The end of the
|
||||||
//! string is either '\n', '\r' or '\0'. Return valie is false
|
//! string is either '\n', '\r' or '\0'. Return valie is false
|
||||||
//! if the input string is NOT a valid property (E.g. does
|
//! if the input string is NOT a valid property (E.g. does
|
||||||
|
@ -194,18 +241,20 @@ public:
|
||||||
static bool ParseProperty (const char* p_szIn, const char** p_szOut,
|
static bool ParseProperty (const char* p_szIn, const char** p_szOut,
|
||||||
Property* pOut);
|
Property* pOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a data type from a string
|
//! Parse a data type from a string
|
||||||
static EDataType ParseDataType(const char* p_szIn,const char** p_szOut);
|
static EDataType ParseDataType(const char* p_szIn,const char** p_szOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a semantic from a string
|
//! Parse a semantic from a string
|
||||||
static ESemantic ParseSemantic(const char* p_szIn,const char** p_szOut);
|
static ESemantic ParseSemantic(const char* p_szIn,const char** p_szOut);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Helper class for an element in a PLY file.
|
/** \brief Helper class for an element in a PLY file.
|
||||||
*
|
*
|
||||||
* This can e.g. be the vertex declaration. Elements contain a
|
* This can e.g. be the vertex declaration. Elements contain a
|
||||||
* well-defined number of properties.
|
* well-defined number of properties.
|
||||||
*/
|
*/
|
||||||
class Element
|
class Element
|
||||||
{
|
{
|
||||||
|
@ -216,9 +265,22 @@ public:
|
||||||
: NumOccur(0), eSemantic (EEST_INVALID)
|
: NumOccur(0), eSemantic (EEST_INVALID)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//! Destructor. Dallocates all storage
|
||||||
|
~Element()
|
||||||
|
{
|
||||||
|
// delete all elements
|
||||||
|
for (std::vector<Property*>::const_iterator
|
||||||
|
i = this->alProperties.begin();
|
||||||
|
i != this->alProperties.end();++i)
|
||||||
|
{
|
||||||
|
delete (*i);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//! List of properties assigned to the element
|
//! List of properties assigned to the element
|
||||||
//! std::vector to support operator[]
|
//! std::vector to support operator[]
|
||||||
std::vector<Property> alProperties;
|
std::vector<Property*> alProperties;
|
||||||
|
|
||||||
//! Semantic of the element
|
//! Semantic of the element
|
||||||
EElementSemantic eSemantic;
|
EElementSemantic eSemantic;
|
||||||
|
@ -230,19 +292,22 @@ public:
|
||||||
//! How many times will the element occur?
|
//! How many times will the element occur?
|
||||||
unsigned int NumOccur;
|
unsigned int NumOccur;
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse an element from a string.
|
//! Parse an element from a string.
|
||||||
//! The function will parse all properties contained in the
|
//! The function will parse all properties contained in the
|
||||||
//! element, too.
|
//! element, too.
|
||||||
static bool ParseElement (const char* p_szIn, const char** p_szOut,
|
static bool ParseElement (const char* p_szIn, const char** p_szOut,
|
||||||
Element* pOut);
|
Element* pOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a semantic from a string
|
//! Parse a semantic from a string
|
||||||
static EElementSemantic ParseSemantic(const char* p_szIn,
|
static EElementSemantic ParseSemantic(const char* p_szIn,
|
||||||
const char** p_szOut);
|
const char** p_szOut);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Instance of a property in a PLY file
|
/** \brief Instance of a property in a PLY file
|
||||||
*/
|
*/
|
||||||
class PropertyInstance
|
class PropertyInstance
|
||||||
{
|
{
|
||||||
|
@ -271,36 +336,43 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! List of all values parsed. Contains only one value
|
//! List of all values parsed. Contains only one value
|
||||||
// for non-list propertys
|
// for non-list propertys
|
||||||
std::list<ValueUnion> avList;
|
std::list<ValueUnion> avList;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a property instance
|
//! Parse a property instance
|
||||||
static bool ParseInstance (const char* p_szIn,const char** p_szOut,
|
static bool ParseInstance (const char* p_szIn,const char** p_szOut,
|
||||||
const Property* prop, PropertyInstance* p_pcOut);
|
const Property* prop, PropertyInstance* p_pcOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a property instance in binary format
|
//! Parse a property instance in binary format
|
||||||
static bool ParseInstanceBinary (const char* p_szIn,const char** p_szOut,
|
static bool ParseInstanceBinary (const char* p_szIn,const char** p_szOut,
|
||||||
const Property* prop, PropertyInstance* p_pcOut,bool p_bBE);
|
const Property* prop, PropertyInstance* p_pcOut,bool p_bBE);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Get the default value for a given data type
|
//! Get the default value for a given data type
|
||||||
static ValueUnion DefaultValue(EDataType eType);
|
static ValueUnion DefaultValue(EDataType eType);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a value
|
//! Parse a value
|
||||||
static bool ParseValue(const char* p_szIn,const char** p_szOut,
|
static bool ParseValue(const char* p_szIn,const char** p_szOut,
|
||||||
EDataType eType,ValueUnion* out);
|
EDataType eType,ValueUnion* out);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a binary value
|
//! Parse a binary value
|
||||||
static bool ParseValueBinary(const char* p_szIn,const char** p_szOut,
|
static bool ParseValueBinary(const char* p_szIn,const char** p_szOut,
|
||||||
EDataType eType,ValueUnion* out,bool p_bBE);
|
EDataType eType,ValueUnion* out,bool p_bBE);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Convert a property value to a given type TYPE
|
//! Convert a property value to a given type TYPE
|
||||||
template <typename TYPE>
|
template <typename TYPE>
|
||||||
static TYPE ConvertTo(ValueUnion v, EDataType eType);
|
static TYPE ConvertTo(ValueUnion v, EDataType eType);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Class for an element instance in a PLY file
|
/** \brief Class for an element instance in a PLY file
|
||||||
*/
|
*/
|
||||||
class ElementInstance
|
class ElementInstance
|
||||||
{
|
{
|
||||||
|
@ -313,17 +385,19 @@ public:
|
||||||
//! List of all parsed properties
|
//! List of all parsed properties
|
||||||
std::vector< PropertyInstance > alProperties;
|
std::vector< PropertyInstance > alProperties;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse an element instance
|
//! Parse an element instance
|
||||||
static bool ParseInstance (const char* p_szIn,const char** p_szOut,
|
static bool ParseInstance (const char* p_szIn,const char** p_szOut,
|
||||||
const Element* pcElement, ElementInstance* p_pcOut);
|
const Element* pcElement, ElementInstance* p_pcOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a binary element instance
|
//! Parse a binary element instance
|
||||||
static bool ParseInstanceBinary (const char* p_szIn,const char** p_szOut,
|
static bool ParseInstanceBinary (const char* p_szIn,const char** p_szOut,
|
||||||
const Element* pcElement, ElementInstance* p_pcOut,bool p_bBE);
|
const Element* pcElement, ElementInstance* p_pcOut,bool p_bBE);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Class for an element instance list in a PLY file
|
/** \brief Class for an element instance list in a PLY file
|
||||||
*/
|
*/
|
||||||
class ElementInstanceList
|
class ElementInstanceList
|
||||||
{
|
{
|
||||||
|
@ -333,25 +407,42 @@ public:
|
||||||
ElementInstanceList ()
|
ElementInstanceList ()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//! Construction from a given element description
|
||||||
ElementInstanceList (const Element* pc)
|
ElementInstanceList (const Element* pc)
|
||||||
{
|
{
|
||||||
|
// reserve enough storage to speedup the process
|
||||||
alInstances.reserve(pc->NumOccur);
|
alInstances.reserve(pc->NumOccur);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! List of all element instances
|
//! Destructor. Dallocates all storage
|
||||||
std::vector< ElementInstance > alInstances;
|
~ElementInstanceList()
|
||||||
|
{
|
||||||
|
// delete all elements
|
||||||
|
for (std::vector<ElementInstance*>::const_iterator
|
||||||
|
i = this->alInstances.begin();
|
||||||
|
i != this->alInstances.end();++i)
|
||||||
|
{
|
||||||
|
delete (*i);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! List of all element instances
|
||||||
|
std::vector< ElementInstance* > alInstances;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse an element instance list
|
//! Parse an element instance list
|
||||||
static bool ParseInstanceList (const char* p_szIn,const char** p_szOut,
|
static bool ParseInstanceList (const char* p_szIn,const char** p_szOut,
|
||||||
const Element* pcElement, ElementInstanceList* p_pcOut);
|
const Element* pcElement, ElementInstanceList* p_pcOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Parse a binary element instance list
|
//! Parse a binary element instance list
|
||||||
static bool ParseInstanceListBinary (const char* p_szIn,const char** p_szOut,
|
static bool ParseInstanceListBinary (const char* p_szIn,const char** p_szOut,
|
||||||
const Element* pcElement, ElementInstanceList* p_pcOut,bool p_bBE);
|
const Element* pcElement, ElementInstanceList* p_pcOut,bool p_bBE);
|
||||||
};
|
};
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Class to represent the document object model of an ASCII or binary
|
/** \brief Class to represent the document object model of an ASCII or binary
|
||||||
* (both little and big-endian) PLY file
|
* (both little and big-endian) PLY file
|
||||||
*/
|
*/
|
||||||
class DOM
|
class DOM
|
||||||
{
|
{
|
||||||
|
@ -361,9 +452,30 @@ public:
|
||||||
DOM()
|
DOM()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//! Destructor. Dallocates all storage
|
||||||
|
~DOM()
|
||||||
|
{
|
||||||
|
// delete all elements
|
||||||
|
for (std::vector<Element*>::const_iterator
|
||||||
|
i = this->alElements.begin();
|
||||||
|
i != this->alElements.end();++i)
|
||||||
|
{
|
||||||
|
delete (*i);
|
||||||
|
}
|
||||||
|
// delete all instance lists
|
||||||
|
for (std::vector<ElementInstanceList*>::const_iterator
|
||||||
|
i = this->alElementData.begin();
|
||||||
|
i != this->alElementData.end();++i)
|
||||||
|
{
|
||||||
|
delete (*i);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Element> alElements;
|
//! Contains all elements of the file format
|
||||||
std::vector<ElementInstanceList> alElementData;
|
std::vector<Element*> alElements;
|
||||||
|
//! Contains the real data of each element's instance list
|
||||||
|
std::vector<ElementInstanceList*> alElementData;
|
||||||
|
|
||||||
//! Parse the DOM for a PLY file. The input string is assumed
|
//! Parse the DOM for a PLY file. The input string is assumed
|
||||||
//! to be terminated with zero
|
//! to be terminated with zero
|
||||||
|
@ -376,19 +488,22 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Handle the file header and read all element descriptions
|
//! Handle the file header and read all element descriptions
|
||||||
bool ParseHeader (const char* p_szIn,const char** p_szOut);
|
bool ParseHeader (const char* p_szIn,const char** p_szOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Read in all element instance lists
|
//! Read in all element instance lists
|
||||||
bool ParseElementInstanceLists (const char* p_szIn,const char** p_szOut);
|
bool ParseElementInstanceLists (const char* p_szIn,const char** p_szOut);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
//! Read in all element instance lists for a binary file format
|
//! Read in all element instance lists for a binary file format
|
||||||
bool ParseElementInstanceListsBinary (const char* p_szIn,
|
bool ParseElementInstanceListsBinary (const char* p_szIn,
|
||||||
const char** p_szOut,bool p_bBE);
|
const char** p_szOut,bool p_bBE);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** \brief Helper class to represent a loaded face
|
/** \brief Helper class to represent a loaded PLY face
|
||||||
*/
|
*/
|
||||||
class Face
|
class Face
|
||||||
{
|
{
|
||||||
|
@ -434,6 +549,8 @@ TYPE PLY::PropertyInstance::ConvertTo(
|
||||||
};
|
};
|
||||||
return (TYPE)0;
|
return (TYPE)0;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
inline bool IsSpace( const char in)
|
inline bool IsSpace( const char in)
|
||||||
{
|
{
|
||||||
|
@ -476,8 +593,6 @@ inline void SkipSpacesAndLineEnd( const char* in, const char** out)
|
||||||
while (*in == ' ' || *in == '\t' || *in == '\r' || *in == '\n')in++;
|
while (*in == ' ' || *in == '\t' || *in == '\r' || *in == '\n')in++;
|
||||||
*out = in;
|
*out = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !! include guard
|
#endif // !! include guard
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the helper class to quickly find vertices close to a given position */
|
/** @file Implementation of the helper class to quickly find vertices close to a given position */
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "SpatialSort.h"
|
#include "SpatialSort.h"
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** Small helper classes to optimise finding vertizes close to a given location */
|
/** Small helper classes to optimise finding vertizes close to a given location */
|
||||||
#ifndef AI_SPATIALSORT_H_INC
|
#ifndef AI_SPATIALSORT_H_INC
|
||||||
#define AI_SPATIALSORT_H_INC
|
#define AI_SPATIALSORT_H_INC
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @file Implementation of the SplitLargeMeshes postprocessing step
|
/** @file Implementation of the SplitLargeMeshes postprocessing step
|
||||||
*/
|
*/
|
||||||
#include "SplitLargeMeshes.h"
|
#include "SplitLargeMeshes.h"
|
||||||
|
@ -7,27 +48,56 @@
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
// Constructor to be privately used by Importer
|
/*static*/ unsigned int SplitLargeMeshesProcess_Triangle::LIMIT = AI_SLM_DEFAULT_MAX_TRIANGLES;
|
||||||
SplitLargeMeshesProcess::SplitLargeMeshesProcess()
|
/*static*/ unsigned int SplitLargeMeshesProcess_Vertex::LIMIT = AI_SLM_DEFAULT_MAX_VERTICES;
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiReturn aiSetVertexSplitLimit(unsigned int pLimit)
|
||||||
|
{
|
||||||
|
if (0 == pLimit)
|
||||||
{
|
{
|
||||||
|
SplitLargeMeshesProcess_Vertex::LIMIT = 0xFFFFFFFF;
|
||||||
|
return AI_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor, private as well
|
SplitLargeMeshesProcess_Vertex::LIMIT = pLimit;
|
||||||
SplitLargeMeshesProcess::~SplitLargeMeshesProcess()
|
return AI_SUCCESS;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
aiReturn aiSetTriangleSplitLimit(unsigned int pLimit)
|
||||||
|
{
|
||||||
|
if (0 == pLimit)
|
||||||
|
{
|
||||||
|
SplitLargeMeshesProcess_Triangle::LIMIT = 0xFFFFFFFF;
|
||||||
|
return AI_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitLargeMeshesProcess_Triangle::LIMIT = pLimit;
|
||||||
|
return AI_SUCCESS;
|
||||||
|
}
|
||||||
|
}; //! extern "C"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SplitLargeMeshesProcess_Triangle::SplitLargeMeshesProcess_Triangle()
|
||||||
|
{
|
||||||
|
// nothing to do here
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SplitLargeMeshesProcess_Triangle::~SplitLargeMeshesProcess_Triangle()
|
||||||
{
|
{
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool SplitLargeMeshesProcess::IsActive( unsigned int pFlags) const
|
bool SplitLargeMeshesProcess_Triangle::IsActive( unsigned int pFlags) const
|
||||||
{
|
{
|
||||||
return (pFlags & aiProcess_SplitLargeMeshes) != 0;
|
return (pFlags & aiProcess_SplitLargeMeshes) != 0 && (0xFFFFFFFF != LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Executes the post processing step on the given imported data.
|
// Executes the post processing step on the given imported data.
|
||||||
void SplitLargeMeshesProcess::Execute( aiScene* pScene)
|
void SplitLargeMeshesProcess_Triangle::Execute( aiScene* pScene)
|
||||||
{
|
{
|
||||||
std::vector<std::pair<aiMesh*, unsigned int> > avList;
|
std::vector<std::pair<aiMesh*, unsigned int> > avList;
|
||||||
|
|
||||||
|
@ -51,12 +121,10 @@ void SplitLargeMeshesProcess::Execute( aiScene* pScene)
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Update a node after some meshes have been split
|
// Update a node after some meshes have been split
|
||||||
void SplitLargeMeshesProcess::UpdateNode(aiNode* pcNode,
|
void SplitLargeMeshesProcess_Triangle::UpdateNode(aiNode* pcNode,
|
||||||
const std::vector<std::pair<aiMesh*, unsigned int> >& avList)
|
const std::vector<std::pair<aiMesh*, unsigned int> >& avList)
|
||||||
{
|
{
|
||||||
// for every index in out list build a new entry
|
// for every index in out list build a new entry
|
||||||
// TODO: Currently O(n^2)
|
|
||||||
|
|
||||||
std::vector<unsigned int> aiEntries;
|
std::vector<unsigned int> aiEntries;
|
||||||
aiEntries.reserve(pcNode->mNumMeshes + 1);
|
aiEntries.reserve(pcNode->mNumMeshes + 1);
|
||||||
for (unsigned int i = 0; i < pcNode->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pcNode->mNumMeshes;++i)
|
||||||
|
@ -81,25 +149,22 @@ void SplitLargeMeshesProcess::UpdateNode(aiNode* pcNode,
|
||||||
// recusively update all other nodes
|
// recusively update all other nodes
|
||||||
for (unsigned int i = 0; i < pcNode->mNumChildren;++i)
|
for (unsigned int i = 0; i < pcNode->mNumChildren;++i)
|
||||||
{
|
{
|
||||||
this->UpdateNode ( pcNode->mChildren[i], avList );
|
UpdateNode ( pcNode->mChildren[i], avList );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Executes the post processing step on the given imported data.
|
// Executes the post processing step on the given imported data.
|
||||||
void SplitLargeMeshesProcess::SplitMesh(
|
void SplitLargeMeshesProcess_Triangle::SplitMesh(
|
||||||
unsigned int a,
|
unsigned int a,
|
||||||
aiMesh* pMesh,
|
aiMesh* pMesh,
|
||||||
std::vector<std::pair<aiMesh*, unsigned int> >& avList)
|
std::vector<std::pair<aiMesh*, unsigned int> >& avList)
|
||||||
{
|
{
|
||||||
// TODO: Mesh splitting is currently not supported for meshes
|
if (pMesh->mNumFaces > LIMIT)
|
||||||
// containing bones
|
|
||||||
|
|
||||||
if (pMesh->mNumVertices > AI_SLM_MAX_VERTICES && 0 == pMesh->mNumBones)
|
|
||||||
{
|
{
|
||||||
// we need to split this mesh into sub meshes
|
// we need to split this mesh into sub meshes
|
||||||
// determine the size of a submesh
|
// determine the size of a submesh
|
||||||
const unsigned int iSubMeshes = (pMesh->mNumVertices / AI_SLM_MAX_VERTICES) + 1;
|
const unsigned int iSubMeshes = (pMesh->mNumFaces / LIMIT) + 1;
|
||||||
|
|
||||||
const unsigned int iOutFaceNum = pMesh->mNumFaces / iSubMeshes;
|
const unsigned int iOutFaceNum = pMesh->mNumFaces / iSubMeshes;
|
||||||
const unsigned int iOutVertexNum = iOutFaceNum * 3;
|
const unsigned int iOutVertexNum = iOutFaceNum * 3;
|
||||||
|
@ -162,19 +227,25 @@ void SplitLargeMeshesProcess::SplitMesh(
|
||||||
}
|
}
|
||||||
|
|
||||||
// (we will also need to copy the array of indices)
|
// (we will also need to copy the array of indices)
|
||||||
|
unsigned int iCurrent = 0;
|
||||||
for (unsigned int p = 0; p < pcMesh->mNumFaces;++p)
|
for (unsigned int p = 0; p < pcMesh->mNumFaces;++p)
|
||||||
{
|
{
|
||||||
pcMesh->mFaces[p].mNumIndices = 3;
|
pcMesh->mFaces[p].mNumIndices = 3;
|
||||||
|
|
||||||
// allocate a new array
|
// allocate a new array
|
||||||
unsigned int* pi = pMesh->mFaces[p + iBase].mIndices;
|
const unsigned int iTemp = p + iBase;
|
||||||
pcMesh->mFaces[p].mIndices = new unsigned int[3];
|
const unsigned int iNumIndices = pMesh->mFaces[iTemp].mNumIndices;
|
||||||
|
|
||||||
|
// setup face type and number of indices
|
||||||
|
pcMesh->mFaces[p].mNumIndices = iNumIndices;
|
||||||
|
unsigned int* pi = pMesh->mFaces[iTemp].mIndices;
|
||||||
|
|
||||||
|
pcMesh->mFaces[p].mIndices = new unsigned int[iNumIndices];
|
||||||
|
|
||||||
// and copy the contents of the old array, offset by current base
|
// and copy the contents of the old array, offset by current base
|
||||||
for (unsigned int v = 0; v < 3;++v)
|
for (unsigned int v = 0; v < iNumIndices;++v)
|
||||||
{
|
{
|
||||||
unsigned int iIndex = pMesh->mFaces[p+iBase].mIndices[v];
|
unsigned int iIndex = pMesh->mFaces[iTemp].mIndices[v];
|
||||||
unsigned int iIndexOut = p*3 + v;
|
unsigned int iIndexOut = iCurrent++;
|
||||||
pcMesh->mFaces[p].mIndices[v] = iIndexOut;
|
pcMesh->mFaces[p].mIndices[v] = iIndexOut;
|
||||||
|
|
||||||
// copy positions
|
// copy positions
|
||||||
|
@ -224,4 +295,222 @@ void SplitLargeMeshesProcess::SplitMesh(
|
||||||
}
|
}
|
||||||
else avList.push_back(std::pair<aiMesh*, unsigned int>(pMesh,a));
|
else avList.push_back(std::pair<aiMesh*, unsigned int>(pMesh,a));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SplitLargeMeshesProcess_Vertex::SplitLargeMeshesProcess_Vertex()
|
||||||
|
{
|
||||||
|
// nothing to do here
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SplitLargeMeshesProcess_Vertex::~SplitLargeMeshesProcess_Vertex()
|
||||||
|
{
|
||||||
|
// nothing to do here
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Returns whether the processing step is present in the given flag field.
|
||||||
|
bool SplitLargeMeshesProcess_Vertex::IsActive( unsigned int pFlags) const
|
||||||
|
{
|
||||||
|
return (pFlags & aiProcess_SplitLargeMeshes) != 0 && (0xFFFFFFFF != LIMIT);
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Executes the post processing step on the given imported data.
|
||||||
|
void SplitLargeMeshesProcess_Vertex::Execute( aiScene* pScene)
|
||||||
|
{
|
||||||
|
std::vector<std::pair<aiMesh*, unsigned int> > avList;
|
||||||
|
|
||||||
|
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||||
|
this->SplitMesh(a, pScene->mMeshes[a],avList);
|
||||||
|
|
||||||
|
if (avList.size() != pScene->mNumMeshes)
|
||||||
|
{
|
||||||
|
// it seems something has been splitted. rebuild the mesh list
|
||||||
|
delete[] pScene->mMeshes;
|
||||||
|
pScene->mNumMeshes = avList.size();
|
||||||
|
pScene->mMeshes = new aiMesh*[avList.size()];
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < avList.size();++i)
|
||||||
|
pScene->mMeshes[i] = avList[i].first;
|
||||||
|
|
||||||
|
// now we need to update all nodes
|
||||||
|
SplitLargeMeshesProcess_Triangle::UpdateNode(pScene->mRootNode,avList);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Executes the post processing step on the given imported data.
|
||||||
|
void SplitLargeMeshesProcess_Vertex::SplitMesh(
|
||||||
|
unsigned int a,
|
||||||
|
aiMesh* pMesh,
|
||||||
|
std::vector<std::pair<aiMesh*, unsigned int> >& avList)
|
||||||
|
{
|
||||||
|
if (pMesh->mNumVertices > SplitLargeMeshesProcess_Vertex::LIMIT)
|
||||||
|
{
|
||||||
|
// we need to split this mesh into sub meshes
|
||||||
|
// determine the estimated size of a submesh
|
||||||
|
// (this could be too large. Max waste is a single digit percentage)
|
||||||
|
const unsigned int iSubMeshes = (pMesh->mNumVertices / SplitLargeMeshesProcess_Vertex::LIMIT) + 1;
|
||||||
|
const unsigned int iOutVertexNum2 = pMesh->mNumVertices /iSubMeshes;
|
||||||
|
|
||||||
|
// create a std::vector<unsigned int> to indicate which vertices
|
||||||
|
// have already been copied
|
||||||
|
std::vector<unsigned int> avWasCopied;
|
||||||
|
avWasCopied.resize(pMesh->mNumVertices,0xFFFFFFFF);
|
||||||
|
|
||||||
|
// try to find a good estimate for the number of output faces
|
||||||
|
// per mesh. Add 12.5% as buffer
|
||||||
|
unsigned int iEstimatedSize = pMesh->mNumFaces / iSubMeshes;
|
||||||
|
iEstimatedSize += iEstimatedSize >> 3;
|
||||||
|
|
||||||
|
// now generate all submeshes
|
||||||
|
unsigned int iBase = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
const unsigned int iOutVertexNum = SplitLargeMeshesProcess_Vertex::LIMIT;
|
||||||
|
|
||||||
|
aiMesh* pcMesh = new aiMesh;
|
||||||
|
pcMesh->mNumVertices = 0;
|
||||||
|
pcMesh->mMaterialIndex = pMesh->mMaterialIndex;
|
||||||
|
|
||||||
|
// clear the temporary helper array
|
||||||
|
if (0 != iBase)
|
||||||
|
{
|
||||||
|
memset(&avWasCopied[0],0xFF,pMesh->mNumVertices * sizeof(unsigned int));
|
||||||
|
}
|
||||||
|
|
||||||
|
// output vectors
|
||||||
|
std::vector<aiFace> vFaces;
|
||||||
|
|
||||||
|
// reserve enough storage for most cases
|
||||||
|
if (pMesh->HasPositions())
|
||||||
|
{
|
||||||
|
pcMesh->mVertices = new aiVector3D[iOutVertexNum];
|
||||||
|
}
|
||||||
|
if (pMesh->HasNormals())
|
||||||
|
{
|
||||||
|
pcMesh->mNormals = new aiVector3D[iOutVertexNum];
|
||||||
|
}
|
||||||
|
if (pMesh->HasTangentsAndBitangents())
|
||||||
|
{
|
||||||
|
pcMesh->mTangents = new aiVector3D[iOutVertexNum];
|
||||||
|
pcMesh->mBitangents = new aiVector3D[iOutVertexNum];
|
||||||
|
}
|
||||||
|
for (unsigned int c = 0; pMesh->HasVertexColors(c);++c)
|
||||||
|
{
|
||||||
|
pcMesh->mColors[c] = new aiColor4D[iOutVertexNum];
|
||||||
|
}
|
||||||
|
for (unsigned int c = 0; pMesh->HasTextureCoords(c);++c)
|
||||||
|
{
|
||||||
|
pcMesh->mNumUVComponents[c] = pMesh->mNumUVComponents[c];
|
||||||
|
pcMesh->mTextureCoords[c] = new aiVector3D[iOutVertexNum];
|
||||||
|
}
|
||||||
|
vFaces.reserve(iEstimatedSize);
|
||||||
|
|
||||||
|
// (we will also need to copy the array of indices)
|
||||||
|
while (iBase < pMesh->mNumFaces)
|
||||||
|
{
|
||||||
|
// allocate a new array
|
||||||
|
const unsigned int iNumIndices = pMesh->mFaces[iBase].mNumIndices;
|
||||||
|
|
||||||
|
// doesn't catch degenerates but is quite fast
|
||||||
|
unsigned int iNeed = 0;
|
||||||
|
for (unsigned int v = 0; v < iNumIndices;++v)
|
||||||
|
{
|
||||||
|
unsigned int iIndex = pMesh->mFaces[iBase].mIndices[v];
|
||||||
|
|
||||||
|
// check whether we do already have this vertex
|
||||||
|
if (0xFFFFFFFF == avWasCopied[iIndex])
|
||||||
|
{
|
||||||
|
iNeed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pcMesh->mNumVertices + iNeed > iOutVertexNum)
|
||||||
|
{
|
||||||
|
// don't use this face
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
vFaces.push_back(aiFace());
|
||||||
|
aiFace& rFace = vFaces.back();
|
||||||
|
|
||||||
|
// setup face type and number of indices
|
||||||
|
rFace.mNumIndices = iNumIndices;
|
||||||
|
rFace.mIndices = new unsigned int[iNumIndices];
|
||||||
|
|
||||||
|
// and copy the contents of the old array, offset by current base
|
||||||
|
for (unsigned int v = 0; v < iNumIndices;++v)
|
||||||
|
{
|
||||||
|
unsigned int iIndex = pMesh->mFaces[iBase].mIndices[v];
|
||||||
|
|
||||||
|
// check whether we do already have this vertex
|
||||||
|
if (0xFFFFFFFF != avWasCopied[iIndex])
|
||||||
|
{
|
||||||
|
rFace.mIndices[v] = avWasCopied[iIndex];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy positions
|
||||||
|
pcMesh->mVertices[pcMesh->mNumVertices] = (pMesh->mVertices[iIndex]);
|
||||||
|
|
||||||
|
// copy normals
|
||||||
|
if (pMesh->HasNormals())
|
||||||
|
{
|
||||||
|
pcMesh->mNormals[pcMesh->mNumVertices] = (pMesh->mNormals[iIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy tangents/bitangents
|
||||||
|
if (pMesh->HasTangentsAndBitangents())
|
||||||
|
{
|
||||||
|
pcMesh->mTangents[pcMesh->mNumVertices] = (pMesh->mTangents[iIndex]);
|
||||||
|
pcMesh->mBitangents[pcMesh->mNumVertices] = (pMesh->mBitangents[iIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// texture coordinates
|
||||||
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
|
{
|
||||||
|
if (pMesh->HasTextureCoords( c))
|
||||||
|
{
|
||||||
|
pcMesh->mTextureCoords[c][pcMesh->mNumVertices] = pMesh->mTextureCoords[c][iIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// vertex colors
|
||||||
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS;++c)
|
||||||
|
{
|
||||||
|
if (pMesh->HasVertexColors( c))
|
||||||
|
{
|
||||||
|
pcMesh->mColors[c][pcMesh->mNumVertices] = pMesh->mColors[c][iIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rFace.mIndices[v] = pcMesh->mNumVertices;
|
||||||
|
avWasCopied[iIndex] = pcMesh->mNumVertices;
|
||||||
|
pcMesh->mNumVertices++;
|
||||||
|
}
|
||||||
|
iBase++;
|
||||||
|
if(pcMesh->mNumVertices == iOutVertexNum)
|
||||||
|
{
|
||||||
|
// break here. The face is only added if it was complete
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// copy the face list to the mesh
|
||||||
|
pcMesh->mFaces = new aiFace[vFaces.size()];
|
||||||
|
pcMesh->mNumFaces = vFaces.size();
|
||||||
|
|
||||||
|
for (unsigned int p = 0; p < pcMesh->mNumFaces;++p)
|
||||||
|
pcMesh->mFaces[p] = vFaces[p];
|
||||||
|
|
||||||
|
// add the newly created mesh to the list
|
||||||
|
avList.push_back(std::pair<aiMesh*, unsigned int>(pcMesh,a));
|
||||||
|
|
||||||
|
if (iBase == pMesh->mNumFaces)
|
||||||
|
{
|
||||||
|
// have all faces ... finish the outer loop, too
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// now delete the old mesh data
|
||||||
|
delete pMesh;
|
||||||
|
}
|
||||||
|
else avList.push_back(std::pair<aiMesh*, unsigned int>(pMesh,a));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,45 @@
|
||||||
/** @file Defines a post processing step to split large meshes into submeshes*/
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Defines a post processing step to split large meshes into submeshes
|
||||||
|
*/
|
||||||
#ifndef AI_SPLITLARGEMESHES_H_INC
|
#ifndef AI_SPLITLARGEMESHES_H_INC
|
||||||
#define AI_SPLITLARGEMESHES_H_INC
|
#define AI_SPLITLARGEMESHES_H_INC
|
||||||
|
|
||||||
|
@ -10,21 +51,32 @@
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
#define AI_SLM_MAX_VERTICES 1000000
|
class SplitLargeMeshesProcess_Triangle;
|
||||||
|
class SplitLargeMeshesProcess_Vertex;
|
||||||
|
|
||||||
|
// default limit for vertices
|
||||||
|
#define AI_SLM_DEFAULT_MAX_VERTICES 1000000
|
||||||
|
|
||||||
|
// default limit for triangles
|
||||||
|
#define AI_SLM_DEFAULT_MAX_TRIANGLES 1000000
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Postprocessing filter to split large meshes into submeshes
|
/** Postprocessing filter to split large meshes into submeshes
|
||||||
|
*
|
||||||
|
* Applied BEFORE the JoinVertices-Step occurs.
|
||||||
|
* Returns NON-UNIQUE vertices, splits by triangle number.
|
||||||
*/
|
*/
|
||||||
class SplitLargeMeshesProcess : public BaseProcess
|
class SplitLargeMeshesProcess_Triangle : public BaseProcess
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
friend class SplitLargeMeshesProcess_Vertex;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Constructor to be privately used by Importer */
|
/** Constructor to be privately used by Importer */
|
||||||
SplitLargeMeshesProcess();
|
SplitLargeMeshesProcess_Triangle();
|
||||||
|
|
||||||
/** Destructor, private as well */
|
/** Destructor, private as well */
|
||||||
~SplitLargeMeshesProcess();
|
~SplitLargeMeshesProcess_Triangle();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -49,10 +101,60 @@ private:
|
||||||
void SplitMesh (unsigned int a, aiMesh* pcMesh,
|
void SplitMesh (unsigned int a, aiMesh* pcMesh,
|
||||||
std::vector<std::pair<aiMesh*, unsigned int> >& avList);
|
std::vector<std::pair<aiMesh*, unsigned int> >& avList);
|
||||||
|
|
||||||
//! Update a node in the asset after a few of its meshes
|
//! Update a node in the asset after a few of its meshes have been split
|
||||||
//! have been split
|
static void UpdateNode(aiNode* pcNode,
|
||||||
void UpdateNode(aiNode* pcNode,
|
|
||||||
const std::vector<std::pair<aiMesh*, unsigned int> >& avList);
|
const std::vector<std::pair<aiMesh*, unsigned int> >& avList);
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Triangle limit set via aiSetTriangleSplitLimit()
|
||||||
|
static unsigned int LIMIT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Postprocessing filter to split large meshes into submeshes
|
||||||
|
*
|
||||||
|
* Applied AFTER the JoinVertices-Step occurs.
|
||||||
|
* Returns UNIQUE vertices, splits by vertex number.
|
||||||
|
*/
|
||||||
|
class SplitLargeMeshesProcess_Vertex : public BaseProcess
|
||||||
|
{
|
||||||
|
friend class Importer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor to be privately used by Importer */
|
||||||
|
SplitLargeMeshesProcess_Vertex();
|
||||||
|
|
||||||
|
/** Destructor, private as well */
|
||||||
|
~SplitLargeMeshesProcess_Vertex();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether the processing step is present in the given flag field.
|
||||||
|
* @param pFlags The processing flags the importer was called with. A bitwise
|
||||||
|
* combination of #aiPostProcessSteps.
|
||||||
|
* @return true if the process is present in this flag fields, false if not.
|
||||||
|
*/
|
||||||
|
bool IsActive( unsigned int pFlags) const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Executes the post processing step on the given imported data.
|
||||||
|
* At the moment a process is not supposed to fail.
|
||||||
|
* @param pScene The imported data to work at.
|
||||||
|
*/
|
||||||
|
void Execute( aiScene* pScene);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! Apply the algorithm to a given mesh
|
||||||
|
void SplitMesh (unsigned int a, aiMesh* pcMesh,
|
||||||
|
std::vector<std::pair<aiMesh*, unsigned int> >& avList);
|
||||||
|
|
||||||
|
// NOTE: Reuse SplitLargeMeshesProcess_Triangle::UpdateNode()
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Triangle limit set via aiSetTriangleSplitLimit()
|
||||||
|
static unsigned int LIMIT;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
|
@ -1,4 +1,46 @@
|
||||||
/** @file Defines a post processing step to triangulate all faces with more than three vertices.*/
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Defines a post processing step to triangulate all faces
|
||||||
|
with more than three vertices.
|
||||||
|
*/
|
||||||
#ifndef AI_TRIANGULATEPROCESS_H_INC
|
#ifndef AI_TRIANGULATEPROCESS_H_INC
|
||||||
#define AI_TRIANGULATEPROCESS_H_INC
|
#define AI_TRIANGULATEPROCESS_H_INC
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @file Defines the helper data structures for importing XFiles */
|
/** @file Defines the helper data structures for importing XFiles */
|
||||||
#ifndef AI_XFILEHELPER_H_INC
|
#ifndef AI_XFILEHELPER_H_INC
|
||||||
#define AI_XFILEHELPER_H_INC
|
#define AI_XFILEHELPER_H_INC
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
/** @file Implementation of the XFile importer class */
|
/** @file Implementation of the XFile importer class */
|
||||||
#include "XFileImporter.h"
|
#include "XFileImporter.h"
|
||||||
#include "XFileParser.h"
|
#include "XFileParser.h"
|
||||||
|
@ -586,7 +626,7 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, const std::vector<XFile::
|
||||||
}
|
}
|
||||||
if (std::string::npos != s2)
|
if (std::string::npos != s2)
|
||||||
{
|
{
|
||||||
sprintf(key,AI_MATKEY_TEXTURE_BUMP_ "[%i]",iHM++);
|
sprintf(key,AI_MATKEY_TEXTURE_HEIGHT_ "[%i]",iHM++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definition of the XFile importer class. */
|
/** @file Definition of the XFile importer class. */
|
||||||
#ifndef AI_XFILEIMPORTER_H_INC
|
#ifndef AI_XFILEIMPORTER_H_INC
|
||||||
#define AI_XFILEIMPORTER_H_INC
|
#define AI_XFILEIMPORTER_H_INC
|
||||||
|
@ -38,51 +78,71 @@ public:
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||||
|
* See BaseImporter::GetExtensionList() for details
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& append)
|
||||||
|
{
|
||||||
|
append.append("*.x");
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Imports the given file into the given scene structure.
|
/** Imports the given file into the given scene structure.
|
||||||
* See BaseImporter::InternReadFile() for details
|
* See BaseImporter::InternReadFile() for details
|
||||||
*/
|
*/
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Constructs the return data structure out of the imported data.
|
/** Constructs the return data structure out of the imported data.
|
||||||
* @param pScene The scene to construct the return data in.
|
* @param pScene The scene to construct the return data in.
|
||||||
* @param pData The imported data in the internal temporary representation.
|
* @param pData The imported data in the internal temporary
|
||||||
|
* representation.
|
||||||
*/
|
*/
|
||||||
void CreateDataRepresentationFromImport( aiScene* pScene, const XFile::Scene* pData);
|
void CreateDataRepresentationFromImport( aiScene* pScene,
|
||||||
|
const XFile::Scene* pData);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Recursively creates scene nodes from the imported hierarchy. The meshes and materials
|
/** Recursively creates scene nodes from the imported hierarchy.
|
||||||
* of the nodes will be extracted on the way.
|
* The meshes and materials of the nodes will be extracted on the way.
|
||||||
* @param pScene The scene to construct the return data in.
|
* @param pScene The scene to construct the return data in.
|
||||||
* @param pParent The parent node where to create new child nodes
|
* @param pParent The parent node where to create new child nodes
|
||||||
* @param pNode The temporary node to copy.
|
* @param pNode The temporary node to copy.
|
||||||
* @return The created node
|
* @return The created node
|
||||||
*/
|
*/
|
||||||
aiNode* CreateNodes( aiScene* pScene, aiNode* pParent, const XFile::Node* pNode);
|
aiNode* CreateNodes( aiScene* pScene, aiNode* pParent,
|
||||||
|
const XFile::Node* pNode);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Converts all meshes in the given mesh array. Each mesh is splitted up per material,
|
/** Converts all meshes in the given mesh array. Each mesh is splitted
|
||||||
* the indices of the generated meshes are stored in the node structure.
|
* up per material, the indices of the generated meshes are stored in
|
||||||
|
* the node structure.
|
||||||
* @param pScene The scene to construct the return data in.
|
* @param pScene The scene to construct the return data in.
|
||||||
* @param pNode The target node structure that references the constructed meshes.
|
* @param pNode The target node structure that references the
|
||||||
|
* constructed meshes.
|
||||||
* @param pMeshes The array of meshes to convert
|
* @param pMeshes The array of meshes to convert
|
||||||
*/
|
*/
|
||||||
void CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vector<XFile::Mesh*>& pMeshes);
|
void CreateMeshes( aiScene* pScene, aiNode* pNode,
|
||||||
|
const std::vector<XFile::Mesh*>& pMeshes);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Converts the animations from the given imported data and creates them in the scene.
|
/** Converts the animations from the given imported data and creates
|
||||||
|
* them in the scene.
|
||||||
* @param pScene The scene to hold to converted animations
|
* @param pScene The scene to hold to converted animations
|
||||||
* @param pData The data to read the animations from
|
* @param pData The data to read the animations from
|
||||||
*/
|
*/
|
||||||
void CreateAnimations( aiScene* pScene, const XFile::Scene* pData);
|
void CreateAnimations( aiScene* pScene, const XFile::Scene* pData);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Converts all materials in the given array and stores them in the scene's material list.
|
/** Converts all materials in the given array and stores them in the
|
||||||
|
* scene's material list.
|
||||||
* @param pScene The scene to hold the converted materials.
|
* @param pScene The scene to hold the converted materials.
|
||||||
* @param pMaterials The material array to convert.
|
* @param pMaterials The material array to convert.
|
||||||
*/
|
*/
|
||||||
void ConvertMaterials( aiScene* pScene, const std::vector<XFile::Material>& pMaterials);
|
void ConvertMaterials( aiScene* pScene,
|
||||||
|
const std::vector<XFile::Material>& pMaterials);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Buffer to hold the loaded file */
|
/** Buffer to hold the loaded file */
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the XFile parser helper class */
|
/** @file Implementation of the XFile parser helper class */
|
||||||
#include "XFileParser.h"
|
#include "XFileParser.h"
|
||||||
#include "XFileHelper.h"
|
#include "XFileHelper.h"
|
||||||
|
|
|
@ -1,3 +1,43 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Helper class to parse a XFile into a temporary structure */
|
/** @file Helper class to parse a XFile into a temporary structure */
|
||||||
#ifndef AI_XFILEPARSER_H_INC
|
#ifndef AI_XFILEPARSER_H_INC
|
||||||
#define AI_XFILEPARSER_H_INC
|
#define AI_XFILEPARSER_H_INC
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "afxres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Deutsch (Deutschland) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||||
|
#ifdef _WIN32
|
||||||
|
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
|
||||||
|
#pragma code_page(1252)
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""afxres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Version
|
||||||
|
//
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION 1,0,0,1
|
||||||
|
PRODUCTVERSION 1,0,0,1
|
||||||
|
FILEFLAGSMASK 0x17L
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x4L
|
||||||
|
FILETYPE 0x7L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040704b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Comments", "Licensed under a 3-clause BSD license"
|
||||||
|
VALUE "CompanyName", "ASSIMP Development Team"
|
||||||
|
VALUE "FileDescription", "Free Asset Import Library "
|
||||||
|
VALUE "FileVersion", "1, 0, 0, 0"
|
||||||
|
VALUE "InternalName", "assimp"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) 2008"
|
||||||
|
VALUE "OriginalFilename", "assimp32.dll"
|
||||||
|
VALUE "ProductName", "Free Asset Import Library "
|
||||||
|
VALUE "ProductVersion", "1, 0, 0, 0"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x407, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // Deutsch (Deutschland) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by assimp.rc
|
||||||
|
|
||||||
|
// Nächste Standardwerte für neue Objekte
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef OBJ_FILEPARSER_H_INC
|
#ifndef OBJ_FILEPARSER_H_INC
|
||||||
#define OBJ_FILEPARSER_H_INC
|
#define OBJ_FILEPARSER_H_INC
|
||||||
|
|
||||||
|
@ -38,8 +79,8 @@ private:
|
||||||
void parseFile();
|
void parseFile();
|
||||||
void copyNextWord(char *pBuffer, size_t length);
|
void copyNextWord(char *pBuffer, size_t length);
|
||||||
void copyNextLine(char *pBuffer, size_t length);
|
void copyNextLine(char *pBuffer, size_t length);
|
||||||
void getVector3(std::vector<aiVector3D_t*> &point3d_array);
|
void getVector3(std::vector<aiVector3D*> &point3d_array);
|
||||||
void getVector2(std::vector<aiVector2D_t*> &point2d_array);
|
void getVector2(std::vector<aiVector2D*> &point2d_array);
|
||||||
void skipLine();
|
void skipLine();
|
||||||
void getFace();
|
void getFace();
|
||||||
void getMaterialDesc();
|
void getMaterialDesc();
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the data structures in which the imported animations are returned. */
|
/** @file Defines the data structures in which the imported animations are returned. */
|
||||||
#ifndef AI_ANIM_H_INC
|
#ifndef AI_ANIM_H_INC
|
||||||
#define AI_ANIM_H_INC
|
#define AI_ANIM_H_INC
|
||||||
|
@ -13,7 +54,7 @@ extern "C" {
|
||||||
struct aiVectorKey
|
struct aiVectorKey
|
||||||
{
|
{
|
||||||
double mTime; ///< The time of this key
|
double mTime; ///< The time of this key
|
||||||
aiVector3D_t mValue; ///< The value of this key
|
C_STRUCT aiVector3D mValue; ///< The value of this key
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A time-value pair specifying a rotation for the given time. For joint animations
|
/** A time-value pair specifying a rotation for the given time. For joint animations
|
||||||
|
@ -22,7 +63,7 @@ struct aiVectorKey
|
||||||
struct aiQuatKey
|
struct aiQuatKey
|
||||||
{
|
{
|
||||||
double mTime; ///< The time of this key
|
double mTime; ///< The time of this key
|
||||||
aiQuaternion_t mValue; ///< The value of this key
|
C_STRUCT aiQuaternion mValue; ///< The value of this key
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Describes the animation of a single bone. The name specifies the bone which is affected by this
|
/** Describes the animation of a single bone. The name specifies the bone which is affected by this
|
||||||
|
@ -32,28 +73,28 @@ struct aiQuatKey
|
||||||
struct aiBoneAnim
|
struct aiBoneAnim
|
||||||
{
|
{
|
||||||
/** The name of the bone affected by this animation. */
|
/** The name of the bone affected by this animation. */
|
||||||
aiString mBoneName;
|
C_STRUCT aiString mBoneName;
|
||||||
|
|
||||||
/** The number of position keys */
|
/** The number of position keys */
|
||||||
unsigned int mNumPositionKeys;
|
unsigned int mNumPositionKeys;
|
||||||
/** The position keys of this animation channel. Positions are specified as 3D vector.
|
/** The position keys of this animation channel. Positions are specified as 3D vector.
|
||||||
* The array is mNumPositionKeys in size.
|
* The array is mNumPositionKeys in size.
|
||||||
*/
|
*/
|
||||||
aiVectorKey* mPositionKeys;
|
C_STRUCT aiVectorKey* mPositionKeys;
|
||||||
|
|
||||||
/** The number of rotation keys */
|
/** The number of rotation keys */
|
||||||
unsigned int mNumRotationKeys;
|
unsigned int mNumRotationKeys;
|
||||||
/** The rotation keys of this animation channel. Rotations are given as quaternions,
|
/** The rotation keys of this animation channel. Rotations are given as quaternions,
|
||||||
* which are 4D vectors. The array is mNumRotationKeys in size.
|
* which are 4D vectors. The array is mNumRotationKeys in size.
|
||||||
*/
|
*/
|
||||||
aiQuatKey* mRotationKeys;
|
C_STRUCT aiQuatKey* mRotationKeys;
|
||||||
|
|
||||||
/** The number of scaling keys */
|
/** The number of scaling keys */
|
||||||
unsigned int mNumScalingKeys;
|
unsigned int mNumScalingKeys;
|
||||||
/** The scaling keys of this animation channel. Scalings are specified as 3D vector.
|
/** The scaling keys of this animation channel. Scalings are specified as 3D vector.
|
||||||
* The array is mNumScalingKeys in size.
|
* The array is mNumScalingKeys in size.
|
||||||
*/
|
*/
|
||||||
aiVectorKey* mScalingKeys;
|
C_STRUCT aiVectorKey* mScalingKeys;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiBoneAnim()
|
aiBoneAnim()
|
||||||
|
@ -80,7 +121,7 @@ struct aiAnimation
|
||||||
/** The name of the animation. If the modelling package this data was exported from does support
|
/** The name of the animation. If the modelling package this data was exported from does support
|
||||||
* only a single animation channel, this name is usually empty (length is zero).
|
* only a single animation channel, this name is usually empty (length is zero).
|
||||||
*/
|
*/
|
||||||
aiString mName;
|
C_STRUCT aiString mName;
|
||||||
|
|
||||||
/** Duration of the animation in ticks. */
|
/** Duration of the animation in ticks. */
|
||||||
double mDuration;
|
double mDuration;
|
||||||
|
@ -92,7 +133,7 @@ struct aiAnimation
|
||||||
/** The bone animation channels. Each channel affects a single bone. The array
|
/** The bone animation channels. Each channel affects a single bone. The array
|
||||||
* is mNumBones in size.
|
* is mNumBones in size.
|
||||||
*/
|
*/
|
||||||
aiBoneAnim** mBones;
|
C_STRUCT aiBoneAnim** mBones;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiAnimation()
|
aiAnimation()
|
||||||
|
|
|
@ -1,6 +1,45 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines generic routines to access memory-mapped files
|
/** @file Defines generic routines to access memory-mapped files
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AI_FILEIO_H_INC
|
#ifndef AI_FILEIO_H_INC
|
||||||
|
@ -14,11 +53,11 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
struct aiFileIO;
|
struct aiFileIO;
|
||||||
//enum aiOrigin;
|
|
||||||
typedef aiFileIO (*aiFileOpenProc)(aiFileIO*, const char*, const char*);
|
typedef aiFileIO (*aiFileOpenProc)(C_STRUCT aiFileIO*, const char*, const char*);
|
||||||
typedef aiReturn (*aiFileCloseProc)(aiFileIO*);
|
typedef aiReturn (*aiFileCloseProc)(C_STRUCT aiFileIO*);
|
||||||
typedef unsigned long (*aiFileReadWriteProc)(aiFileIO*, char*, unsigned int, unsigned int);
|
typedef unsigned long (*aiFileReadWriteProc)(C_STRUCT aiFileIO*, char*, unsigned int, unsigned int);
|
||||||
typedef unsigned long (*aiFileTellProc)(aiFileIO*);
|
typedef unsigned long (*aiFileTellProc)(C_STRUCT aiFileIO*);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Define seek origins in fseek()-style.
|
/** Define seek origins in fseek()-style.
|
||||||
|
@ -44,13 +83,27 @@ typedef char* aiUserData;
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct aiFileIO
|
struct aiFileIO
|
||||||
{
|
{
|
||||||
|
//! User data assigned to the structure
|
||||||
aiUserData UserData;
|
aiUserData UserData;
|
||||||
|
|
||||||
|
//! Function used to open a new file
|
||||||
aiFileOpenProc OpenFunc;
|
aiFileOpenProc OpenFunc;
|
||||||
|
|
||||||
|
//! Function used to close an existing file
|
||||||
aiFileCloseProc CloseFunc;
|
aiFileCloseProc CloseFunc;
|
||||||
|
|
||||||
|
//! Function used to read from a file
|
||||||
aiFileReadWriteProc ReadFunc;
|
aiFileReadWriteProc ReadFunc;
|
||||||
|
|
||||||
|
//! Function used to write to a file
|
||||||
aiFileReadWriteProc WriteFunc;
|
aiFileReadWriteProc WriteFunc;
|
||||||
|
|
||||||
|
//! Function used to retrieve the current
|
||||||
|
//! position of the file cursor (ftell())
|
||||||
aiFileTellProc TellProc;
|
aiFileTellProc TellProc;
|
||||||
|
|
||||||
|
//! Function used to set the current position
|
||||||
|
//! of the file cursor (fseek())
|
||||||
aiFileSeek SeekProc;
|
aiFileSeek SeekProc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,43 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the material system of the library
|
/** @file Defines the material system of the library
|
||||||
*
|
*
|
||||||
|
@ -24,57 +63,51 @@ enum aiPropertyTypeInfo
|
||||||
*/
|
*/
|
||||||
aiPTI_Float = 0x1,
|
aiPTI_Float = 0x1,
|
||||||
|
|
||||||
|
|
||||||
/** aiString data structure
|
/** aiString data structure
|
||||||
*/
|
*/
|
||||||
aiPTI_String = 0x3,
|
aiPTI_String = 0x3,
|
||||||
|
|
||||||
|
|
||||||
/** Array of Integers
|
/** Array of Integers
|
||||||
*/
|
*/
|
||||||
aiPTI_Integer = 0x4,
|
aiPTI_Integer = 0x4,
|
||||||
|
|
||||||
|
|
||||||
/** Simple binary buffer
|
/** Simple binary buffer
|
||||||
*/
|
*/
|
||||||
aiPTI_Buffer = 0x5,
|
aiPTI_Buffer = 0x5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Defines algorithms for generating UVW-coords (for texture sampling)
|
/** Defines texture operations like add, mul ...
|
||||||
* procedurally.
|
*
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
enum aiTexUVWGen
|
enum aiTextureOp
|
||||||
{
|
{
|
||||||
/** The view vector will be reflected to a pixel's normal.
|
/** T = T1 * T2
|
||||||
*
|
*/
|
||||||
* The result is used as UVW-coordinate for
|
aiTextureOp_Multiply = 0x0,
|
||||||
* accessing a cubemap
|
|
||||||
*/
|
|
||||||
aiTexUVWGen_VIEWREFLEFT = 0x800001,
|
|
||||||
|
|
||||||
|
/** T = T1 + T2
|
||||||
|
*/
|
||||||
|
aiTextureOp_Add = 0x1,
|
||||||
|
|
||||||
/** The view vector will be used as UVW-src
|
/** T = T1 - T2
|
||||||
*
|
*/
|
||||||
* The view vector is used as UVW-coordinate for
|
aiTextureOp_Subtract = 0x2,
|
||||||
* accessing a cubemap
|
|
||||||
*/
|
|
||||||
aiTexUVWGen_VIEW = 0x800002,
|
|
||||||
|
|
||||||
|
/** T = T1 / T2
|
||||||
|
*/
|
||||||
|
aiTextureOp_Divide = 0x3,
|
||||||
|
|
||||||
/** The view vector will be refracted to the pixel's normal.
|
/** T = (T1 + T2) - (T1 * T2)
|
||||||
*
|
*/
|
||||||
* If this is used, the refraction index to be applied should
|
aiTextureOp_SmoothAdd = 0x4,
|
||||||
* also be contained in the material description.
|
|
||||||
* The result is used as UVW-coordinate for
|
/** T = T1 + (T2-0.5)
|
||||||
* accessing a cubemap.
|
*/
|
||||||
*/
|
aiTextureOp_SignedAdd = 0x5
|
||||||
aiTexUVWGen_VIEWREFRACT = 0x800003
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Defines all shading models supported by the library
|
/** Defines all shading models supported by the library
|
||||||
*
|
*
|
||||||
|
@ -92,12 +125,10 @@ enum aiShadingMode
|
||||||
*/
|
*/
|
||||||
aiShadingMode_Flat = 0x1,
|
aiShadingMode_Flat = 0x1,
|
||||||
|
|
||||||
|
|
||||||
/** Diffuse gouraud shading. Shading on per-vertex base
|
/** Diffuse gouraud shading. Shading on per-vertex base
|
||||||
*/
|
*/
|
||||||
aiShadingMode_Gouraud = 0x2,
|
aiShadingMode_Gouraud = 0x2,
|
||||||
|
|
||||||
|
|
||||||
/** Diffuse/Specular Phong-Shading
|
/** Diffuse/Specular Phong-Shading
|
||||||
*
|
*
|
||||||
* Shading is applied on per-pixel base. This is the
|
* Shading is applied on per-pixel base. This is the
|
||||||
|
@ -105,7 +136,6 @@ enum aiShadingMode
|
||||||
*/
|
*/
|
||||||
aiShadingMode_Phong = 0x3,
|
aiShadingMode_Phong = 0x3,
|
||||||
|
|
||||||
|
|
||||||
/** Diffuse/Specular Phong-Blinn-Shading
|
/** Diffuse/Specular Phong-Blinn-Shading
|
||||||
*
|
*
|
||||||
* Shading is applied on per-pixel base. This is a little
|
* Shading is applied on per-pixel base. This is a little
|
||||||
|
@ -114,7 +144,6 @@ enum aiShadingMode
|
||||||
*/
|
*/
|
||||||
aiShadingMode_Blinn = 0x4,
|
aiShadingMode_Blinn = 0x4,
|
||||||
|
|
||||||
|
|
||||||
/** Toon-Shading per pixel
|
/** Toon-Shading per pixel
|
||||||
*
|
*
|
||||||
* Shading is applied on per-pixel base. The output looks
|
* Shading is applied on per-pixel base. The output looks
|
||||||
|
@ -122,7 +151,6 @@ enum aiShadingMode
|
||||||
*/
|
*/
|
||||||
aiShadingMode_Toon = 0x5,
|
aiShadingMode_Toon = 0x5,
|
||||||
|
|
||||||
|
|
||||||
/** OrenNayar-Shading per pixel
|
/** OrenNayar-Shading per pixel
|
||||||
*
|
*
|
||||||
* Extension to standard lambertian shading, taking the
|
* Extension to standard lambertian shading, taking the
|
||||||
|
@ -131,7 +159,6 @@ enum aiShadingMode
|
||||||
*/
|
*/
|
||||||
aiShadingMode_OrenNayar = 0x6,
|
aiShadingMode_OrenNayar = 0x6,
|
||||||
|
|
||||||
|
|
||||||
/** Minnaert-Shading per pixel
|
/** Minnaert-Shading per pixel
|
||||||
*
|
*
|
||||||
* Extension to standard lambertian shading, taking the
|
* Extension to standard lambertian shading, taking the
|
||||||
|
@ -139,12 +166,10 @@ enum aiShadingMode
|
||||||
*/
|
*/
|
||||||
aiShadingMode_Minnaert = 0x7,
|
aiShadingMode_Minnaert = 0x7,
|
||||||
|
|
||||||
|
|
||||||
/** CookTorrance-Shading per pixel
|
/** CookTorrance-Shading per pixel
|
||||||
*/
|
*/
|
||||||
aiShadingMode_CookTorrance = 0x8,
|
aiShadingMode_CookTorrance = 0x8,
|
||||||
|
|
||||||
|
|
||||||
/** No shading at all
|
/** No shading at all
|
||||||
*/
|
*/
|
||||||
aiShadingMode_NoShading = 0x8
|
aiShadingMode_NoShading = 0x8
|
||||||
|
@ -163,14 +188,12 @@ struct aiMaterialProperty
|
||||||
*
|
*
|
||||||
* Keys are case insensitive.
|
* Keys are case insensitive.
|
||||||
*/
|
*/
|
||||||
aiString* mKey;
|
C_STRUCT aiString* mKey;
|
||||||
|
|
||||||
|
|
||||||
/** Size of the buffer mData is pointing to, in bytes
|
/** Size of the buffer mData is pointing to, in bytes
|
||||||
*/
|
*/
|
||||||
unsigned int mDataLength;
|
unsigned int mDataLength;
|
||||||
|
|
||||||
|
|
||||||
/** Type information for the property.
|
/** Type information for the property.
|
||||||
*
|
*
|
||||||
* Defines the data layout inside the
|
* Defines the data layout inside the
|
||||||
|
@ -179,7 +202,6 @@ struct aiMaterialProperty
|
||||||
*/
|
*/
|
||||||
aiPropertyTypeInfo mType;
|
aiPropertyTypeInfo mType;
|
||||||
|
|
||||||
|
|
||||||
/** Binary buffer to hold the property's value
|
/** Binary buffer to hold the property's value
|
||||||
*
|
*
|
||||||
* The buffer has no terminal character. However,
|
* The buffer has no terminal character. However,
|
||||||
|
@ -199,19 +221,17 @@ struct aiMaterialProperty
|
||||||
* for nearly all purposes.
|
* for nearly all purposes.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
#ifdef __cplusplus
|
struct aiMaterial
|
||||||
class aiMaterial
|
|
||||||
{
|
{
|
||||||
|
#ifdef __cplusplus
|
||||||
protected:
|
protected:
|
||||||
aiMaterial() {}
|
aiMaterial() {}
|
||||||
public:
|
public:
|
||||||
#else
|
|
||||||
struct aiMaterial
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
/** List of all material properties loaded.
|
/** List of all material properties loaded.
|
||||||
*/
|
*/
|
||||||
aiMaterialProperty** mProperties;
|
C_STRUCT aiMaterialProperty** mProperties;
|
||||||
|
|
||||||
/** Number of properties loaded
|
/** Number of properties loaded
|
||||||
*/
|
*/
|
||||||
|
@ -231,6 +251,11 @@ struct aiMaterial
|
||||||
*/
|
*/
|
||||||
#define AI_MATKEY_SHADING_MODEL "$mat.shadingm"
|
#define AI_MATKEY_SHADING_MODEL "$mat.shadingm"
|
||||||
|
|
||||||
|
/** @def AI_MATKEY_ENABLE_WIREFRAM
|
||||||
|
* Integer property. 1 to enable wireframe for rendering
|
||||||
|
*/
|
||||||
|
#define AI_MATKEY_ENABLE_WIREFRAME "$mat.wireframe"
|
||||||
|
|
||||||
/** @def AI_MATKEY_OPACITY
|
/** @def AI_MATKEY_OPACITY
|
||||||
* Defines the base opacity of the material
|
* Defines the base opacity of the material
|
||||||
*/
|
*/
|
||||||
|
@ -297,15 +322,15 @@ struct aiMaterial
|
||||||
#define AI_MATKEY_TEXTURE_NORMALS(N) "$tex.file.normals["#N"]"
|
#define AI_MATKEY_TEXTURE_NORMALS(N) "$tex.file.normals["#N"]"
|
||||||
#define AI_MATKEY_TEXTURE_NORMALS_ "$tex.file.normals"
|
#define AI_MATKEY_TEXTURE_NORMALS_ "$tex.file.normals"
|
||||||
|
|
||||||
/** @def AI_MATKEY_TEXTURE_BUMP
|
/** @def AI_MATKEY_TEXTURE_HEIGHT
|
||||||
* Defines a specified bumpmap texture (=heightmap) channel of the material
|
* Defines a specified bumpmap texture (=heightmap) channel of the material
|
||||||
* This is very similar to #AI_MATKEY_TEXTURE_NORMALS. It is provided
|
* This is very similar to #AI_MATKEY_TEXTURE_NORMALS. It is provided
|
||||||
* to allow applications to determine whether the input data for
|
* to allow applications to determine whether the input data for
|
||||||
* normal mapping is already a normal map or needs to be converted to
|
* normal mapping is already a normal map or needs to be converted from
|
||||||
* a heightmap.
|
* a heightmap to a normal map.
|
||||||
*/
|
*/
|
||||||
#define AI_MATKEY_TEXTURE_BUMP(N) "$tex.file.bump["#N"]"
|
#define AI_MATKEY_TEXTURE_HEIGHT(N) "$tex.file.bump["#N"]"
|
||||||
#define AI_MATKEY_TEXTURE_BUMP_ "$tex.file.bump"
|
#define AI_MATKEY_TEXTURE_HEIGHT_ "$tex.file.bump"
|
||||||
|
|
||||||
/** @def AI_MATKEY_TEXTURE_SHININESS
|
/** @def AI_MATKEY_TEXTURE_SHININESS
|
||||||
* Defines a specified shininess texture channel of the material
|
* Defines a specified shininess texture channel of the material
|
||||||
|
@ -325,37 +350,55 @@ struct aiMaterial
|
||||||
#define AI_MATKEY_TEXOP_SPECULAR(N) "$tex.op.specular["#N"]"
|
#define AI_MATKEY_TEXOP_SPECULAR(N) "$tex.op.specular["#N"]"
|
||||||
#define AI_MATKEY_TEXOP_EMISSIVE(N) "$tex.op.emissive["#N"]"
|
#define AI_MATKEY_TEXOP_EMISSIVE(N) "$tex.op.emissive["#N"]"
|
||||||
#define AI_MATKEY_TEXOP_NORMALS(N) "$tex.op.normals["#N"]"
|
#define AI_MATKEY_TEXOP_NORMALS(N) "$tex.op.normals["#N"]"
|
||||||
#define AI_MATKEY_TEXOP_BUMP(N) "$tex.op.bump["#N"]"
|
#define AI_MATKEY_TEXOP_HEIGHT(N) "$tex.op.bump["#N"]"
|
||||||
#define AI_MATKEY_TEXOP_SHININESS(N) "$tex.op.shininess["#N"]"
|
#define AI_MATKEY_TEXOP_SHININESS(N) "$tex.op.shininess["#N"]"
|
||||||
#define AI_MATKEY_TEXOP_OPACITY(N) "$tex.op.opacity["#N"]"
|
#define AI_MATKEY_TEXOP_OPACITY(N) "$tex.op.opacity["#N"]"
|
||||||
|
|
||||||
|
#define AI_MATKEY_TEXOP_DIFFUSE_ "$tex.op.diffuse"
|
||||||
|
#define AI_MATKEY_TEXOP_AMBIENT_ "$tex.op.ambient"
|
||||||
|
#define AI_MATKEY_TEXOP_SPECULAR_ "$tex.op.specular"
|
||||||
|
#define AI_MATKEY_TEXOP_EMISSIVE_ "$tex.op.emissive"
|
||||||
|
#define AI_MATKEY_TEXOP_NORMALS_ "$tex.op.normals"
|
||||||
|
#define AI_MATKEY_TEXOP_HEIGHT_ "$tex.op.bump"
|
||||||
|
#define AI_MATKEY_TEXOP_SHININESS_ "$tex.op.shininess"
|
||||||
|
#define AI_MATKEY_TEXOP_OPACITY_ "$tex.op.opacity"
|
||||||
|
|
||||||
#define AI_MATKEY_UVWSRC_DIFFUSE(N) "$tex.uvw.diffuse["#N"]"
|
#define AI_MATKEY_UVWSRC_DIFFUSE(N) "$tex.uvw.diffuse["#N"]"
|
||||||
#define AI_MATKEY_UVWSRC_AMBIENT(N) "$tex.uvw.ambient["#N"]"
|
#define AI_MATKEY_UVWSRC_AMBIENT(N) "$tex.uvw.ambient["#N"]"
|
||||||
#define AI_MATKEY_UVWSRC_SPECULAR(N) "$tex.uvw.specular["#N"]"
|
#define AI_MATKEY_UVWSRC_SPECULAR(N) "$tex.uvw.specular["#N"]"
|
||||||
#define AI_MATKEY_UVWSRC_EMISSIVE(N) "$tex.uvw.emissive["#N"]"
|
#define AI_MATKEY_UVWSRC_EMISSIVE(N) "$tex.uvw.emissive["#N"]"
|
||||||
#define AI_MATKEY_UVWSRC_NORMALS(N) "$tex.uvw.normals["#N"]"
|
#define AI_MATKEY_UVWSRC_NORMALS(N) "$tex.uvw.normals["#N"]"
|
||||||
#define AI_MATKEY_UVWSRC_BUMP(N) "$tex.uvw.bump["#N"]"
|
#define AI_MATKEY_UVWSRC_HEIGHT(N) "$tex.uvw.bump["#N"]"
|
||||||
#define AI_MATKEY_UVWSRC_SHININESS(N) "$tex.uvw.shininess["#N"]"
|
#define AI_MATKEY_UVWSRC_SHININESS(N) "$tex.uvw.shininess["#N"]"
|
||||||
#define AI_MATKEY_UVWSRC_OPACITY(N) "$tex.uvw.opacity["#N"]"
|
#define AI_MATKEY_UVWSRC_OPACITY(N) "$tex.uvw.opacity["#N"]"
|
||||||
|
|
||||||
#define AI_MATKEY_REFRACTI_DIFFUSE(N) "$tex.refracti.diffuse["#N"]"
|
#define AI_MATKEY_UVWSRC_DIFFUSE_ "$tex.uvw.diffuse"
|
||||||
#define AI_MATKEY_REFRACTI_AMBIENT(N) "$tex.refracti.ambient["#N"]"
|
#define AI_MATKEY_UVWSRC_AMBIENT_ "$tex.uvw.ambient"
|
||||||
#define AI_MATKEY_REFRACTI_SPECULAR(N) "$tex.refracti.specular["#N"]"
|
#define AI_MATKEY_UVWSRC_SPECULAR_ "$tex.uvw.specular"
|
||||||
#define AI_MATKEY_REFRACTI_EMISSIVE(N) "$tex.refracti.emissive["#N"]"
|
#define AI_MATKEY_UVWSRC_EMISSIVE_ "$tex.uvw.emissive"
|
||||||
#define AI_MATKEY_REFRACTI_NORMALS(N) "$tex.refracti.normals["#N"]"
|
#define AI_MATKEY_UVWSRC_NORMALS_ "$tex.uvw.normals"
|
||||||
#define AI_MATKEY_REFRACTI_BUMP(N) "$tex.refracti.bump["#N"]"
|
#define AI_MATKEY_UVWSRC_HEIGHT_ "$tex.uvw.bump"
|
||||||
#define AI_MATKEY_REFRACTI_SHININESS(N) "$tex.refracti.shininess["#N"]"
|
#define AI_MATKEY_UVWSRC_SHININESS_ "$tex.uvw.shininess"
|
||||||
#define AI_MATKEY_REFRACTI_OPACITY(N) "$tex.refracti.opacity["#N"]"
|
#define AI_MATKEY_UVWSRC_OPACITY_ "$tex.uvw.opacity"
|
||||||
|
|
||||||
#define AI_MATKEY_TEXBLEND_DIFFUSE(N) "$tex.blend.diffuse["#N"]"
|
#define AI_MATKEY_TEXBLEND_DIFFUSE(N) "$tex.blend.diffuse["#N"]"
|
||||||
#define AI_MATKEY_TEXBLEND_AMBIENT(N) "$tex.blend.ambient["#N"]"
|
#define AI_MATKEY_TEXBLEND_AMBIENT(N) "$tex.blend.ambient["#N"]"
|
||||||
#define AI_MATKEY_TEXBLEND_SPECULAR(N) "$tex.blend.specular["#N"]"
|
#define AI_MATKEY_TEXBLEND_SPECULAR(N) "$tex.blend.specular["#N"]"
|
||||||
#define AI_MATKEY_TEXBLEND_EMISSIVE(N) "$tex.blend.emissive["#N"]"
|
#define AI_MATKEY_TEXBLEND_EMISSIVE(N) "$tex.blend.emissive["#N"]"
|
||||||
#define AI_MATKEY_TEXBLEND_NORMALS(N) "$tex.blend.normals["#N"]"
|
#define AI_MATKEY_TEXBLEND_NORMALS(N) "$tex.blend.normals["#N"]"
|
||||||
#define AI_MATKEY_TEXBLEND_BUMP(N) "$tex.blend.bump["#N"]"
|
#define AI_MATKEY_TEXBLEND_HEIGHT(N) "$tex.blend.bump["#N"]"
|
||||||
#define AI_MATKEY_TEXBLEND_SHININESS(N) "$tex.blend.shininess["#N"]"
|
#define AI_MATKEY_TEXBLEND_SHININESS(N) "$tex.blend.shininess["#N"]"
|
||||||
#define AI_MATKEY_TEXBLEND_OPACITY(N) "$tex.blend.opacity["#N"]"
|
#define AI_MATKEY_TEXBLEND_OPACITY(N) "$tex.blend.opacity["#N"]"
|
||||||
|
|
||||||
|
#define AI_MATKEY_TEXBLEND_DIFFUSE_ "$tex.blend.diffuse"
|
||||||
|
#define AI_MATKEY_TEXBLEND_AMBIENT_ "$tex.blend.ambient"
|
||||||
|
#define AI_MATKEY_TEXBLEND_SPECULAR_ "$tex.blend.specular"
|
||||||
|
#define AI_MATKEY_TEXBLEND_EMISSIVE_ "$tex.blend.emissive"
|
||||||
|
#define AI_MATKEY_TEXBLEND_NORMALS_ "$tex.blend.normals"
|
||||||
|
#define AI_MATKEY_TEXBLEND_HEIGHT_ "$tex.blend.bump"
|
||||||
|
#define AI_MATKEY_TEXBLEND_SHININESS_ "$tex.blend.shininess"
|
||||||
|
#define AI_MATKEY_TEXBLEND_OPACITY_ "$tex.blend.opacity"
|
||||||
|
|
||||||
|
|
||||||
#define AI_MATKEY_ORENNAYAR_ROUGHNESS "$shading.orennayar.roughness"
|
#define AI_MATKEY_ORENNAYAR_ROUGHNESS "$shading.orennayar.roughness"
|
||||||
#define AI_MATKEY_MINNAERT_DARKNESS "$shading.minnaert.darkness"
|
#define AI_MATKEY_MINNAERT_DARKNESS "$shading.minnaert.darkness"
|
||||||
|
@ -379,9 +422,9 @@ struct aiMaterial
|
||||||
* structure or NULL if the key has not been found.
|
* structure or NULL if the key has not been found.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
|
aiReturn aiGetMaterialProperty(const C_STRUCT aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
const aiMaterialProperty** pPropOut);
|
const C_STRUCT aiMaterialProperty** pPropOut);
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -395,16 +438,16 @@ aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
|
||||||
* Receives the number of values (not bytes!) read.
|
* Receives the number of values (not bytes!) read.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
|
aiReturn aiGetMaterialFloatArray(const C_STRUCT aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
float* pOut,
|
float* pOut,
|
||||||
unsigned int* pMax);
|
unsigned int* pMax);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
// inline it
|
// inline it
|
||||||
inline aiReturn aiGetMaterialFloat(const aiMaterial* pMat,
|
inline aiReturn aiGetMaterialFloat(const C_STRUCT aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
float* pOut)
|
float* pOut)
|
||||||
{return aiGetMaterialFloatArray(pMat,pKey,pOut,(unsigned int*)0x0);}
|
{return aiGetMaterialFloatArray(pMat,pKey,pOut,(unsigned int*)0x0);}
|
||||||
#else
|
#else
|
||||||
// use our friend, the C preprocessor
|
// use our friend, the C preprocessor
|
||||||
|
@ -424,16 +467,16 @@ inline aiReturn aiGetMaterialFloat(const aiMaterial* pMat,
|
||||||
* Receives the number of values (not bytes!) read.
|
* Receives the number of values (not bytes!) read.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
|
aiReturn aiGetMaterialIntegerArray(const C_STRUCT aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
int* pOut,
|
int* pOut,
|
||||||
unsigned int* pMax);
|
unsigned int* pMax);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
// inline it
|
// inline it
|
||||||
inline aiReturn aiGetMaterialInteger(const aiMaterial* pMat,
|
inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
int* pOut)
|
int* pOut)
|
||||||
{return aiGetMaterialIntegerArray(pMat,pKey,pOut,(unsigned int*)0x0);}
|
{return aiGetMaterialIntegerArray(pMat,pKey,pOut,(unsigned int*)0x0);}
|
||||||
#else
|
#else
|
||||||
// use our friend, the C preprocessor
|
// use our friend, the C preprocessor
|
||||||
|
@ -451,9 +494,9 @@ inline aiReturn aiGetMaterialInteger(const aiMaterial* pMat,
|
||||||
* @param pOut Pointer to a buffer to receive the result.
|
* @param pOut Pointer to a buffer to receive the result.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
aiReturn aiGetMaterialColor(const aiMaterial* pMat,
|
aiReturn aiGetMaterialColor(const C_STRUCT aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
aiColor4D* pOut);
|
aiColor4D* pOut);
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -464,9 +507,46 @@ aiReturn aiGetMaterialColor(const aiMaterial* pMat,
|
||||||
* @param pOut Pointer to a buffer to receive the result.
|
* @param pOut Pointer to a buffer to receive the result.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
aiReturn aiGetMaterialString(const aiMaterial* pMat,
|
aiReturn aiGetMaterialString(const C_STRUCT aiMaterial* pMat,
|
||||||
const char* pKey,
|
const char* pKey,
|
||||||
aiString* pOut);
|
aiString* pOut);
|
||||||
|
|
||||||
|
|
||||||
|
#define AI_TEXTYPE_DIFFUSE 0x0
|
||||||
|
#define AI_TEXTYPE_SPECULAR 0x1
|
||||||
|
#define AI_TEXTYPE_AMBIENT 0x2
|
||||||
|
#define AI_TEXTYPE_EMISSIVE 0x3
|
||||||
|
#define AI_TEXTYPE_HEIGHT 0x4
|
||||||
|
#define AI_TEXTYPE_NORMALS 0x5
|
||||||
|
#define AI_TEXTYPE_SHININESS 0x6
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Helper function to get a diffuse texture from a material
|
||||||
|
*
|
||||||
|
* This function is provided just for convinience.
|
||||||
|
* @param pMat Pointer to the input material. May not be NULL
|
||||||
|
* @param iIndex Index of the texture to retrieve. If the index is too
|
||||||
|
* large the function fails.
|
||||||
|
* @param iTexType One of the AI_TEXTYPE constants. Specifies the type of
|
||||||
|
* the texture to retrieve (e.g. diffuse, specular, height map ...)
|
||||||
|
* @param szPath Receives the output path
|
||||||
|
* NULL is no allowed as value
|
||||||
|
* @param piUVIndex Receives the UV index of the texture.
|
||||||
|
* NULL is allowed as value.
|
||||||
|
* @param pfBlendFactor Receives the blend factor for the texture
|
||||||
|
* NULL is allowed as value.
|
||||||
|
* @param peTextureOp Receives the texture operation to perform between
|
||||||
|
* this texture and the previous texture.
|
||||||
|
* NULL is allowed as value.
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* pMat,
|
||||||
|
unsigned int iIndex,
|
||||||
|
unsigned int iTexType,
|
||||||
|
C_STRUCT aiString* szPath,
|
||||||
|
unsigned int* piUVIndex,
|
||||||
|
float* pfBlendFactor,
|
||||||
|
aiTextureOp* peTextureOp);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct aiMatrix4x4;
|
||||||
/** Represents a column-major 3x3 matrix
|
/** Represents a column-major 3x3 matrix
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
typedef struct aiMatrix3x3
|
struct aiMatrix3x3
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiMatrix3x3 () :
|
aiMatrix3x3 () :
|
||||||
|
@ -41,7 +41,7 @@ typedef struct aiMatrix3x3
|
||||||
float a1, a2, a3;
|
float a1, a2, a3;
|
||||||
float b1, b2, b3;
|
float b1, b2, b3;
|
||||||
float c1, c2, c3;
|
float c1, c2, c3;
|
||||||
} aiMatrix3x3_t;
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // end of extern C
|
} // end of extern C
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct aiMatrix3x3;
|
||||||
* use this for homogenious coordinates
|
* use this for homogenious coordinates
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
typedef struct aiMatrix4x4
|
struct aiMatrix4x4
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiMatrix4x4 () :
|
aiMatrix4x4 () :
|
||||||
|
@ -60,7 +60,7 @@ typedef struct aiMatrix4x4
|
||||||
float c1, c2, c3, c4;
|
float c1, c2, c3, c4;
|
||||||
float d1, d2, d3, d4;
|
float d1, d2, d3, d4;
|
||||||
|
|
||||||
} PACK_STRUCT aiMatrix4x4_t;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
// Reset packing
|
// Reset packing
|
||||||
|
|
193
include/aiMesh.h
193
include/aiMesh.h
|
@ -1,4 +1,46 @@
|
||||||
/** @file Defines the data structures in which the imported geometry is returned. */
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Defines the data structures in which the imported geometry is
|
||||||
|
returned by ASSIMP */
|
||||||
#ifndef AI_MESH_H_INC
|
#ifndef AI_MESH_H_INC
|
||||||
#define AI_MESH_H_INC
|
#define AI_MESH_H_INC
|
||||||
|
|
||||||
|
@ -10,31 +52,43 @@ extern "C" {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** A single face in a mesh, referring to multiple vertices.
|
/** A single face in a mesh, referring to multiple vertices.
|
||||||
* If mNumIndices is 3, the face is a triangle, for mNumIndices > 3 it's a polygon.
|
*
|
||||||
|
* If mNumIndices is 3, the face is a triangle,
|
||||||
|
* for mNumIndices > 3 it's a polygon.
|
||||||
|
* Point and line primitives are rarely used and are NOT supported. However,
|
||||||
|
* a load could pass them as degenerated triangles.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct aiFace
|
struct aiFace
|
||||||
{
|
{
|
||||||
unsigned int mNumIndices; ///< Number of indices defining this face. 3 for a triangle, >3 for polygon
|
//! Number of indices defining this face. 3 for a triangle, >3 for polygon
|
||||||
unsigned int* mIndices; ///< Pointer to the indices array. Size of the array is given in numIndices.
|
unsigned int mNumIndices;
|
||||||
|
|
||||||
|
//! Pointer to the indices array. Size of the array is given in numIndices.
|
||||||
|
unsigned int* mIndices;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
aiFace()
|
aiFace()
|
||||||
{
|
{
|
||||||
mNumIndices = 0; mIndices = NULL;
|
mNumIndices = 0; mIndices = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Default destructor. Delete the index array
|
||||||
~aiFace()
|
~aiFace()
|
||||||
{
|
{
|
||||||
delete [] mIndices;
|
delete [] mIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Copy constructor. Copy the index array
|
||||||
aiFace( const aiFace& o)
|
aiFace( const aiFace& o)
|
||||||
{
|
{
|
||||||
mIndices = NULL;
|
mIndices = NULL;
|
||||||
*this = o;
|
*this = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assignment operator. Copy the index array
|
||||||
const aiFace& operator = ( const aiFace& o)
|
const aiFace& operator = ( const aiFace& o)
|
||||||
{
|
{
|
||||||
if (&o == this)
|
if (&o == this)
|
||||||
|
@ -47,21 +101,58 @@ struct aiFace
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Comparison operator. Checks whether the index array
|
||||||
|
//! of two faces is identical
|
||||||
|
bool operator== (const aiFace& o) const
|
||||||
|
{
|
||||||
|
if (this->mIndices == o.mIndices)return true;
|
||||||
|
else if (this->mIndices && this->mNumIndices == o.mNumIndices)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0;i < this->mNumIndices;++i)
|
||||||
|
{
|
||||||
|
if (this->mIndices[i] != o.mIndices[i])return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Inverse comparison operator. Checks whether the index
|
||||||
|
//! array of two faces is NOT identical
|
||||||
|
bool operator != (const aiFace& o) const
|
||||||
|
{
|
||||||
|
return !(*this == o);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** A single influence of a bone on a vertex. */
|
/** A single influence of a bone on a vertex.
|
||||||
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct aiVertexWeight
|
struct aiVertexWeight
|
||||||
{
|
{
|
||||||
unsigned int mVertexId; ///< Index of the vertex which is influenced by the bone.
|
//! Index of the vertex which is influenced by the bone.
|
||||||
float mWeight; ///< The strength of the influence in the range (0...1). The influence from all bones at one vertex amounts to 1.
|
unsigned int mVertexId;
|
||||||
|
|
||||||
|
//! The strength of the influence in the range (0...1).
|
||||||
|
//! The influence from all bones at one vertex amounts to 1.
|
||||||
|
float mWeight;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
aiVertexWeight() { }
|
aiVertexWeight() { }
|
||||||
aiVertexWeight( unsigned int pID, float pWeight) : mVertexId( pID), mWeight( pWeight) { }
|
|
||||||
|
//! Initialisation from a given index and vertex weight factor
|
||||||
|
//! \param pID ID
|
||||||
|
//! \param pWeight Vertex weight factor
|
||||||
|
aiVertexWeight( unsigned int pID, float pWeight)
|
||||||
|
: mVertexId( pID), mWeight( pWeight)
|
||||||
|
{ /* nothing to do here */ }
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,17 +165,27 @@ struct aiVertexWeight
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
struct aiBone
|
struct aiBone
|
||||||
{
|
{
|
||||||
aiString mName; ///< The name of the bone.
|
//! The name of the bone.
|
||||||
unsigned int mNumWeights; ///< The number of vertices affected by this bone
|
C_STRUCT aiString mName;
|
||||||
aiVertexWeight* mWeights; ///< The vertices affected by this bone
|
|
||||||
aiMatrix4x4 mOffsetMatrix; ///< Matrix that transforms from mesh space to bone space in bind pose
|
//! The number of vertices affected by this bone
|
||||||
|
unsigned int mNumWeights;
|
||||||
|
|
||||||
|
//! The vertices affected by this bone
|
||||||
|
C_STRUCT aiVertexWeight* mWeights;
|
||||||
|
|
||||||
|
//! Matrix that transforms from mesh space to bone space in bind pose
|
||||||
|
C_STRUCT aiMatrix4x4 mOffsetMatrix;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
aiBone()
|
aiBone()
|
||||||
{
|
{
|
||||||
mNumWeights = 0; mWeights = NULL;
|
mNumWeights = 0; mWeights = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Destructor to delete the array of vertex weights
|
||||||
~aiBone()
|
~aiBone()
|
||||||
{
|
{
|
||||||
delete [] mWeights;
|
delete [] mWeights;
|
||||||
|
@ -92,31 +193,48 @@ struct aiBone
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if (!defined AI_MAX_NUMBER_OF_COLOR_SETS)
|
||||||
|
|
||||||
/** Maximum number of vertex color sets per mesh.
|
/** Maximum number of vertex color sets per mesh.
|
||||||
*
|
*
|
||||||
* Diffuse, specular, ambient and emissive
|
* Normally: Diffuse, specular, ambient and emissive
|
||||||
|
* However, one could use the vertex color sets for any other purpose, too.
|
||||||
|
*
|
||||||
|
* \note Some internal structures expect (and assert) this value
|
||||||
|
* to be at least 4
|
||||||
*/
|
*/
|
||||||
#define AI_MAX_NUMBER_OF_COLOR_SETS 0x4
|
#define AI_MAX_NUMBER_OF_COLOR_SETS 0x4
|
||||||
|
|
||||||
|
#endif // !! AI_MAX_NUMBER_OF_COLOR_SETS
|
||||||
|
#if (!defined AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||||
|
|
||||||
/** Maximum number of texture coord sets (UV channels) per mesh
|
/** Maximum number of texture coord sets (UV(W) channels) per mesh
|
||||||
|
*
|
||||||
|
* The material system uses the AI_MATKEY_UVWSRC_XXX keys to specify
|
||||||
|
* which UVW channel serves as data source for a texture,
|
||||||
|
*
|
||||||
|
* \note Some internal structures expect (and assert) this value
|
||||||
|
* to be at least 4
|
||||||
*/
|
*/
|
||||||
#define AI_MAX_NUMBER_OF_TEXTURECOORDS 0x4
|
#define AI_MAX_NUMBER_OF_TEXTURECOORDS 0x4
|
||||||
|
|
||||||
|
#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** A mesh represents a geometry or model with a single material.
|
/** A mesh represents a geometry or model with a single material.
|
||||||
*
|
*
|
||||||
* It usually consists of a number of vertices and a series of primitives/faces
|
* It usually consists of a number of vertices and a series of primitives/faces
|
||||||
* referencing the vertices. In addition there might be a series of bones, each
|
* referencing the vertices. In addition there might be a series of bones, each
|
||||||
* of them addressing a number of vertices with a certain weight. Vertex data is
|
* of them addressing a number of vertices with a certain weight. Vertex data
|
||||||
* presented in channels with each channel containing a single per-vertex
|
* is presented in channels with each channel containing a single per-vertex
|
||||||
* information such as a set of texture coords or a normal vector.
|
* information such as a set of texture coords or a normal vector.
|
||||||
* If a data pointer is non-null, the corresponding data stream is present.
|
* If a data pointer is non-null, the corresponding data stream is present.
|
||||||
* From C++-programs you can also use the comfort functions Has*() to
|
* From C++-programs you can also use the comfort functions Has*() to
|
||||||
* test for the presence of various data streams.
|
* test for the presence of various data streams.
|
||||||
*
|
*
|
||||||
* A Mesh uses only a single material which is referenced by a material ID.
|
* A Mesh uses only a single material which is referenced by a material ID.
|
||||||
|
* \note The mPositions member is not optional, although a Has()-Method is
|
||||||
|
* provided for it.
|
||||||
*/
|
*/
|
||||||
struct aiMesh
|
struct aiMesh
|
||||||
{
|
{
|
||||||
|
@ -134,13 +252,13 @@ struct aiMesh
|
||||||
* This array is always present in a mesh. The array is
|
* This array is always present in a mesh. The array is
|
||||||
* mNumVertices in size.
|
* mNumVertices in size.
|
||||||
*/
|
*/
|
||||||
aiVector3D_t* mVertices;
|
C_STRUCT aiVector3D* mVertices;
|
||||||
|
|
||||||
/** Vertex normals.
|
/** Vertex normals.
|
||||||
* The array contains normalized vectors, NULL if not present.
|
* The array contains normalized vectors, NULL if not present.
|
||||||
* The array is mNumVertices in size.
|
* The array is mNumVertices in size.
|
||||||
*/
|
*/
|
||||||
aiVector3D_t* mNormals;
|
C_STRUCT aiVector3D* mNormals;
|
||||||
|
|
||||||
/** Vertex tangents.
|
/** Vertex tangents.
|
||||||
* The tangent of a vertex points in the direction of the positive
|
* The tangent of a vertex points in the direction of the positive
|
||||||
|
@ -149,7 +267,7 @@ struct aiMesh
|
||||||
* @note If the mesh contains tangents, it automatically also
|
* @note If the mesh contains tangents, it automatically also
|
||||||
* contains bitangents.
|
* contains bitangents.
|
||||||
*/
|
*/
|
||||||
aiVector3D_t* mTangents;
|
C_STRUCT aiVector3D* mTangents;
|
||||||
|
|
||||||
/** Vertex bitangents.
|
/** Vertex bitangents.
|
||||||
* The bitangent of a vertex points in the direction of the positive
|
* The bitangent of a vertex points in the direction of the positive
|
||||||
|
@ -158,20 +276,20 @@ struct aiMesh
|
||||||
* @note If the mesh contains tangents, it automatically also contains
|
* @note If the mesh contains tangents, it automatically also contains
|
||||||
* bitangents.
|
* bitangents.
|
||||||
*/
|
*/
|
||||||
aiVector3D_t* mBitangents;
|
C_STRUCT aiVector3D* mBitangents;
|
||||||
|
|
||||||
/** Vertex color sets.
|
/** Vertex color sets.
|
||||||
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
|
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
|
||||||
* colors per vertex. NULL if not present. Each array is
|
* colors per vertex. NULL if not present. Each array is
|
||||||
* mNumVertices in size if present.
|
* mNumVertices in size if present.
|
||||||
*/
|
*/
|
||||||
aiColor4D_t* mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
C_STRUCT aiColor4D* mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
||||||
|
|
||||||
/** Vertex texture coords, also known as UV channels.
|
/** Vertex texture coords, also known as UV channels.
|
||||||
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
||||||
* vertex. NULL if not present. The array is mNumVertices in size.
|
* vertex. NULL if not present. The array is mNumVertices in size.
|
||||||
*/
|
*/
|
||||||
aiVector3D_t* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
C_STRUCT aiVector3D* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
|
||||||
/** Specifies the number of components for a given UV channel.
|
/** Specifies the number of components for a given UV channel.
|
||||||
* Up to three channels are supported (UVW, for accessing volume
|
* Up to three channels are supported (UVW, for accessing volume
|
||||||
|
@ -187,7 +305,7 @@ struct aiMesh
|
||||||
* This array is always present in a mesh, its size is given
|
* This array is always present in a mesh, its size is given
|
||||||
* in mNumFaces.
|
* in mNumFaces.
|
||||||
*/
|
*/
|
||||||
aiFace* mFaces;
|
C_STRUCT aiFace* mFaces;
|
||||||
|
|
||||||
/** The number of bones this mesh contains.
|
/** The number of bones this mesh contains.
|
||||||
* Can be 0, in which case the mBones array is NULL.
|
* Can be 0, in which case the mBones array is NULL.
|
||||||
|
@ -198,7 +316,7 @@ struct aiMesh
|
||||||
* A bone consists of a name by which it can be found in the
|
* A bone consists of a name by which it can be found in the
|
||||||
* frame hierarchy and a set of vertex weights.
|
* frame hierarchy and a set of vertex weights.
|
||||||
*/
|
*/
|
||||||
aiBone** mBones;
|
C_STRUCT aiBone** mBones;
|
||||||
|
|
||||||
/** The material used by this mesh.
|
/** The material used by this mesh.
|
||||||
* A mesh does use only a single material. If an imported model uses multiple materials,
|
* A mesh does use only a single material. If an imported model uses multiple materials,
|
||||||
|
@ -240,23 +358,40 @@ struct aiMesh
|
||||||
delete [] mBones;
|
delete [] mBones;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasNormals() const { return mNormals != NULL; }
|
//! Check whether the mesh contains positions. Should always return true
|
||||||
bool HasTangentsAndBitangents() const { return mTangents != NULL && mBitangents != NULL; }
|
inline bool HasPositions() const
|
||||||
bool HasVertexColors( unsigned int pIndex)
|
{ return mVertices != NULL; }
|
||||||
|
|
||||||
|
//! Check whether the mesh contains normal vectors
|
||||||
|
inline bool HasNormals() const
|
||||||
|
{ return mNormals != NULL; }
|
||||||
|
|
||||||
|
//! Check whether the mesh contains tangent and bitangent vectors
|
||||||
|
inline bool HasTangentsAndBitangents() const
|
||||||
|
{ return mTangents != NULL && mBitangents != NULL; }
|
||||||
|
|
||||||
|
//! Check whether the mesh contains a vertex color set
|
||||||
|
//! \param pIndex Index of the vertex color set
|
||||||
|
inline bool HasVertexColors( unsigned int pIndex)
|
||||||
{
|
{
|
||||||
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
|
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return mColors[pIndex] != NULL;
|
return mColors[pIndex] != NULL;
|
||||||
}
|
}
|
||||||
bool HasTextureCoords( unsigned int pIndex)
|
|
||||||
|
//! Check whether the mesh contains a texture coordinate set
|
||||||
|
//! \param pIndex Index of the texture coordinates set
|
||||||
|
inline bool HasTextureCoords( unsigned int pIndex)
|
||||||
{
|
{
|
||||||
if( pIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
if( pIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return mTextureCoords[pIndex] != NULL;
|
return mTextureCoords[pIndex] != NULL;
|
||||||
}
|
}
|
||||||
bool HasBones() const { return mBones != NULL; }
|
//! Check whether the mesh contains bones
|
||||||
|
inline bool HasBones() const
|
||||||
|
{ return mBones != NULL; }
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,49 @@
|
||||||
|
/*
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Definitions for import post processing steps */
|
/** @file Definitions for import post processing steps */
|
||||||
#ifndef AI_POSTPROCESS_H_INC
|
#ifndef AI_POSTPROCESS_H_INC
|
||||||
#define AI_POSTPROCESS_H_INC
|
#define AI_POSTPROCESS_H_INC
|
||||||
|
|
||||||
|
#include "aiTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,12 +107,37 @@ enum aiPostProcessSteps
|
||||||
* This is quite useful for realtime rendering where the number of vertices
|
* This is quite useful for realtime rendering where the number of vertices
|
||||||
* is usually limited by the video driver.
|
* is usually limited by the video driver.
|
||||||
*
|
*
|
||||||
* A mesh is split if it consists of more than 1 * 10^6 vertices. This is defined
|
* The split limits can be set through aiSetVertexSplitLimit() and
|
||||||
* in the internal SplitLargeMeshes.h header as AI_SLM_MAX_VERTICES.
|
* aiSetTriangleSplitLimit(). The default values for this are defined
|
||||||
|
* in the internal SplitLargeMeshes.h header as AI_SLM_DEFAULT_MAX_VERTICES
|
||||||
|
* and AI_SLM_DEFAULT_MAX_TRIANGLES.
|
||||||
*/
|
*/
|
||||||
aiProcess_SplitLargeMeshes = 0x80
|
aiProcess_SplitLargeMeshes = 0x80
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Set the maximum number of vertices in a mesh.
|
||||||
|
*
|
||||||
|
* This is used by the SplitLargeMeshes PostProcess-Step to determine
|
||||||
|
* whether a mesh must be splitted or not.
|
||||||
|
* \param pLimit Vertex limit.
|
||||||
|
* \note The default value is AI_SLM_DEFAULT_MAX_VERTICES, defined in
|
||||||
|
* the internal header file SplitLargeMeshes.h
|
||||||
|
*/
|
||||||
|
aiReturn aiSetVertexSplitLimit(unsigned int pLimit);
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \brief Set the maximum number of triangles in a mesh.
|
||||||
|
*
|
||||||
|
* This is used by the SplitLargeMeshes PostProcess-Step to determine
|
||||||
|
* whether a mesh must be splitted or not.
|
||||||
|
* \param pLimit Triangle limit
|
||||||
|
* \note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES, defined in
|
||||||
|
* the internal header file SplitLargeMeshes.h
|
||||||
|
*/
|
||||||
|
aiReturn aiSetTriangleSplitLimit(unsigned int pLimit);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // end of extern "C"
|
} // end of extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,7 +11,7 @@ extern "C" {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Represents a quaternion in a 4D vector. */
|
/** Represents a quaternion in a 4D vector. */
|
||||||
typedef struct aiQuaternion
|
struct aiQuaternion
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiQuaternion() : w(0.0f), x(0.0f), y(0.0f), z(0.0f) {}
|
aiQuaternion() : w(0.0f), x(0.0f), y(0.0f), z(0.0f) {}
|
||||||
|
@ -23,8 +23,9 @@ typedef struct aiQuaternion
|
||||||
aiMatrix3x3 GetMatrix() const;
|
aiMatrix3x3 GetMatrix() const;
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
//! w,x,y,z components of the quaternion
|
||||||
float w, x, y, z;
|
float w, x, y, z;
|
||||||
} aiQuaternion_t;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -33,43 +34,44 @@ typedef struct aiQuaternion
|
||||||
// Constructs a quaternion from a rotation matrix
|
// Constructs a quaternion from a rotation matrix
|
||||||
inline aiQuaternion::aiQuaternion( const aiMatrix3x3 &pRotMatrix)
|
inline aiQuaternion::aiQuaternion( const aiMatrix3x3 &pRotMatrix)
|
||||||
{
|
{
|
||||||
float t = 1 + pRotMatrix.a1 + pRotMatrix.b2 + pRotMatrix.c3;
|
float t = 1 + pRotMatrix.a1 + pRotMatrix.b2 + pRotMatrix.c3;
|
||||||
|
|
||||||
// large enough
|
// large enough
|
||||||
if( t > 0.00001f)
|
if( t > 0.00001f)
|
||||||
{
|
{
|
||||||
float s = sqrt( t) * 2.0f;
|
float s = sqrt( t) * 2.0f;
|
||||||
x = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
x = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
||||||
y = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
y = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
||||||
z = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
z = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
||||||
w = 0.25f * s;
|
w = 0.25f * s;
|
||||||
} // else we have to check several cases
|
} // else we have to check several cases
|
||||||
else if( pRotMatrix.a1 > pRotMatrix.b2 && pRotMatrix.a1 > pRotMatrix.c3 )
|
else if( pRotMatrix.a1 > pRotMatrix.b2 && pRotMatrix.a1 > pRotMatrix.c3 )
|
||||||
{
|
{
|
||||||
// Column 0:
|
// Column 0:
|
||||||
float s = sqrt( 1.0f + pRotMatrix.a1 - pRotMatrix.b2 - pRotMatrix.c3) * 2.0f;
|
float s = sqrt( 1.0f + pRotMatrix.a1 - pRotMatrix.b2 - pRotMatrix.c3) * 2.0f;
|
||||||
x = 0.25f * s;
|
x = 0.25f * s;
|
||||||
y = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
y = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
||||||
z = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
z = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
||||||
w = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
w = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
||||||
} else
|
}
|
||||||
if( pRotMatrix.b2 > pRotMatrix.c3)
|
else if( pRotMatrix.b2 > pRotMatrix.c3)
|
||||||
{
|
{
|
||||||
// Column 1:
|
// Column 1:
|
||||||
float s = sqrt( 1.0f + pRotMatrix.b2 - pRotMatrix.a1 - pRotMatrix.c3) * 2.0f;
|
float s = sqrt( 1.0f + pRotMatrix.b2 - pRotMatrix.a1 - pRotMatrix.c3) * 2.0f;
|
||||||
x = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
x = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
||||||
y = 0.25f * s;
|
y = 0.25f * s;
|
||||||
z = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
z = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
||||||
w = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
w = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
||||||
} else
|
}
|
||||||
{
|
else
|
||||||
// Column 2:
|
{
|
||||||
float s = sqrt( 1.0f + pRotMatrix.c3 - pRotMatrix.a1 - pRotMatrix.b2) * 2.0f;
|
// Column 2:
|
||||||
x = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
float s = sqrt( 1.0f + pRotMatrix.c3 - pRotMatrix.a1 - pRotMatrix.b2) * 2.0f;
|
||||||
y = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
x = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
||||||
z = 0.25f * s;
|
y = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
||||||
w = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
z = 0.25f * s;
|
||||||
}
|
w = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the data structures in which the imported scene is returned. */
|
/** @file Defines the data structures in which the imported scene is returned. */
|
||||||
#ifndef AI_SCENE_H_INC
|
#ifndef AI_SCENE_H_INC
|
||||||
#define AI_SCENE_H_INC
|
#define AI_SCENE_H_INC
|
||||||
|
@ -5,6 +46,7 @@
|
||||||
#include "aiTypes.h"
|
#include "aiTypes.h"
|
||||||
#include "aiMesh.h"
|
#include "aiMesh.h"
|
||||||
#include "aiMaterial.h"
|
#include "aiMaterial.h"
|
||||||
|
#include "aiTexture.h"
|
||||||
#include "aiAnim.h"
|
#include "aiAnim.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -28,19 +70,19 @@ struct aiNode
|
||||||
* The name might be empty (length of zero) but all nodes which
|
* The name might be empty (length of zero) but all nodes which
|
||||||
* need to be accessed afterwards by bones or anims are usually named.
|
* need to be accessed afterwards by bones or anims are usually named.
|
||||||
*/
|
*/
|
||||||
aiString mName;
|
C_STRUCT aiString mName;
|
||||||
|
|
||||||
/** The transformation relative to the node's parent. */
|
/** The transformation relative to the node's parent. */
|
||||||
aiMatrix4x4 mTransformation;
|
aiMatrix4x4 mTransformation;
|
||||||
|
|
||||||
/** Parent node. NULL if this node is the root node. */
|
/** Parent node. NULL if this node is the root node. */
|
||||||
aiNode* mParent;
|
C_STRUCT aiNode* mParent;
|
||||||
|
|
||||||
/** The number of child nodes of this node. */
|
/** The number of child nodes of this node. */
|
||||||
unsigned int mNumChildren;
|
unsigned int mNumChildren;
|
||||||
/** The child nodes of this node. NULL if mNumChildren is 0. */
|
/** The child nodes of this node. NULL if mNumChildren is 0. */
|
||||||
|
|
||||||
aiNode** mChildren;
|
C_STRUCT aiNode** mChildren;
|
||||||
|
|
||||||
/** The number of meshes of this node. */
|
/** The number of meshes of this node. */
|
||||||
unsigned int mNumMeshes;
|
unsigned int mNumMeshes;
|
||||||
|
@ -83,7 +125,7 @@ struct aiScene
|
||||||
* was successful. Presence of further nodes depends on the
|
* was successful. Presence of further nodes depends on the
|
||||||
* format and content of the imported file.
|
* format and content of the imported file.
|
||||||
*/
|
*/
|
||||||
aiNode* mRootNode;
|
C_STRUCT aiNode* mRootNode;
|
||||||
|
|
||||||
/** The number of meshes in the scene. */
|
/** The number of meshes in the scene. */
|
||||||
unsigned int mNumMeshes;
|
unsigned int mNumMeshes;
|
||||||
|
@ -93,7 +135,7 @@ struct aiScene
|
||||||
* Use the indices given in the aiNode structure to access
|
* Use the indices given in the aiNode structure to access
|
||||||
* this array. The array is mNumMeshes in size.
|
* this array. The array is mNumMeshes in size.
|
||||||
*/
|
*/
|
||||||
aiMesh** mMeshes;
|
C_STRUCT aiMesh** mMeshes;
|
||||||
|
|
||||||
/** The number of materials in the scene. */
|
/** The number of materials in the scene. */
|
||||||
unsigned int mNumMaterials;
|
unsigned int mNumMaterials;
|
||||||
|
@ -103,7 +145,7 @@ struct aiScene
|
||||||
* Use the index given in each aiMesh structure to access this
|
* Use the index given in each aiMesh structure to access this
|
||||||
* array. The array is mNumMaterials in size.
|
* array. The array is mNumMaterials in size.
|
||||||
*/
|
*/
|
||||||
aiMaterial** mMaterials;
|
C_STRUCT aiMaterial** mMaterials;
|
||||||
|
|
||||||
/** The number of animations in the scene. */
|
/** The number of animations in the scene. */
|
||||||
unsigned int mNumAnimations;
|
unsigned int mNumAnimations;
|
||||||
|
@ -113,7 +155,18 @@ struct aiScene
|
||||||
* All animations imported from the given file are listed here.
|
* All animations imported from the given file are listed here.
|
||||||
* The array is mNumAnimations in size.
|
* The array is mNumAnimations in size.
|
||||||
*/
|
*/
|
||||||
aiAnimation** mAnimations;
|
C_STRUCT aiAnimation** mAnimations;
|
||||||
|
|
||||||
|
/** The number of textures embedded into the file */
|
||||||
|
unsigned int mNumTextures;
|
||||||
|
|
||||||
|
/** The array of embedded textures.
|
||||||
|
*
|
||||||
|
* Not many file formats embedd their textures into the file.
|
||||||
|
* Examples include Quake's MDL format (which is also used by
|
||||||
|
* some GameStudio™ versions)
|
||||||
|
*/
|
||||||
|
C_STRUCT aiTexture** mTextures;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiScene()
|
aiScene()
|
||||||
|
@ -122,6 +175,7 @@ struct aiScene
|
||||||
mNumMeshes = 0; mMeshes = NULL;
|
mNumMeshes = 0; mMeshes = NULL;
|
||||||
mNumMaterials = 0; mMaterials = NULL;
|
mNumMaterials = 0; mMaterials = NULL;
|
||||||
mNumAnimations = 0; mAnimations = NULL;
|
mNumAnimations = 0; mAnimations = NULL;
|
||||||
|
mNumTextures = 0; mTextures = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
~aiScene()
|
~aiScene()
|
||||||
|
@ -136,6 +190,9 @@ struct aiScene
|
||||||
for( unsigned int a = 0; a < mNumAnimations; a++)
|
for( unsigned int a = 0; a < mNumAnimations; a++)
|
||||||
delete mAnimations[a];
|
delete mAnimations[a];
|
||||||
delete [] mAnimations;
|
delete [] mAnimations;
|
||||||
|
for( unsigned int a = 0; a < mNumTextures; a++)
|
||||||
|
delete mTextures[a];
|
||||||
|
delete [] mTextures;
|
||||||
}
|
}
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
** This file is part of the Free Asset Import Library ASSIMP.
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
**
|
||||||
|
** ASSIMP is free software: you can redistribute it and/or modify it
|
||||||
|
** under the terms of the GNU Lesser General Public License as published
|
||||||
|
** by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** ASSIMP is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU Lesser General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU Lesser General Public License
|
||||||
|
** along with ASSIMP. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
**/
|
||||||
|
|
||||||
|
/** @file Defines texture helper structures for the library
|
||||||
|
*
|
||||||
|
* Used for file formats that embedd their textures into the file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AI_TEXTURE_H_INC
|
||||||
|
#define AI_TEXTURE_H_INC
|
||||||
|
|
||||||
|
#include "aiTypes.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** \def AI_MAKE_EMBEDDED_TEXNAME
|
||||||
|
* Used to build the reserved path name used by the material system to
|
||||||
|
* reference textures that are embedded into their corresponding
|
||||||
|
* model files. The parameter specifies the index of the texture
|
||||||
|
* (zero-based, in the aiScene::mTextures array)
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
#if (!defined AI_MAKE_EMBEDDED_TEXNAME)
|
||||||
|
# define AI_MAKE_EMBEDDED_TEXNAME(_n_) "*" # _n_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ugly compiler dependent packing stuff
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||||
|
# pragma pack(push,1)
|
||||||
|
# define PACK_STRUCT
|
||||||
|
#elif defined( __GNUC__ )
|
||||||
|
# define PACK_STRUCT __attribute__((packed))
|
||||||
|
#else
|
||||||
|
# error Compiler not supported. Never do this again.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Helper structure to represent a texel in ARGB8888 format
|
||||||
|
*
|
||||||
|
* Used by aiTexture
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct aiTexel
|
||||||
|
{
|
||||||
|
unsigned char b;
|
||||||
|
unsigned char g;
|
||||||
|
unsigned char r;
|
||||||
|
unsigned char a;
|
||||||
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
// reset packing to the original value
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||||
|
# pragma pack( pop )
|
||||||
|
#endif
|
||||||
|
#undef PACK_STRUCT
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Helper structure to describe an embedded texture
|
||||||
|
*
|
||||||
|
* Normally textures are contained in external files but some file formats
|
||||||
|
* do embedd them. Embedded
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
struct aiTexture
|
||||||
|
{
|
||||||
|
/** Width of the texture, in pixels
|
||||||
|
*
|
||||||
|
* If mHeight is zero the texture is compressedin a format
|
||||||
|
* like JPEG. In this case mWidth specifies the size of the
|
||||||
|
* memory area pcData is pointing to, in bytes.
|
||||||
|
*/
|
||||||
|
unsigned int mWidth;
|
||||||
|
|
||||||
|
/** Height of the texture, in pixels
|
||||||
|
*
|
||||||
|
* If this value is zero, pcData points to an compressed texture
|
||||||
|
* in an unknown format (e.g. JPEG).
|
||||||
|
*/
|
||||||
|
unsigned int mHeight;
|
||||||
|
|
||||||
|
/** A hint from the loader to make it easier for applications
|
||||||
|
* to determine the type of embedded compressed textures.
|
||||||
|
*
|
||||||
|
* If mHeight != 0 this member is undefined. Otherwise it
|
||||||
|
* will be set to '\0\0\0\0' if the loader has no additional
|
||||||
|
* information about the texture file format used OR the
|
||||||
|
* file extension of the format without a leading dot.
|
||||||
|
* E.g. 'dds\0', 'pcx\0'
|
||||||
|
*/
|
||||||
|
char achFormatHint[4];
|
||||||
|
|
||||||
|
/** Data of the texture.
|
||||||
|
*
|
||||||
|
* Points to an array of mWidth * mHeight aiTexel's.
|
||||||
|
* The format of the texture data is always ARGB8888 to
|
||||||
|
* make the implementation for user of the library as easy
|
||||||
|
* as possible. If mHeight = 0 this is a pointer to a memory
|
||||||
|
* buffer of size mWidth containing the compressed texture
|
||||||
|
* data. Good luck, have fun!
|
||||||
|
*/
|
||||||
|
aiTexel* pcData;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
// Construction
|
||||||
|
aiTexture ()
|
||||||
|
: mHeight(0), mWidth(0), pcData(NULL)
|
||||||
|
{
|
||||||
|
achFormatHint[0] = '\0';
|
||||||
|
achFormatHint[1] = '\0';
|
||||||
|
achFormatHint[2] = '\0';
|
||||||
|
achFormatHint[3] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destruction
|
||||||
|
~aiTexture ()
|
||||||
|
{
|
||||||
|
delete[] pcData;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // AI_TEXTURE_H_INC
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef AI_TYPES_H_INC
|
#ifndef AI_TYPES_H_INC
|
||||||
#define AI_TYPES_H_INC
|
#define AI_TYPES_H_INC
|
||||||
|
|
||||||
|
@ -16,50 +57,57 @@
|
||||||
#include "aiMatrix4x4.inl"
|
#include "aiMatrix4x4.inl"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include <string>
|
# include <string>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
# define C_STRUCT
|
||||||
|
#else
|
||||||
|
# define C_STRUCT struct
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Maximum dimension for strings, ASSIMP strings are zero terminated */
|
/** Maximum dimension for strings, ASSIMP strings are zero terminated */
|
||||||
|
#ifdef __cplusplus
|
||||||
const size_t MAXLEN = 1024;
|
const size_t MAXLEN = 1024;
|
||||||
|
#else
|
||||||
|
# define MAXLEN 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Represents a two-dimensional vector.
|
/** Represents a two-dimensional vector.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
typedef struct aiVector2D
|
struct aiVector2D
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiVector2D () : x(0.0f), y(0.0f) {}
|
aiVector2D () : x(0.0f), y(0.0f) {}
|
||||||
aiVector2D (float _x, float _y) : x(_x), y(_y) {}
|
aiVector2D (float _x, float _y) : x(_x), y(_y) {}
|
||||||
aiVector2D (const aiVector2D& o) : x(o.x), y(o.y) {}
|
aiVector2D (const aiVector2D& o) : x(o.x), y(o.y) {}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // !__cplusplus
|
||||||
|
|
||||||
|
//! X and y coordinates
|
||||||
float x, y;
|
float x, y;
|
||||||
} aiVector2D_t;
|
} ;
|
||||||
|
|
||||||
// aiVector3D type moved to separate header due to size of operators
|
// aiVector3D type moved to separate header due to size of operators
|
||||||
|
|
||||||
// aiQuaternion type moved to separate header due to size of operators
|
// aiQuaternion type moved to separate header due to size of operators
|
||||||
|
|
||||||
// aiMatrix4x4 type moved to separate header due to size of operators
|
// aiMatrix4x4 type moved to separate header due to size of operators
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Represents a color in Red-Green-Blue space.
|
/** Represents a color in Red-Green-Blue space.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
typedef struct aiColor3D
|
struct aiColor3D
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
|
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
|
||||||
aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
|
aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
|
||||||
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // !__cplusplus
|
||||||
|
|
||||||
|
//! Red, green and blue color values
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
} aiColor3D_t;
|
};
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -67,7 +115,7 @@ typedef struct aiColor3D
|
||||||
* alpha component.
|
* alpha component.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
typedef struct aiColor4D
|
struct aiColor4D
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiColor4D () : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}
|
aiColor4D () : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}
|
||||||
|
@ -76,17 +124,18 @@ typedef struct aiColor4D
|
||||||
aiColor4D (const aiColor4D& o)
|
aiColor4D (const aiColor4D& o)
|
||||||
: r(o.r), g(o.g), b(o.b), a(o.a) {}
|
: r(o.r), g(o.g), b(o.b), a(o.a) {}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // !__cplusplus
|
||||||
|
|
||||||
|
//! Red, green, blue and alpha color values
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
} aiColor4D_t;
|
};
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Represents a string, zero byte terminated
|
/** Represents a string, zero byte terminated
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
typedef struct aiString
|
struct aiString
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
inline aiString() :
|
inline aiString() :
|
||||||
|
@ -110,11 +159,14 @@ typedef struct aiString
|
||||||
memcpy( data, pString.c_str(), length);
|
memcpy( data, pString.c_str(), length);
|
||||||
data[length] = 0;
|
data[length] = 0;
|
||||||
}
|
}
|
||||||
#endif // __cplusplus
|
#endif // !__cplusplus
|
||||||
|
|
||||||
|
//! Length of the string excluding the terminal 0
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
|
//! String buffer. Size limit is MAXLEN
|
||||||
char data[MAXLEN];
|
char data[MAXLEN];
|
||||||
} aiString_t;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -124,17 +176,27 @@ typedef struct aiString
|
||||||
* AI_SUCCESS.
|
* AI_SUCCESS.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
enum aiReturn
|
enum aiReturn
|
||||||
{
|
{
|
||||||
|
//! Indicates that a function was successful
|
||||||
AI_SUCCESS = 0x0,
|
AI_SUCCESS = 0x0,
|
||||||
|
//! Indicates that a function failed
|
||||||
AI_FAILURE = -0x1,
|
AI_FAILURE = -0x1,
|
||||||
|
//! Indicates that a file was invalid
|
||||||
AI_INVALIDFILE = -0x2,
|
AI_INVALIDFILE = -0x2,
|
||||||
|
//! Indicates that not enough memory was available
|
||||||
|
//! to perform the requested operation
|
||||||
AI_OUTOFMEMORY = -0x3,
|
AI_OUTOFMEMORY = -0x3,
|
||||||
|
//! Indicates that an illegal argument has been
|
||||||
|
//! passed to a function. This is rarely used,
|
||||||
|
//! most functions assert in this case.
|
||||||
AI_INVALIDARG = -0x4
|
AI_INVALIDARG = -0x4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif //! __cplusplus
|
||||||
#endif
|
#endif //!! include guard
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,13 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "aiAssert.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Represents a three-dimensional vector. */
|
/** Represents a three-dimensional vector. */
|
||||||
typedef struct aiVector3D
|
struct aiVector3D
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiVector3D () : x(0.0f), y(0.0f), z(0.0f) {}
|
aiVector3D () : x(0.0f), y(0.0f), z(0.0f) {}
|
||||||
|
@ -33,7 +31,7 @@ typedef struct aiVector3D
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
} aiVector3D_t;
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // end extern "C"
|
} // end extern "C"
|
||||||
|
@ -71,16 +69,15 @@ inline aiVector3D operator * ( const aiVector3D& v, float f)
|
||||||
// scalar division
|
// scalar division
|
||||||
inline aiVector3D operator / ( const aiVector3D& v, float f)
|
inline aiVector3D operator / ( const aiVector3D& v, float f)
|
||||||
{
|
{
|
||||||
//ai_assert(0.0f != f);
|
|
||||||
return v * (1/f);
|
return v * (1/f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vector division
|
// vector division
|
||||||
inline aiVector3D operator / ( const aiVector3D& v, const aiVector3D& v2)
|
inline aiVector3D operator / ( const aiVector3D& v, const aiVector3D& v2)
|
||||||
{
|
{
|
||||||
//ai_assert(0.0f != v2.x && 0.0f != v2.y && 0.0f != v2.z);
|
|
||||||
return aiVector3D(v.x / v2.x,v.y / v2.y,v.z / v2.z);
|
return aiVector3D(v.x / v2.x,v.y / v2.y,v.z / v2.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cross product
|
// cross product
|
||||||
inline aiVector3D operator ^ ( const aiVector3D& v1, const aiVector3D& v2)
|
inline aiVector3D operator ^ ( const aiVector3D& v1, const aiVector3D& v2)
|
||||||
|
|
|
@ -1,14 +1,58 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the C-API to the Asset Import Library. */
|
/** @file Defines the C-API to the Asset Import Library. */
|
||||||
#ifndef AI_ASSIMP_H_INC
|
#ifndef AI_ASSIMP_H_INC
|
||||||
#define AI_ASSIMP_H_INC
|
#define AI_ASSIMP_H_INC
|
||||||
|
|
||||||
|
#include "aiTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct aiScene;
|
struct aiScene;
|
||||||
struct aiFileIO;
|
struct aiFileIO;
|
||||||
//enum aiOrigin;
|
struct aiString;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Reads the given file and returns its content.
|
/** Reads the given file and returns its content.
|
||||||
|
@ -20,14 +64,14 @@ struct aiFileIO;
|
||||||
* this file. If the import fails, NULL is returned instead. Call
|
* this file. If the import fails, NULL is returned instead. Call
|
||||||
* aiGetErrorString() to retrieve a human-readable error text.
|
* aiGetErrorString() to retrieve a human-readable error text.
|
||||||
* @param pFile Path and filename of the file to be imported,
|
* @param pFile Path and filename of the file to be imported,
|
||||||
* expected to be a null-terminated c-string.
|
* expected to be a null-terminated c-string. NULL is not a valid value.
|
||||||
* @param pFlags Optional post processing steps to be executed after
|
* @param pFlags Optional post processing steps to be executed after
|
||||||
* a successful import. Provide a bitwise combination of the #aiPostProcessSteps
|
* a successful import. Provide a bitwise combination of the #aiPostProcessSteps
|
||||||
* flags.
|
* flags.
|
||||||
* @return Pointer to the imported data or NULL if the import failed.
|
* @return Pointer to the imported data or NULL if the import failed.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
const aiScene* aiImportFile( const char* pFile, unsigned int pFlags);
|
const C_STRUCT aiScene* aiImportFile( const char* pFile, unsigned int pFlags);
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -41,13 +85,16 @@ const aiScene* aiImportFile( const char* pFile, unsigned int pFlags);
|
||||||
* this file. If the import fails, NULL is returned instead. Call
|
* this file. If the import fails, NULL is returned instead. Call
|
||||||
* aiGetErrorString() to retrieve a human-readable error text.
|
* aiGetErrorString() to retrieve a human-readable error text.
|
||||||
* @param pFile aiFileIO structure. All functions pointers must be
|
* @param pFile aiFileIO structure. All functions pointers must be
|
||||||
* initialized. aiFileIO::OpenFunc() and aiFileIO::CloseFunc()
|
* initialized. aiFileIO::OpenFunc() and aiFileIO::CloseFunc()
|
||||||
* will be used to open other files in the fs if the asset to be
|
* will be used to open other files in the fs if the asset to be
|
||||||
* loaded depends on them.
|
* loaded depends on them. NULL is not a valid value.
|
||||||
* @return Pointer to the imported data or NULL if the import failed.
|
* @return Pointer to the imported data or NULL if the import failed.
|
||||||
|
*
|
||||||
|
* @note The C-API creates a new Importer instance internally for each call
|
||||||
|
* to this function. Therefore the C-API is thread-safe.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
const aiScene* aiImportFileEx( const aiFileIO* pFile);
|
const C_STRUCT aiScene* aiImportFileEx( const C_STRUCT aiFileIO* pFile);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,10 +102,10 @@ const aiScene* aiImportFileEx( const aiFileIO* pFile);
|
||||||
/** Releases all resources associated with the given import process.
|
/** Releases all resources associated with the given import process.
|
||||||
*
|
*
|
||||||
* Call this function after you're done with the imported data.
|
* Call this function after you're done with the imported data.
|
||||||
* @param pScene The imported data to release.
|
* @param pScene The imported data to release. NULL is a valid value.
|
||||||
*/
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
void aiReleaseImport( const aiScene* pScene);
|
void aiReleaseImport( const C_STRUCT aiScene* pScene);
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -70,6 +117,29 @@ void aiReleaseImport( const aiScene* pScene);
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
const char* aiGetErrorString();
|
const char* aiGetErrorString();
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Returns whether a given file extension is supported by ASSIMP
|
||||||
|
*
|
||||||
|
* @param szExtension Extension for which the function queries support.
|
||||||
|
* Must include a leading dot '.'. Example: ".3ds", ".md3"
|
||||||
|
* @return 1 if the extension is supported, 0 otherwise
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
int aiIsExtensionSupported(const char* szExtension);
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** Get a full list of all file extensions generally supported by ASSIMP.
|
||||||
|
*
|
||||||
|
* If a file extension is contained in the list this does, of course, not
|
||||||
|
* mean that ASSIMP is able to load all files with this extension.
|
||||||
|
* @param szOut String to receive the extension list.
|
||||||
|
* Format of the list: "*.3ds;*.obj;*.dae". NULL is not a valid parameter.
|
||||||
|
*/
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
void aiGetExtensionList(C_STRUCT aiString* szOut);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,3 +1,44 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Defines the CPP-API to the Asset Import Library. */
|
/** @file Defines the CPP-API to the Asset Import Library. */
|
||||||
#ifndef AI_ASSIMP_HPP_INC
|
#ifndef AI_ASSIMP_HPP_INC
|
||||||
#define AI_ASSIMP_HPP_INC
|
#define AI_ASSIMP_HPP_INC
|
||||||
|
@ -32,10 +73,13 @@ class IOSystem;
|
||||||
* GetErrorString().
|
* GetErrorString().
|
||||||
*
|
*
|
||||||
* If you need the Importer to do custom file handling to access the files,
|
* If you need the Importer to do custom file handling to access the files,
|
||||||
* implement IOSystem and IOStream and supply an instance of your custom IOSystem
|
* implement IOSystem and IOStream and supply an instance of your custom
|
||||||
* implementation by calling SetIOHandler() before calling ReadFile(). If you
|
* IOSystem implementation by calling SetIOHandler() before calling ReadFile().
|
||||||
* do not assign a custion IO handler, a default handler using the standard C++
|
* If you do not assign a custion IO handler, a default handler using the
|
||||||
* IO logic will be used.
|
* standard C++ IO logic will be used.
|
||||||
|
*
|
||||||
|
* @note One Importer instance is not thread-safe. If you use multiple
|
||||||
|
* threads for loading each thread should manage its own Importer instance.
|
||||||
*/
|
*/
|
||||||
class Importer
|
class Importer
|
||||||
{
|
{
|
||||||
|
@ -55,16 +99,17 @@ public:
|
||||||
~Importer();
|
~Importer();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Supplies a custom IO handler to the importer to open and access files.
|
/** Supplies a custom IO handler to the importer to use to open and
|
||||||
* If you need the importer to use custion IO logic to access the files,
|
* access files. If you need the importer to use custion IO logic to
|
||||||
* you need to provide a custom implementation of IOSystem and IOFile
|
* access the files, you need to provide a custom implementation of
|
||||||
* to the importer. Then create an instance of your custion IOSystem
|
* IOSystem and IOFile to the importer. Then create an instance of
|
||||||
* implementation and supply it by this function.
|
* your custion IOSystem implementation and supply it by this function.
|
||||||
*
|
*
|
||||||
* The Importer takes ownership of the object and will destroy it afterwards.
|
* The Importer takes ownership of the object and will destroy it
|
||||||
* The previously assigned handler will be deleted.
|
* afterwards. The previously assigned handler will be deleted.
|
||||||
*
|
*
|
||||||
* @param pIOHandler The IO handler to be used in all file accesses of the Importer.
|
* @param pIOHandler The IO handler to be used in all file accesses
|
||||||
|
* of the Importer. NULL resets it to the default handler.
|
||||||
*/
|
*/
|
||||||
void SetIOHandler( IOSystem* pIOHandler);
|
void SetIOHandler( IOSystem* pIOHandler);
|
||||||
|
|
||||||
|
@ -95,6 +140,27 @@ public:
|
||||||
inline const std::string& GetErrorString() const
|
inline const std::string& GetErrorString() const
|
||||||
{ return mErrorString; }
|
{ return mErrorString; }
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Returns whether a given file extension is supported by ASSIMP
|
||||||
|
*
|
||||||
|
* @param szExtension Extension for which the function queries support.
|
||||||
|
* Must include a leading dot '.'. Example: ".3ds", ".md3"
|
||||||
|
* @return true if the extension is supported, false otherwise
|
||||||
|
*/
|
||||||
|
bool IsExtensionSupported(const std::string& szExtension);
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Get a full list of all file extensions generally supported by ASSIMP.
|
||||||
|
*
|
||||||
|
* If a file extension is contained in the list this does, of course, not
|
||||||
|
* mean that ASSIMP is able to load all files with this extension.
|
||||||
|
* @param szOut String to receive the extension list.
|
||||||
|
* Format of the list: "*.3ds;*.obj;*.dae". NULL is not a valid parameter.
|
||||||
|
*/
|
||||||
|
void GetExtensionList(std::string& szOut);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Empty copy constructor. */
|
/** Empty copy constructor. */
|
||||||
Importer(const Importer &other);
|
Importer(const Importer &other);
|
||||||
|
|
|
@ -1,12 +1,43 @@
|
||||||
//-------------------------------------------------------------------------------
|
/*
|
||||||
/**
|
---------------------------------------------------------------------------
|
||||||
* This program is distributed under the terms of the GNU Lesser General
|
Free Asset Import Library (ASSIMP)
|
||||||
* Public License (LGPL).
|
---------------------------------------------------------------------------
|
||||||
*
|
|
||||||
* ASSIMP Viewer Utility
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
*
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "stdafx.h"
|
|
@ -1,12 +1,43 @@
|
||||||
//-------------------------------------------------------------------------------
|
/*
|
||||||
/**
|
---------------------------------------------------------------------------
|
||||||
* This program is distributed under the terms of the GNU Lesser General
|
Free Asset Import Library (ASSIMP)
|
||||||
* Public License (LGPL).
|
---------------------------------------------------------------------------
|
||||||
*
|
|
||||||
* ASSIMP Viewer Utility
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
*
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
|
@ -1,12 +1,43 @@
|
||||||
//-------------------------------------------------------------------------------
|
/*
|
||||||
/**
|
---------------------------------------------------------------------------
|
||||||
* This program is distributed under the terms of the GNU Lesser General
|
Free Asset Import Library (ASSIMP)
|
||||||
* Public License (LGPL).
|
---------------------------------------------------------------------------
|
||||||
*
|
|
||||||
* ASSIMP Viewer Utility
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
*
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
|
@ -1,12 +1,43 @@
|
||||||
//-------------------------------------------------------------------------------
|
/*
|
||||||
/**
|
---------------------------------------------------------------------------
|
||||||
* This program is distributed under the terms of the GNU Lesser General
|
Free Asset Import Library (ASSIMP)
|
||||||
* Public License (LGPL).
|
---------------------------------------------------------------------------
|
||||||
*
|
|
||||||
* ASSIMP Viewer Utility
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
*
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
|
@ -1,12 +1,43 @@
|
||||||
//-------------------------------------------------------------------------------
|
/*
|
||||||
/**
|
---------------------------------------------------------------------------
|
||||||
* This program is distributed under the terms of the GNU Lesser General
|
Free Asset Import Library (ASSIMP)
|
||||||
* Public License (LGPL).
|
---------------------------------------------------------------------------
|
||||||
*
|
|
||||||
* ASSIMP Viewer Utility
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
*
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if (!defined AV_LOG_DISPLAY_H_INCLUDED)
|
#if (!defined AV_LOG_DISPLAY_H_INCLUDED)
|
||||||
#define AV_LOG_DISPLAY_H_INCLUDE
|
#define AV_LOG_DISPLAY_H_INCLUDE
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "assimp_view.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace AssimpView {
|
||||||
|
|
||||||
|
/* extern */ CLogWindow CLogWindow::s_cInstance;
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Message procedure for the log window
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
|
WPARAM wParam,LPARAM lParam)
|
||||||
|
{
|
||||||
|
lParam;
|
||||||
|
switch (uMsg)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_SIZE:
|
||||||
|
{
|
||||||
|
int x = LOWORD(lParam);
|
||||||
|
int y = HIWORD(lParam);
|
||||||
|
|
||||||
|
SetWindowPos(GetDlgItem(hwndDlg,IDC_EDIT1),NULL,0,0,
|
||||||
|
x,y,SWP_NOMOVE|SWP_NOZORDER);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
case WM_CLOSE:
|
||||||
|
EndDialog(hwndDlg,0);
|
||||||
|
return TRUE;
|
||||||
|
};
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
void CLogWindow::Init ()
|
||||||
|
{
|
||||||
|
this->hwnd = ::CreateDialog(g_hInstance,MAKEINTRESOURCE(IDD_LOGVIEW),
|
||||||
|
NULL,&LogDialogProc);
|
||||||
|
|
||||||
|
if (!this->hwnd)
|
||||||
|
{
|
||||||
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create logger window",
|
||||||
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
void CLogWindow::Show()
|
||||||
|
{
|
||||||
|
if (this->hwnd)
|
||||||
|
{
|
||||||
|
ShowWindow(this->hwnd,SW_SHOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}; //! AssimpView
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Free Asset Import Library (ASSIMP)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (!defined AV_LOG_WINDOW_H_INCLUDED)
|
||||||
|
#define AV_LOG_WINDOW_H_INCLUDE
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
/** \brief Class to display log strings in a separate window
|
||||||
|
*/
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
class CLogWindow
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
CLogWindow() : hwnd(NULL) {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
// Singleton accessors
|
||||||
|
static CLogWindow s_cInstance;
|
||||||
|
inline static CLogWindow& Instance ()
|
||||||
|
{
|
||||||
|
return s_cInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// initializes the log window
|
||||||
|
void Init ();
|
||||||
|
|
||||||
|
// Shows the log window
|
||||||
|
void Show();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Window handle
|
||||||
|
HWND hwnd;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AV_LOG_DISPLA
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,43 @@
|
||||||
//-------------------------------------------------------------------------------
|
/*
|
||||||
/**
|
---------------------------------------------------------------------------
|
||||||
* This program is distributed under the terms of the GNU Lesser General
|
Free Asset Import Library (ASSIMP)
|
||||||
* Public License (LGPL).
|
---------------------------------------------------------------------------
|
||||||
*
|
|
||||||
* ASSIMP Viewer Utility
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
*
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
@ -15,9 +46,7 @@
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
// Static array to keep custom color values
|
// Static array to keep custom color values
|
||||||
COLORREF g_aclCustomColors[16] =
|
COLORREF g_aclCustomColors[16] = {0};
|
||||||
{0};
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Setup file associations for all formats supported by the library
|
// Setup file associations for all formats supported by the library
|
||||||
|
@ -27,12 +56,6 @@ COLORREF g_aclCustomColors[16] =
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void MakeFileAssociations()
|
void MakeFileAssociations()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
; .wscript
|
|
||||||
root: HKCR; Flags: deletekey; Subkey: ".uscript"; ValueType: string; ValueData: "UE_WSCRIPT_CLASS"; Components: rt
|
|
||||||
root: HKCR; Flags: deletekey; Subkey: "UE_WSCRIPT_CLASS"; ValueName:; ValueType: string; ValueData: "UtopicEngine Console Script"; Components: rt
|
|
||||||
root: HKCR; Flags: deletekey; Subkey: "UE_WSCRIPT_CLASS\shell\open\command"; ValueName:; ValueType: string; ValueData: "notepad.exe %1"; Components: rt
|
|
||||||
*/
|
|
||||||
char szTemp2[MAX_PATH];
|
char szTemp2[MAX_PATH];
|
||||||
char szTemp[MAX_PATH + 10];
|
char szTemp[MAX_PATH + 10];
|
||||||
|
|
||||||
|
@ -45,130 +68,105 @@ void MakeFileAssociations()
|
||||||
// .3ds
|
// .3ds
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.3ds",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.3ds",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AV3DSCLASS",(DWORD)strlen("AV3DSCLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AV3DSCLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AV3DSCLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .x
|
// .x
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.x",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.x",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVXCLASS",(DWORD)strlen("AVXCLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVXCLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVXCLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .obj
|
// .obj
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.obj",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.obj",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVOBJCLASS",(DWORD)strlen("AVOBJCLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVOBJCLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVOBJCLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .ms3d
|
// .ms3d
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.ms3d",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.ms3d",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVMS3DCLASS",(DWORD)strlen("AVMS3DCLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMS3DCLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMS3DCLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .md3
|
// .md3
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md3",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md3",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVMD3CLASS",(DWORD)strlen("AVMD3CLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD3CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD3CLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .md2
|
// .md2
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md2",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md2",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVMD2CLASS",(DWORD)strlen("AVMD2CLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD3CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD2CLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .md4
|
// .md4/mdr
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md4",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md4",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVMD4CLASS",(DWORD)strlen("AVMD4CLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD4CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.mdr",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegCloseKey(hTemp);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD4CLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .md5
|
// .md5
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md5",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.md5",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVMD5CLASS",(DWORD)strlen("AVMD5CLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD5CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
// -------------------------------------------------
|
||||||
|
// .mdl
|
||||||
|
// -------------------------------------------------
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.mdl",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVMD5CLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
|
||||||
RegCloseKey(hTemp);
|
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// .ply
|
// .ply
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.ply",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.ply",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"AVPLYCLASS",(DWORD)strlen("AVPLYCLASS")+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVPLYCLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// .ase/.ask
|
||||||
|
// -------------------------------------------------
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.ase",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
|
RegCloseKey(hTemp);
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\.ask",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\AVPLYCLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
|
||||||
|
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
RegSetValueEx(hTemp,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
|
||||||
RegCloseKey(hTemp);
|
RegCloseKey(hTemp);
|
||||||
|
|
||||||
CLogDisplay::Instance().AddEntry("[OK] File assocations have been registered",
|
CLogDisplay::Instance().AddEntry("[OK] File assocations have been registered",
|
||||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||||
|
|
||||||
|
aiString sz;
|
||||||
|
aiGetExtensionList(&sz);
|
||||||
|
CLogDisplay::Instance().AddEntry(sz.data,
|
||||||
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,6 +246,47 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
SetDlgItemText(hwndDlg,IDC_EFACE,"0");
|
SetDlgItemText(hwndDlg,IDC_EFACE,"0");
|
||||||
SetDlgItemText(hwndDlg,IDC_EMAT,"0");
|
SetDlgItemText(hwndDlg,IDC_EMAT,"0");
|
||||||
SetDlgItemText(hwndDlg,IDC_ESHADER,"0");
|
SetDlgItemText(hwndDlg,IDC_ESHADER,"0");
|
||||||
|
SetDlgItemText(hwndDlg,IDC_ENODE,"0");
|
||||||
|
SetDlgItemText(hwndDlg,IDC_ETEX,"0");
|
||||||
|
|
||||||
|
// setup the default window title
|
||||||
|
SetWindowText(hwndDlg,AI_VIEW_CAPTION_BASE);
|
||||||
|
{
|
||||||
|
// read some UI properties from the registry and apply them
|
||||||
|
DWORD dwValue;
|
||||||
|
DWORD dwTemp = sizeof( DWORD );
|
||||||
|
HKEY hTemp;
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\ASSIMP\\Viewer",
|
||||||
|
NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
|
|
||||||
|
if(ERROR_SUCCESS != RegQueryValueEx(hTemp,"LastUIState",NULL,NULL,
|
||||||
|
(BYTE*)&dwValue,&dwTemp))
|
||||||
|
{
|
||||||
|
dwValue = 1;
|
||||||
|
}
|
||||||
|
if (0 == dwValue)
|
||||||
|
{
|
||||||
|
// collapse the viewer
|
||||||
|
// adjust the size
|
||||||
|
RECT sRect;
|
||||||
|
GetWindowRect(hwndDlg,&sRect);
|
||||||
|
sRect.right -= sRect.left;
|
||||||
|
sRect.bottom -= sRect.top;
|
||||||
|
|
||||||
|
RECT sRect2;
|
||||||
|
GetWindowRect(GetDlgItem ( hwndDlg, IDC_BLUBB ),&sRect2);
|
||||||
|
sRect2.left -= sRect.left;
|
||||||
|
sRect2.top -= sRect.top;
|
||||||
|
|
||||||
|
SetWindowPos(hwndDlg,NULL,0,0,sRect.right-188,sRect.bottom,
|
||||||
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
|
SetWindowText(GetDlgItem(hwndDlg,IDC_BLUBB),">>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CheckDlgButton(hwndDlg,IDC_BLUBB,BST_CHECKED);
|
||||||
|
}
|
||||||
|
RegCloseKey(hTemp);}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
|
@ -365,34 +404,6 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
g_eClick = EClickPos_CircleVert;
|
g_eClick = EClickPos_CircleVert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OLD version of this code. Not using a texture lookup to
|
|
||||||
// determine the exact position, but using maths and the fact
|
|
||||||
// that we have a circle f(x) = m +rx ;-)
|
|
||||||
#if 0
|
|
||||||
g_eClick = EClickPos_Circle;
|
|
||||||
if (yPos < 10 && yPos > -10)
|
|
||||||
{
|
|
||||||
if ((xPos2 > fHalfX-5 && xPos2 < fHalfX+15) ||
|
|
||||||
(xPos2 > fHalfX+(int)sDesc.Width-10 && xPos2 < fHalfX+(int)sDesc.Width+10))
|
|
||||||
{
|
|
||||||
g_eClick = EClickPos_CircleHor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (xPos < 10 && xPos > -10)
|
|
||||||
{
|
|
||||||
if ((yPos2 > fHalfY-5 && yPos2 < fHalfY+15) ||
|
|
||||||
(yPos2 > fHalfY+(int)sDesc.Height-10 && yPos2 < fHalfY+(int)sDesc.Height+10))
|
|
||||||
{
|
|
||||||
g_eClick = EClickPos_CircleVert;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sqrtf((float)(xPos * xPos + yPos * yPos)) > (float)(sDesc.Width/2))
|
|
||||||
{
|
|
||||||
g_eClick = EClickPos_Outside;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
|
@ -467,6 +478,10 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_ABOUTBOX),
|
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_ABOUTBOX),
|
||||||
hwndDlg,&AboutMessageProc);
|
hwndDlg,&AboutMessageProc);
|
||||||
}
|
}
|
||||||
|
else if (ID_TOOLS_LOGWINDOW == LOWORD(wParam))
|
||||||
|
{
|
||||||
|
CLogWindow::Instance().Show();
|
||||||
|
}
|
||||||
else if (ID_VIEWER_H == LOWORD(wParam))
|
else if (ID_VIEWER_H == LOWORD(wParam))
|
||||||
{
|
{
|
||||||
MakeFileAssociations();
|
MakeFileAssociations();
|
||||||
|
@ -657,10 +672,24 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
if (!sz)sz = strrchr(szFileName,'/');
|
if (!sz)sz = strrchr(szFileName,'/');
|
||||||
if (!sz)*sz = 0;
|
if (!sz)*sz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get a list of all file extensions supported by ASSIMP
|
||||||
|
aiString sz;
|
||||||
|
aiGetExtensionList(&sz);
|
||||||
|
|
||||||
|
char szList[MAXLEN + 100];
|
||||||
|
strcpy(szList,"ASSIMP assets");
|
||||||
|
char* szCur = szList + 14;
|
||||||
|
strcpy(szCur,sz.data);
|
||||||
|
szCur += sz.length+1;
|
||||||
|
strcpy(szCur,"All files");
|
||||||
|
szCur += 10;
|
||||||
|
strcpy(szCur,"*.*");
|
||||||
|
szCur[4] = 0;
|
||||||
|
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(NULL), szList, NULL, 0, 1,
|
||||||
"ASSIMP assets\0*.x;*.obj;*.ms3d;*.3ds;*.md3;*.md1;*.md2;*.md4;*.md5;*.ply\0All files\0*.*", NULL, 0, 1,
|
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, NULL, 0, NULL,
|
||||||
"Import Asset into ASSIMP",
|
"Import Asset into ASSIMP",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
|
@ -728,6 +757,44 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
|
|
||||||
SetupFPSView();
|
SetupFPSView();
|
||||||
}
|
}
|
||||||
|
else if (IDC_BLUBB == LOWORD(wParam))
|
||||||
|
{
|
||||||
|
// adjust the size
|
||||||
|
RECT sRect;
|
||||||
|
GetWindowRect(hwndDlg,&sRect);
|
||||||
|
sRect.right -= sRect.left;
|
||||||
|
sRect.bottom -= sRect.top;
|
||||||
|
|
||||||
|
RECT sRect2;
|
||||||
|
GetWindowRect(GetDlgItem ( hwndDlg, IDC_BLUBB ),&sRect2);
|
||||||
|
sRect2.left -= sRect.left;
|
||||||
|
sRect2.top -= sRect.top;
|
||||||
|
|
||||||
|
HKEY hTemp;
|
||||||
|
DWORD dwValue;
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\ASSIMP\\Viewer",
|
||||||
|
NULL,NULL,0,KEY_ALL_ACCESS, NULL, &hTemp,NULL);
|
||||||
|
|
||||||
|
if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg,IDC_BLUBB))
|
||||||
|
{
|
||||||
|
SetWindowPos(hwndDlg,NULL,0,0,sRect.right-188,sRect.bottom,
|
||||||
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
|
|
||||||
|
dwValue = 0;
|
||||||
|
SetWindowText(GetDlgItem(hwndDlg,IDC_BLUBB),">>");
|
||||||
|
RegSetValueExA(hTemp,"LastUIState",0,REG_DWORD,(const BYTE*)&dwValue,4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetWindowPos(hwndDlg,NULL,0,0,sRect.right+188,sRect.bottom,
|
||||||
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
|
|
||||||
|
dwValue = 1;
|
||||||
|
SetWindowText(GetDlgItem(hwndDlg,IDC_BLUBB),"<<");
|
||||||
|
RegSetValueExA(hTemp,"LastUIState",0,REG_DWORD,(const BYTE*)&dwValue,4);
|
||||||
|
}
|
||||||
|
RegCloseKey(hTemp);
|
||||||
|
}
|
||||||
else if (IDC_TOGGLENORMALS == LOWORD(wParam))
|
else if (IDC_TOGGLENORMALS == LOWORD(wParam))
|
||||||
{
|
{
|
||||||
g_sOptions.bRenderNormals = !g_sOptions.bRenderNormals;
|
g_sOptions.bRenderNormals = !g_sOptions.bRenderNormals;
|
||||||
|
@ -898,6 +965,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
CLogDisplay::Instance().AddEntry("[OK] The viewer has been initialized successfully");
|
CLogDisplay::Instance().AddEntry("[OK] The viewer has been initialized successfully");
|
||||||
|
|
||||||
|
// create the log window
|
||||||
|
CLogWindow::Instance().Init();
|
||||||
|
// set the focus to the main window
|
||||||
|
SetFocus(g_hDlg);
|
||||||
|
|
||||||
// recover background skyboxes/textures from the last session
|
// recover background skyboxes/textures from the last session
|
||||||
HKEY hTemp;
|
HKEY hTemp;
|
||||||
union
|
union
|
||||||
|
|
|
@ -1,12 +1,43 @@
|
||||||
//-------------------------------------------------------------------------------
|
/*
|
||||||
/**
|
---------------------------------------------------------------------------
|
||||||
* This program is distributed under the terms of the GNU Lesser General
|
Free Asset Import Library (ASSIMP)
|
||||||
* Public License (LGPL).
|
---------------------------------------------------------------------------
|
||||||
*
|
|
||||||
* ASSIMP Viewer Utility
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||||
*
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
@ -15,16 +46,6 @@
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
std::string g_szNormalsShader = std::string(
|
std::string g_szNormalsShader = std::string(
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
/**\n"
|
|
||||||
* This program is distributed under the terms of the GNU Lesser General\n
|
|
||||||
* Public License (LGPL). \n
|
|
||||||
*\n
|
|
||||||
* ASSIMP Viewer Utility\n
|
|
||||||
*\n"
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
|
|
||||||
|
|
||||||
// World * View * Projection matrix\n"
|
// World * View * Projection matrix\n"
|
||||||
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
||||||
|
@ -90,16 +111,6 @@ std::string g_szNormalsShader = std::string(
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string g_szSkyboxShader = std::string(
|
std::string g_szSkyboxShader = std::string(
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
/**\n"
|
|
||||||
* This program is distributed under the terms of the GNU Lesser General\n
|
|
||||||
* Public License (LGPL). \n
|
|
||||||
*\n
|
|
||||||
* ASSIMP Viewer Utility\n
|
|
||||||
*\n"
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// ----------------------------------------------------------------------------\n"
|
||||||
// Sampler and texture for the skybox\n"
|
// Sampler and texture for the skybox\n"
|
||||||
|
@ -252,16 +263,6 @@ std::string g_szSkyboxShader = std::string(
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string g_szDefaultShader = std::string(
|
std::string g_szDefaultShader = std::string(
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
/**\n"
|
|
||||||
* This program is distributed under the terms of the GNU Lesser General\n
|
|
||||||
* Public License (LGPL). \n
|
|
||||||
*\n
|
|
||||||
* ASSIMP Viewer Utility\n
|
|
||||||
*\n"
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
|
|
||||||
|
|
||||||
// World * View * Projection matrix\n"
|
// World * View * Projection matrix\n"
|
||||||
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
||||||
|
@ -453,16 +454,6 @@ std::string g_szDefaultShader = std::string(
|
||||||
|
|
||||||
|
|
||||||
std::string g_szMaterialShader = std::string(
|
std::string g_szMaterialShader = std::string(
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
/**\n"
|
|
||||||
* This program is distributed under the terms of the GNU Lesser General\n
|
|
||||||
* Public License (LGPL). \n
|
|
||||||
*\n
|
|
||||||
* ASSIMP Viewer Utility\n
|
|
||||||
*\n"
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
|
|
||||||
|
|
||||||
// World * View * Projection matrix\n"
|
// World * View * Projection matrix\n"
|
||||||
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
||||||
|
@ -1143,15 +1134,6 @@ std::string g_szMaterialShader = std::string(
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string g_szPassThroughShader = std::string(
|
std::string g_szPassThroughShader = std::string(
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
/**\n"
|
|
||||||
* This program is distributed under the terms of the GNU Lesser General\n
|
|
||||||
* Public License (LGPL). \n
|
|
||||||
*\n
|
|
||||||
* ASSIMP Viewer Utility\n
|
|
||||||
*\n"
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------\n"
|
|
||||||
|
|
||||||
"texture TEXTURE_2D;\n"
|
"texture TEXTURE_2D;\n"
|
||||||
"sampler TEXTURE_SAMPLER = sampler_state\n"
|
"sampler TEXTURE_SAMPLER = sampler_state\n"
|
||||||
|
|
Binary file not shown.
|
@ -67,7 +67,7 @@ AssetHelper *g_pcAsset = NULL;
|
||||||
unsigned char* g_szImageMask = NULL;
|
unsigned char* g_szImageMask = NULL;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// table of colors used for normal vectors.
|
// Table of colors used for normal vectors.
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
D3DXVECTOR4 g_aclNormalColors[14] =
|
D3DXVECTOR4 g_aclNormalColors[14] =
|
||||||
{
|
{
|
||||||
|
@ -94,27 +94,41 @@ D3DXVECTOR4 g_aclNormalColors[14] =
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//! \brief Entry point for loader thread
|
// Entry point for the loader thread
|
||||||
|
// The laoder thread loads the asset while the progress dialog displays the
|
||||||
|
// smart progress bar
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(lpParameter);
|
UNREFERENCED_PARAMETER(lpParameter);
|
||||||
|
|
||||||
|
// get current time
|
||||||
double fCur = (double)timeGetTime();
|
double fCur = (double)timeGetTime();
|
||||||
|
|
||||||
|
// call ASSIMPs C-API to load the file
|
||||||
g_pcAsset->pcScene = aiImportFile(g_szFileName,
|
g_pcAsset->pcScene = aiImportFile(g_szFileName,
|
||||||
aiProcess_CalcTangentSpace | aiProcess_JoinIdenticalVertices | aiProcess_Triangulate |
|
aiProcess_CalcTangentSpace | // calculate tangents and bitangents
|
||||||
aiProcess_GenSmoothNormals | aiProcess_ConvertToLeftHanded | aiProcess_SplitLargeMeshes);
|
aiProcess_JoinIdenticalVertices | // join identical vertices
|
||||||
|
aiProcess_Triangulate | // triangulate n-polygons
|
||||||
|
aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing
|
||||||
|
aiProcess_ConvertToLeftHanded | // convert everything to D3D left handed space
|
||||||
|
aiProcess_SplitLargeMeshes); // split large, unrenderable meshes into submeshes
|
||||||
|
|
||||||
|
// get the end time of zje operation, calculate delta t
|
||||||
double fEnd = (double)timeGetTime();
|
double fEnd = (double)timeGetTime();
|
||||||
double dTime = (fEnd - fCur) / 1000;
|
double dTime = (fEnd - fCur) / 1000;
|
||||||
char szTemp[128];
|
char szTemp[128];
|
||||||
sprintf(szTemp,"%.5f",(float)dTime);
|
sprintf(szTemp,"%.5f",(float)dTime);
|
||||||
SetDlgItemText(g_hDlg,IDC_ELOAD,szTemp);
|
SetDlgItemText(g_hDlg,IDC_ELOAD,szTemp);
|
||||||
g_bLoadingFinished = true;
|
g_bLoadingFinished = true;
|
||||||
|
|
||||||
|
// check whether the loading process has failed ...
|
||||||
if (NULL == g_pcAsset->pcScene)
|
if (NULL == g_pcAsset->pcScene)
|
||||||
{
|
{
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load this asset:",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load this asset:",
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
|
||||||
|
// print ASSIMPs error string to the log display
|
||||||
CLogDisplay::Instance().AddEntry(aiGetErrorString(),
|
CLogDisplay::Instance().AddEntry(aiGetErrorString(),
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -123,42 +137,72 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
// Recursivly count the number of nodes in an asset's node graph
|
||||||
|
// Used by LoadAsset()
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
void GetNodeCount(aiNode* pcNode, unsigned int* piCnt)
|
||||||
|
{
|
||||||
|
*piCnt = *piCnt+1;
|
||||||
|
for (unsigned int i = 0; i < pcNode->mNumChildren;++i)
|
||||||
|
GetNodeCount(pcNode->mChildren[i],piCnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// load the current asset
|
||||||
|
// THe path to the asset is specified in the global path variable
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int LoadAsset(void)
|
int LoadAsset(void)
|
||||||
{
|
{
|
||||||
|
// set the world and world rotation matrices to the identuty
|
||||||
g_mWorldRotate = aiMatrix4x4();
|
g_mWorldRotate = aiMatrix4x4();
|
||||||
g_mWorld = aiMatrix4x4();
|
g_mWorld = aiMatrix4x4();
|
||||||
|
|
||||||
|
// create a helper thread to load the asset
|
||||||
DWORD dwID;
|
DWORD dwID;
|
||||||
g_bLoadingCanceled = false;
|
g_bLoadingCanceled = false;
|
||||||
g_pcAsset = new AssetHelper();
|
g_pcAsset = new AssetHelper();
|
||||||
g_hThreadHandle = CreateThread(NULL,0,&LoadThreadProc,NULL,0,&dwID);
|
g_hThreadHandle = CreateThread(NULL,0,&LoadThreadProc,NULL,0,&dwID);
|
||||||
|
|
||||||
|
if (!g_hThreadHandle)
|
||||||
|
{
|
||||||
|
CLogDisplay::Instance().AddEntry(
|
||||||
|
"[ERROR] Unable to create helper thread for loading",
|
||||||
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// show the progress bar dialog
|
||||||
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_LOADDIALOG),
|
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_LOADDIALOG),
|
||||||
g_hDlg,&ProgressMessageProc);
|
g_hDlg,&ProgressMessageProc);
|
||||||
|
|
||||||
|
// now we should have loaded the asset. Check this ...
|
||||||
g_bLoadingFinished = false;
|
g_bLoadingFinished = false;
|
||||||
if (!g_pcAsset || !g_pcAsset->pcScene)
|
if (!g_pcAsset || !g_pcAsset->pcScene)
|
||||||
{
|
{
|
||||||
if (g_pcAsset)
|
if (g_pcAsset)
|
||||||
{
|
{
|
||||||
delete g_pcAsset;
|
delete g_pcAsset;
|
||||||
g_pcAsset = NULL;
|
g_pcAsset = NULL;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate a new MeshHelper array and build a new instance
|
||||||
|
// for each mesh in the original asset
|
||||||
g_pcAsset->apcMeshes = new AssetHelper::MeshHelper*[
|
g_pcAsset->apcMeshes = new AssetHelper::MeshHelper*[
|
||||||
g_pcAsset->pcScene->mNumMeshes]();
|
g_pcAsset->pcScene->mNumMeshes]();
|
||||||
|
|
||||||
|
// get the number of vertices/faces in the model
|
||||||
unsigned int iNumVert = 0;
|
unsigned int iNumVert = 0;
|
||||||
unsigned int iNumFaces = 0;
|
unsigned int iNumFaces = 0;
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
iNumVert += g_pcAsset->pcScene->mMeshes[i]->mNumVertices;
|
iNumVert += g_pcAsset->pcScene->mMeshes[i]->mNumVertices;
|
||||||
iNumFaces += g_pcAsset->pcScene->mMeshes[i]->mNumFaces;
|
iNumFaces += g_pcAsset->pcScene->mMeshes[i]->mNumFaces;
|
||||||
g_pcAsset->apcMeshes[i] = new AssetHelper::MeshHelper();
|
g_pcAsset->apcMeshes[i] = new AssetHelper::MeshHelper();
|
||||||
}
|
}
|
||||||
char szOut[120];
|
// and fill the statistic edit controls
|
||||||
|
char szOut[1024];
|
||||||
sprintf(szOut,"%i",(int)iNumVert);
|
sprintf(szOut,"%i",(int)iNumVert);
|
||||||
SetDlgItemText(g_hDlg,IDC_EVERT,szOut);
|
SetDlgItemText(g_hDlg,IDC_EVERT,szOut);
|
||||||
sprintf(szOut,"%i",(int)iNumFaces);
|
sprintf(szOut,"%i",(int)iNumFaces);
|
||||||
|
@ -166,25 +210,41 @@ int LoadAsset(void)
|
||||||
sprintf(szOut,"%i",(int)g_pcAsset->pcScene->mNumMaterials);
|
sprintf(szOut,"%i",(int)g_pcAsset->pcScene->mNumMaterials);
|
||||||
SetDlgItemText(g_hDlg,IDC_EMAT,szOut);
|
SetDlgItemText(g_hDlg,IDC_EMAT,szOut);
|
||||||
|
|
||||||
|
// need to get the number of nodes
|
||||||
|
iNumVert = 0;
|
||||||
|
GetNodeCount(g_pcAsset->pcScene->mRootNode,&iNumVert);
|
||||||
|
sprintf(szOut,"%i",(int)iNumVert);
|
||||||
|
SetDlgItemText(g_hDlg,IDC_ENODE,szOut);
|
||||||
|
|
||||||
|
// build a new caption string for the viewer
|
||||||
|
sprintf(szOut,AI_VIEW_CAPTION_BASE " [%s]",g_szFileName);
|
||||||
|
SetWindowText(g_hDlg,szOut);
|
||||||
|
|
||||||
|
// scale the asset vertices to fit into the viewer window
|
||||||
ScaleAsset();
|
ScaleAsset();
|
||||||
|
|
||||||
|
// reset the camera view to the default position
|
||||||
g_sCamera.vPos = aiVector3D(0.0f,0.0f,-10.0f);
|
g_sCamera.vPos = aiVector3D(0.0f,0.0f,-10.0f);
|
||||||
g_sCamera.vLookAt = aiVector3D(0.0f,0.0f,1.0f);
|
g_sCamera.vLookAt = aiVector3D(0.0f,0.0f,1.0f);
|
||||||
g_sCamera.vUp = aiVector3D(0.0f,1.0f,0.0f);
|
g_sCamera.vUp = aiVector3D(0.0f,1.0f,0.0f);
|
||||||
g_sCamera.vRight = aiVector3D(0.0f,1.0f,0.0f);
|
g_sCamera.vRight = aiVector3D(0.0f,1.0f,0.0f);
|
||||||
|
|
||||||
|
// build native D3D vertex/index buffers, textures, materials
|
||||||
return CreateAssetData();
|
return CreateAssetData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
// Delete the loaded asset
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int DeleteAsset(void)
|
int DeleteAsset(void)
|
||||||
{
|
{
|
||||||
if (!g_pcAsset)return 0;
|
if (!g_pcAsset)return 0;
|
||||||
|
|
||||||
|
// don't anymore know why this was necessary ...
|
||||||
Render();
|
Render();
|
||||||
|
|
||||||
|
// delete everything
|
||||||
DeleteAssetData();
|
DeleteAssetData();
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
|
@ -195,9 +255,16 @@ int DeleteAsset(void)
|
||||||
delete g_pcAsset;
|
delete g_pcAsset;
|
||||||
g_pcAsset = NULL;
|
g_pcAsset = NULL;
|
||||||
|
|
||||||
|
// clear all stats edit controls
|
||||||
SetDlgItemText(g_hDlg,IDC_EVERT,"0");
|
SetDlgItemText(g_hDlg,IDC_EVERT,"0");
|
||||||
SetDlgItemText(g_hDlg,IDC_EFACE,"0");
|
SetDlgItemText(g_hDlg,IDC_EFACE,"0");
|
||||||
SetDlgItemText(g_hDlg,IDC_EMAT,"0");
|
SetDlgItemText(g_hDlg,IDC_EMAT,"0");
|
||||||
|
SetDlgItemText(g_hDlg,IDC_ENODE,"0");
|
||||||
|
SetDlgItemText(g_hDlg,IDC_ESHADER,"0");
|
||||||
|
SetDlgItemText(g_hDlg,IDC_ETEX,"0");
|
||||||
|
|
||||||
|
// reset the caption of the viewer window
|
||||||
|
SetWindowText(g_hDlg,AI_VIEW_CAPTION_BASE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,12 +424,12 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo
|
||||||
// The animations are added in order
|
// The animations are added in order
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int FillAnimList(void)
|
int FillAnimList(void)
|
||||||
{
|
{
|
||||||
// clear the combo box
|
// clear the combo box
|
||||||
SendDlgItemMessage(g_hDlg,IDC_COMBO1,CB_RESETCONTENT,0,0);
|
SendDlgItemMessage(g_hDlg,IDC_COMBO1,CB_RESETCONTENT,0,0);
|
||||||
|
|
||||||
if (0 == g_pcAsset->pcScene->mNumAnimations)
|
if (0 == g_pcAsset->pcScene->mNumAnimations)
|
||||||
{
|
{
|
||||||
// disable all UI components related to animations
|
// disable all UI components related to animations
|
||||||
EnableWindow(GetDlgItem(g_hDlg,IDC_PLAYANIM),FALSE);
|
EnableWindow(GetDlgItem(g_hDlg,IDC_PLAYANIM),FALSE);
|
||||||
EnableWindow(GetDlgItem(g_hDlg,IDC_SPEED),FALSE);
|
EnableWindow(GetDlgItem(g_hDlg,IDC_SPEED),FALSE);
|
||||||
|
@ -374,7 +441,7 @@ int FillAnimList(void)
|
||||||
EnableWindow(GetDlgItem(g_hDlg,IDC_COMBO1),FALSE);
|
EnableWindow(GetDlgItem(g_hDlg,IDC_COMBO1),FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// reenable all animation components if they have been
|
// reenable all animation components if they have been
|
||||||
// disabled for a previous mesh
|
// disabled for a previous mesh
|
||||||
EnableWindow(GetDlgItem(g_hDlg,IDC_PLAYANIM),TRUE);
|
EnableWindow(GetDlgItem(g_hDlg,IDC_PLAYANIM),TRUE);
|
||||||
|
@ -388,13 +455,276 @@ int FillAnimList(void)
|
||||||
|
|
||||||
// now fill in all animation names
|
// now fill in all animation names
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumAnimations;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumAnimations;++i)
|
||||||
{
|
{
|
||||||
SendDlgItemMessage(g_hDlg,IDC_COMBO1,CB_ADDSTRING,0,
|
SendDlgItemMessage(g_hDlg,IDC_COMBO1,CB_ADDSTRING,0,
|
||||||
( LPARAM ) g_pcAsset->pcScene->mAnimations[i]->mName.data);
|
( LPARAM ) g_pcAsset->pcScene->mAnimations[i]->mName.data);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Add a node to the display list
|
||||||
|
// Recusrivly add all subnodes
|
||||||
|
// iNode - Index of the node image in the tree view's image lust
|
||||||
|
// iIndex - Index of the node in the parent's child list
|
||||||
|
// iDepth - Current depth of the node
|
||||||
|
// pcNode - Node object
|
||||||
|
// hRoot - Parent tree view node
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
int AddNodeToDisplayList(unsigned int iNode,
|
||||||
|
unsigned int iIndex,
|
||||||
|
unsigned int iDepth,
|
||||||
|
const aiNode* pcNode,
|
||||||
|
HTREEITEM hRoot)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcNode);
|
||||||
|
|
||||||
|
char chTemp[512];
|
||||||
|
|
||||||
|
if(0 == pcNode->mName.length)
|
||||||
|
{
|
||||||
|
if (iNode >= 100)
|
||||||
|
{
|
||||||
|
iNode += iDepth * 1000;
|
||||||
|
}
|
||||||
|
else if (iNode >= 10)
|
||||||
|
{
|
||||||
|
iNode += iDepth * 100;
|
||||||
|
}
|
||||||
|
else iNode += iDepth * 10;
|
||||||
|
sprintf(chTemp,"Node %i",iNode);
|
||||||
|
}
|
||||||
|
else strcpy(chTemp,pcNode->mName.data);
|
||||||
|
|
||||||
|
TVITEMEX tvi;
|
||||||
|
TVINSERTSTRUCT sNew;
|
||||||
|
tvi.pszText = chTemp;
|
||||||
|
tvi.cchTextMax = (int)strlen(chTemp);
|
||||||
|
tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE;
|
||||||
|
tvi.iImage = iNode;
|
||||||
|
tvi.iSelectedImage = iNode;
|
||||||
|
tvi.lParam = (LPARAM)0;
|
||||||
|
|
||||||
|
sNew.itemex = tvi;
|
||||||
|
sNew.hInsertAfter = TVI_LAST;
|
||||||
|
sNew.hParent = hRoot;
|
||||||
|
|
||||||
|
// add the item to the list
|
||||||
|
HTREEITEM hTexture = (HTREEITEM)SendMessage(GetDlgItem(g_hDlg,IDC_TREE1),
|
||||||
|
TVM_INSERTITEM,
|
||||||
|
0,
|
||||||
|
(LPARAM)(LPTVINSERTSTRUCT)&sNew);
|
||||||
|
|
||||||
|
// recursively add all child nodes
|
||||||
|
++iDepth;
|
||||||
|
for (unsigned int i = 0; i< pcNode->mNumChildren;++i)
|
||||||
|
{
|
||||||
|
AddNodeToDisplayList(iNode,i,iDepth,pcNode->mChildren[i],hTexture);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Add a texture to the display list
|
||||||
|
// pcMat - material containing the texture
|
||||||
|
// hTexture - Handle to the material tree item
|
||||||
|
// iTexture - Index of the texture image in the image list of the tree view
|
||||||
|
// szPath - Path to the texture
|
||||||
|
// iUVIndex - UV index to be used for the texture
|
||||||
|
// fBlendFactor - Blend factor to be used for the texture
|
||||||
|
// eTextureOp - texture operation to be used for the texture
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
int AddTextureToDisplayList(unsigned int iType,
|
||||||
|
unsigned int iIndex,
|
||||||
|
const aiString* szPath,
|
||||||
|
HTREEITEM hFX,
|
||||||
|
const aiMaterial* pcMat,
|
||||||
|
unsigned int iTexture = 0,
|
||||||
|
unsigned int iUVIndex = 0,
|
||||||
|
const float fBlendFactor = 0.0f,
|
||||||
|
aiTextureOp eTextureOp = aiTextureOp_Multiply)
|
||||||
|
{
|
||||||
|
char chTemp[512];
|
||||||
|
const char* sz = strrchr(szPath->data,'\\');
|
||||||
|
if (!sz)sz = strrchr(szPath->data,'/');
|
||||||
|
if (!sz)sz = szPath->data;
|
||||||
|
|
||||||
|
const char* szType;
|
||||||
|
switch (iType)
|
||||||
|
{
|
||||||
|
case AI_TEXTYPE_DIFFUSE:
|
||||||
|
szType = "Diffuse";break;
|
||||||
|
case AI_TEXTYPE_SPECULAR:
|
||||||
|
szType = "Specular";break;
|
||||||
|
case AI_TEXTYPE_AMBIENT:
|
||||||
|
szType = "Ambient";break;
|
||||||
|
case AI_TEXTYPE_EMISSIVE:
|
||||||
|
szType = "Emissive";break;
|
||||||
|
case AI_TEXTYPE_HEIGHT:
|
||||||
|
szType = "HeightMap";break;
|
||||||
|
case AI_TEXTYPE_NORMALS:
|
||||||
|
szType = "NormalMap";break;
|
||||||
|
case AI_TEXTYPE_SHININESS:
|
||||||
|
szType = "Shininess";break;
|
||||||
|
};
|
||||||
|
sprintf(chTemp,"%s %i (%s)",szType,iIndex+1,sz);
|
||||||
|
|
||||||
|
TVITEMEX tvi;
|
||||||
|
TVINSERTSTRUCT sNew;
|
||||||
|
tvi.pszText = chTemp;
|
||||||
|
tvi.cchTextMax = (int)strlen(chTemp);
|
||||||
|
tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE;
|
||||||
|
tvi.iImage = iTexture;
|
||||||
|
tvi.iSelectedImage = iTexture;
|
||||||
|
tvi.lParam = (LPARAM)0;
|
||||||
|
|
||||||
|
sNew.itemex = tvi;
|
||||||
|
sNew.hInsertAfter = TVI_LAST;
|
||||||
|
sNew.hParent = hFX;
|
||||||
|
|
||||||
|
// add the item to the list
|
||||||
|
HTREEITEM hTexture = (HTREEITEM)SendMessage(GetDlgItem(g_hDlg,IDC_TREE1),
|
||||||
|
TVM_INSERTITEM,
|
||||||
|
0,
|
||||||
|
(LPARAM)(LPTVINSERTSTRUCT)&sNew);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Add a material and all sub textures to the display mode list
|
||||||
|
// pcMat - material to be added
|
||||||
|
// hRoot - Handle to the root of the tree view
|
||||||
|
// iFX - Index of the material image in the image list of the tree view
|
||||||
|
// iTexture - Index of the texture image in the image list of the tree view
|
||||||
|
// iIndex - Material index
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
int AddMaterialToDisplayList(HTREEITEM hRoot, const aiMaterial* pcMat,
|
||||||
|
unsigned int iFX, unsigned int iTexture, unsigned int iIndex)
|
||||||
|
{
|
||||||
|
// use the name of the material, if possible
|
||||||
|
char chTemp[512];
|
||||||
|
aiString szOut;
|
||||||
|
if (AI_SUCCESS != aiGetMaterialString(pcMat,AI_MATKEY_NAME,&szOut))
|
||||||
|
{
|
||||||
|
sprintf(chTemp,"Material %i",iIndex+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(chTemp,"%s (%i)",szOut.data,iIndex+1);
|
||||||
|
}
|
||||||
|
TVITEMEX tvi;
|
||||||
|
TVINSERTSTRUCT sNew;
|
||||||
|
tvi.pszText = chTemp;
|
||||||
|
tvi.cchTextMax = (int)strlen(chTemp);
|
||||||
|
tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE | TVIF_STATE;
|
||||||
|
tvi.iImage = iFX;
|
||||||
|
tvi.iSelectedImage = iFX;
|
||||||
|
tvi.lParam = (LPARAM)0;
|
||||||
|
tvi.state = TVIS_EXPANDED | TVIS_EXPANDEDONCE ;
|
||||||
|
|
||||||
|
sNew.itemex = tvi;
|
||||||
|
sNew.hInsertAfter = TVI_LAST;
|
||||||
|
sNew.hParent = hRoot;
|
||||||
|
|
||||||
|
// add the item to the list
|
||||||
|
HTREEITEM hTexture = (HTREEITEM)SendMessage(GetDlgItem(g_hDlg,IDC_TREE1),
|
||||||
|
TVM_INSERTITEM,
|
||||||
|
0,
|
||||||
|
(LPARAM)(LPTVINSERTSTRUCT)&sNew);
|
||||||
|
|
||||||
|
// for each texture in the list ... add it
|
||||||
|
unsigned int iUV;
|
||||||
|
float fBlend;
|
||||||
|
aiTextureOp eOp;
|
||||||
|
aiString szPath;
|
||||||
|
for (unsigned int i = 0; i < 7;++i)
|
||||||
|
{
|
||||||
|
unsigned int iNum = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (AI_SUCCESS != aiGetMaterialTexture(pcMat,iNum,i,
|
||||||
|
&szPath,&iUV,&fBlend,&eOp))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
AddTextureToDisplayList(i,iNum,&szPath,hTexture,
|
||||||
|
pcMat,iTexture,iUV,fBlend,eOp);
|
||||||
|
++iNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Fill the UI combobox with a list of all supported view modi
|
||||||
|
//
|
||||||
|
// The display modes are added in order
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
int FillDisplayList(void)
|
||||||
|
{
|
||||||
|
// Initialize the tree view window.
|
||||||
|
|
||||||
|
// First, create the image list we will need.
|
||||||
|
#define NUM_BITMAPS 4
|
||||||
|
HIMAGELIST hIml = ImageList_Create( 16,16,ILC_COLOR24, NUM_BITMAPS, 0 );
|
||||||
|
|
||||||
|
|
||||||
|
// Load the bitmaps and add them to the image lists.
|
||||||
|
HBITMAP hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BFX));
|
||||||
|
int iFX = ImageList_Add(hIml, hBmp, NULL);
|
||||||
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
|
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BNODE));
|
||||||
|
int iNode = ImageList_Add(hIml, hBmp, NULL);
|
||||||
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
|
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BTX));
|
||||||
|
int iTexture = ImageList_Add(hIml, hBmp, NULL);
|
||||||
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
|
hBmp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BROOT));
|
||||||
|
int iRoot = ImageList_Add(hIml, hBmp, NULL);
|
||||||
|
DeleteObject(hBmp);
|
||||||
|
|
||||||
|
// Associate the image list with the tree.
|
||||||
|
TreeView_SetImageList(GetDlgItem(g_hDlg,IDC_TREE1), hIml, TVSIL_NORMAL);
|
||||||
|
|
||||||
|
// fill in the first entry
|
||||||
|
TVITEMEX tvi;
|
||||||
|
TVINSERTSTRUCT sNew;
|
||||||
|
tvi.pszText = "Model";
|
||||||
|
tvi.cchTextMax = (int)strlen(tvi.pszText);
|
||||||
|
tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE | TVIF_STATE;
|
||||||
|
tvi.state = TVIS_EXPANDED ;
|
||||||
|
tvi.iImage = iRoot;
|
||||||
|
tvi.iSelectedImage = iRoot;
|
||||||
|
tvi.lParam = (LPARAM)0;
|
||||||
|
|
||||||
|
sNew.itemex = tvi;
|
||||||
|
sNew.hInsertAfter = TVI_ROOT;
|
||||||
|
sNew.hParent = 0;
|
||||||
|
|
||||||
|
HTREEITEM hRoot = (HTREEITEM)SendMessage(GetDlgItem(g_hDlg,IDC_TREE1),
|
||||||
|
TVM_INSERTITEM,
|
||||||
|
0,
|
||||||
|
(LPARAM)(LPTVINSERTSTRUCT)&sNew);
|
||||||
|
|
||||||
|
|
||||||
|
// add each loaded material
|
||||||
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMaterials;++i)
|
||||||
|
{
|
||||||
|
AddMaterialToDisplayList(hRoot,g_pcAsset->pcScene->mMaterials[i],
|
||||||
|
iFX,iTexture,i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now add all loaded nodes recursively
|
||||||
|
AddNodeToDisplayList(iNode,0,0,g_pcAsset->pcScene->mRootNode,hRoot);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -416,29 +746,59 @@ int CreateAssetData(void)
|
||||||
MessageBox(g_hDlg,"Failed to create vertex buffer",
|
MessageBox(g_hDlg,"Failed to create vertex buffer",
|
||||||
"ASSIMP Viewer Utility",MB_OK);
|
"ASSIMP Viewer Utility",MB_OK);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
// create index buffer
|
|
||||||
if(FAILED( g_piDevice->CreateIndexBuffer( 4 *
|
// check whether we can use 16 bit indices
|
||||||
g_pcAsset->pcScene->mMeshes[i]->mNumFaces * 3,
|
if (g_pcAsset->pcScene->mMeshes[i]->mNumFaces * 3 >= 65536)
|
||||||
D3DUSAGE_WRITEONLY,
|
{
|
||||||
D3DFMT_INDEX32,
|
// create 32 bit index buffer
|
||||||
D3DPOOL_DEFAULT, &g_pcAsset->apcMeshes[i]->piIB,NULL)))
|
if(FAILED( g_piDevice->CreateIndexBuffer( 4 *
|
||||||
|
g_pcAsset->pcScene->mMeshes[i]->mNumFaces * 3,
|
||||||
|
D3DUSAGE_WRITEONLY,
|
||||||
|
D3DFMT_INDEX32,
|
||||||
|
D3DPOOL_DEFAULT, &g_pcAsset->apcMeshes[i]->piIB,NULL)))
|
||||||
{
|
{
|
||||||
MessageBox(g_hDlg,"Failed to create index buffer",
|
MessageBox(g_hDlg,"Failed to create 32 Bit index buffer",
|
||||||
"ASSIMP Viewer Utility",MB_OK);
|
"ASSIMP Viewer Utility",MB_OK);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now fill the index buffer
|
// now fill the index buffer
|
||||||
unsigned int* pbData;
|
unsigned int* pbData;
|
||||||
g_pcAsset->apcMeshes[i]->piIB->Lock(0,0,(void**)&pbData,0);
|
g_pcAsset->apcMeshes[i]->piIB->Lock(0,0,(void**)&pbData,0);
|
||||||
for (unsigned int x = 0; x < g_pcAsset->pcScene->mMeshes[i]->mNumFaces;++x)
|
for (unsigned int x = 0; x < g_pcAsset->pcScene->mMeshes[i]->mNumFaces;++x)
|
||||||
{
|
{
|
||||||
for (unsigned int a = 0; a < 3;++a)
|
for (unsigned int a = 0; a < 3;++a)
|
||||||
{
|
{
|
||||||
*pbData++ = g_pcAsset->pcScene->mMeshes[i]->mFaces[x].mIndices[a];
|
*pbData++ = g_pcAsset->pcScene->mMeshes[i]->mFaces[x].mIndices[a];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// create 16 bit index buffer
|
||||||
|
if(FAILED( g_piDevice->CreateIndexBuffer( 2 *
|
||||||
|
g_pcAsset->pcScene->mMeshes[i]->mNumFaces * 3,
|
||||||
|
D3DUSAGE_WRITEONLY,
|
||||||
|
D3DFMT_INDEX16,
|
||||||
|
D3DPOOL_DEFAULT, &g_pcAsset->apcMeshes[i]->piIB,NULL)))
|
||||||
|
{
|
||||||
|
MessageBox(g_hDlg,"Failed to create 16 Bit index buffer",
|
||||||
|
"ASSIMP Viewer Utility",MB_OK);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now fill the index buffer
|
||||||
|
uint16_t* pbData;
|
||||||
|
g_pcAsset->apcMeshes[i]->piIB->Lock(0,0,(void**)&pbData,0);
|
||||||
|
for (unsigned int x = 0; x < g_pcAsset->pcScene->mMeshes[i]->mNumFaces;++x)
|
||||||
|
{
|
||||||
|
for (unsigned int a = 0; a < 3;++a)
|
||||||
|
{
|
||||||
|
*pbData++ = (uint16_t)g_pcAsset->pcScene->mMeshes[i]->mFaces[x].mIndices[a];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
g_pcAsset->apcMeshes[i]->piIB->Unlock();
|
g_pcAsset->apcMeshes[i]->piIB->Unlock();
|
||||||
|
|
||||||
// now fill the vertex buffer
|
// now fill the vertex buffer
|
||||||
|
@ -504,6 +864,7 @@ int CreateAssetData(void)
|
||||||
sprintf(szTemp,"%i", g_iShaderCount);
|
sprintf(szTemp,"%i", g_iShaderCount);
|
||||||
SetDlgItemText(g_hDlg,IDC_ESHADER,szTemp);
|
SetDlgItemText(g_hDlg,IDC_ESHADER,szTemp);
|
||||||
|
|
||||||
|
FillDisplayList();
|
||||||
return FillAnimList();
|
return FillAnimList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,6 +1116,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
{
|
{
|
||||||
D3DDEVTYPE eType = bHW ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
|
D3DDEVTYPE eType = bHW ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
|
||||||
|
|
||||||
|
// get the client rectangle of the window.
|
||||||
RECT sRect;
|
RECT sRect;
|
||||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
||||||
sRect.right -= sRect.left;
|
sRect.right -= sRect.left;
|
||||||
|
@ -763,17 +1125,26 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
D3DPRESENT_PARAMETERS sParams;
|
D3DPRESENT_PARAMETERS sParams;
|
||||||
memset(&sParams,0,sizeof(D3DPRESENT_PARAMETERS));
|
memset(&sParams,0,sizeof(D3DPRESENT_PARAMETERS));
|
||||||
|
|
||||||
|
// get the current display mode
|
||||||
D3DDISPLAYMODE sMode;
|
D3DDISPLAYMODE sMode;
|
||||||
g_piD3D->GetAdapterDisplayMode(0,&sMode);
|
g_piD3D->GetAdapterDisplayMode(0,&sMode);
|
||||||
|
|
||||||
sParams.Windowed = TRUE;
|
// fill the presentation parameter structure
|
||||||
sParams.hDeviceWindow = GetDlgItem( g_hDlg, IDC_RT );
|
sParams.Windowed = TRUE;
|
||||||
sParams.EnableAutoDepthStencil = TRUE;
|
sParams.hDeviceWindow = GetDlgItem( g_hDlg, IDC_RT );
|
||||||
sParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
sParams.EnableAutoDepthStencil = TRUE;
|
||||||
sParams.BackBufferWidth = (UINT)sRect.right;
|
sParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||||
sParams.BackBufferHeight = (UINT)sRect.bottom;
|
sParams.BackBufferWidth = (UINT)sRect.right;
|
||||||
sParams.AutoDepthStencilFormat = D3DFMT_D24X8;
|
sParams.BackBufferHeight = (UINT)sRect.bottom;
|
||||||
sParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
sParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
|
|
||||||
|
// check whether we can use a D32 depth buffer format
|
||||||
|
if (SUCCEEDED ( g_piD3D->CheckDepthStencilMatch(0,eType,
|
||||||
|
D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,D3DFMT_D32)))
|
||||||
|
{
|
||||||
|
sParams.AutoDepthStencilFormat = D3DFMT_D32;
|
||||||
|
}
|
||||||
|
else sParams.AutoDepthStencilFormat = D3DFMT_D24X8;
|
||||||
|
|
||||||
// find the highest multisample type available on this device
|
// find the highest multisample type available on this device
|
||||||
D3DMULTISAMPLE_TYPE sMS = D3DMULTISAMPLE_2_SAMPLES;
|
D3DMULTISAMPLE_TYPE sMS = D3DMULTISAMPLE_2_SAMPLES;
|
||||||
|
@ -797,6 +1168,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
sParams.MultiSampleType = sMSOut;
|
sParams.MultiSampleType = sMSOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create the D3D9 device object
|
||||||
if(FAILED(g_piD3D->CreateDevice(0,eType,
|
if(FAILED(g_piD3D->CreateDevice(0,eType,
|
||||||
g_hDlg,D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,&sParams,&g_piDevice)))
|
g_hDlg,D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,&sParams,&g_piDevice)))
|
||||||
{
|
{
|
||||||
|
@ -810,6 +1182,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
}
|
}
|
||||||
g_piDevice->SetFVF(AssetHelper::Vertex::GetFVF());
|
g_piDevice->SetFVF(AssetHelper::Vertex::GetFVF());
|
||||||
|
|
||||||
|
// compile the default material shader (gray gouraud/phong)
|
||||||
ID3DXBuffer* piBuffer = NULL;
|
ID3DXBuffer* piBuffer = NULL;
|
||||||
if(FAILED( D3DXCreateEffect(g_piDevice,
|
if(FAILED( D3DXCreateEffect(g_piDevice,
|
||||||
g_szDefaultShader.c_str(),
|
g_szDefaultShader.c_str(),
|
||||||
|
@ -833,6 +1206,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
piBuffer = NULL;
|
piBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create the shader used to draw the HUD
|
||||||
if(FAILED( D3DXCreateEffect(g_piDevice,
|
if(FAILED( D3DXCreateEffect(g_piDevice,
|
||||||
g_szPassThroughShader.c_str(),(UINT)g_szPassThroughShader.length(),
|
g_szPassThroughShader.c_str(),(UINT)g_szPassThroughShader.length(),
|
||||||
NULL,NULL,D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,NULL,&g_piPassThroughEffect,&piBuffer)))
|
NULL,NULL,D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,NULL,&g_piPassThroughEffect,&piBuffer)))
|
||||||
|
@ -850,6 +1224,8 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
piBuffer = NULL;
|
piBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create the shader used to visualize normal vectors
|
||||||
if(FAILED( D3DXCreateEffect(g_piDevice,
|
if(FAILED( D3DXCreateEffect(g_piDevice,
|
||||||
g_szNormalsShader.c_str(),(UINT)g_szNormalsShader.length(),
|
g_szNormalsShader.c_str(),(UINT)g_szNormalsShader.length(),
|
||||||
NULL,NULL,D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,NULL,&g_piNormalsEffect, &piBuffer)))
|
NULL,NULL,D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,NULL,&g_piNormalsEffect, &piBuffer)))
|
||||||
|
@ -868,6 +1244,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
piBuffer = NULL;
|
piBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the capabilities of the device object
|
||||||
g_piDevice->GetDeviceCaps(&g_sCaps);
|
g_piDevice->GetDeviceCaps(&g_sCaps);
|
||||||
if(g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0))
|
if(g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0))
|
||||||
{
|
{
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue