worked on getting assimpl compiled on BE

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@201 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
alil 2008-10-28 23:18:06 +00:00
parent e9dc280739
commit ef3cd69ae6
10 changed files with 80 additions and 75 deletions

View File

@ -54,9 +54,9 @@ struct SubChunkHeader
//! @param outFile Pointer to the file data - points to the chunk data afterwards
//! @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->type);
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
//! @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_LSWAP4(head->type);
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
//! @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)
{
return "The file is not an IFF file: FORM chunk is missing";

View File

@ -67,7 +67,7 @@ void LWOImporter::LoadLWOBFile()
throw new ImportErrorException("LWOB: Invalid chunk length");
break;
}
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
uint8_t* const next = mFileBuffer+head->length;
switch (head->type)
{
// vertex list
@ -220,7 +220,7 @@ void LWOImporter::LoadLWOBSurface(unsigned int size)
if (mFileBuffer + head->length > end)
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)
{
// diffuse color

View File

@ -699,7 +699,7 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length)
}
// 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;
CountVertsAndFacesLWO2(iNumVertices,iNumFaces,cursor,end);
@ -707,7 +707,7 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length)
// allocate the output array and copy face indices
if (iNumFaces)
{
cursor = (LE_NCONST uint16_t*)mFileBuffer;
cursor = (uint16_t*)mFileBuffer;
mCurLayer->mFaces.resize(iNumFaces);
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,
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--)
{
@ -733,7 +733,7 @@ void LWOImporter::CountVertsAndFacesLWO2(unsigned int& verts, unsigned int& face
// ------------------------------------------------------------------------------------------------
void LWOImporter::CopyFaceIndicesLWO2(FaceList::iterator& it,
LE_NCONST uint16_t*& cursor,
uint16_t*& cursor,
const uint16_t* const end)
{
while (cursor < end)
@ -979,7 +979,7 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
// first - get the index of the clip
clip.idx = GetU4();
LE_NCONST IFF::SubChunkHeader* const head = IFF::LoadSubChunk(mFileBuffer);
IFF::SubChunkHeader* const head = IFF::LoadSubChunk(mFileBuffer);
switch (head->type)
{
case AI_LWO_STIL:
@ -994,7 +994,8 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
int16_t start = GetU2(); mFileBuffer+=4;
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 << std::setw(digits) << offset + start;
GetS0(s,head->length);
@ -1029,14 +1030,14 @@ void LWOImporter::LoadLWO2File()
while (true)
{
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)
{
throw new ImportErrorException("LWO2: Chunk length points behind the file");
break;
}
LE_NCONST uint8_t* const next = mFileBuffer+head->length;
uint8_t* const next = mFileBuffer+head->length;
unsigned int iUnnamed = 0;
switch (head->type)
{

View File

@ -217,7 +217,7 @@ private:
*/
void CountVertsAndFacesLWO2(unsigned int& verts,
unsigned int& faces,
LE_NCONST uint16_t*& cursor,
uint16_t*& cursor,
const uint16_t* const end,
unsigned int max = 0xffffffff);
@ -231,7 +231,7 @@ private:
/** Read vertices and faces in a LWOB/LWO2 file
*/
void CopyFaceIndicesLWO2(LWO::FaceList::iterator& it,
LE_NCONST uint16_t*& cursor,
uint16_t*& cursor,
const uint16_t* const end);
// -------------------------------------------------------------------
@ -375,7 +375,7 @@ protected:
ClipList mClips;
/** file buffer */
LE_NCONST uint8_t* mFileBuffer;
uint8_t* mFileBuffer;
/** Size of the file, in bytes */
unsigned int fileSize;

View File

@ -380,7 +380,7 @@ void LWOImporter::LoadLWO2ImageMap(unsigned int size, LWO::Texture& tex )
if (mFileBuffer + head->length > end)
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)
{
case AI_LWO_PROJ:
@ -445,7 +445,7 @@ void LWOImporter::LoadLWO2TextureHeader(unsigned int size, LWO::Texture& tex )
if (mFileBuffer + head->length > end)
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)
{
case AI_LWO_CHAN:
@ -549,7 +549,7 @@ void LWOImporter::LoadLWO2ShaderBlock(LE_NCONST IFF::SubChunkHeader* head, unsig
if (mFileBuffer + head->length > end)
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)
{
case AI_LWO_ENAB:
@ -567,7 +567,7 @@ void LWOImporter::LoadLWO2ShaderBlock(LE_NCONST IFF::SubChunkHeader* head, unsig
if (mFileBuffer + head->length > end)
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)
{
case AI_LWO_FUNC:
@ -628,7 +628,7 @@ void LWOImporter::LoadLWO2Surface(unsigned int size)
if (mFileBuffer + head->length > end)
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)
{
// diffuse color

View File

@ -246,7 +246,7 @@ void MD2Importer::InternReadFile( const std::string& pFile,
BE_NCONST MD2::Vertex* pcVerts = (BE_NCONST MD2::Vertex*) (pcFrame->vertices);
#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)
{

View File

@ -170,17 +170,17 @@ void MD3Importer::InternReadFile(
#ifdef AI_BUILD_BIG_ENDIAN
ByteSwap::Swap4(&pcHeader->VERSION);
ByteSwap::Swap4(&pcHeader->FLAGS);
ByteSwap::Swap4(&pcHeader->IDENT);
ByteSwap::Swap4(&pcHeader->NUM_FRAMES);
ByteSwap::Swap4(&pcHeader->NUM_SKINS);
ByteSwap::Swap4(&pcHeader->NUM_SURFACES);
ByteSwap::Swap4(&pcHeader->NUM_TAGS);
ByteSwap::Swap4(&pcHeader->OFS_EOF);
ByteSwap::Swap4(&pcHeader->OFS_FRAMES);
ByteSwap::Swap4(&pcHeader->OFS_SURFACES);
ByteSwap::Swap4(&pcHeader->OFS_TAGS);
AI_SWAP4(pcHeader->VERSION);
AI_SWAP4(pcHeader->FLAGS);
AI_SWAP4(pcHeader->IDENT);
AI_SWAP4(pcHeader->NUM_FRAMES);
AI_SWAP4(pcHeader->NUM_SKINS);
AI_SWAP4(pcHeader->NUM_SURFACES);
AI_SWAP4(pcHeader->NUM_TAGS);
AI_SWAP4(pcHeader->OFS_EOF);
AI_SWAP4(pcHeader->OFS_FRAMES);
AI_SWAP4(pcHeader->OFS_SURFACES);
AI_SWAP4(pcHeader->OFS_TAGS);
#endif
@ -188,7 +188,7 @@ void MD3Importer::InternReadFile(
this->ValidateHeaderOffsets();
// 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
pScene->mNumMeshes = pcHeader->NUM_SURFACES;
@ -210,17 +210,17 @@ void MD3Importer::InternReadFile(
#ifdef AI_BUILD_BIG_ENDIAN
ByteSwap::Swap4(pcSurfaces->FLAGS);
ByteSwap::Swap4(pcSurfaces->IDENT);
ByteSwap::Swap4(pcSurfaces->NUM_FRAMES);
ByteSwap::Swap4(pcSurfaces->NUM_SHADER);
ByteSwap::Swap4(pcSurfaces->NUM_TRIANGLES);
ByteSwap::Swap4(pcSurfaces->NUM_VERTICES);
ByteSwap::Swap4(pcSurfaces->OFS_END);
ByteSwap::Swap4(pcSurfaces->OFS_SHADERS);
ByteSwap::Swap4(pcSurfaces->OFS_ST);
ByteSwap::Swap4(pcSurfaces->OFS_TRIANGLES);
ByteSwap::Swap4(pcSurfaces->OFS_XYZNORMAL);
AI_SWAP4(pcSurfaces->FLAGS);
AI_SWAP4(pcSurfaces->IDENT);
AI_SWAP4(pcSurfaces->NUM_FRAMES);
AI_SWAP4(pcSurfaces->NUM_SHADER);
AI_SWAP4(pcSurfaces->NUM_TRIANGLES);
AI_SWAP4(pcSurfaces->NUM_VERTICES);
AI_SWAP4(pcSurfaces->OFS_END);
AI_SWAP4(pcSurfaces->OFS_SHADERS);
AI_SWAP4(pcSurfaces->OFS_ST);
AI_SWAP4(pcSurfaces->OFS_TRIANGLES);
AI_SWAP4(pcSurfaces->OFS_XYZNORMAL);
#endif
@ -228,25 +228,25 @@ void MD3Importer::InternReadFile(
this->ValidateSurfaceHeaderOffsets(pcSurfaces);
// 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);
// 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);
// 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);
// 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);
// if the submesh is empty ignore it
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--;
continue;
}
@ -255,19 +255,19 @@ void MD3Importer::InternReadFile(
for (uint32_t i = 0; i < pcSurfaces->NUM_VERTICES;++i)
{
ByteSwap::Swap2( & pcVertices[i].NORMAL );
ByteSwap::Swap2( & pcVertices[i].X );
ByteSwap::Swap2( & pcVertices[i].Y );
ByteSwap::Swap2( & pcVertices[i].Z );
AI_SWAP2( pcVertices[i].NORMAL );
AI_SWAP2( pcVertices[i].X );
AI_SWAP2( pcVertices[i].Y );
AI_SWAP2( pcVertices[i].Z );
ByteSwap::Swap4( & pcUVs[i].U );
ByteSwap::Swap4( & pcUVs[i].U );
AI_SWAP4( pcUVs[i].U );
AI_SWAP4( pcUVs[i].U );
}
for (uint32_t i = 0; i < pcSurfaces->NUM_TRIANGLES;++i)
{
ByteSwap::Swap4(pcTriangles[i].INDEXES[0]);
ByteSwap::Swap4(pcTriangles[i].INDEXES[1]);
ByteSwap::Swap4(pcTriangles[i].INDEXES[2]);
AI_SWAP4(pcTriangles[i].INDEXES[0]);
AI_SWAP4(pcTriangles[i].INDEXES[1]);
AI_SWAP4(pcTriangles[i].INDEXES[2]);
}
#endif
@ -424,7 +424,7 @@ void MD3Importer::InternReadFile(
}
}
// 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)

View File

@ -234,7 +234,7 @@ void MDCImporter::InternReadFile(
if (pcSurface2->ulNumVertices && pcSurface2->ulNumTriangles)++pScene->mNumMeshes;
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);
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];

View File

@ -317,7 +317,7 @@ void FlipQuakeHeader(BE_NCONST MDL::Header* pcHeader)
}
ByteSwap::Swap4(& pcHeader->size);
ByteSwap::Swap4(& pcHeader->skinheight);
ByteSwap::Swap4(& pcHeader->skin);
// ByteSwap::Swap4(& pcHeader->skin);
}
#endif
// ------------------------------------------------------------------------------------------------
@ -374,17 +374,17 @@ void MDLImporter::InternReadFile_Quake1( )
}
}
// 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;
// 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;
VALIDATE_FILE_SIZE(szCurrent);
// now get a pointer to the first frame in the file
const MDL::Frame* pcFrames = (const MDL::Frame*)szCurrent;
const MDL::SimpleFrame* pcFirstFrame;
BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent;
BE_NCONST MDL::SimpleFrame* pcFirstFrame;
if (0 == pcFrames->type)
{
@ -394,10 +394,10 @@ void MDLImporter::InternReadFile_Quake1( )
else
{
// get the first frame in the group
const MDL::GroupFrame* pcFrames2 = (const MDL::GroupFrame*)pcFrames;
pcFirstFrame = (const MDL::SimpleFrame*)(&pcFrames2->time + pcFrames->type);
BE_NCONST MDL::GroupFrame* pcFrames2 = (BE_NCONST MDL::GroupFrame*)pcFrames;
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));
VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts));
@ -553,7 +553,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345( )
ai_assert(NULL != pScene);
// 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
FlipQuakeHeader(pcHeader);
#endif
@ -586,13 +586,13 @@ void MDLImporter::InternReadFile_3DGS_MDL345( )
}
// 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;
// NOTE: for MDLn formats "synctype" corresponds to the number of UV coords
// 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;
#ifdef AI_BUILD_BIG_ENDIAN

View File

@ -241,9 +241,11 @@ void MDRImporter::InternReadFile( const std::string& pFile,
// get a pointer to the next vertex
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->normal.x);AI_SWAP4(v->normal.y);AI_SWAP4(v->normal.z);
AI_SWAP4(v->texCoords.x);AI_SWAP4(v->texCoords.y);
#endif
VertexInfo& vert = mVertices[m];
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)
{
#ifndef AI_BUILD_BIG_ENDIAN
AI_SWAP4(tri->indexes[o]);
#endif
register unsigned int temp = tri->indexes[o];
if (temp >= surf->numVerts)
throw new ImportErrorException("MDR: Vertex index is out of range");