Commit a3a41d80 authored by hybrid's avatar hybrid

Major update to LWO loader to support more material properties and work with...

Major update to LWO loader to support more material properties and work with more meshes. Changed some meshloader constructors to take scenemanager instead of other parameters. Fixed obj loader texture loading with mixed file separators.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1215 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b5ac2dfa
...@@ -14,14 +14,12 @@ namespace scene ...@@ -14,14 +14,12 @@ namespace scene
{ {
//! Constructor //! Constructor
CBSPMeshFileLoader::CBSPMeshFileLoader(io::IFileSystem* fs,video::IVideoDriver* driver, scene::ISceneManager* smgr) CBSPMeshFileLoader::CBSPMeshFileLoader(scene::ISceneManager* smgr,
: FileSystem(fs), Driver(driver), SceneManager(smgr) io::IFileSystem* fs)
: FileSystem(fs), SceneManager(smgr)
{ {
if (FileSystem) if (FileSystem)
FileSystem->grab(); FileSystem->grab();
if (Driver)
Driver->grab();
} }
...@@ -30,9 +28,6 @@ CBSPMeshFileLoader::~CBSPMeshFileLoader() ...@@ -30,9 +28,6 @@ CBSPMeshFileLoader::~CBSPMeshFileLoader()
{ {
if (FileSystem) if (FileSystem)
FileSystem->drop(); FileSystem->drop();
if (Driver)
Driver->drop();
} }
...@@ -53,7 +48,7 @@ IAnimatedMesh* CBSPMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -53,7 +48,7 @@ IAnimatedMesh* CBSPMeshFileLoader::createMesh(io::IReadFile* file)
// load quake 3 bsp // load quake 3 bsp
if (strstr(file->getFileName(), ".bsp")) if (strstr(file->getFileName(), ".bsp"))
{ {
CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, Driver, SceneManager); CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, SceneManager);
q->getShader ( "scripts/models.shader", 1 ); q->getShader ( "scripts/models.shader", 1 );
q->getShader ( "scripts/liquid.shader", 1 ); q->getShader ( "scripts/liquid.shader", 1 );
...@@ -68,7 +63,7 @@ IAnimatedMesh* CBSPMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -68,7 +63,7 @@ IAnimatedMesh* CBSPMeshFileLoader::createMesh(io::IReadFile* file)
// load quake 3 shader container // load quake 3 shader container
if (strstr(file->getFileName(), ".shader")) if (strstr(file->getFileName(), ".shader"))
{ {
CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, Driver, SceneManager); CQ3LevelMesh* q = new CQ3LevelMesh(FileSystem, SceneManager);
q->getShader ( file->getFileName(), 1 ); q->getShader ( file->getFileName(), 1 );
return q; return q;
} }
......
...@@ -21,7 +21,7 @@ class CBSPMeshFileLoader : public IMeshLoader ...@@ -21,7 +21,7 @@ class CBSPMeshFileLoader : public IMeshLoader
public: public:
//! Constructor //! Constructor
CBSPMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr); CBSPMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
//! destructor //! destructor
virtual ~CBSPMeshFileLoader(); virtual ~CBSPMeshFileLoader();
...@@ -39,7 +39,6 @@ public: ...@@ -39,7 +39,6 @@ public:
private: private:
io::IFileSystem* FileSystem; io::IFileSystem* FileSystem;
video::IVideoDriver* Driver;
scene::ISceneManager* SceneManager; scene::ISceneManager* SceneManager;
}; };
......
...@@ -266,9 +266,9 @@ namespace scene ...@@ -266,9 +266,9 @@ namespace scene
//! Constructor //! Constructor
CColladaFileLoader::CColladaFileLoader(video::IVideoDriver* driver, CColladaFileLoader::CColladaFileLoader(scene::ISceneManager* smgr,
scene::ISceneManager* smgr, io::IFileSystem* fs) io::IFileSystem* fs)
: Driver(driver), SceneManager(smgr), FileSystem(fs), DummyMesh(0), : SceneManager(smgr), FileSystem(fs), DummyMesh(0),
FirstLoadedMesh(0), LoadedMeshCount(0), CreateInstances(false) FirstLoadedMesh(0), LoadedMeshCount(0), CreateInstances(false)
{ {
...@@ -2485,6 +2485,7 @@ video::ITexture* CColladaFileLoader::getTextureFromImage(core::stringc uri) ...@@ -2485,6 +2485,7 @@ video::ITexture* CColladaFileLoader::getTextureFromImage(core::stringc uri)
#ifdef COLLADA_READER_DEBUG #ifdef COLLADA_READER_DEBUG
os::Printer::log("COLLADA searching texture", uri.c_str()); os::Printer::log("COLLADA searching texture", uri.c_str());
#endif #endif
video::IVideoDriver* driver = SceneManager->getVideoDriver();
for (;;) for (;;)
{ {
uriToId(uri); uriToId(uri);
...@@ -2493,7 +2494,7 @@ video::ITexture* CColladaFileLoader::getTextureFromImage(core::stringc uri) ...@@ -2493,7 +2494,7 @@ video::ITexture* CColladaFileLoader::getTextureFromImage(core::stringc uri)
if (uri == Images[i].Id) if (uri == Images[i].Id)
{ {
if (Images[i].Source.size() && Images[i].SourceIsFilename) if (Images[i].Source.size() && Images[i].SourceIsFilename)
return Driver->getTexture(Images[i].Source.c_str()); return driver->getTexture(Images[i].Source.c_str());
else else
if (Images[i].Source.size()) if (Images[i].Source.size())
{ {
...@@ -2508,8 +2509,8 @@ video::ITexture* CColladaFileLoader::getTextureFromImage(core::stringc uri) ...@@ -2508,8 +2509,8 @@ video::ITexture* CColladaFileLoader::getTextureFromImage(core::stringc uri)
++ptrdest; ++ptrdest;
ptrsrc += 4; ptrsrc += 4;
} }
video::IImage* img = Driver->createImageFromData(video::ECF_A8R8G8B8, Images[i].Dimension, data, true, true); video::IImage* img = driver->createImageFromData(video::ECF_A8R8G8B8, Images[i].Dimension, data, true, true);
video::ITexture* tex = Driver->addTexture((CurrentlyLoadingMesh+"#"+Images[i].Id).c_str(), img); video::ITexture* tex = driver->addTexture((CurrentlyLoadingMesh+"#"+Images[i].Id).c_str(), img);
img->drop(); img->drop();
return tex; return tex;
} }
......
...@@ -177,8 +177,7 @@ class CColladaFileLoader : public IMeshLoader ...@@ -177,8 +177,7 @@ class CColladaFileLoader : public IMeshLoader
public: public:
//! Constructor //! Constructor
CColladaFileLoader(video::IVideoDriver* driver, CColladaFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
scene::ISceneManager* smgr, io::IFileSystem* fs);
//! destructor //! destructor
virtual ~CColladaFileLoader(); virtual ~CColladaFileLoader();
...@@ -331,7 +330,6 @@ private: ...@@ -331,7 +330,6 @@ private:
//! read a parameter and value //! read a parameter and value
void readParameter(io::IXMLReaderUTF8* reader); void readParameter(io::IXMLReaderUTF8* reader);
video::IVideoDriver* Driver;
scene::ISceneManager* SceneManager; scene::ISceneManager* SceneManager;
io::IFileSystem* FileSystem; io::IFileSystem* FileSystem;
......
...@@ -31,27 +31,15 @@ namespace scene ...@@ -31,27 +31,15 @@ namespace scene
{ {
/** Constructor*/ /** Constructor*/
CDMFLoader::CDMFLoader(video::IVideoDriver* driver, ISceneManager* smgr) CDMFLoader::CDMFLoader(ISceneManager* smgr)
: Driver(driver) , SceneMgr(smgr) : SceneMgr(smgr)
{ {
#ifdef _DEBUG #ifdef _DEBUG
IReferenceCounted::setDebugName("CDMFLoader"); IReferenceCounted::setDebugName("CDMFLoader");
#endif #endif
if (Driver)
Driver->grab();
}
/** Destructor*/
CDMFLoader::~CDMFLoader()
{
if (Driver)
Driver->drop();
} }
/** Given first three points of a face, returns a face normal*/ /** Given first three points of a face, returns a face normal*/
void CDMFLoader::GetFaceNormal( f32 a[3], //First point void CDMFLoader::GetFaceNormal( f32 a[3], //First point
f32 b[3], //Second point f32 b[3], //Second point
...@@ -91,6 +79,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -91,6 +79,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
{ {
if (!file) if (!file)
return 0; return 0;
video::IVideoDriver* driver = SceneMgr->getVideoDriver();
//Load stringlist //Load stringlist
StringList dmfRawFile(file); StringList dmfRawFile(file);
...@@ -229,8 +218,8 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -229,8 +218,8 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
//Primary texture is normal //Primary texture is normal
if ((materiali[i].textureFlag==0) || (materiali[i].textureBlend==4)) if ((materiali[i].textureFlag==0) || (materiali[i].textureBlend==4))
Driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT,true); driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT,true);
tex = Driver->getTexture((path+String(materiali[i].textureName)).c_str()); tex = driver->getTexture((path+String(materiali[i].textureName)).c_str());
//Primary texture is just a colour //Primary texture is just a colour
if(materiali[i].textureFlag==1) if(materiali[i].textureFlag==1)
...@@ -260,12 +249,12 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -260,12 +249,12 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
//just for compatibility with older Irrlicht versions //just for compatibility with older Irrlicht versions
//to support transparent materials //to support transparent materials
if (color.getAlpha()!=255 && materiali[i].textureBlend==4) if (color.getAlpha()!=255 && materiali[i].textureBlend==4)
Driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT,true); driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT,true);
IImage *immagine=Driver->createImageFromData(ECF_A8R8G8B8, IImage *immagine=driver->createImageFromData(ECF_A8R8G8B8,
core::dimension2d<s32>(8,8),buf); core::dimension2d<s32>(8,8),buf);
tex = Driver->addTexture("", immagine); tex = driver->addTexture("", immagine);
//to support transparent materials //to support transparent materials
if(color.getAlpha()!=255 && materiali[i].textureBlend==4) if(color.getAlpha()!=255 && materiali[i].textureBlend==4)
...@@ -278,7 +267,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -278,7 +267,7 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
//Lightmap is present //Lightmap is present
if (materiali[i].lightmapFlag == 0) if (materiali[i].lightmapFlag == 0)
lig = Driver->getTexture((path+String(materiali[i].lightmapName)).c_str()); lig = driver->getTexture((path+String(materiali[i].lightmapName)).c_str());
else //no lightmap else //no lightmap
{ {
lig = 0; lig = 0;
......
...@@ -50,10 +50,7 @@ namespace scene ...@@ -50,10 +50,7 @@ namespace scene
public: public:
/** constructor*/ /** constructor*/
CDMFLoader(video::IVideoDriver* driver, ISceneManager* smgr); CDMFLoader(ISceneManager* smgr);
/** destructor*/
virtual ~CDMFLoader();
//! returns true if the file maybe is able to be loaded by this class //! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".cob") //! based on the file extension (e.g. ".cob")
......
...@@ -22,15 +22,9 @@ namespace scene ...@@ -22,15 +22,9 @@ namespace scene
//! Constructor //! Constructor
CIrrMeshFileLoader::CIrrMeshFileLoader(video::IVideoDriver* driver, CIrrMeshFileLoader::CIrrMeshFileLoader(scene::ISceneManager* smgr,
scene::ISceneManager* smgr, io::IFileSystem* fs) io::IFileSystem* fs)
: Driver(driver), SceneManager(smgr), FileSystem(fs) : SceneManager(smgr), FileSystem(fs)
{
}
//! destructor
CIrrMeshFileLoader::~CIrrMeshFileLoader()
{ {
} }
...@@ -175,10 +169,10 @@ IMeshBuffer* CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader) ...@@ -175,10 +169,10 @@ IMeshBuffer* CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader)
{ {
//we've got a material //we've got a material
io::IAttributes* attributes = FileSystem->createEmptyAttributes(Driver); io::IAttributes* attributes = FileSystem->createEmptyAttributes(SceneManager->getVideoDriver());
attributes->read(reader, true, L"material"); attributes->read(reader, true, L"material");
Driver->fillMaterialStructureFromAttributes(material, attributes); SceneManager->getVideoDriver()->fillMaterialStructureFromAttributes(material, attributes);
attributes->drop(); attributes->drop();
} }
else else
......
...@@ -25,11 +25,7 @@ class CIrrMeshFileLoader : public IMeshLoader ...@@ -25,11 +25,7 @@ class CIrrMeshFileLoader : public IMeshLoader
public: public:
//! Constructor //! Constructor
CIrrMeshFileLoader(video::IVideoDriver* driver, CIrrMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
scene::ISceneManager* smgr, io::IFileSystem* fs);
//! destructor
virtual ~CIrrMeshFileLoader();
//! returns true if the file maybe is able to be loaded by this class //! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".cob") //! based on the file extension (e.g. ".cob")
...@@ -83,7 +79,6 @@ private: ...@@ -83,7 +79,6 @@ private:
// member variables // member variables
video::IVideoDriver* Driver;
scene::ISceneManager* SceneManager; scene::ISceneManager* SceneManager;
io::IFileSystem* FileSystem; io::IFileSystem* FileSystem;
}; };
......
...@@ -81,7 +81,7 @@ bool CIrrMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla ...@@ -81,7 +81,7 @@ bool CIrrMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla
Writer->writeLineBreak(); Writer->writeLineBreak();
// write mesh buffers // write mesh buffers
for (int i=0; i<(int)mesh->getMeshBufferCount(); ++i) for (int i=0; i<(int)mesh->getMeshBufferCount(); ++i)
{ {
scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i); scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i);
...@@ -102,8 +102,8 @@ bool CIrrMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla ...@@ -102,8 +102,8 @@ bool CIrrMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla
void CIrrMeshWriter::writeBoundingBox(const core::aabbox3df& box) void CIrrMeshWriter::writeBoundingBox(const core::aabbox3df& box)
{ {
Writer->writeElement(L"boundingBox", true, Writer->writeElement(L"boundingBox", true,
L"minEdge", getVectorAsStringLine(box.MinEdge).c_str(), L"minEdge", getVectorAsStringLine(box.MinEdge).c_str(),
L"maxEdge", getVectorAsStringLine(box.MaxEdge).c_str() ); L"maxEdge", getVectorAsStringLine(box.MaxEdge).c_str());
} }
...@@ -116,7 +116,7 @@ core::stringw CIrrMeshWriter::getVectorAsStringLine(const core::vector3df& v) co ...@@ -116,7 +116,7 @@ core::stringw CIrrMeshWriter::getVectorAsStringLine(const core::vector3df& v) co
str += core::stringw(v.Y); str += core::stringw(v.Y);
str += L" "; str += L" ";
str += core::stringw(v.Z); str += core::stringw(v.Z);
return str; return str;
} }
...@@ -128,7 +128,7 @@ core::stringw CIrrMeshWriter::getVectorAsStringLine(const core::vector2df& v) co ...@@ -128,7 +128,7 @@ core::stringw CIrrMeshWriter::getVectorAsStringLine(const core::vector2df& v) co
str = core::stringw(v.X); str = core::stringw(v.X);
str += L" "; str += L" ";
str += core::stringw(v.Y); str += core::stringw(v.Y);
return str; return str;
} }
...@@ -151,7 +151,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) ...@@ -151,7 +151,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer)
const core::stringw vertexTypeStr = video::sBuiltInVertexTypeNames[buffer->getVertexType()]; const core::stringw vertexTypeStr = video::sBuiltInVertexTypeNames[buffer->getVertexType()];
Writer->writeElement(L"vertices", false, Writer->writeElement(L"vertices", false,
L"type", vertexTypeStr.c_str(), L"type", vertexTypeStr.c_str(),
L"vertexCount", core::stringw(buffer->getVertexCount()).c_str()); L"vertexCount", core::stringw(buffer->getVertexCount()).c_str());
...@@ -176,7 +176,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) ...@@ -176,7 +176,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer)
str += getVectorAsStringLine(vtx[j].TCoords); str += getVectorAsStringLine(vtx[j].TCoords);
Writer->writeText(str.c_str()); Writer->writeText(str.c_str());
Writer->writeLineBreak(); Writer->writeLineBreak();
} }
} }
...@@ -198,7 +198,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) ...@@ -198,7 +198,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer)
str += L" "; str += L" ";
str += getVectorAsStringLine(vtx[j].TCoords2); str += getVectorAsStringLine(vtx[j].TCoords2);
Writer->writeText(str.c_str()); Writer->writeText(str.c_str());
Writer->writeLineBreak(); Writer->writeLineBreak();
} }
} }
...@@ -222,7 +222,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) ...@@ -222,7 +222,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer)
str += L" "; str += L" ";
str += getVectorAsStringLine(vtx[j].Binormal); str += getVectorAsStringLine(vtx[j].Binormal);
Writer->writeText(str.c_str()); Writer->writeText(str.c_str());
Writer->writeLineBreak(); Writer->writeLineBreak();
} }
} }
...@@ -234,7 +234,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) ...@@ -234,7 +234,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer)
// write indices // write indices
Writer->writeElement(L"indices", false, Writer->writeElement(L"indices", false,
L"indexCount", core::stringw(buffer->getIndexCount()).c_str()); L"indexCount", core::stringw(buffer->getIndexCount()).c_str());
Writer->writeLineBreak(); Writer->writeLineBreak();
...@@ -247,7 +247,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) ...@@ -247,7 +247,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer)
{ {
core::stringw str((int)idx[i]); core::stringw str((int)idx[i]);
Writer->writeText(str.c_str()); Writer->writeText(str.c_str());
if (i % maxIndicesPerLine != maxIndicesPerLine) if (i % maxIndicesPerLine != maxIndicesPerLine)
{ {
if (i % maxIndicesPerLine == maxIndicesPerLine-1) if (i % maxIndicesPerLine == maxIndicesPerLine-1)
...@@ -273,7 +273,7 @@ void CIrrMeshWriter::writeMaterial(const video::SMaterial& material) ...@@ -273,7 +273,7 @@ void CIrrMeshWriter::writeMaterial(const video::SMaterial& material)
{ {
// simply use irrlichts built-in attribute serialization capabilities here: // simply use irrlichts built-in attribute serialization capabilities here:
io::IAttributes* attributes = io::IAttributes* attributes =
VideoDriver->createAttributesFromMaterial(material); VideoDriver->createAttributesFromMaterial(material);
if (attributes) if (attributes)
......
#include "CLWOMeshFileLoader.h" #include "CLWOMeshFileLoader.h"
#include <cstring>
#include "os.h" #include "os.h"
#include "SAnimatedMesh.h" #include "SAnimatedMesh.h"
#include "SMesh.h" #include "SMesh.h"
#include "IReadFile.h" #include "IReadFile.h"
#include "ISceneManager.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "IMeshManipulator.h"
using namespace std; using namespace std;
...@@ -49,7 +52,7 @@ struct tLWOTextureInfo ...@@ -49,7 +52,7 @@ struct tLWOTextureInfo
struct CLWOMeshFileLoader::tLWOMaterial struct CLWOMeshFileLoader::tLWOMaterial
{ {
tLWOMaterial() : Meshbuffer(0), Flags(0), ReflMode(3), TranspMode(3), tLWOMaterial() : Meshbuffer(0), TagType(0), Flags(0), ReflMode(3), TranspMode(3),
Glow(0), AlphaMode(2), Luminance(0.0f), Diffuse(1.0f), Specular(0.0f), Glow(0), AlphaMode(2), Luminance(0.0f), Diffuse(1.0f), Specular(0.0f),
Reflection(0.0f), Transparency(0.0f), Translucency(0.0f), Reflection(0.0f), Transparency(0.0f), Translucency(0.0f),
Sharpness(0.0f), ReflSeamAngle(0.0f), ReflBlur(0.0f), Sharpness(0.0f), ReflSeamAngle(0.0f), ReflBlur(0.0f),
...@@ -61,6 +64,7 @@ struct CLWOMeshFileLoader::tLWOMaterial ...@@ -61,6 +64,7 @@ struct CLWOMeshFileLoader::tLWOMaterial
core::stringc Name; core::stringc Name;
scene::SMeshBuffer *Meshbuffer; scene::SMeshBuffer *Meshbuffer;
core::stringc ReflMap; core::stringc ReflMap;
u16 TagType;
u16 Flags; u16 Flags;
u16 ReflMode; u16 ReflMode;
u16 TranspMode; u16 TranspMode;
...@@ -103,27 +107,21 @@ struct tLWOLayerInfo ...@@ -103,27 +107,21 @@ struct tLWOLayerInfo
//! Constructor //! Constructor
CLWOMeshFileLoader::CLWOMeshFileLoader(video::IVideoDriver* driver) CLWOMeshFileLoader::CLWOMeshFileLoader(scene::ISceneManager* smgr,
: Driver(driver), File(0), Mesh(0) io::IFileSystem* fs)
: SceneManager(smgr), FileSystem(fs), File(0), Mesh(0)
{ {
if (Driver)
Driver->grab();
} }
//! destructor //! destructor
CLWOMeshFileLoader::~CLWOMeshFileLoader() CLWOMeshFileLoader::~CLWOMeshFileLoader()
{ {
if (Driver)
Driver->drop();
if (Mesh) if (Mesh)
Mesh->drop(); Mesh->drop();
} }
//! returns true if the file maybe is able to be loaded by this class //! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".bsp") //! based on the file extension (e.g. ".bsp")
bool CLWOMeshFileLoader::isALoadableFileExtension(const c8* filename) const bool CLWOMeshFileLoader::isALoadableFileExtension(const c8* filename) const
...@@ -155,13 +153,51 @@ IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -155,13 +153,51 @@ IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file)
SAnimatedMesh* am = new SAnimatedMesh(); SAnimatedMesh* am = new SAnimatedMesh();
am->Type = EAMT_3DS; am->Type = EAMT_3DS;
for (u32 polyIndex=0; polyIndex<MaterialMapping.size(); ++polyIndex)
{
const u16 tag=MaterialMapping[polyIndex];
scene::SMeshBuffer *mb=Materials[tag]->Meshbuffer;
const s32 vertCount=mb->Vertices.size();
const core::array<u32>& poly = Indices[polyIndex];
const u32 polySize=poly.size();
video::S3DVertex vertex;
for (u32 i=0; i<polySize; ++i)
{
const s32 j=poly[i];
vertex.Pos=Points[j];
if (Materials[tag]->Texture[0].TCoords && (Materials[tag]->Texture[0].TCoords->size()>0))
vertex.TCoords=(*Materials[tag]->Texture[0].TCoords)[j];
mb->Vertices.push_back(vertex);
}
if (polySize>2)
{
for (u32 i=1; i<polySize-1; ++i)
{
core::vector3df normal = core::plane3df(mb->Vertices[vertCount].Pos,mb->Vertices[vertCount+i].Pos,mb->Vertices[vertCount+i+1].Pos).Normal.normalize();
mb->Vertices[vertCount].Normal=normal;
mb->Vertices[vertCount+i].Normal=normal;
mb->Vertices[vertCount+i+1].Normal=normal;
mb->Indices.push_back(vertCount);
mb->Indices.push_back(vertCount+i);
mb->Indices.push_back(vertCount+i+1);
}
}
}
for (u32 i=0; i<Materials.size(); ++i) for (u32 i=0; i<Materials.size(); ++i)
{ {
for (u32 j=0; j<Materials[i]->Meshbuffer->Vertices.size(); ++j) for (u32 j=0; j<Materials[i]->Meshbuffer->Vertices.size(); ++j)
Materials[i]->Meshbuffer->Vertices[j].Color=Materials[i]->Meshbuffer->Material.DiffuseColor; Materials[i]->Meshbuffer->Vertices[j].Color=Materials[i]->Meshbuffer->Material.DiffuseColor;
Materials[i]->Meshbuffer->recalculateBoundingBox(); Materials[i]->Meshbuffer->recalculateBoundingBox();
Mesh->addMeshBuffer(Materials[i]->Meshbuffer); if (Materials[i]->Meshbuffer->Material.MaterialType==video::EMT_NORMAL_MAP_SOLID)
Materials[i]->Meshbuffer->drop(); {
SMesh tmpmesh;
tmpmesh.addMeshBuffer(Materials[i]->Meshbuffer);
SceneManager->getMeshManipulator()->createMeshWithTangents(&tmpmesh);
Mesh->addMeshBuffer(tmpmesh.getMeshBuffer(0));
}
else
Mesh->addMeshBuffer(Materials[i]->Meshbuffer);
Mesh->getMeshBuffer(Mesh->getMeshBufferCount()-1)->drop();
} }
Mesh->recalculateBoundingBox(); Mesh->recalculateBoundingBox();
...@@ -172,7 +208,9 @@ IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -172,7 +208,9 @@ IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file)
Mesh = 0; Mesh = 0;
Points.clear(); Points.clear();
Polygons.clear(); Indices.clear();
MaterialMapping.clear();
VMap.clear();
TCoords.clear(); TCoords.clear();
Materials.clear(); Materials.clear();
Images.clear(); Images.clear();
...@@ -372,6 +410,7 @@ bool CLWOMeshFileLoader::readChunks() ...@@ -372,6 +410,7 @@ bool CLWOMeshFileLoader::readChunks()
return true; return true;
} }
void CLWOMeshFileLoader::readObj1(u32 size) void CLWOMeshFileLoader::readObj1(u32 size)
{ {
u32 pos; u32 pos;
...@@ -435,7 +474,7 @@ void CLWOMeshFileLoader::readVertexMapping(u32 size) ...@@ -435,7 +474,7 @@ void CLWOMeshFileLoader::readVertexMapping(u32 size)
core::stringc name; core::stringc name;
File->read(&type, 4); File->read(&type, 4);
#ifdef LWO_READER_DEBUG #ifdef LWO_READER_DEBUG
os::Printer::log("LWO loader: Vertex map", type); os::Printer::log("LWO loader: Vertex map type", type);
#endif #endif
File->read(&dimension, 2); File->read(&dimension, 2);
#ifndef __BIG_ENDIAN__ #ifndef __BIG_ENDIAN__
...@@ -451,10 +490,13 @@ void CLWOMeshFileLoader::readVertexMapping(u32 size) ...@@ -451,10 +490,13 @@ void CLWOMeshFileLoader::readVertexMapping(u32 size)
File->seek(size, true); File->seek(size, true);
return; return;
} }
VMap.insert(name,TCoords.size());
TCoords.push_back(core::array<core::vector2df>());
u32 index; u32 index;
core::vector2df tcoord; core::vector2df tcoord;
TCoords.set_used(Points.size()); core::array<core::vector2df>& tcArray = TCoords.getLast();
tcArray.set_used(Points.size());
while (size!=0) while (size!=0)
{ {
size -= readVX(index); size -= readVX(index);
...@@ -466,8 +508,8 @@ void CLWOMeshFileLoader::readVertexMapping(u32 size) ...@@ -466,8 +508,8 @@ void CLWOMeshFileLoader::readVertexMapping(u32 size)
#ifndef __BIG_ENDIAN__ #ifndef __BIG_ENDIAN__
tcoord.Y=os::Byteswap::byteswap(tcoord.Y); tcoord.Y=os::Byteswap::byteswap(tcoord.Y);
#endif #endif
tcoord.Y=-tcoord.Y; tcoord.Y=tcoord.Y;
TCoords[index]=tcoord; tcArray[index]=tcoord;
size -= 8; size -= 8;
} }
} }
...@@ -478,7 +520,7 @@ void CLWOMeshFileLoader::readTagMapping(u32 size) ...@@ -478,7 +520,7 @@ void CLWOMeshFileLoader::readTagMapping(u32 size)
type[4]=0; type[4]=0;
File->read(&type, 4); File->read(&type, 4);
size -= 4; size -= 4;
if ((strncmp(type, "SURF", 4))||(Polygons.size()==0)) if ((strncmp(type, "SURF", 4))||(Indices.size()==0))
{ {
File->seek(size, true); File->seek(size, true);
return; return;
...@@ -494,28 +536,8 @@ void CLWOMeshFileLoader::readTagMapping(u32 size) ...@@ -494,28 +536,8 @@ void CLWOMeshFileLoader::readTagMapping(u32 size)
tag=os::Byteswap::byteswap(tag); tag=os::Byteswap::byteswap(tag);
#endif #endif
size -= 2; size -= 2;
MaterialMapping[polyIndex]=tag;
scene::SMeshBuffer *mb=Materials[tag]->Meshbuffer; Materials[tag]->TagType=1;
const s32 vertCount=mb->Vertices.size();
const s32 polySize=Polygons[polyIndex].size();
video::S3DVertex vertex;
for (s32 i=0; i<polySize; ++i)
{
vertex.Pos=Points[Polygons[polyIndex][i]];
if (TCoords.size()>0)
vertex.TCoords=TCoords[Polygons[polyIndex][i]];
mb->Vertices.push_back(vertex);
}
for (s32 i=1; i<polySize-1; ++i)
{
core::vector3df normal = core::plane3df(mb->Vertices[vertCount].Pos,mb->Vertices[vertCount+i].Pos,mb->Vertices[vertCount+i+1].Pos).Normal.normalize();
mb->Vertices[vertCount].Normal=normal;
mb->Vertices[vertCount+i].Normal=normal;
mb->Vertices[vertCount+i+1].Normal=normal;
mb->Indices.push_back(vertCount);
mb->Indices.push_back(vertCount+i);
mb->Indices.push_back(vertCount+i+1);
}
} }
} }
...@@ -525,7 +547,7 @@ void CLWOMeshFileLoader::readObj2(u32 size) ...@@ -525,7 +547,7 @@ void CLWOMeshFileLoader::readObj2(u32 size)
type[4]=0; type[4]=0;
File->read(&type, 4); File->read(&type, 4);
size -= 4; size -= 4;
Polygons.clear(); Indices.clear();
if (strncmp(type, "FACE", 4)) // also possible are splines, subdivision patches, metaballs, and bones if (strncmp(type, "FACE", 4)) // also possible are splines, subdivision patches, metaballs, and bones
{ {
File->seek(size, true); File->seek(size, true);
...@@ -542,9 +564,9 @@ void CLWOMeshFileLoader::readObj2(u32 size) ...@@ -542,9 +564,9 @@ void CLWOMeshFileLoader::readObj2(u32 size)
numVerts &= 0x03FF; numVerts &= 0x03FF;
size -= 2; size -= 2;
Polygons.push_back(core::array<u32>()); Indices.push_back(core::array<u32>());
u32 vertIndex; u32 vertIndex;
core::array<u32>& polyArray = Polygons.getLast(); core::array<u32>& polyArray = Indices.getLast();
polyArray.reallocate(numVerts); polyArray.reallocate(numVerts);
for (u16 i=0; i<numVerts; ++i) for (u16 i=0; i<numVerts; ++i)
{ {
...@@ -552,6 +574,9 @@ void CLWOMeshFileLoader::readObj2(u32 size) ...@@ -552,6 +574,9 @@ void CLWOMeshFileLoader::readObj2(u32 size)
polyArray.push_back(vertIndex); polyArray.push_back(vertIndex);
} }
} }
MaterialMapping.reallocate(Indices.size());
for (u32 j=0; j<Indices.size(); ++j)
MaterialMapping.push_back(0);
} }
...@@ -563,7 +588,7 @@ void CLWOMeshFileLoader::readMat(u32 size) ...@@ -563,7 +588,7 @@ void CLWOMeshFileLoader::readMat(u32 size)
size -= readString(name); size -= readString(name);
for (u32 i=0; i<Materials.size(); ++i) for (u32 i=0; i<Materials.size(); ++i)
{ {
if (Materials[i]->Name==name) if ((Materials[i]->TagType==1) && (Materials[i]->Name==name))
{ {
mat=Materials[i]; mat=Materials[i];
break; break;
...@@ -1479,7 +1504,8 @@ void CLWOMeshFileLoader::readMat(u32 size) ...@@ -1479,7 +1504,8 @@ void CLWOMeshFileLoader::readMat(u32 size)
{ {
core::stringc name; core::stringc name;
size -= readString(name); size -= readString(name);
mat->Texture[currTexture].TCoords = &TCoords; // TODO: Needs to be searched for if (VMap.find(name) != 0)
mat->Texture[currTexture].TCoords = &TCoords[VMap.find(name)->getValue()];
} }
break; break;
case charsToUIntD('B','L','O','K'): case charsToUIntD('B','L','O','K'):
...@@ -1543,30 +1569,11 @@ void CLWOMeshFileLoader::readMat(u32 size) ...@@ -1543,30 +1569,11 @@ void CLWOMeshFileLoader::readMat(u32 size)
} }
} }
s32 stringPos;
if (mat->Texture[0].Map != "") // diffuse if (mat->Texture[0].Map != "") // diffuse
{ irrMat->setTexture(0,loadTexture(mat->Texture[0].Map));
irrMat->setTexture(0,Driver->getTexture(mat->Texture[0].Map.c_str()));
if (!irrMat->getTexture(0))
{
stringPos = mat->Texture[0].Map.findLast('/');
if (stringPos==-1)
stringPos = mat->Texture[0].Map.findLast('\\');
if (stringPos != -1)
irrMat->setTexture(0, Driver->getTexture(mat->Texture[0].Map.subString(stringPos+1, mat->Texture[0].Map.size()-stringPos).c_str()));
}
}
if (mat->Texture[3].Map != "") // reflection if (mat->Texture[3].Map != "") // reflection
{ {
video::ITexture* reflTexture = Driver->getTexture(mat->Texture[3].Map.c_str()); video::ITexture* reflTexture = loadTexture(mat->Texture[3].Map);
if (!reflTexture)
{
stringPos = mat->Texture[3].Map.findLast('/');
if (stringPos==-1)
stringPos = mat->Texture[3].Map.findLast('\\');
if (stringPos != -1)
reflTexture = Driver->getTexture(mat->Texture[3].Map.subString(stringPos+1, mat->Texture[3].Map.size()-stringPos).c_str());
}
if (reflTexture) if (reflTexture)
{ {
irrMat->setTexture(1, irrMat->getTexture(0)); irrMat->setTexture(1, irrMat->getTexture(0));
...@@ -1576,15 +1583,7 @@ void CLWOMeshFileLoader::readMat(u32 size) ...@@ -1576,15 +1583,7 @@ void CLWOMeshFileLoader::readMat(u32 size)
} }
if (mat->Texture[4].Map != "") // transparency if (mat->Texture[4].Map != "") // transparency
{ {
video::ITexture* transTexture = Driver->getTexture(mat->Texture[4].Map.c_str()); video::ITexture* transTexture = loadTexture(mat->Texture[4].Map);
if (!transTexture)
{
stringPos = mat->Texture[4].Map.findLast('/');
if (stringPos==-1)
stringPos = mat->Texture[4].Map.findLast('\\');
if (stringPos != -1)
transTexture = Driver->getTexture(mat->Texture[4].Map.subString(stringPos+1, mat->Texture[4].Map.size()-stringPos).c_str());
}
if (transTexture) if (transTexture)
{ {
irrMat->setTexture(1, irrMat->getTexture(0)); irrMat->setTexture(1, irrMat->getTexture(0));
...@@ -1594,19 +1593,11 @@ void CLWOMeshFileLoader::readMat(u32 size) ...@@ -1594,19 +1593,11 @@ void CLWOMeshFileLoader::readMat(u32 size)
} }
if (mat->Texture[6].Map != "") // bump if (mat->Texture[6].Map != "") // bump
{ {
irrMat->setTexture(1, Driver->getTexture(mat->Texture[6].Map.c_str())); irrMat->setTexture(1, loadTexture(mat->Texture[6].Map));
if (!irrMat->getTexture(1))
{
stringPos = mat->Texture[6].Map.findLast('/');
if (stringPos==-1)
stringPos = mat->Texture[6].Map.findLast('\\');
if (stringPos != -1)
irrMat->setTexture(1, Driver->getTexture(mat->Texture[6].Map.subString(stringPos+1, mat->Texture[6].Map.size()-stringPos).c_str()));
}
if (irrMat->getTexture(1)) if (irrMat->getTexture(1))
{ {
Driver->makeNormalMapTexture(irrMat->getTexture(1)); // SceneManager->getVideoDriver()->makeNormalMapTexture(irrMat->getTexture(1));
irrMat->MaterialType=video::EMT_PARALLAX_MAP_SOLID; irrMat->MaterialType=video::EMT_NORMAL_MAP_SOLID;
} }
} }
} }
...@@ -1748,6 +1739,41 @@ bool CLWOMeshFileLoader::readFileHeader() ...@@ -1748,6 +1739,41 @@ bool CLWOMeshFileLoader::readFileHeader()
} }
video::ITexture* CLWOMeshFileLoader::loadTexture(const core::stringc& file)
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
if (FileSystem->existFile(file.c_str()))
return driver->getTexture(file.c_str());
core::stringc strippedName;
s32 stringPos = file.findLast('/');
if (stringPos==-1)
stringPos = file.findLast('\\');
if (stringPos != -1)
{
strippedName = file.subString(stringPos+1, file.size()-stringPos);
if (FileSystem->existFile(strippedName.c_str()))
return driver->getTexture(strippedName.c_str());
}
else
strippedName = file;
core::stringc newpath = File->getFileName();
stringPos = newpath.findLast('/');
if (stringPos==-1)
stringPos = newpath.findLast('\\');
if (stringPos != -1)
{
newpath = newpath.subString(0,stringPos+1);
newpath.append(strippedName);
if (FileSystem->existFile(newpath.c_str()))
return driver->getTexture(newpath.c_str());
}
os::Printer::log("Could not load texture", file.c_str(), ELL_WARNING);
return 0;
}
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
...@@ -2,20 +2,22 @@ ...@@ -2,20 +2,22 @@
#define __C_LWO_MESH_FILE_LOADER_H_INCLUDED__ #define __C_LWO_MESH_FILE_LOADER_H_INCLUDED__
#include "IMeshLoader.h" #include "IMeshLoader.h"
#include "IVideoDriver.h"
#include "irrString.h"
#include "SMeshBuffer.h" #include "SMeshBuffer.h"
#include "irrString.h"
#include "irrMap.h"
namespace irr namespace irr
{ {
namespace io namespace io
{ {
class IReadFile; class IReadFile;
class IFileSystem;
} // end namespace io } // end namespace io
namespace scene namespace scene
{ {
struct SMesh; struct SMesh;
class ISceneManager;
//! Meshloader capable of loading Lightwave 3D meshes. //! Meshloader capable of loading Lightwave 3D meshes.
class CLWOMeshFileLoader : public IMeshLoader class CLWOMeshFileLoader : public IMeshLoader
...@@ -23,7 +25,7 @@ class CLWOMeshFileLoader : public IMeshLoader ...@@ -23,7 +25,7 @@ class CLWOMeshFileLoader : public IMeshLoader
public: public:
//! Constructor //! Constructor
CLWOMeshFileLoader(video::IVideoDriver* driver); CLWOMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
//! destructor //! destructor
virtual ~CLWOMeshFileLoader(); virtual ~CLWOMeshFileLoader();
...@@ -53,14 +55,18 @@ private: ...@@ -53,14 +55,18 @@ private:
u32 readVec(core::vector3df& vec); u32 readVec(core::vector3df& vec);
u32 readVX(u32& num); u32 readVX(u32& num);
u32 readColor(video::SColor& color); u32 readColor(video::SColor& color);
video::ITexture* loadTexture(const core::stringc& file);
video::IVideoDriver* Driver; scene::ISceneManager* SceneManager;
io::IFileSystem* FileSystem;
io::IReadFile* File; io::IReadFile* File;
SMesh* Mesh; SMesh* Mesh;
core::array<core::vector3df> Points; core::array<core::vector3df> Points;
core::array<core::array<u32> > Polygons; core::array<core::array<u32> > Indices;
core::array<core::vector2df> TCoords; core::array<u16> MaterialMapping;
core::map<core::stringc, u32> VMap;
core::array<core::array<core::vector2df> > TCoords;
core::array<tLWOMaterial*> Materials; core::array<tLWOMaterial*> Materials;
core::array<core::stringc> Images; core::array<core::stringc> Images;
u8 FormatVersion; u8 FormatVersion;
......
...@@ -454,11 +454,13 @@ void COBJMeshFileLoader::readMTL(const c8* fileName, core::stringc relPath) ...@@ -454,11 +454,13 @@ void COBJMeshFileLoader::readMTL(const c8* fileName, core::stringc relPath)
} }
video::ITexture * texture = 0; video::ITexture * texture = 0;
if (FileSystem->existFile(textureNameBuf)) core::stringc texname(textureNameBuf);
texture = Driver->getTexture( textureNameBuf ); texname.replace('\\', '/');
if (FileSystem->existFile(texname.c_str()))
texture = Driver->getTexture(texname.c_str());
else else
// try to read in the relative path, the .obj is loaded from // try to read in the relative path, the .obj is loaded from
texture = Driver->getTexture( (relPath + textureNameBuf).c_str() ); texture = Driver->getTexture( (relPath + texname).c_str() );
if ( texture ) if ( texture )
{ {
if (type==0) if (type==0)
......
...@@ -20,10 +20,10 @@ namespace scene ...@@ -20,10 +20,10 @@ namespace scene
//! constructor //! constructor
CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr) CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, scene::ISceneManager* smgr)
: Textures(0), LightMaps(0), : Textures(0), LightMaps(0),
Vertices(0), Faces(0), Planes(0), Nodes(0), Leafs(0), LeafFaces(0), Vertices(0), Faces(0), Planes(0), Nodes(0), Leafs(0), LeafFaces(0),
MeshVerts(0), Brushes(0), Driver(driver), FileSystem(fs), SceneManager ( smgr ) MeshVerts(0), Brushes(0), FileSystem(fs), SceneManager ( smgr )
{ {
#ifdef _DEBUG #ifdef _DEBUG
IReferenceCounted::setDebugName("CQ3LevelMesh"); IReferenceCounted::setDebugName("CQ3LevelMesh");
...@@ -34,6 +34,10 @@ CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, sce ...@@ -34,6 +34,10 @@ CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, sce
Mesh[i] = 0; Mesh[i] = 0;
} }
if (smgr)
Driver = smgr->getVideoDriver();
else
Driver = 0;
if (Driver) if (Driver)
Driver->grab(); Driver->grab();
......
...@@ -24,7 +24,7 @@ namespace scene ...@@ -24,7 +24,7 @@ namespace scene
public: public:
//! constructor //! constructor
CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr); CQ3LevelMesh(io::IFileSystem* fs, scene::ISceneManager* smgr);
//! destructor //! destructor
virtual ~CQ3LevelMesh(); virtual ~CQ3LevelMesh();
......
...@@ -192,10 +192,10 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, ...@@ -192,10 +192,10 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
// add file format loaders // add file format loaders
#ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_ #ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
MeshLoaderList.push_back(new CIrrMeshFileLoader(Driver, this, FileSystem)); MeshLoaderList.push_back(new CIrrMeshFileLoader(this, FileSystem));
#endif #endif
#ifdef _IRR_COMPILE_WITH_BSP_LOADER_ #ifdef _IRR_COMPILE_WITH_BSP_LOADER_
MeshLoaderList.push_back(new CBSPMeshFileLoader(FileSystem, Driver, this)); MeshLoaderList.push_back(new CBSPMeshFileLoader(this, FileSystem));
#endif #endif
#ifdef _IRR_COMPILE_WITH_MD2_LOADER_ #ifdef _IRR_COMPILE_WITH_MD2_LOADER_
MeshLoaderList.push_back(new CMD2MeshFileLoader()); MeshLoaderList.push_back(new CMD2MeshFileLoader());
...@@ -222,10 +222,10 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, ...@@ -222,10 +222,10 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
MeshLoaderList.push_back(new CMY3DMeshFileLoader(FileSystem, Driver, this)); MeshLoaderList.push_back(new CMY3DMeshFileLoader(FileSystem, Driver, this));
#endif #endif
#ifdef _IRR_COMPILE_WITH_COLLADA_LOADER_ #ifdef _IRR_COMPILE_WITH_COLLADA_LOADER_
MeshLoaderList.push_back(new CColladaFileLoader(Driver, this, FileSystem)); MeshLoaderList.push_back(new CColladaFileLoader(this, FileSystem));
#endif #endif
#ifdef _IRR_COMPILE_WITH_DMF_LOADER_ #ifdef _IRR_COMPILE_WITH_DMF_LOADER_
MeshLoaderList.push_back(new CDMFLoader(Driver, this)); MeshLoaderList.push_back(new CDMFLoader(this));
#endif #endif
#ifdef _IRR_COMPILE_WITH_OGRE_LOADER_ #ifdef _IRR_COMPILE_WITH_OGRE_LOADER_
MeshLoaderList.push_back(new COgreMeshFileLoader(MeshManipulator, FileSystem, Driver)); MeshLoaderList.push_back(new COgreMeshFileLoader(MeshManipulator, FileSystem, Driver));
...@@ -240,7 +240,7 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, ...@@ -240,7 +240,7 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
MeshLoaderList.push_back(new CB3DMeshFileLoader(this)); MeshLoaderList.push_back(new CB3DMeshFileLoader(this));
#endif #endif
#ifdef _IRR_COMPILE_WITH_LWO_LOADER_ #ifdef _IRR_COMPILE_WITH_LWO_LOADER_
MeshLoaderList.push_back(new CLWOMeshFileLoader(Driver)); MeshLoaderList.push_back(new CLWOMeshFileLoader(this, FileSystem));
#endif #endif
#ifdef _IRR_COMPILE_WITH_STL_LOADER_ #ifdef _IRR_COMPILE_WITH_STL_LOADER_
MeshLoaderList.push_back(new CSTLMeshFileLoader()); MeshLoaderList.push_back(new CSTLMeshFileLoader());
...@@ -1813,7 +1813,6 @@ bool CSceneManager::loadScene(io::IReadFile* file, ISceneUserDataSerializer* use ...@@ -1813,7 +1813,6 @@ bool CSceneManager::loadScene(io::IReadFile* file, ISceneUserDataSerializer* use
reader->drop(); reader->drop();
return true; return true;
} }
......
...@@ -33,7 +33,7 @@ namespace scene ...@@ -33,7 +33,7 @@ namespace scene
//! constructor //! constructor
CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
gui::ICursorControl* cursorControl, IMeshCache* cache = 0, gui::ICursorControl* cursorControl, IMeshCache* cache = 0,
gui::IGUIEnvironment *guiEnvironment = 0); gui::IGUIEnvironment *guiEnvironment = 0);
//! destructor //! destructor
...@@ -58,7 +58,7 @@ namespace scene ...@@ -58,7 +58,7 @@ namespace scene
const video::SColor tail = video::SColor(0, 0, 0, 0), const video::SColor tail = video::SColor(0, 0, 0, 0),
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
//! adds a cube scene node to the scene. It is a simple cube of (1,1,1) size. //! adds a cube scene node to the scene. It is a simple cube of (1,1,1) size.
//! the returned pointer must not be dropped. //! the returned pointer must not be dropped.
virtual ISceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, virtual ISceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
...@@ -79,7 +79,7 @@ namespace scene ...@@ -79,7 +79,7 @@ namespace scene
//! adds a scene node for rendering a static mesh //! adds a scene node for rendering a static mesh
//! the returned pointer must not be dropped. //! the returned pointer must not be dropped.
virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f),
bool alsoAddIfMeshPointerZero=false); bool alsoAddIfMeshPointerZero=false);
...@@ -102,16 +102,16 @@ namespace scene ...@@ -102,16 +102,16 @@ namespace scene
//! draws all scene nodes //! draws all scene nodes
virtual void drawAll(); virtual void drawAll();
//! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering //! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree. //! faster then a bsp tree.
virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false);
//! Adss a scene node for rendering using a octtree. This a good method for rendering //! Adss a scene node for rendering using a octtree. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree. //! faster then a bsp tree.
virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false);
//! Adds a camera scene node to the tree and sets it as active camera. //! Adds a camera scene node to the tree and sets it as active camera.
...@@ -121,7 +121,7 @@ namespace scene ...@@ -121,7 +121,7 @@ namespace scene
//! the camera will move too. //! the camera will move too.
//! \return Returns pointer to interface to camera //! \return Returns pointer to interface to camera
virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& lookat = core::vector3df(0,0,0), s32 id=-1); const core::vector3df& lookat = core::vector3df(0,0,0), s32 id=-1);
//! Adds a camera scene node which is able to be controlle with the mouse similar //! Adds a camera scene node which is able to be controlle with the mouse similar
...@@ -131,7 +131,7 @@ namespace scene ...@@ -131,7 +131,7 @@ namespace scene
f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 100.0f, s32 id=-1); f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 100.0f, s32 id=-1);
//! Adds a camera scene node which is able to be controled with the mouse and keys //! Adds a camera scene node which is able to be controled with the mouse and keys
//! like in most first person shooters (FPS): //! like in most first person shooters (FPS):
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 1500.0f, f32 moveSpeed = 200.0f, s32 id=-1, f32 rotateSpeed = 1500.0f, f32 moveSpeed = 200.0f, s32 id=-1,
SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false,
...@@ -153,7 +153,7 @@ namespace scene ...@@ -153,7 +153,7 @@ namespace scene
video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF); video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF);
//! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and //! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and
//! is drawn around the camera position. //! is drawn around the camera position.
virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom,
video::ITexture* left, video::ITexture* right, video::ITexture* front, video::ITexture* left, video::ITexture* right, video::ITexture* front,
video::ITexture* back, ISceneNode* parent = 0, s32 id=-1); video::ITexture* back, ISceneNode* parent = 0, s32 id=-1);
...@@ -164,10 +164,10 @@ namespace scene ...@@ -164,10 +164,10 @@ namespace scene
u32 horiRes, u32 vertRes, f64 texturePercentage, u32 horiRes, u32 vertRes, f64 texturePercentage,
f64 spherePercentage, ISceneNode* parent=0, s32 id=-1); f64 spherePercentage, ISceneNode* parent=0, s32 id=-1);
//! Adds a text scene node, which is able to display //! Adds a text scene node, which is able to display
//! 2d text at a position in three dimensional space //! 2d text at a position in three dimensional space
virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text,
video::SColor color=video::SColor(100,255,255,255), video::SColor color=video::SColor(100,255,255,255),
ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0),
s32 id=-1); s32 id=-1);
...@@ -193,7 +193,7 @@ namespace scene ...@@ -193,7 +193,7 @@ namespace scene
//! name as parameter. //! name as parameter.
virtual IAnimatedMesh* addHillPlaneMesh(const c8* name, virtual IAnimatedMesh* addHillPlaneMesh(const c8* name,
const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount, const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount,
video::SMaterial* material = 0, f32 hillHeight = 0.0f, video::SMaterial* material = 0, f32 hillHeight = 0.0f,
const core::dimension2d<f32>& countHills = core::dimension2d<f32>(1.0f, 1.0f), const core::dimension2d<f32>& countHills = core::dimension2d<f32>(1.0f, 1.0f),
const core::dimension2d<f32>& textureRepeatCount = core::dimension2d<f32>(1.0f, 1.0f)); const core::dimension2d<f32>& textureRepeatCount = core::dimension2d<f32>(1.0f, 1.0f));
...@@ -213,7 +213,7 @@ namespace scene ...@@ -213,7 +213,7 @@ namespace scene
IAnimatedMesh* addSphereMesh(const c8* name, IAnimatedMesh* addSphereMesh(const c8* name,
f32 radius, u32 polyCountX, u32 polyCountY); f32 radius, u32 polyCountX, u32 polyCountY);
//! Adds a particle system scene node. //! Adds a particle system scene node.
virtual IParticleSystemSceneNode* addParticleSystemSceneNode( virtual IParticleSystemSceneNode* addParticleSystemSceneNode(
bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& position = core::vector3df(0,0,0),
...@@ -222,8 +222,8 @@ namespace scene ...@@ -222,8 +222,8 @@ namespace scene
//! Adds a terrain scene node to the scene graph. //! Adds a terrain scene node to the scene graph.
virtual ITerrainSceneNode* addTerrainSceneNode( virtual ITerrainSceneNode* addTerrainSceneNode(
const c8* heightMapFileName, const c8* heightMapFileName,
ISceneNode* parent=0, s32 id=-1, ISceneNode* parent=0, s32 id=-1,
const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f),
const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f),
const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f),
...@@ -233,8 +233,8 @@ namespace scene ...@@ -233,8 +233,8 @@ namespace scene
//! Adds a terrain scene node to the scene graph. //! Adds a terrain scene node to the scene graph.
virtual ITerrainSceneNode* addTerrainSceneNode( virtual ITerrainSceneNode* addTerrainSceneNode(
io::IReadFile* heightMap, io::IReadFile* heightMap,
ISceneNode* parent=0, s32 id=-1, ISceneNode* parent=0, s32 id=-1,
const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f),
const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f),
const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f),
...@@ -249,7 +249,7 @@ namespace scene ...@@ -249,7 +249,7 @@ namespace scene
//! Adds an empty scene node. //! Adds an empty scene node.
virtual ISceneNode* addEmptySceneNode(ISceneNode* parent, s32 id=-1); virtual ISceneNode* addEmptySceneNode(ISceneNode* parent, s32 id=-1);
//! Returns the root scene node. This is the scene node wich is parent //! Returns the root scene node. This is the scene node wich is parent
//! of all scene nodes. The root scene node is a special scene node which //! of all scene nodes. The root scene node is a special scene node which
//! only exists to manage all scene nodes. It is not rendered and cannot //! only exists to manage all scene nodes. It is not rendered and cannot
//! be removed from the scene. //! be removed from the scene.
...@@ -271,9 +271,9 @@ namespace scene ...@@ -271,9 +271,9 @@ namespace scene
//! and the animator will animate it. //! and the animator will animate it.
virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond); virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond);
//! creates a fly circle animator, which lets the attached scene node fly //! creates a fly circle animator, which lets the attached scene node fly
//! around a center. The center is the position of the scene node. //! around a center. The center is the position of the scene node.
//! \param rotationSpeed: //! \param rotationSpeed:
//! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() //! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator()
//! and the animator will animate it. //! and the animator will animate it.
virtual ISceneNodeAnimator* createFlyCircleAnimator(const core::vector3df& normal, f32 radius, f32 speed, virtual ISceneNodeAnimator* createFlyCircleAnimator(const core::vector3df& normal, f32 radius, f32 speed,
...@@ -294,17 +294,17 @@ namespace scene ...@@ -294,17 +294,17 @@ namespace scene
virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMS); virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMS);
//! Creates a special scene node animator for doing automatic collision detection //! Creates a special scene node animator for doing automatic collision detection
//! and response. //! and response.
virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator(
ITriangleSelector* world, ISceneNode* sceneNode, ITriangleSelector* world, ISceneNode* sceneNode,
const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30),
const core::vector3df& gravityPerSecond = core::vector3df(0,-1.0f,0), const core::vector3df& gravityPerSecond = core::vector3df(0,-1.0f,0),
const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0),
f32 slidingValue = 0.0005f); f32 slidingValue = 0.0005f);
//! Creates a follow spline animator. //! Creates a follow spline animator.
virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime,
const core::array< core::vector3df >& points, const core::array< core::vector3df >& points,
f32 speed = 1.0f, f32 tightness = 0.5f); f32 speed = 1.0f, f32 tightness = 0.5f);
...@@ -337,7 +337,7 @@ namespace scene ...@@ -337,7 +337,7 @@ namespace scene
//! Returns a pointer to the mesh manipulator. //! Returns a pointer to the mesh manipulator.
virtual IMeshManipulator* getMeshManipulator(); virtual IMeshManipulator* getMeshManipulator();
//! Sets the color of stencil buffers shadows drawn by the scene manager. //! Sets the color of stencil buffers shadows drawn by the scene manager.
virtual void setShadowColor(video::SColor color); virtual void setShadowColor(video::SColor color);
...@@ -363,7 +363,7 @@ namespace scene ...@@ -363,7 +363,7 @@ namespace scene
//! use this method, it is used by the internal engine. //! use this method, it is used by the internal engine.
virtual bool postEventFromUser(const SEvent& event); virtual bool postEventFromUser(const SEvent& event);
//! Clears the whole scene. All scene nodes are removed. //! Clears the whole scene. All scene nodes are removed.
virtual void clear(); virtual void clear();
//! Removes all children of this scene node //! Removes all children of this scene node
...@@ -372,10 +372,10 @@ namespace scene ...@@ -372,10 +372,10 @@ namespace scene
//! Returns interface to the parameters set in this scene. //! Returns interface to the parameters set in this scene.
virtual io::IAttributes* getParameters(); virtual io::IAttributes* getParameters();
//! Returns current render pass. //! Returns current render pass.
virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const; virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const;
//! Creates a new scene manager. //! Creates a new scene manager.
virtual ISceneManager* createNewSceneManager(bool cloneContent); virtual ISceneManager* createNewSceneManager(bool cloneContent);
//! Returns type of the scene node //! Returns type of the scene node
...@@ -385,7 +385,7 @@ namespace scene ...@@ -385,7 +385,7 @@ namespace scene
virtual ISceneNodeFactory* getDefaultSceneNodeFactory(); virtual ISceneNodeFactory* getDefaultSceneNodeFactory();
//! Adds a scene node factory to the scene manager. //! Adds a scene node factory to the scene manager.
/** Use this to extend the scene manager with new scene node types which it should be /** Use this to extend the scene manager with new scene node types which it should be
able to create automaticly, for example when loading data from xml files. */ able to create automaticly, for example when loading data from xml files. */
virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd); virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd);
...@@ -425,11 +425,11 @@ namespace scene ...@@ -425,11 +425,11 @@ namespace scene
virtual bool loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0); virtual bool loadScene(const c8* filename, ISceneUserDataSerializer* userDataSerializer=0);
//! Loads a scene. Note that the current scene is not cleared before. //! Loads a scene. Note that the current scene is not cleared before.
virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0); virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0);
//! Writes attributes of the scene node. //! Writes attributes of the scene node.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
//! Reads attributes of the scene node. //! Reads attributes of the scene node.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
...@@ -467,7 +467,7 @@ namespace scene ...@@ -467,7 +467,7 @@ namespace scene
//! reads user data of a node //! reads user data of a node
void readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer); void readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer);
struct DefaultNodeEntry struct DefaultNodeEntry
{ {
DefaultNodeEntry() {}; DefaultNodeEntry() {};
...@@ -527,7 +527,7 @@ namespace scene ...@@ -527,7 +527,7 @@ namespace scene
DistanceNodeEntry(ISceneNode* n, const core::vector3df &cameraPos) DistanceNodeEntry(ISceneNode* n, const core::vector3df &cameraPos)
{ {
node = n; node = n;
distance = (node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(cameraPos)); distance = (node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(cameraPos));
distance -= node->getBoundingBox().getExtent().getLengthSQ() / 2.0; distance -= node->getBoundingBox().getExtent().getLengthSQ() / 2.0;
} }
......
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