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