worked on getting assimpl compiled on BE
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@201 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
e9dc280739
commit
ef3cd69ae6
12
code/IFF.h
12
code/IFF.h
|
@ -54,9 +54,9 @@ struct SubChunkHeader
|
||||||
//! @param outFile Pointer to the file data - points to the chunk data afterwards
|
//! @param outFile Pointer to the file data - points to the chunk data afterwards
|
||||||
//! @return Pointer to the chunk header
|
//! @return Pointer to the chunk header
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
inline LE_NCONST ChunkHeader* LoadChunk(LE_NCONST uint8_t*& outFile)
|
inline ChunkHeader* LoadChunk(uint8_t*& outFile)
|
||||||
{
|
{
|
||||||
LE_NCONST ChunkHeader* head = (LE_NCONST ChunkHeader*) outFile;
|
ChunkHeader* head = (ChunkHeader*) outFile;
|
||||||
AI_LSWAP4(head->length);
|
AI_LSWAP4(head->length);
|
||||||
AI_LSWAP4(head->type);
|
AI_LSWAP4(head->type);
|
||||||
outFile += sizeof(ChunkHeader);
|
outFile += sizeof(ChunkHeader);
|
||||||
|
@ -68,9 +68,9 @@ inline LE_NCONST ChunkHeader* LoadChunk(LE_NCONST uint8_t*& outFile)
|
||||||
//! @param outFile Pointer to the file data - points to the chunk data afterwards
|
//! @param outFile Pointer to the file data - points to the chunk data afterwards
|
||||||
//! @return Pointer to the sub chunk header
|
//! @return Pointer to the sub chunk header
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
inline LE_NCONST SubChunkHeader* LoadSubChunk(LE_NCONST uint8_t*& outFile)
|
inline SubChunkHeader* LoadSubChunk(uint8_t*& outFile)
|
||||||
{
|
{
|
||||||
LE_NCONST SubChunkHeader* head = (LE_NCONST SubChunkHeader*) outFile;
|
SubChunkHeader* head = (SubChunkHeader*) outFile;
|
||||||
AI_LSWAP2(head->length);
|
AI_LSWAP2(head->length);
|
||||||
AI_LSWAP4(head->type);
|
AI_LSWAP4(head->type);
|
||||||
outFile += sizeof(SubChunkHeader);
|
outFile += sizeof(SubChunkHeader);
|
||||||
|
@ -84,9 +84,9 @@ inline LE_NCONST SubChunkHeader* LoadSubChunk(LE_NCONST uint8_t*& outFile)
|
||||||
//! @param fileType Receives the type of the file
|
//! @param fileType Receives the type of the file
|
||||||
//! @return 0 if everything was OK, otherwise an error message
|
//! @return 0 if everything was OK, otherwise an error message
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
inline const char* ReadHeader(LE_NCONST uint8_t* outFile,uint32_t& fileType)
|
inline const char* ReadHeader(uint8_t* outFile,uint32_t& fileType)
|
||||||
{
|
{
|
||||||
LE_NCONST ChunkHeader* head = LoadChunk(outFile);
|
ChunkHeader* head = LoadChunk(outFile);
|
||||||
if(AI_IFF_FOURCC_FORM != head->type)
|
if(AI_IFF_FOURCC_FORM != head->type)
|
||||||
{
|
{
|
||||||
return "The file is not an IFF file: FORM chunk is missing";
|
return "The file is not an IFF file: FORM chunk is missing";
|
||||||
|
|
|
@ -67,7 +67,7 @@ void LWOImporter::LoadLWOBFile()
|
||||||
throw new ImportErrorException("LWOB: Invalid chunk length");
|
throw new ImportErrorException("LWOB: Invalid chunk length");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
// vertex list
|
// vertex list
|
||||||
|
@ -220,7 +220,7 @@ void LWOImporter::LoadLWOBSurface(unsigned int size)
|
||||||
if (mFileBuffer + head->length > end)
|
if (mFileBuffer + head->length > end)
|
||||||
throw new ImportErrorException("LWOB: Invalid surface chunk length");
|
throw new ImportErrorException("LWOB: Invalid surface chunk length");
|
||||||
|
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
// diffuse color
|
// diffuse color
|
||||||
|
|
|
@ -699,7 +699,7 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// first find out how many faces and vertices we'll finally need
|
// first find out how many faces and vertices we'll finally need
|
||||||
LE_NCONST uint16_t* cursor = (LE_NCONST uint16_t*)mFileBuffer;
|
uint16_t* cursor = (uint16_t*)mFileBuffer;
|
||||||
|
|
||||||
unsigned int iNumFaces = 0,iNumVertices = 0;
|
unsigned int iNumFaces = 0,iNumVertices = 0;
|
||||||
CountVertsAndFacesLWO2(iNumVertices,iNumFaces,cursor,end);
|
CountVertsAndFacesLWO2(iNumVertices,iNumFaces,cursor,end);
|
||||||
|
@ -707,7 +707,7 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length)
|
||||||
// allocate the output array and copy face indices
|
// allocate the output array and copy face indices
|
||||||
if (iNumFaces)
|
if (iNumFaces)
|
||||||
{
|
{
|
||||||
cursor = (LE_NCONST uint16_t*)mFileBuffer;
|
cursor = (uint16_t*)mFileBuffer;
|
||||||
|
|
||||||
mCurLayer->mFaces.resize(iNumFaces);
|
mCurLayer->mFaces.resize(iNumFaces);
|
||||||
FaceList::iterator it = mCurLayer->mFaces.begin();
|
FaceList::iterator it = mCurLayer->mFaces.begin();
|
||||||
|
@ -717,7 +717,7 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LWOImporter::CountVertsAndFacesLWO2(unsigned int& verts, unsigned int& faces,
|
void LWOImporter::CountVertsAndFacesLWO2(unsigned int& verts, unsigned int& faces,
|
||||||
LE_NCONST uint16_t*& cursor, const uint16_t* const end, unsigned int max)
|
uint16_t*& cursor, const uint16_t* const end, unsigned int max)
|
||||||
{
|
{
|
||||||
while (cursor < end && max--)
|
while (cursor < end && max--)
|
||||||
{
|
{
|
||||||
|
@ -733,7 +733,7 @@ void LWOImporter::CountVertsAndFacesLWO2(unsigned int& verts, unsigned int& face
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LWOImporter::CopyFaceIndicesLWO2(FaceList::iterator& it,
|
void LWOImporter::CopyFaceIndicesLWO2(FaceList::iterator& it,
|
||||||
LE_NCONST uint16_t*& cursor,
|
uint16_t*& cursor,
|
||||||
const uint16_t* const end)
|
const uint16_t* const end)
|
||||||
{
|
{
|
||||||
while (cursor < end)
|
while (cursor < end)
|
||||||
|
@ -979,7 +979,7 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
|
||||||
// first - get the index of the clip
|
// first - get the index of the clip
|
||||||
clip.idx = GetU4();
|
clip.idx = GetU4();
|
||||||
|
|
||||||
LE_NCONST IFF::SubChunkHeader* const head = IFF::LoadSubChunk(mFileBuffer);
|
IFF::SubChunkHeader* const head = IFF::LoadSubChunk(mFileBuffer);
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
case AI_LWO_STIL:
|
case AI_LWO_STIL:
|
||||||
|
@ -994,7 +994,8 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
|
||||||
int16_t start = GetU2(); mFileBuffer+=4;
|
int16_t start = GetU2(); mFileBuffer+=4;
|
||||||
|
|
||||||
std::string s;std::stringstream ss;
|
std::string s;std::stringstream ss;
|
||||||
GetS0(s,head->length);head->length -= (unsigned int)s.length()+1;
|
GetS0(s,head->length);
|
||||||
|
head->length -= (unsigned int)s.length()+1;
|
||||||
ss << s;
|
ss << s;
|
||||||
ss << std::setw(digits) << offset + start;
|
ss << std::setw(digits) << offset + start;
|
||||||
GetS0(s,head->length);
|
GetS0(s,head->length);
|
||||||
|
@ -1029,14 +1030,14 @@ void LWOImporter::LoadLWO2File()
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)break;
|
if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)break;
|
||||||
LE_NCONST IFF::ChunkHeader* const head = IFF::LoadChunk(mFileBuffer);
|
IFF::ChunkHeader* const head = IFF::LoadChunk(mFileBuffer);
|
||||||
|
|
||||||
if (mFileBuffer + head->length > end)
|
if (mFileBuffer + head->length > end)
|
||||||
{
|
{
|
||||||
throw new ImportErrorException("LWO2: Chunk length points behind the file");
|
throw new ImportErrorException("LWO2: Chunk length points behind the file");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
unsigned int iUnnamed = 0;
|
unsigned int iUnnamed = 0;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,7 +217,7 @@ private:
|
||||||
*/
|
*/
|
||||||
void CountVertsAndFacesLWO2(unsigned int& verts,
|
void CountVertsAndFacesLWO2(unsigned int& verts,
|
||||||
unsigned int& faces,
|
unsigned int& faces,
|
||||||
LE_NCONST uint16_t*& cursor,
|
uint16_t*& cursor,
|
||||||
const uint16_t* const end,
|
const uint16_t* const end,
|
||||||
unsigned int max = 0xffffffff);
|
unsigned int max = 0xffffffff);
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ private:
|
||||||
/** Read vertices and faces in a LWOB/LWO2 file
|
/** Read vertices and faces in a LWOB/LWO2 file
|
||||||
*/
|
*/
|
||||||
void CopyFaceIndicesLWO2(LWO::FaceList::iterator& it,
|
void CopyFaceIndicesLWO2(LWO::FaceList::iterator& it,
|
||||||
LE_NCONST uint16_t*& cursor,
|
uint16_t*& cursor,
|
||||||
const uint16_t* const end);
|
const uint16_t* const end);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -375,7 +375,7 @@ protected:
|
||||||
ClipList mClips;
|
ClipList mClips;
|
||||||
|
|
||||||
/** file buffer */
|
/** file buffer */
|
||||||
LE_NCONST uint8_t* mFileBuffer;
|
uint8_t* mFileBuffer;
|
||||||
|
|
||||||
/** Size of the file, in bytes */
|
/** Size of the file, in bytes */
|
||||||
unsigned int fileSize;
|
unsigned int fileSize;
|
||||||
|
|
|
@ -380,7 +380,7 @@ void LWOImporter::LoadLWO2ImageMap(unsigned int size, LWO::Texture& tex )
|
||||||
if (mFileBuffer + head->length > end)
|
if (mFileBuffer + head->length > end)
|
||||||
throw new ImportErrorException("LWO2: Invalid SURF.BLOCK chunk length");
|
throw new ImportErrorException("LWO2: Invalid SURF.BLOCK chunk length");
|
||||||
|
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
case AI_LWO_PROJ:
|
case AI_LWO_PROJ:
|
||||||
|
@ -445,7 +445,7 @@ void LWOImporter::LoadLWO2TextureHeader(unsigned int size, LWO::Texture& tex )
|
||||||
if (mFileBuffer + head->length > end)
|
if (mFileBuffer + head->length > end)
|
||||||
throw new ImportErrorException("LWO2: Invalid texture header chunk length");
|
throw new ImportErrorException("LWO2: Invalid texture header chunk length");
|
||||||
|
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
case AI_LWO_CHAN:
|
case AI_LWO_CHAN:
|
||||||
|
@ -549,7 +549,7 @@ void LWOImporter::LoadLWO2ShaderBlock(LE_NCONST IFF::SubChunkHeader* head, unsig
|
||||||
if (mFileBuffer + head->length > end)
|
if (mFileBuffer + head->length > end)
|
||||||
throw new ImportErrorException("LWO2: Invalid shader header chunk length");
|
throw new ImportErrorException("LWO2: Invalid shader header chunk length");
|
||||||
|
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
case AI_LWO_ENAB:
|
case AI_LWO_ENAB:
|
||||||
|
@ -567,7 +567,7 @@ void LWOImporter::LoadLWO2ShaderBlock(LE_NCONST IFF::SubChunkHeader* head, unsig
|
||||||
if (mFileBuffer + head->length > end)
|
if (mFileBuffer + head->length > end)
|
||||||
throw new ImportErrorException("LWO2: Invalid shader data chunk length");
|
throw new ImportErrorException("LWO2: Invalid shader data chunk length");
|
||||||
|
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
case AI_LWO_FUNC:
|
case AI_LWO_FUNC:
|
||||||
|
@ -628,7 +628,7 @@ void LWOImporter::LoadLWO2Surface(unsigned int size)
|
||||||
if (mFileBuffer + head->length > end)
|
if (mFileBuffer + head->length > end)
|
||||||
throw new ImportErrorException("LWO2: Invalid surface chunk length");
|
throw new ImportErrorException("LWO2: Invalid surface chunk length");
|
||||||
|
|
||||||
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
|
uint8_t* const next = mFileBuffer+head->length;
|
||||||
switch (head->type)
|
switch (head->type)
|
||||||
{
|
{
|
||||||
// diffuse color
|
// diffuse color
|
||||||
|
|
|
@ -246,7 +246,7 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
BE_NCONST MD2::Vertex* pcVerts = (BE_NCONST MD2::Vertex*) (pcFrame->vertices);
|
BE_NCONST MD2::Vertex* pcVerts = (BE_NCONST MD2::Vertex*) (pcFrame->vertices);
|
||||||
|
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
for (uint32_t i = 0; i< m_pcHeader->numTriangles)
|
for (uint32_t i = 0; i< m_pcHeader->numTriangles; ++i)
|
||||||
{
|
{
|
||||||
for (unsigned int p = 0; p < 3;++p)
|
for (unsigned int p = 0; p < 3;++p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,17 +170,17 @@ void MD3Importer::InternReadFile(
|
||||||
|
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
|
|
||||||
ByteSwap::Swap4(&pcHeader->VERSION);
|
AI_SWAP4(pcHeader->VERSION);
|
||||||
ByteSwap::Swap4(&pcHeader->FLAGS);
|
AI_SWAP4(pcHeader->FLAGS);
|
||||||
ByteSwap::Swap4(&pcHeader->IDENT);
|
AI_SWAP4(pcHeader->IDENT);
|
||||||
ByteSwap::Swap4(&pcHeader->NUM_FRAMES);
|
AI_SWAP4(pcHeader->NUM_FRAMES);
|
||||||
ByteSwap::Swap4(&pcHeader->NUM_SKINS);
|
AI_SWAP4(pcHeader->NUM_SKINS);
|
||||||
ByteSwap::Swap4(&pcHeader->NUM_SURFACES);
|
AI_SWAP4(pcHeader->NUM_SURFACES);
|
||||||
ByteSwap::Swap4(&pcHeader->NUM_TAGS);
|
AI_SWAP4(pcHeader->NUM_TAGS);
|
||||||
ByteSwap::Swap4(&pcHeader->OFS_EOF);
|
AI_SWAP4(pcHeader->OFS_EOF);
|
||||||
ByteSwap::Swap4(&pcHeader->OFS_FRAMES);
|
AI_SWAP4(pcHeader->OFS_FRAMES);
|
||||||
ByteSwap::Swap4(&pcHeader->OFS_SURFACES);
|
AI_SWAP4(pcHeader->OFS_SURFACES);
|
||||||
ByteSwap::Swap4(&pcHeader->OFS_TAGS);
|
AI_SWAP4(pcHeader->OFS_TAGS);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void MD3Importer::InternReadFile(
|
||||||
this->ValidateHeaderOffsets();
|
this->ValidateHeaderOffsets();
|
||||||
|
|
||||||
// now navigate to the list of surfaces
|
// now navigate to the list of surfaces
|
||||||
const MD3::Surface* pcSurfaces = (const MD3::Surface*)(mBuffer + pcHeader->OFS_SURFACES);
|
BE_NCONST MD3::Surface* pcSurfaces = (BE_NCONST MD3::Surface*)(mBuffer + pcHeader->OFS_SURFACES);
|
||||||
|
|
||||||
// allocate output storage
|
// allocate output storage
|
||||||
pScene->mNumMeshes = pcHeader->NUM_SURFACES;
|
pScene->mNumMeshes = pcHeader->NUM_SURFACES;
|
||||||
|
@ -210,17 +210,17 @@ void MD3Importer::InternReadFile(
|
||||||
|
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
|
|
||||||
ByteSwap::Swap4(pcSurfaces->FLAGS);
|
AI_SWAP4(pcSurfaces->FLAGS);
|
||||||
ByteSwap::Swap4(pcSurfaces->IDENT);
|
AI_SWAP4(pcSurfaces->IDENT);
|
||||||
ByteSwap::Swap4(pcSurfaces->NUM_FRAMES);
|
AI_SWAP4(pcSurfaces->NUM_FRAMES);
|
||||||
ByteSwap::Swap4(pcSurfaces->NUM_SHADER);
|
AI_SWAP4(pcSurfaces->NUM_SHADER);
|
||||||
ByteSwap::Swap4(pcSurfaces->NUM_TRIANGLES);
|
AI_SWAP4(pcSurfaces->NUM_TRIANGLES);
|
||||||
ByteSwap::Swap4(pcSurfaces->NUM_VERTICES);
|
AI_SWAP4(pcSurfaces->NUM_VERTICES);
|
||||||
ByteSwap::Swap4(pcSurfaces->OFS_END);
|
AI_SWAP4(pcSurfaces->OFS_END);
|
||||||
ByteSwap::Swap4(pcSurfaces->OFS_SHADERS);
|
AI_SWAP4(pcSurfaces->OFS_SHADERS);
|
||||||
ByteSwap::Swap4(pcSurfaces->OFS_ST);
|
AI_SWAP4(pcSurfaces->OFS_ST);
|
||||||
ByteSwap::Swap4(pcSurfaces->OFS_TRIANGLES);
|
AI_SWAP4(pcSurfaces->OFS_TRIANGLES);
|
||||||
ByteSwap::Swap4(pcSurfaces->OFS_XYZNORMAL);
|
AI_SWAP4(pcSurfaces->OFS_XYZNORMAL);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -228,25 +228,25 @@ void MD3Importer::InternReadFile(
|
||||||
this->ValidateSurfaceHeaderOffsets(pcSurfaces);
|
this->ValidateSurfaceHeaderOffsets(pcSurfaces);
|
||||||
|
|
||||||
// navigate to the vertex list of the surface
|
// navigate to the vertex list of the surface
|
||||||
const MD3::Vertex* pcVertices = (const MD3::Vertex*)
|
BE_NCONST MD3::Vertex* pcVertices = (BE_NCONST MD3::Vertex*)
|
||||||
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_XYZNORMAL);
|
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_XYZNORMAL);
|
||||||
|
|
||||||
// navigate to the triangle list of the surface
|
// navigate to the triangle list of the surface
|
||||||
const MD3::Triangle* pcTriangles = (const MD3::Triangle*)
|
BE_NCONST MD3::Triangle* pcTriangles = (BE_NCONST MD3::Triangle*)
|
||||||
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_TRIANGLES);
|
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_TRIANGLES);
|
||||||
|
|
||||||
// navigate to the texture coordinate list of the surface
|
// navigate to the texture coordinate list of the surface
|
||||||
const MD3::TexCoord* pcUVs = (const MD3::TexCoord*)
|
BE_NCONST MD3::TexCoord* pcUVs = (BE_NCONST MD3::TexCoord*)
|
||||||
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_ST);
|
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_ST);
|
||||||
|
|
||||||
// navigate to the shader list of the surface
|
// navigate to the shader list of the surface
|
||||||
const MD3::Shader* pcShaders = (const MD3::Shader*)
|
BE_NCONST MD3::Shader* pcShaders = (BE_NCONST MD3::Shader*)
|
||||||
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_SHADERS);
|
(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_SHADERS);
|
||||||
|
|
||||||
// if the submesh is empty ignore it
|
// if the submesh is empty ignore it
|
||||||
if (0 == pcSurfaces->NUM_VERTICES || 0 == pcSurfaces->NUM_TRIANGLES)
|
if (0 == pcSurfaces->NUM_VERTICES || 0 == pcSurfaces->NUM_TRIANGLES)
|
||||||
{
|
{
|
||||||
pcSurfaces = (const MD3::Surface*)(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_END);
|
pcSurfaces = (BE_NCONST MD3::Surface*)(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_END);
|
||||||
pScene->mNumMeshes--;
|
pScene->mNumMeshes--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -255,19 +255,19 @@ void MD3Importer::InternReadFile(
|
||||||
|
|
||||||
for (uint32_t i = 0; i < pcSurfaces->NUM_VERTICES;++i)
|
for (uint32_t i = 0; i < pcSurfaces->NUM_VERTICES;++i)
|
||||||
{
|
{
|
||||||
ByteSwap::Swap2( & pcVertices[i].NORMAL );
|
AI_SWAP2( pcVertices[i].NORMAL );
|
||||||
ByteSwap::Swap2( & pcVertices[i].X );
|
AI_SWAP2( pcVertices[i].X );
|
||||||
ByteSwap::Swap2( & pcVertices[i].Y );
|
AI_SWAP2( pcVertices[i].Y );
|
||||||
ByteSwap::Swap2( & pcVertices[i].Z );
|
AI_SWAP2( pcVertices[i].Z );
|
||||||
|
|
||||||
ByteSwap::Swap4( & pcUVs[i].U );
|
AI_SWAP4( pcUVs[i].U );
|
||||||
ByteSwap::Swap4( & pcUVs[i].U );
|
AI_SWAP4( pcUVs[i].U );
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < pcSurfaces->NUM_TRIANGLES;++i)
|
for (uint32_t i = 0; i < pcSurfaces->NUM_TRIANGLES;++i)
|
||||||
{
|
{
|
||||||
ByteSwap::Swap4(pcTriangles[i].INDEXES[0]);
|
AI_SWAP4(pcTriangles[i].INDEXES[0]);
|
||||||
ByteSwap::Swap4(pcTriangles[i].INDEXES[1]);
|
AI_SWAP4(pcTriangles[i].INDEXES[1]);
|
||||||
ByteSwap::Swap4(pcTriangles[i].INDEXES[2]);
|
AI_SWAP4(pcTriangles[i].INDEXES[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -424,7 +424,7 @@ void MD3Importer::InternReadFile(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// go to the next surface
|
// go to the next surface
|
||||||
pcSurfaces = (const MD3::Surface*)(((unsigned char*)pcSurfaces) + pcSurfaces->OFS_END);
|
pcSurfaces = (BE_NCONST MD3::Surface*)(((unsigned char*)pcSurfaces) + pcSurfaces->OFS_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pScene->mNumMeshes)
|
if (!pScene->mNumMeshes)
|
||||||
|
|
|
@ -234,7 +234,7 @@ void MDCImporter::InternReadFile(
|
||||||
|
|
||||||
if (pcSurface2->ulNumVertices && pcSurface2->ulNumTriangles)++pScene->mNumMeshes;
|
if (pcSurface2->ulNumVertices && pcSurface2->ulNumTriangles)++pScene->mNumMeshes;
|
||||||
iNumShaders += pcSurface2->ulNumShaders;
|
iNumShaders += pcSurface2->ulNumShaders;
|
||||||
pcSurface2 = (const MDC::Surface*)((int8_t*)pcSurface2 + pcSurface2->ulOffsetEnd);
|
pcSurface2 = (BE_NCONST MDC::Surface*)((int8_t*)pcSurface2 + pcSurface2->ulOffsetEnd);
|
||||||
}
|
}
|
||||||
aszShaders.reserve(iNumShaders);
|
aszShaders.reserve(iNumShaders);
|
||||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
||||||
|
|
|
@ -317,7 +317,7 @@ void FlipQuakeHeader(BE_NCONST MDL::Header* pcHeader)
|
||||||
}
|
}
|
||||||
ByteSwap::Swap4(& pcHeader->size);
|
ByteSwap::Swap4(& pcHeader->size);
|
||||||
ByteSwap::Swap4(& pcHeader->skinheight);
|
ByteSwap::Swap4(& pcHeader->skinheight);
|
||||||
ByteSwap::Swap4(& pcHeader->skin);
|
// ByteSwap::Swap4(& pcHeader->skin);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -374,17 +374,17 @@ void MDLImporter::InternReadFile_Quake1( )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get a pointer to the texture coordinates
|
// get a pointer to the texture coordinates
|
||||||
const MDL::TexCoord* pcTexCoords = (const MDL::TexCoord*)szCurrent;
|
BE_NCONST MDL::TexCoord* pcTexCoords = (BE_NCONST MDL::TexCoord*)szCurrent;
|
||||||
szCurrent += sizeof(MDL::TexCoord) * pcHeader->num_verts;
|
szCurrent += sizeof(MDL::TexCoord) * pcHeader->num_verts;
|
||||||
|
|
||||||
// get a pointer to the triangles
|
// get a pointer to the triangles
|
||||||
const MDL::Triangle* pcTriangles = (const MDL::Triangle*)szCurrent;
|
BE_NCONST MDL::Triangle* pcTriangles = (BE_NCONST MDL::Triangle*)szCurrent;
|
||||||
szCurrent += sizeof(MDL::Triangle) * pcHeader->num_tris;
|
szCurrent += sizeof(MDL::Triangle) * pcHeader->num_tris;
|
||||||
VALIDATE_FILE_SIZE(szCurrent);
|
VALIDATE_FILE_SIZE(szCurrent);
|
||||||
|
|
||||||
// now get a pointer to the first frame in the file
|
// now get a pointer to the first frame in the file
|
||||||
const MDL::Frame* pcFrames = (const MDL::Frame*)szCurrent;
|
BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent;
|
||||||
const MDL::SimpleFrame* pcFirstFrame;
|
BE_NCONST MDL::SimpleFrame* pcFirstFrame;
|
||||||
|
|
||||||
if (0 == pcFrames->type)
|
if (0 == pcFrames->type)
|
||||||
{
|
{
|
||||||
|
@ -394,10 +394,10 @@ void MDLImporter::InternReadFile_Quake1( )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get the first frame in the group
|
// get the first frame in the group
|
||||||
const MDL::GroupFrame* pcFrames2 = (const MDL::GroupFrame*)pcFrames;
|
BE_NCONST MDL::GroupFrame* pcFrames2 = (BE_NCONST MDL::GroupFrame*)pcFrames;
|
||||||
pcFirstFrame = (const MDL::SimpleFrame*)(&pcFrames2->time + pcFrames->type);
|
pcFirstFrame = (BE_NCONST MDL::SimpleFrame*)(&pcFrames2->time + pcFrames->type);
|
||||||
}
|
}
|
||||||
const MDL::Vertex* pcVertices = (const MDL::Vertex*) ((pcFirstFrame->name) +
|
BE_NCONST MDL::Vertex* pcVertices = (BE_NCONST MDL::Vertex*) ((pcFirstFrame->name) +
|
||||||
sizeof(pcFirstFrame->name));
|
sizeof(pcFirstFrame->name));
|
||||||
|
|
||||||
VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts));
|
VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts));
|
||||||
|
@ -553,7 +553,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345( )
|
||||||
ai_assert(NULL != pScene);
|
ai_assert(NULL != pScene);
|
||||||
|
|
||||||
// the header of MDL 3/4/5 is nearly identical to the original Quake1 header
|
// the header of MDL 3/4/5 is nearly identical to the original Quake1 header
|
||||||
const MDL::Header* pcHeader = (const MDL::Header*)this->mBuffer;
|
BE_NCONST MDL::Header* pcHeader = (BE_NCONST MDL::Header*)this->mBuffer;
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
FlipQuakeHeader(pcHeader);
|
FlipQuakeHeader(pcHeader);
|
||||||
#endif
|
#endif
|
||||||
|
@ -586,13 +586,13 @@ void MDLImporter::InternReadFile_3DGS_MDL345( )
|
||||||
|
|
||||||
}
|
}
|
||||||
// get a pointer to the texture coordinates
|
// get a pointer to the texture coordinates
|
||||||
const MDL::TexCoord_MDL3* pcTexCoords = (const MDL::TexCoord_MDL3*)szCurrent;
|
BE_NCONST MDL::TexCoord_MDL3* pcTexCoords = (BE_NCONST MDL::TexCoord_MDL3*)szCurrent;
|
||||||
szCurrent += sizeof(MDL::TexCoord_MDL3) * pcHeader->synctype;
|
szCurrent += sizeof(MDL::TexCoord_MDL3) * pcHeader->synctype;
|
||||||
|
|
||||||
// NOTE: for MDLn formats "synctype" corresponds to the number of UV coords
|
// NOTE: for MDLn formats "synctype" corresponds to the number of UV coords
|
||||||
|
|
||||||
// get a pointer to the triangles
|
// get a pointer to the triangles
|
||||||
const MDL::Triangle_MDL3* pcTriangles = (const MDL::Triangle_MDL3*)szCurrent;
|
BE_NCONST MDL::Triangle_MDL3* pcTriangles = (BE_NCONST MDL::Triangle_MDL3*)szCurrent;
|
||||||
szCurrent += sizeof(MDL::Triangle_MDL3) * pcHeader->num_tris;
|
szCurrent += sizeof(MDL::Triangle_MDL3) * pcHeader->num_tris;
|
||||||
|
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
|
|
|
@ -241,9 +241,11 @@ void MDRImporter::InternReadFile( const std::string& pFile,
|
||||||
// get a pointer to the next vertex
|
// get a pointer to the next vertex
|
||||||
v = (LE_NCONST MDR::Vertex*)((uint8_t*)(v+1) + v->numWeights*sizeof(MDR::Weight));
|
v = (LE_NCONST MDR::Vertex*)((uint8_t*)(v+1) + v->numWeights*sizeof(MDR::Weight));
|
||||||
|
|
||||||
|
#ifndef AI_BUILD_BIG_ENDIAN
|
||||||
AI_SWAP4(v->numWeights);
|
AI_SWAP4(v->numWeights);
|
||||||
AI_SWAP4(v->normal.x);AI_SWAP4(v->normal.y);AI_SWAP4(v->normal.z);
|
AI_SWAP4(v->normal.x);AI_SWAP4(v->normal.y);AI_SWAP4(v->normal.z);
|
||||||
AI_SWAP4(v->texCoords.x);AI_SWAP4(v->texCoords.y);
|
AI_SWAP4(v->texCoords.x);AI_SWAP4(v->texCoords.y);
|
||||||
|
#endif
|
||||||
|
|
||||||
VertexInfo& vert = mVertices[m];
|
VertexInfo& vert = mVertices[m];
|
||||||
vert.uv.x = v->texCoords.x; vert.uv.y = v->texCoords.y;
|
vert.uv.x = v->texCoords.x; vert.uv.y = v->texCoords.y;
|
||||||
|
@ -263,7 +265,9 @@ void MDRImporter::InternReadFile( const std::string& pFile,
|
||||||
{
|
{
|
||||||
for (unsigned int o = 0; o < 3;++o)
|
for (unsigned int o = 0; o < 3;++o)
|
||||||
{
|
{
|
||||||
|
#ifndef AI_BUILD_BIG_ENDIAN
|
||||||
AI_SWAP4(tri->indexes[o]);
|
AI_SWAP4(tri->indexes[o]);
|
||||||
|
#endif
|
||||||
register unsigned int temp = tri->indexes[o];
|
register unsigned int temp = tri->indexes[o];
|
||||||
if (temp >= surf->numVerts)
|
if (temp >= surf->numVerts)
|
||||||
throw new ImportErrorException("MDR: Vertex index is out of range");
|
throw new ImportErrorException("MDR: Vertex index is out of range");
|
||||||
|
|
Loading…
Reference in New Issue