Commit 35fe8766 authored by hybrid's avatar hybrid

Some dmf simplifications.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2875 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 06379558
...@@ -57,7 +57,8 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -57,7 +57,8 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
video::IVideoDriver* driver = SceneMgr->getVideoDriver(); video::IVideoDriver* driver = SceneMgr->getVideoDriver();
//Load stringlist //Load stringlist
StringList dmfRawFile(file); StringList dmfRawFile;
LoadFromFile(file, dmfRawFile);
if (dmfRawFile.size()==0) if (dmfRawFile.size()==0)
return 0; return 0;
...@@ -69,13 +70,13 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -69,13 +70,13 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
dmfHeader header; dmfHeader header;
//load header //load header
core::array<dmfMaterial> materiali;
if (GetDMFHeader(dmfRawFile, header)) if (GetDMFHeader(dmfRawFile, header))
{ {
//let's set ambient light //let's set ambient light
SceneMgr->setAmbientLight(header.dmfAmbient); SceneMgr->setAmbientLight(header.dmfAmbient);
//let's create the correct number of materials, vertices and faces //let's create the correct number of materials, vertices and faces
core::array<dmfMaterial> materiali;
dmfVert *verts=new dmfVert[header.numVertices]; dmfVert *verts=new dmfVert[header.numVertices];
dmfFace *faces=new dmfFace[header.numFaces]; dmfFace *faces=new dmfFace[header.numFaces];
...@@ -113,7 +114,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -113,7 +114,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
for (i = 0; i < header.numFaces; i++) for (i = 0; i < header.numFaces; i++)
{ {
#ifdef _IRR_DMF_DEBUG_ #ifdef _IRR_DMF_DEBUG_
// os::Printer::log("Polygon with #vertices", core::stringc(faces[i].numVerts).c_str()); os::Printer::log("Polygon with #vertices", core::stringc(faces[i].numVerts).c_str());
#endif #endif
if (faces[i].numVerts < 3) if (faces[i].numVerts < 3)
continue; continue;
...@@ -187,6 +188,33 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -187,6 +188,33 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
} }
} }
delete verts;
delete faces;
}
// delete all buffers without geometry in it.
#ifdef _IRR_DMF_DEBUG_
os::Printer::log("Cleaning meshbuffers.");
#endif
i = 0;
while(i < mesh->MeshBuffers.size())
{
if (mesh->MeshBuffers[i]->getVertexCount() == 0 ||
mesh->MeshBuffers[i]->getIndexCount() == 0)
{
// Meshbuffer is empty -- drop it
mesh->MeshBuffers[i]->drop();
mesh->MeshBuffers.erase(i);
materiali.erase(i);
}
else
{
i++;
}
}
{
//load textures and lightmaps in materials. //load textures and lightmaps in materials.
//don't worry if you receive a could not load texture, cause if you don't need //don't worry if you receive a could not load texture, cause if you don't need
//a particular material in your scene it will be loaded and then destroyed. //a particular material in your scene it will be loaded and then destroyed.
...@@ -202,7 +230,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -202,7 +230,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
path = FileSystem->getFileDir(file->getFileName()); path = FileSystem->getFileDir(file->getFileName());
path += ('/'); path += ('/');
for (i=0; i<header.numMaterials; i++) for (i=0; i<mesh->getMeshBufferCount(); i++)
{ {
//texture and lightmap //texture and lightmap
video::ITexture *tex = 0; video::ITexture *tex = 0;
...@@ -368,29 +396,6 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -368,29 +396,6 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
mat.setTexture(0, tex); mat.setTexture(0, tex);
mat.setTexture(1, lig); mat.setTexture(1, lig);
} }
delete verts;
delete faces;
}
// delete all buffers without geometry in it.
#ifdef _IRR_DMF_DEBUG_
os::Printer::log("Cleaning meshbuffers.");
#endif
i = 0;
while(i < mesh->MeshBuffers.size())
{
if (mesh->MeshBuffers[i]->getVertexCount() == 0 ||
mesh->MeshBuffers[i]->getIndexCount() == 0)
{
// Meshbuffer is empty -- drop it
mesh->MeshBuffers[i]->drop();
mesh->MeshBuffers.erase(i);
}
else
{
i++;
}
} }
// create bounding box // create bounding box
......
This diff is collapsed.
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