Commit 38677f72 authored by hybrid's avatar hybrid

Replace private filename method by FileSystem member. Some more cleanup.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2068 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 06ae5c41
...@@ -28,9 +28,9 @@ namespace scene ...@@ -28,9 +28,9 @@ namespace scene
//! Constructor //! Constructor
CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs) CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs)
: SceneManager(smgr), FileSystem(fs), AnimatedMesh(0), MajorVersion(0), : SceneManager(smgr), FileSystem(fs), AnimatedMesh(0),
MinorVersion(0), BinaryFormat(false), BinaryNumCount(0), Buffer(0), BinaryNumCount(0), Buffer(0), P(0), End(0), BinaryFormat(false),
P(0), End(0), FloatSize(0), CurFrame(0) CurFrame(0), MajorVersion(0), MinorVersion(0), FloatSize(0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CXMeshFileLoader"); setDebugName("CXMeshFileLoader");
...@@ -448,7 +448,7 @@ bool CXMeshFileLoader::readFileIntoMemory(io::IReadFile* file) ...@@ -448,7 +448,7 @@ bool CXMeshFileLoader::readFileIntoMemory(io::IReadFile* file)
P = &Buffer[16]; P = &Buffer[16];
readUntilEndOfLine(); readUntilEndOfLine();
FilePath = stripPathFromString(file->getFileName(),true); FilePath = FileSystem->getFileDir(file->getFileName());
return true; return true;
} }
...@@ -780,7 +780,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh) ...@@ -780,7 +780,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
polygonfaces.set_used(fcnt); polygonfaces.set_used(fcnt);
u32 triangles = (fcnt-2); u32 triangles = (fcnt-2);
mesh.Indices.set_used(mesh.Indices.size() + ((triangles-1)*3)); mesh.Indices.set_used(mesh.Indices.size() + ((triangles-1)*3));
mesh.IndexCountPerFace[k] = triangles * 3; mesh.IndexCountPerFace[k] = (u16)(triangles * 3);
for (u32 f=0; f<fcnt; ++f) for (u32 f=0; f<fcnt; ++f)
polygonfaces[f] = readInt(); polygonfaces[f] = readInt();
...@@ -1526,17 +1526,17 @@ bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material) ...@@ -1526,17 +1526,17 @@ bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material)
return false; return false;
// original name // original name
if (FileSystem->existFile(TextureFileName.c_str())) if (FileSystem->existFile(TextureFileName))
material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture (TextureFileName.c_str())); material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(TextureFileName));
// mesh path // mesh path
else else
{ {
TextureFileName=FilePath + stripPathFromString(TextureFileName,false); TextureFileName=FilePath + FileSystem->getFileBasename(TextureFileName);
if (FileSystem->existFile(TextureFileName.c_str())) if (FileSystem->existFile(TextureFileName))
material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(TextureFileName.c_str())); material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(TextureFileName));
// working directory // working directory
else else
material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(stripPathFromString(TextureFileName,false).c_str())); material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(FileSystem->getFileBasename(TextureFileName)));
} }
++textureLayer; ++textureLayer;
if (textureLayer==2) if (textureLayer==2)
...@@ -1551,17 +1551,17 @@ bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material) ...@@ -1551,17 +1551,17 @@ bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material)
return false; return false;
// original name // original name
if (FileSystem->existFile(TextureFileName.c_str())) if (FileSystem->existFile(TextureFileName))
material.setTexture(1, SceneManager->getVideoDriver()->getTexture (TextureFileName.c_str())); material.setTexture(1, SceneManager->getVideoDriver()->getTexture(TextureFileName));
// mesh path // mesh path
else else
{ {
TextureFileName=FilePath + stripPathFromString(TextureFileName,false); TextureFileName=FilePath + FileSystem->getFileBasename(TextureFileName);
if (FileSystem->existFile(TextureFileName.c_str())) if (FileSystem->existFile(TextureFileName))
material.setTexture(1, SceneManager->getVideoDriver()->getTexture(TextureFileName.c_str())); material.setTexture(1, SceneManager->getVideoDriver()->getTexture(TextureFileName));
// working directory // working directory
else else
material.setTexture(1, SceneManager->getVideoDriver()->getTexture(stripPathFromString(TextureFileName,false).c_str())); material.setTexture(1, SceneManager->getVideoDriver()->getTexture(FileSystem->getFileBasename(TextureFileName)));
} }
if (textureLayer==1) if (textureLayer==1)
++textureLayer; ++textureLayer;
...@@ -2390,29 +2390,6 @@ bool CXMeshFileLoader::readMatrix(core::matrix4& mat) ...@@ -2390,29 +2390,6 @@ bool CXMeshFileLoader::readMatrix(core::matrix4& mat)
} }
core::stringc CXMeshFileLoader::stripPathFromString(core::stringc string, bool returnPath)
{
s32 slashIndex=string.findLast('/'); // forward slash
s32 backSlash=string.findLast('\\'); // back slash
if (backSlash>slashIndex)
slashIndex=backSlash;
if (slashIndex==-1)//no slashes found
{
if (returnPath)
return core::stringc(); //no path to return
else
return string;
}
if (returnPath)
return string.subString(0, slashIndex + 1);
else
return string.subString(slashIndex+1, string.size() - (slashIndex+1));
}
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
u32 MaxSkinWeightsPerFace; u32 MaxSkinWeightsPerFace;
u32 BoneCount; u32 BoneCount;
core::array< u32 > IndexCountPerFace; // default 3, but could be more core::array<u16> IndexCountPerFace; // default 3, but could be more
core::array<scene::SSkinMeshBuffer*> Buffers; core::array<scene::SSkinMeshBuffer*> Buffers;
...@@ -75,13 +75,13 @@ public: ...@@ -75,13 +75,13 @@ public:
core::array<video::SMaterial> Materials; // material array core::array<video::SMaterial> Materials; // material array
core::array<u32> WeightJoint;
core::array<u32> WeightNum;
s32 AttachedJointID; s32 AttachedJointID;
bool HasSkinning; bool HasSkinning;
bool HasVertexColors; bool HasVertexColors;
core::array<u32> WeightJoint;
core::array<u32> WeightNum;
}; };
private: private:
...@@ -92,7 +92,6 @@ private: ...@@ -92,7 +92,6 @@ private:
bool parseFile(); bool parseFile();
bool parseDataObject(); bool parseDataObject();
bool parseDataObjectTemplate(); bool parseDataObjectTemplate();
...@@ -156,8 +155,6 @@ private: ...@@ -156,8 +155,6 @@ private:
void readUntilEndOfLine(); void readUntilEndOfLine();
core::stringc stripPathFromString(core::stringc string, bool returnPath);
u16 readBinWord(); u16 readBinWord();
u32 readBinDWord(); u32 readBinDWord();
u32 readInt(); u32 readInt();
...@@ -175,16 +172,11 @@ private: ...@@ -175,16 +172,11 @@ private:
CSkinnedMesh* AnimatedMesh; CSkinnedMesh* AnimatedMesh;
u32 MajorVersion;
u32 MinorVersion;
bool BinaryFormat;
// counter for number arrays in binary format
u32 BinaryNumCount;
c8* Buffer; c8* Buffer;
const c8* P; const c8* P;
c8* End; c8* End;
c8 FloatSize; // counter for number arrays in binary format
u32 BinaryNumCount;
u32 Line; u32 Line;
core::stringc FilePath; core::stringc FilePath;
...@@ -193,10 +185,14 @@ private: ...@@ -193,10 +185,14 @@ private:
core::array<SXMesh*> Meshes; core::array<SXMesh*> Meshes;
core::array<SXTemplateMaterial> TemplateMaterials; core::array<SXTemplateMaterial> TemplateMaterials;
u32 MajorVersion;
u32 MinorVersion;
bool BinaryFormat;
c8 FloatSize;
}; };
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
#endif #endif
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