Commit 9f2d1075 authored by hybrid's avatar hybrid

Added debug info in ms3d loader.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1967 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7e336eea
...@@ -16,6 +16,10 @@ namespace irr ...@@ -16,6 +16,10 @@ namespace irr
namespace scene namespace scene
{ {
#ifdef _DEBUG
#define _IRR_DEBUG_MS3D_LOADER_
#endif
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing ) # pragma pack( push, packing )
...@@ -195,6 +199,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -195,6 +199,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
os::Printer::log("Only Milkshape3D version 3 and 4 (1.3 to 1.8) is supported. Loading failed", file->getFileName(), ELL_ERROR); os::Printer::log("Only Milkshape3D version 3 and 4 (1.3 to 1.8) is supported. Loading failed", file->getFileName(), ELL_ERROR);
return false; return false;
} }
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Loaded header version", core::stringc(pHeader->Version).c_str());
#endif
// get pointers to data // get pointers to data
...@@ -202,6 +209,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -202,6 +209,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
u16 numVertices = *(u16*)pPtr; u16 numVertices = *(u16*)pPtr;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
numVertices = os::Byteswap::byteswap(numVertices); numVertices = os::Byteswap::byteswap(numVertices);
#endif
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Load vertices", core::stringc(numVertices).c_str());
#endif #endif
pPtr += sizeof(u16); pPtr += sizeof(u16);
MS3DVertex *vertices = (MS3DVertex*)pPtr; MS3DVertex *vertices = (MS3DVertex*)pPtr;
...@@ -227,6 +237,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -227,6 +237,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
u16 numTriangles = *(u16*)pPtr; u16 numTriangles = *(u16*)pPtr;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
numTriangles = os::Byteswap::byteswap(numTriangles); numTriangles = os::Byteswap::byteswap(numTriangles);
#endif
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Load Triangles", core::stringc(numTriangles).c_str());
#endif #endif
pPtr += sizeof(u16); pPtr += sizeof(u16);
MS3DTriangle *triangles = (MS3DTriangle*)pPtr; MS3DTriangle *triangles = (MS3DTriangle*)pPtr;
...@@ -261,6 +274,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -261,6 +274,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
u16 numGroups = *(u16*)pPtr; u16 numGroups = *(u16*)pPtr;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
numGroups = os::Byteswap::byteswap(numGroups); numGroups = os::Byteswap::byteswap(numGroups);
#endif
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Load Groups", core::stringc(numGroups).c_str());
#endif #endif
pPtr += sizeof(u16); pPtr += sizeof(u16);
...@@ -313,6 +329,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -313,6 +329,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
u16 numMaterials = *(u16*)pPtr; u16 numMaterials = *(u16*)pPtr;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
numMaterials = os::Byteswap::byteswap(numMaterials); numMaterials = os::Byteswap::byteswap(numMaterials);
#endif
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Load Materials", core::stringc(numMaterials).c_str());
#endif #endif
pPtr += sizeof(u16); pPtr += sizeof(u16);
...@@ -378,6 +397,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -378,6 +397,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
f32 framesPerSecond = *(float*)pPtr; f32 framesPerSecond = *(float*)pPtr;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
framesPerSecond = os::Byteswap::byteswap(framesPerSecond); framesPerSecond = os::Byteswap::byteswap(framesPerSecond);
#endif
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("FPS", core::stringc(framesPerSecond).c_str());
#endif #endif
pPtr += sizeof(float) * 2; // fps and current time pPtr += sizeof(float) * 2; // fps and current time
...@@ -394,6 +416,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -394,6 +416,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
u16 jointCount = *(u16*)pPtr; u16 jointCount = *(u16*)pPtr;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
jointCount = os::Byteswap::byteswap(jointCount); jointCount = os::Byteswap::byteswap(jointCount);
#endif
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Joints", core::stringc(jointCount).c_str());
#endif #endif
pPtr += sizeof(u16); pPtr += sizeof(u16);
if (pPtr > buffer+fileSize) if (pPtr > buffer+fileSize)
...@@ -430,6 +455,11 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -430,6 +455,11 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
ISkinnedMesh::SJoint *jnt = AnimatedMesh->createJoint(); ISkinnedMesh::SJoint *jnt = AnimatedMesh->createJoint();
jnt->Name = pJoint->Name; jnt->Name = pJoint->Name;
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Joint", jnt->Name.c_str());
os::Printer::log("Rotation keyframes", core::stringc(pJoint->NumRotationKeyframes).c_str());
os::Printer::log("Translation keyframes", core::stringc(pJoint->NumTranslationKeyframes).c_str());
#endif
jnt->LocalMatrix.makeIdentity(); jnt->LocalMatrix.makeIdentity();
jnt->LocalMatrix.setRotationRadians( jnt->LocalMatrix.setRotationRadians(
core::vector3df(pJoint->Rotation[0], pJoint->Rotation[1], pJoint->Rotation[2]) ); core::vector3df(pJoint->Rotation[0], pJoint->Rotation[1], pJoint->Rotation[2]) );
...@@ -525,6 +555,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -525,6 +555,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
for (u32 j=0; j<4; ++j) // four comment groups for (u32 j=0; j<4; ++j) // four comment groups
{ {
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Skipping comment group", core::stringc(j+1).c_str());
#endif
u32 numComments = *(u32*)pPtr; u32 numComments = *(u32*)pPtr;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
numComments = os::Byteswap::byteswap(numComments); numComments = os::Byteswap::byteswap(numComments);
...@@ -557,6 +590,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -557,6 +590,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
#endif #endif
pPtr += sizeof(s32); pPtr += sizeof(s32);
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Reading vertex weights");
#endif
// read vertex weights, ignoring data 'extra' from 1.8.2 // read vertex weights, ignoring data 'extra' from 1.8.2
vertexWeights.reallocate(numVertices); vertexWeights.reallocate(numVertices);
const char offset = (subVersion==1)?6:10; const char offset = (subVersion==1)?6:10;
...@@ -582,6 +618,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -582,6 +618,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
#endif #endif
pPtr += sizeof(s32); pPtr += sizeof(s32);
// skip joint colors // skip joint colors
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Skip joint color");
#endif
pPtr += 3*sizeof(float)*jointCount; pPtr += 3*sizeof(float)*jointCount;
if (pPtr > buffer+fileSize) if (pPtr > buffer+fileSize)
...@@ -599,6 +638,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -599,6 +638,9 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
subVersion = os::Byteswap::byteswap(subVersion); subVersion = os::Byteswap::byteswap(subVersion);
#endif #endif
pPtr += sizeof(s32); pPtr += sizeof(s32);
#ifdef _IRR_DEBUG_MS3D_LOADER_
os::Printer::log("Skip model extra information");
#endif
// now the model extra information would follow // now the model extra information would follow
// we also skip this for now // we also skip this for now
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment