Commit 5f2e459f authored by hybrid's avatar hybrid

Replaced path method by FileSystem function. Replaced const ints by enum.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2169 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b6a67db1
...@@ -23,31 +23,33 @@ namespace irr ...@@ -23,31 +23,33 @@ namespace irr
namespace scene namespace scene
{ {
// Main Chunks enum OGRE_CHUNKS
const u16 COGRE_HEADER= 0x1000; {
const u16 COGRE_MESH= 0x3000; // Main Chunks
COGRE_HEADER= 0x1000,
// sub chunks of COGRE_MESH COGRE_MESH= 0x3000,
const u16 COGRE_SUBMESH= 0x4000;
const u16 COGRE_GEOMETRY= 0x5000; // sub chunks of COGRE_MESH
const u16 COGRE_SKELETON_LINK= 0x6000; COGRE_SUBMESH= 0x4000,
const u16 COGRE_BONE_ASSIGNMENT= 0x7000; COGRE_GEOMETRY= 0x5000,
const u16 COGRE_MESH_LOD= 0x8000; COGRE_SKELETON_LINK= 0x6000,
const u16 COGRE_MESH_BOUNDS= 0x9000; COGRE_BONE_ASSIGNMENT= 0x7000,
const u16 COGRE_MESH_SUBMESH_NAME_TABLE= 0xA000; COGRE_MESH_LOD= 0x8000,
const u16 COGRE_MESH_EDGE_LISTS= 0xB000; COGRE_MESH_BOUNDS= 0x9000,
COGRE_MESH_SUBMESH_NAME_TABLE= 0xA000,
// sub chunks of COGRE_GEOMETRY COGRE_MESH_EDGE_LISTS= 0xB000,
const u16 COGRE_GEOMETRY_VERTEX_DECLARATION= 0x5100;
const u16 COGRE_GEOMETRY_VERTEX_ELEMENT= 0x5110; // sub chunks of COGRE_SUBMESH
const u16 COGRE_GEOMETRY_VERTEX_BUFFER= 0x5200; COGRE_SUBMESH_OPERATION= 0x4010,
const u16 COGRE_GEOMETRY_VERTEX_BUFFER_DATA= 0x5210; COGRE_SUBMESH_BONE_ASSIGNMENT= 0x4100,
COGRE_SUBMESH_TEXTURE_ALIAS= 0x4200,
// sub chunks of COGRE_SUBMESH
const u16 COGRE_SUBMESH_OPERATION= 0x4010; // sub chunks of COGRE_GEOMETRY
const u16 COGRE_SUBMESH_BONE_ASSIGNMENT= 0x4100; COGRE_GEOMETRY_VERTEX_DECLARATION= 0x5100,
const u16 COGRE_SUBMESH_TEXTURE_ALIAS= 0x4200; COGRE_GEOMETRY_VERTEX_ELEMENT= 0x5110,
COGRE_GEOMETRY_VERTEX_BUFFER= 0x5200,
COGRE_GEOMETRY_VERTEX_BUFFER_DATA= 0x5210
};
//! Constructor //! Constructor
COgreMeshFileLoader::COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) COgreMeshFileLoader::COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver)
...@@ -115,10 +117,10 @@ IAnimatedMesh* COgreMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -115,10 +117,10 @@ IAnimatedMesh* COgreMeshFileLoader::createMesh(io::IReadFile* file)
if (Mesh) if (Mesh)
Mesh->drop(); Mesh->drop();
Mesh = new SMesh(); CurrentlyLoadingFromPath = FileSystem->getFileDir(file->getFileName());
setCurrentlyLoadingPath(file);
loadMaterials(file); loadMaterials(file);
Mesh = new SMesh();
if (readChunk(file)) if (readChunk(file))
{ {
// success // success
...@@ -936,7 +938,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) ...@@ -936,7 +938,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile)
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Load Materials"); os::Printer::log("Load Materials");
#endif #endif
core::stringc token =meshFile->getFileName(); core::stringc token = meshFile->getFileName();
core::string<c16> filename = token.subString(0, token.size()-4) + L"material"; core::string<c16> filename = token.subString(0, token.size()-4) + L"material";
io::IReadFile* file = FileSystem->createAndOpenFile(filename.c_str()); io::IReadFile* file = FileSystem->createAndOpenFile(filename.c_str());
...@@ -1105,23 +1107,6 @@ void COgreMeshFileLoader::readVector(io::IReadFile* file, ChunkData& data, core: ...@@ -1105,23 +1107,6 @@ void COgreMeshFileLoader::readVector(io::IReadFile* file, ChunkData& data, core:
readFloat(file, data, out.Z); readFloat(file, data, out.Z);
} }
void COgreMeshFileLoader::setCurrentlyLoadingPath(io::IReadFile* file)
{
CurrentlyLoadingFromPath = file->getFileName();
int idx = CurrentlyLoadingFromPath.findLast('/');
if (idx != -1)
{
CurrentlyLoadingFromPath = CurrentlyLoadingFromPath.subString(0, idx);
}
else
{
idx = CurrentlyLoadingFromPath.findLast('\\');
if (idx != -1)
CurrentlyLoadingFromPath = CurrentlyLoadingFromPath.subString(0, idx);
}
}
void COgreMeshFileLoader::clearMeshes() void COgreMeshFileLoader::clearMeshes()
{ {
......
...@@ -216,7 +216,6 @@ private: ...@@ -216,7 +216,6 @@ private:
void readPass(io::IReadFile* file, OgreTechnique& technique); void readPass(io::IReadFile* file, OgreTechnique& technique);
void loadMaterials(io::IReadFile* file); void loadMaterials(io::IReadFile* file);
core::stringc getTextureFileName(const core::stringc& texture, core::stringc& model); core::stringc getTextureFileName(const core::stringc& texture, core::stringc& model);
void setCurrentlyLoadingPath(io::IReadFile* file);
void clearMeshes(); void clearMeshes();
io::IFileSystem* FileSystem; io::IFileSystem* FileSystem;
...@@ -225,7 +224,7 @@ private: ...@@ -225,7 +224,7 @@ private:
core::stringc Version; core::stringc Version;
bool SwapEndian; bool SwapEndian;
core::array<OgreMesh> Meshes; core::array<OgreMesh> Meshes;
core::stringc CurrentlyLoadingFromPath; core::string<c16> CurrentlyLoadingFromPath;
core::array<OgreMaterial> Materials; core::array<OgreMaterial> Materials;
......
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