Refactored the 3ds and ase loaders, anon. union and struct isn't anymore necessary
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@48 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
cbbb704198
commit
3dbd8c1619
|
@ -131,20 +131,20 @@ void Dot3DSImporter::CheckIndices(Dot3DS::Mesh* sMesh)
|
||||||
i != sMesh->mFaces.end();++i)
|
i != sMesh->mFaces.end();++i)
|
||||||
{
|
{
|
||||||
// check whether all indices are in range
|
// check whether all indices are in range
|
||||||
if ((*i).a.b.i1 >= sMesh->mPositions.size())
|
if ((*i).mIndices[0] >= sMesh->mPositions.size())
|
||||||
{
|
{
|
||||||
DefaultLogger::get()->warn("Face index overflow in 3DS file (#1)");
|
DefaultLogger::get()->warn("Face index overflow in 3DS file (#1)");
|
||||||
(*i).a.b.i1 = sMesh->mPositions.size()-1;
|
(*i).mIndices[0] = sMesh->mPositions.size()-1;
|
||||||
}
|
}
|
||||||
if ((*i).a.b.i2 >= sMesh->mPositions.size())
|
if ((*i).mIndices[1] >= sMesh->mPositions.size())
|
||||||
{
|
{
|
||||||
DefaultLogger::get()->warn("Face index overflow in 3DS file (#2)");
|
DefaultLogger::get()->warn("Face index overflow in 3DS file (#2)");
|
||||||
(*i).a.b.i2 = sMesh->mPositions.size()-1;
|
(*i).mIndices[1] = sMesh->mPositions.size()-1;
|
||||||
}
|
}
|
||||||
if ((*i).a.b.i3 >= sMesh->mPositions.size())
|
if ((*i).mIndices[2] >= sMesh->mPositions.size())
|
||||||
{
|
{
|
||||||
DefaultLogger::get()->warn("Face index overflow in 3DS file (#3)");
|
DefaultLogger::get()->warn("Face index overflow in 3DS file (#3)");
|
||||||
(*i).a.b.i3 = sMesh->mPositions.size()-1;
|
(*i).mIndices[2] = sMesh->mPositions.size()-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -169,20 +169,20 @@ void Dot3DSImporter::MakeUnique(Dot3DS::Mesh* sMesh)
|
||||||
uint32_t iTemp1,iTemp2;
|
uint32_t iTemp1,iTemp2;
|
||||||
|
|
||||||
// position and texture coordinates
|
// position and texture coordinates
|
||||||
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i3];
|
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[2]];
|
||||||
vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].a.b.i3];
|
vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].mIndices[2]];
|
||||||
iTemp1 = iBase++;
|
iTemp1 = iBase++;
|
||||||
|
|
||||||
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i2];
|
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[1]];
|
||||||
vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].a.b.i2];
|
vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].mIndices[1]];
|
||||||
iTemp2 = iBase++;
|
iTemp2 = iBase++;
|
||||||
|
|
||||||
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i1];
|
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[0]];
|
||||||
vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].a.b.i1];
|
vNew2[iBase] = sMesh->mTexCoords[sMesh->mFaces[i].mIndices[0]];
|
||||||
sMesh->mFaces[i].a.b.i3 = iBase++;
|
sMesh->mFaces[i].mIndices[2] = iBase++;
|
||||||
|
|
||||||
sMesh->mFaces[i].a.b.i1 = iTemp1;
|
sMesh->mFaces[i].mIndices[0] = iTemp1;
|
||||||
sMesh->mFaces[i].a.b.i2 = iTemp2;
|
sMesh->mFaces[i].mIndices[1] = iTemp2;
|
||||||
|
|
||||||
// handle the face order ...
|
// handle the face order ...
|
||||||
/*if (iTemp1 > iTemp2)
|
/*if (iTemp1 > iTemp2)
|
||||||
|
@ -198,17 +198,17 @@ void Dot3DSImporter::MakeUnique(Dot3DS::Mesh* sMesh)
|
||||||
uint32_t iTemp1,iTemp2;
|
uint32_t iTemp1,iTemp2;
|
||||||
|
|
||||||
// position only
|
// position only
|
||||||
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i3];
|
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[2]];
|
||||||
iTemp1 = iBase++;
|
iTemp1 = iBase++;
|
||||||
|
|
||||||
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i2];
|
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[1]];
|
||||||
iTemp2 = iBase++;
|
iTemp2 = iBase++;
|
||||||
|
|
||||||
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].a.b.i1];
|
vNew[iBase] = sMesh->mPositions[sMesh->mFaces[i].mIndices[0]];
|
||||||
sMesh->mFaces[i].a.b.i3 = iBase++;
|
sMesh->mFaces[i].mIndices[2] = iBase++;
|
||||||
|
|
||||||
sMesh->mFaces[i].a.b.i1 = iTemp1;
|
sMesh->mFaces[i].mIndices[0] = iTemp1;
|
||||||
sMesh->mFaces[i].a.b.i2 = iTemp2;
|
sMesh->mFaces[i].mIndices[1] = iTemp2;
|
||||||
|
|
||||||
// handle the face order ...
|
// handle the face order ...
|
||||||
/*if (iTemp1 > iTemp2)
|
/*if (iTemp1 > iTemp2)
|
||||||
|
@ -451,16 +451,16 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
|
||||||
p_pcOut->mFaces[q].mNumIndices = 3;
|
p_pcOut->mFaces[q].mNumIndices = 3;
|
||||||
|
|
||||||
p_pcOut->mFaces[q].mIndices[2] = iBase;
|
p_pcOut->mFaces[q].mIndices[2] = iBase;
|
||||||
p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].a.b.i1];
|
p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].mIndices[0]];
|
||||||
p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].a.b.i1];
|
p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].mIndices[0]];
|
||||||
|
|
||||||
p_pcOut->mFaces[q].mIndices[1] = iBase;
|
p_pcOut->mFaces[q].mIndices[1] = iBase;
|
||||||
p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].a.b.i2];
|
p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].mIndices[1]];
|
||||||
p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].a.b.i2];
|
p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].mIndices[1]];
|
||||||
|
|
||||||
p_pcOut->mFaces[q].mIndices[0] = iBase;
|
p_pcOut->mFaces[q].mIndices[0] = iBase;
|
||||||
p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].a.b.i3];
|
p_pcOut->mVertices[iBase] = (*i).mPositions[(*i).mFaces[iIndex].mIndices[2]];
|
||||||
p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].a.b.i3];
|
p_pcOut->mNormals[iBase++] = (*i).mNormals[(*i).mFaces[iIndex].mIndices[2]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// convert texture coordinates
|
// convert texture coordinates
|
||||||
|
@ -473,15 +473,15 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
|
||||||
{
|
{
|
||||||
unsigned int iIndex2 = aiSplit[p][q];
|
unsigned int iIndex2 = aiSplit[p][q];
|
||||||
|
|
||||||
unsigned int iIndex = (*i).mFaces[iIndex2].a.b.i1;
|
unsigned int iIndex = (*i).mFaces[iIndex2].mIndices[0];
|
||||||
aiVector2D& pc = (*i).mTexCoords[iIndex];
|
aiVector2D& pc = (*i).mTexCoords[iIndex];
|
||||||
p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f);
|
p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f);
|
||||||
|
|
||||||
iIndex = (*i).mFaces[iIndex2].a.b.i2;
|
iIndex = (*i).mFaces[iIndex2].mIndices[1];
|
||||||
pc = (*i).mTexCoords[iIndex];
|
pc = (*i).mTexCoords[iIndex];
|
||||||
p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f);
|
p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f);
|
||||||
|
|
||||||
iIndex = (*i).mFaces[iIndex2].a.b.i3;
|
iIndex = (*i).mFaces[iIndex2].mIndices[2];
|
||||||
pc = (*i).mTexCoords[iIndex];
|
pc = (*i).mTexCoords[iIndex];
|
||||||
p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f);
|
p_pcOut->mTextureCoords[0][iBase++] = aiVector3D(pc.x,pc.y,0.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,17 +62,17 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
|
||||||
Dot3DS::Face& face = sMesh->mFaces[a];
|
Dot3DS::Face& face = sMesh->mFaces[a];
|
||||||
|
|
||||||
// assume it is a triangle
|
// assume it is a triangle
|
||||||
aiVector3D* pV1 = &sMesh->mPositions[face.a.b.i1];
|
aiVector3D* pV1 = &sMesh->mPositions[face.mIndices[0]];
|
||||||
aiVector3D* pV2 = &sMesh->mPositions[face.a.b.i2];
|
aiVector3D* pV2 = &sMesh->mPositions[face.mIndices[1]];
|
||||||
aiVector3D* pV3 = &sMesh->mPositions[face.a.b.i3];
|
aiVector3D* pV3 = &sMesh->mPositions[face.mIndices[2]];
|
||||||
|
|
||||||
aiVector3D pDelta1 = *pV2 - *pV1;
|
aiVector3D pDelta1 = *pV2 - *pV1;
|
||||||
aiVector3D pDelta2 = *pV3 - *pV1;
|
aiVector3D pDelta2 = *pV3 - *pV1;
|
||||||
aiVector3D vNor = pDelta1 ^ pDelta2;
|
aiVector3D vNor = pDelta1 ^ pDelta2;
|
||||||
|
|
||||||
sMesh->mNormals[face.a.b.i1] = vNor;
|
sMesh->mNormals[face.mIndices[0]] = vNor;
|
||||||
sMesh->mNormals[face.a.b.i2] = vNor;
|
sMesh->mNormals[face.mIndices[1]] = vNor;
|
||||||
sMesh->mNormals[face.a.b.i3] = vNor;
|
sMesh->mNormals[face.mIndices[2]] = vNor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate the position bounds so we have a reliable epsilon to
|
// calculate the position bounds so we have a reliable epsilon to
|
||||||
|
@ -111,7 +111,7 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
|
||||||
for (unsigned int c = 0; c < 3;++c)
|
for (unsigned int c = 0; c < 3;++c)
|
||||||
{
|
{
|
||||||
|
|
||||||
sSort.FindPositions(sMesh->mPositions[(*i).a.mIndices[c]],(*i).iSmoothGroup,
|
sSort.FindPositions(sMesh->mPositions[(*i).mIndices[c]],(*i).iSmoothGroup,
|
||||||
posEpsilon,poResult);
|
posEpsilon,poResult);
|
||||||
|
|
||||||
aiVector3D vNormals;
|
aiVector3D vNormals;
|
||||||
|
@ -127,7 +127,7 @@ void Dot3DSImporter::GenNormals(Dot3DS::Mesh* sMesh)
|
||||||
vNormals.y /= fDiv;
|
vNormals.y /= fDiv;
|
||||||
vNormals.z /= fDiv;
|
vNormals.z /= fDiv;
|
||||||
vNormals.Normalize();
|
vNormals.Normalize();
|
||||||
avNormals[(*i).a.mIndices[c]] = vNormals;
|
avNormals[(*i).mIndices[c]] = vNormals;
|
||||||
poResult.clear();
|
poResult.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,25 +308,16 @@ struct Face
|
||||||
Face() : iSmoothGroup(0), bFlipped(false)
|
Face() : iSmoothGroup(0), bFlipped(false)
|
||||||
{
|
{
|
||||||
// let the rest uninitialized for performance
|
// let the rest uninitialized for performance
|
||||||
this->a.b.i1 = 0;
|
this->mIndices[0] = 0;
|
||||||
this->a.b.i2 = 0;
|
this->mIndices[1] = 0;
|
||||||
this->a.b.i3 = 0;
|
this->mIndices[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! 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
|
||||||
union
|
uint32_t mIndices[3];
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint32_t i1;
|
|
||||||
uint32_t i2;
|
|
||||||
uint32_t i3;
|
|
||||||
} b; // DUMMY NAME
|
|
||||||
uint32_t mIndices[3];
|
|
||||||
} a; // DUMMY NAME
|
|
||||||
|
|
||||||
//! specifies to which smoothing group the face belongs to
|
//! specifies to which smoothing group the face belongs to
|
||||||
uint32_t iSmoothGroup;
|
uint32_t iSmoothGroup;
|
||||||
|
|
|
@ -983,11 +983,11 @@ void Dot3DSImporter::ParseMeshChunk(int* piRemaining)
|
||||||
while (iNum-- > 0)
|
while (iNum-- > 0)
|
||||||
{
|
{
|
||||||
Dot3DS::Face sFace;
|
Dot3DS::Face sFace;
|
||||||
sFace.a.b.i1 = *((uint16_t*)this->mCurrent);
|
sFace.mIndices[0] = *((uint16_t*)this->mCurrent);
|
||||||
this->mCurrent += sizeof(uint16_t);
|
this->mCurrent += sizeof(uint16_t);
|
||||||
sFace.a.b.i2 = *((uint16_t*)this->mCurrent);
|
sFace.mIndices[1] = *((uint16_t*)this->mCurrent);
|
||||||
this->mCurrent += sizeof(uint16_t);
|
this->mCurrent += sizeof(uint16_t);
|
||||||
sFace.a.b.i3 = *((uint16_t*)this->mCurrent);
|
sFace.mIndices[2] = *((uint16_t*)this->mCurrent);
|
||||||
this->mCurrent += 2*sizeof(uint16_t);
|
this->mCurrent += 2*sizeof(uint16_t);
|
||||||
mMesh.mFaces.push_back(sFace);
|
mMesh.mFaces.push_back(sFace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,18 +73,18 @@ void D3DSSpatialSorter::AddFace(const Dot3DS::Face* pcFace,
|
||||||
ai_assert(NULL != pcFace);
|
ai_assert(NULL != pcFace);
|
||||||
|
|
||||||
// store position by index and distance
|
// store position by index and distance
|
||||||
float distance = vPositions[pcFace->a.b.i1] * mPlaneNormal;
|
float distance = vPositions[pcFace->mIndices[0]] * mPlaneNormal;
|
||||||
mPositions.push_back( Entry( pcFace->a.b.i1, vPositions[pcFace->a.b.i1],
|
mPositions.push_back( Entry( pcFace->mIndices[0], vPositions[pcFace->mIndices[0]],
|
||||||
distance, pcFace->iSmoothGroup));
|
distance, pcFace->iSmoothGroup));
|
||||||
|
|
||||||
// triangle vertex 2
|
// triangle vertex 2
|
||||||
distance = vPositions[pcFace->a.b.i2] * mPlaneNormal;
|
distance = vPositions[pcFace->mIndices[1]] * mPlaneNormal;
|
||||||
mPositions.push_back( Entry( pcFace->a.b.i2, vPositions[pcFace->a.b.i2],
|
mPositions.push_back( Entry( pcFace->mIndices[1], vPositions[pcFace->mIndices[1]],
|
||||||
distance, pcFace->iSmoothGroup));
|
distance, pcFace->iSmoothGroup));
|
||||||
|
|
||||||
// triangle vertex 3
|
// triangle vertex 3
|
||||||
distance = vPositions[pcFace->a.b.i3] * mPlaneNormal;
|
distance = vPositions[pcFace->mIndices[2]] * mPlaneNormal;
|
||||||
mPositions.push_back( Entry( pcFace->a.b.i3, vPositions[pcFace->a.b.i3],
|
mPositions.push_back( Entry( pcFace->mIndices[2], vPositions[pcFace->mIndices[2]],
|
||||||
distance, pcFace->iSmoothGroup));
|
distance, pcFace->iSmoothGroup));
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -286,7 +286,7 @@ void ASEImporter::BuildUniqueRepresentation(ASE::Mesh& mesh)
|
||||||
{
|
{
|
||||||
for (unsigned int n = 0; n < 3;++n,++iCurrent)
|
for (unsigned int n = 0; n < 3;++n,++iCurrent)
|
||||||
{
|
{
|
||||||
mPositions[iCurrent] = mesh.mPositions[(*i).a.mIndices[n]];
|
mPositions[iCurrent] = mesh.mPositions[(*i).mIndices[n]];
|
||||||
|
|
||||||
// add texture coordinates
|
// add texture coordinates
|
||||||
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
||||||
|
@ -304,20 +304,20 @@ void ASEImporter::BuildUniqueRepresentation(ASE::Mesh& mesh)
|
||||||
// add normal vectors
|
// add normal vectors
|
||||||
if (!mesh.mNormals.empty())
|
if (!mesh.mNormals.empty())
|
||||||
{
|
{
|
||||||
mNormals[iCurrent] = mesh.mNormals[(*i).a.mIndices[n]];
|
mNormals[iCurrent] = mesh.mNormals[(*i).mIndices[n]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle bone vertices
|
// handle bone vertices
|
||||||
if ((*i).a.mIndices[n] < mesh.mBoneVertices.size())
|
if ((*i).mIndices[n] < mesh.mBoneVertices.size())
|
||||||
{
|
{
|
||||||
// (sometimes this will cause bone verts to be duplicated
|
// (sometimes this will cause bone verts to be duplicated
|
||||||
// however, I' quite sure Schrompf' JoinVerticesStep
|
// however, I' quite sure Schrompf' JoinVerticesStep
|
||||||
// will fix that again ...)
|
// will fix that again ...)
|
||||||
mBoneVertices[iCurrent] = mesh.mBoneVertices[(*i).a.mIndices[n]];
|
mBoneVertices[iCurrent] = mesh.mBoneVertices[(*i).mIndices[n]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign a new valid index to the face
|
// assign a new valid index to the face
|
||||||
(*i).a.mIndices[n] = iCurrent;
|
(*i).mIndices[n] = iCurrent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene)
|
||||||
|
|
||||||
for (unsigned int t = 0; t < 3;++t)
|
for (unsigned int t = 0; t < 3;++t)
|
||||||
{
|
{
|
||||||
const uint32_t iIndex2 = mesh.mFaces[iIndex].a.mIndices[t];
|
const uint32_t iIndex2 = mesh.mFaces[iIndex].mIndices[t];
|
||||||
|
|
||||||
p_pcOut->mVertices[iBase] = mesh.mPositions[iIndex2];
|
p_pcOut->mVertices[iBase] = mesh.mPositions[iIndex2];
|
||||||
p_pcOut->mNormals[iBase] = mesh.mNormals[iIndex2];
|
p_pcOut->mNormals[iBase] = mesh.mNormals[iIndex2];
|
||||||
|
@ -618,7 +618,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene)
|
||||||
unsigned int iIndex = aiSplit[p][q];
|
unsigned int iIndex = aiSplit[p][q];
|
||||||
for (unsigned int t = 0; t < 3;++t)
|
for (unsigned int t = 0; t < 3;++t)
|
||||||
{
|
{
|
||||||
p_pcOut->mTextureCoords[c][iBase++] = mesh.amTexCoords[c][mesh.mFaces[iIndex].a.mIndices[t]];
|
p_pcOut->mTextureCoords[c][iBase++] = mesh.amTexCoords[c][mesh.mFaces[iIndex].mIndices[t]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// setup the number of valid vertex components
|
// setup the number of valid vertex components
|
||||||
|
@ -636,7 +636,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene)
|
||||||
unsigned int iIndex = aiSplit[p][q];
|
unsigned int iIndex = aiSplit[p][q];
|
||||||
for (unsigned int t = 0; t < 3;++t)
|
for (unsigned int t = 0; t < 3;++t)
|
||||||
{
|
{
|
||||||
p_pcOut->mColors[0][iBase++] = mesh.mVertexColors[mesh.mFaces[iIndex].a.mIndices[t]];
|
p_pcOut->mColors[0][iBase++] = mesh.mVertexColors[mesh.mFaces[iIndex].mIndices[t]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -738,9 +738,9 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, aiScene* pcScene)
|
||||||
p_pcOut->mFaces[iFace].mIndices = new unsigned int[3];
|
p_pcOut->mFaces[iFace].mIndices = new unsigned int[3];
|
||||||
|
|
||||||
// copy indices
|
// copy indices
|
||||||
p_pcOut->mFaces[iFace].mIndices[0] = mesh.mFaces[iFace].a.mIndices[0];
|
p_pcOut->mFaces[iFace].mIndices[0] = mesh.mFaces[iFace].mIndices[0];
|
||||||
p_pcOut->mFaces[iFace].mIndices[1] = mesh.mFaces[iFace].a.mIndices[1];
|
p_pcOut->mFaces[iFace].mIndices[1] = mesh.mFaces[iFace].mIndices[1];
|
||||||
p_pcOut->mFaces[iFace].mIndices[2] = mesh.mFaces[iFace].a.mIndices[2];
|
p_pcOut->mFaces[iFace].mIndices[2] = mesh.mFaces[iFace].mIndices[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy vertex bones
|
// copy vertex bones
|
||||||
|
@ -889,17 +889,17 @@ void ASEImporter::GenerateNormals(ASE::Mesh& mesh)
|
||||||
const ASE::Face& face = mesh.mFaces[a];
|
const ASE::Face& face = mesh.mFaces[a];
|
||||||
|
|
||||||
// assume it is a triangle
|
// assume it is a triangle
|
||||||
aiVector3D* pV1 = &mesh.mPositions[face.a.b.i1];
|
aiVector3D* pV1 = &mesh.mPositions[face.mIndices[0]];
|
||||||
aiVector3D* pV2 = &mesh.mPositions[face.a.b.i2];
|
aiVector3D* pV2 = &mesh.mPositions[face.mIndices[1]];
|
||||||
aiVector3D* pV3 = &mesh.mPositions[face.a.b.i3];
|
aiVector3D* pV3 = &mesh.mPositions[face.mIndices[2]];
|
||||||
|
|
||||||
aiVector3D pDelta1 = *pV2 - *pV1;
|
aiVector3D pDelta1 = *pV2 - *pV1;
|
||||||
aiVector3D pDelta2 = *pV3 - *pV1;
|
aiVector3D pDelta2 = *pV3 - *pV1;
|
||||||
aiVector3D vNor = pDelta1 ^ pDelta2;
|
aiVector3D vNor = pDelta1 ^ pDelta2;
|
||||||
|
|
||||||
mesh.mNormals[face.a.b.i1] = vNor;
|
mesh.mNormals[face.mIndices[0]] = vNor;
|
||||||
mesh.mNormals[face.a.b.i2] = vNor;
|
mesh.mNormals[face.mIndices[1]] = vNor;
|
||||||
mesh.mNormals[face.a.b.i3] = vNor;
|
mesh.mNormals[face.mIndices[2]] = vNor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate the position bounds so we have a reliable epsilon to
|
// calculate the position bounds so we have a reliable epsilon to
|
||||||
|
@ -934,7 +934,7 @@ void ASEImporter::GenerateNormals(ASE::Mesh& mesh)
|
||||||
std::vector<unsigned int> poResult;
|
std::vector<unsigned int> poResult;
|
||||||
for (unsigned int c = 0; c < 3;++c)
|
for (unsigned int c = 0; c < 3;++c)
|
||||||
{
|
{
|
||||||
sSort.FindPositions(mesh.mPositions[(*i).a.mIndices[c]],(*i).iSmoothGroup,
|
sSort.FindPositions(mesh.mPositions[(*i).mIndices[c]],(*i).iSmoothGroup,
|
||||||
posEpsilon,poResult);
|
posEpsilon,poResult);
|
||||||
|
|
||||||
aiVector3D vNormals;
|
aiVector3D vNormals;
|
||||||
|
@ -948,7 +948,7 @@ void ASEImporter::GenerateNormals(ASE::Mesh& mesh)
|
||||||
}
|
}
|
||||||
vNormals.x /= fDiv;vNormals.y /= fDiv;vNormals.z /= fDiv;
|
vNormals.x /= fDiv;vNormals.y /= fDiv;vNormals.z /= fDiv;
|
||||||
vNormals.Normalize();
|
vNormals.Normalize();
|
||||||
avNormals[(*i).a.mIndices[c]] = vNormals;
|
avNormals[(*i).mIndices[c]] = vNormals;
|
||||||
poResult.clear();
|
poResult.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1567,7 +1567,7 @@ __EARTHQUAKE_XXL:
|
||||||
if(!SkipSpaces(this->m_szFile,&this->m_szFile))
|
if(!SkipSpaces(this->m_szFile,&this->m_szFile))
|
||||||
BLUBB("Unable to parse *MESH_FACE Element: Unexpected EOL. Vertex index ecpected [#4]")
|
BLUBB("Unable to parse *MESH_FACE Element: Unexpected EOL. Vertex index ecpected [#4]")
|
||||||
|
|
||||||
out.a.mIndices[iIndex] = strtol10(this->m_szFile,&this->m_szFile);
|
out.mIndices[iIndex] = strtol10(this->m_szFile,&this->m_szFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we need to skip the AB, BC, CA blocks.
|
// now we need to skip the AB, BC, CA blocks.
|
||||||
|
|
Loading…
Reference in New Issue