Commit 2da809bc authored by irrlicht's avatar irrlicht

added mesh writing features. COLLADA file writer is finished, .irrmesh writer...

added mesh writing features. COLLADA file writer is finished, .irrmesh writer is under construction.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@924 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7b734957
Changes in version 1.4 (... 2007) Changes in version 1.4 (... 2007)
- Irrlicht is now able to write Meshes out into files again. Use ISceneManager::createMeshWriter()
to obtain an interface with which you can write out meshes. Currently, an own .irrmesh
file format is supported as well as COLLADA.
- the base class for nearly all Irrlicht classes has been renamed from IUnknown to IReferenceCounted - the base class for nearly all Irrlicht classes has been renamed from IUnknown to IReferenceCounted
- fixed the keyboard autorepeat difference betwenn Linux and Windows. Thanks to denton we now have only KeyPressed events on both systems in case of autorepeat. - fixed the keyboard autorepeat difference betwenn Linux and Windows. Thanks to denton we now have only KeyPressed events on both systems in case of autorepeat.
......
#ifndef __IRR_I_MESH_WRITER_H_INCLUDED__
#define __IRR_I_MESH_WRITER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "IWriteFile.h"
#include "irrTypes.h"
namespace irr
{
class IrrlichtDevice;
namespace scene
{
class IMesh;
//! An enumeration for all supported types of built-in mesh writers
/** A scene mesh writers is represented by a four character code
such as 'irrm' or 'coll' instead of simple numbers, to avoid
name clashes with external mesh writers.*/
enum EMESH_WRITER_TYPE
{
//! Irrlicht Native mesh writer, for static .irrmesh files.
EMWT_IRR_MESH = MAKE_IRR_ID('i','r','r','m'),
//! COLLADA mesh writer for .dae and .xml files
EMWT_COLLADA = MAKE_IRR_ID('c','o','l','l'),
};
//! flags configuring mesh writing
enum E_MESH_WRITER_FLAGS
{
//! no writer flags
EMWF_NONE = 0,
//! write lightmap textures out if possible
EMWF_WRITE_LIGHTMAPS = 0x1
};
// interface for writing meshes
class IMeshWriter : public virtual irr::IReferenceCounted
{
public:
virtual ~IMeshWriter() {};
//! Returns the type of the mesh writer
/** For own implementations, use MAKE_IRR_ID as shown in the EMESH_WRITER_TYPE
enumeration to return your own unique mesh type id.*/
virtual EMESH_WRITER_TYPE getType() const = 0;
//! writes a static mesh
/** \return Returns true if sucessful */
virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh,
s32 flags=EMWF_NONE) = 0;
// writes an animated mesh
// for future use, no writer is able to write animated meshes currently
/* \return Returns true if sucessful */
//virtual bool writeAnimatedMesh(io::IWriteFile* file,
// scene::IAnimatedMesh* mesh,
// s32 flags=EMWF_NONE) = 0;
};
} // end namespace
} // end namespace
#endif
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "ETerrainElements.h" #include "ETerrainElements.h"
#include "ESceneNodeTypes.h" #include "ESceneNodeTypes.h"
#include "SceneParameters.h" #include "SceneParameters.h"
#include "IMeshWriter.h"
namespace irr namespace irr
{ {
...@@ -1216,6 +1217,11 @@ namespace scene ...@@ -1216,6 +1217,11 @@ namespace scene
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0; virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0;
//! Returns a mesh writer implementation if available
/** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
for details. */
virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type) = 0;
//! Sets ambient color of the scene //! Sets ambient color of the scene
virtual void setAmbientLight(const video::SColorf &ambientColor) = 0; virtual void setAmbientLight(const video::SColorf &ambientColor) = 0;
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
#include "IMeshCache.h" #include "IMeshCache.h"
#include "IMeshSceneNode.h" #include "IMeshSceneNode.h"
#include "IMeshManipulator.h" #include "IMeshManipulator.h"
#include "IMeshWriter.h"
#include "IMetaTriangleSelector.h" #include "IMetaTriangleSelector.h"
#include "IReadFile.h" #include "IReadFile.h"
#include "IrrlichtDevice.h" #include "IrrlichtDevice.h"
......
This diff is collapsed.
#ifndef __IRR_C_COLLADA_MESH_WRITER_H_INCLUDED__
#define __IRR_C_COLLADA_MESH_WRITER_H_INCLUDED__
#include "IMeshWriter.h"
#include "S3DVertex.h"
#include "IVideoDriver.h"
#include "IFileSystem.h"
namespace irr
{
namespace io
{
class IXMLWriter;
}
namespace scene
{
//! class to write meshes, implementing a COLLADA (.dae, .xml) writer
/** This writer implementation has been originally developed for irrEdit and then
merged out to the Irrlicht Engine */
class CColladaMeshWriter : public IMeshWriter
{
public:
CColladaMeshWriter(irr::video::IVideoDriver* driver, irr::io::IFileSystem* fs);
virtual ~CColladaMeshWriter();
//! Returns the type of the mesh writer
virtual EMESH_WRITER_TYPE getType() const;
//! writes a mesh
virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags=EMWF_NONE);
protected:
bool hasSecondTextureCoordinates(video::E_VERTEX_TYPE type);
struct SComponentGlobalStartPos
{
SComponentGlobalStartPos()
{
PosStartIndex = -1;
PosLastIndex = -1;
NormalStartIndex = -1;
NormalLastIndex = -1;
TCoord0LastIndex = -1;
TCoord0LastIndex = -1;
TCoord1LastIndex = -1;
TCoord1LastIndex = -1;
}
s32 PosStartIndex;
s32 PosLastIndex;
s32 TCoord0StartIndex;
s32 TCoord0LastIndex;
s32 NormalStartIndex;
s32 NormalLastIndex;
s32 TCoord1StartIndex;
s32 TCoord1LastIndex;
};
io::IFileSystem* FileSystem;
video::IVideoDriver* VideoDriver;
io::IXMLWriter* Writer;
};
} // end namespace
} // end namespace
#endif
\ No newline at end of file
#include "CIrrMeshWriter.h"
#include "os.h"
#include "IXMLWriter.h"
#include "IMesh.h"
#include "IAttributes.h"
namespace irr
{
namespace scene
{
CIrrMeshWriter::CIrrMeshWriter(irr::video::IVideoDriver* driver,
irr::io::IFileSystem* fs)
: VideoDriver(driver), FileSystem(fs)
{
if (VideoDriver)
VideoDriver->grab();
if (FileSystem)
FileSystem->grab();
}
CIrrMeshWriter::~CIrrMeshWriter()
{
if (VideoDriver)
VideoDriver->drop();
if (FileSystem)
FileSystem->drop();
}
//! Returns the type of the mesh writer
EMESH_WRITER_TYPE CIrrMeshWriter::getType() const
{
return EMWT_IRR_MESH;
}
//! writes a mesh
bool CIrrMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags)
{
if (!file)
return false;
Writer = FileSystem->createXMLWriter(file);
if (!Writer)
{
os::Printer::log("Could not write file", file->getFileName());
return false;
}
os::Printer::log("Writing mesh", file->getFileName());
// write IRR MESH header
Writer->writeXMLHeader();
Writer->writeElement(L"irrmesh", false,
L"xmlns", L"http://irrlicht.sourceforge.net/IRRMESH_08_2007",
L"version", L"1.0");
Writer->writeLineBreak();
// write mesh
// TODO: implement
Writer->drop();
return true;
}
} // end namespace
} // end namespace
#ifndef __IRR_IRR_MESH_WRITER_H_INCLUDED__
#define __IRR_IRR_MESH_WRITER_H_INCLUDED__
#include "IMeshWriter.h"
#include "S3DVertex.h"
#include "IVideoDriver.h"
#include "IFileSystem.h"
namespace irr
{
namespace io
{
class IXMLWriter;
}
namespace scene
{
//! class to write meshes, implementing a IrrMesh (.irrmesh, .xml) writer
/** This writer implementation has been originally developed for irrEdit and then
merged out to the Irrlicht Engine */
class CIrrMeshWriter : public IMeshWriter
{
public:
CIrrMeshWriter(irr::video::IVideoDriver* driver, irr::io::IFileSystem* fs);
virtual ~CIrrMeshWriter();
//! Returns the type of the mesh writer
virtual EMESH_WRITER_TYPE getType() const;
//! writes a mesh
virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags=EMWF_NONE);
protected:
io::IFileSystem* FileSystem;
video::IVideoDriver* VideoDriver;
io::IXMLWriter* Writer;
};
} // end namespace
} // end namespace
#endif
\ No newline at end of file
...@@ -117,6 +117,9 @@ ...@@ -117,6 +117,9 @@
#include "CQuake3ShaderSceneNode.h" #include "CQuake3ShaderSceneNode.h"
#include "CColladaMeshWriter.h"
#include "CIrrMeshWriter.h"
//! Enable debug features //! Enable debug features
#define SCENEMANAGER_DEBUG #define SCENEMANAGER_DEBUG
...@@ -2173,6 +2176,21 @@ video::SColorf CSceneManager::getAmbientLight() ...@@ -2173,6 +2176,21 @@ video::SColorf CSceneManager::getAmbientLight()
} }
//! Returns a mesh writer implementation if available
IMeshWriter* CSceneManager::createMeshWriter(EMESH_WRITER_TYPE type)
{
switch(type)
{
case EMWT_IRR_MESH:
return new CIrrMeshWriter(Driver, FileSystem);
case EMWT_COLLADA:
return new CColladaMeshWriter(Driver, FileSystem);
}
return 0;
}
// creates a scenemanager // creates a scenemanager
ISceneManager* createSceneManager(video::IVideoDriver* driver, ISceneManager* createSceneManager(video::IVideoDriver* driver,
io::IFileSystem* fs, gui::ICursorControl* cursorcontrol, io::IFileSystem* fs, gui::ICursorControl* cursorcontrol,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "irrString.h" #include "irrString.h"
#include "irrArray.h" #include "irrArray.h"
#include "IMeshLoader.h" #include "IMeshLoader.h"
#include "IMeshWriter.h"
#include "CAttributes.h" #include "CAttributes.h"
namespace irr namespace irr
...@@ -424,6 +425,9 @@ namespace scene ...@@ -424,6 +425,9 @@ namespace scene
//! 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);
//! Returns a mesh writer implementation if available
virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type);
//! Sets ambient color of the scene //! Sets ambient color of the scene
virtual void setAmbientLight(const video::SColorf &ambientColor); virtual void setAmbientLight(const video::SColorf &ambientColor);
......
...@@ -403,27 +403,6 @@ ...@@ -403,27 +403,6 @@
</Filter> </Filter>
<Filter <Filter
Name="scene"> Name="scene">
<File
RelativePath=".\CParticleAnimatedMeshSceneNodeEmitter.cpp">
</File>
<File
RelativePath=".\CParticleAttractionAffector.cpp">
</File>
<File
RelativePath=".\CParticleCylinderEmitter.cpp">
</File>
<File
RelativePath=".\CParticleMeshEmitter.cpp">
</File>
<File
RelativePath=".\CParticleRingEmitter.cpp">
</File>
<File
RelativePath=".\CParticleRotationAffector.cpp">
</File>
<File
RelativePath=".\CParticleSphereEmitter.cpp">
</File>
<File <File
RelativePath="..\..\include\ECullingTypes.h"> RelativePath="..\..\include\ECullingTypes.h">
</File> </File>
...@@ -481,6 +460,9 @@ ...@@ -481,6 +460,9 @@
<File <File
RelativePath=".\..\..\include\IMeshSceneNode.h"> RelativePath=".\..\..\include\IMeshSceneNode.h">
</File> </File>
<File
RelativePath="..\..\include\IMeshWriter.h">
</File>
<File <File
RelativePath=".\..\..\include\IMetaTriangleSelector.h"> RelativePath=".\..\..\include\IMetaTriangleSelector.h">
</File> </File>
...@@ -1495,12 +1477,21 @@ ...@@ -1495,12 +1477,21 @@
</Filter> </Filter>
<Filter <Filter
Name="particleSystem"> Name="particleSystem">
<File
RelativePath=".\CParticleAnimatedMeshSceneNodeEmitter.cpp">
</File>
<File
RelativePath=".\CParticleAttractionAffector.cpp">
</File>
<File <File
RelativePath="CParticleBoxEmitter.cpp"> RelativePath="CParticleBoxEmitter.cpp">
</File> </File>
<File <File
RelativePath="CParticleBoxEmitter.h"> RelativePath="CParticleBoxEmitter.h">
</File> </File>
<File
RelativePath=".\CParticleCylinderEmitter.cpp">
</File>
<File <File
RelativePath="CParticleFadeOutAffector.cpp"> RelativePath="CParticleFadeOutAffector.cpp">
</File> </File>
...@@ -1513,12 +1504,24 @@ ...@@ -1513,12 +1504,24 @@
<File <File
RelativePath="CParticleGravityAffector.h"> RelativePath="CParticleGravityAffector.h">
</File> </File>
<File
RelativePath=".\CParticleMeshEmitter.cpp">
</File>
<File <File
RelativePath="CParticlePointEmitter.cpp"> RelativePath="CParticlePointEmitter.cpp">
</File> </File>
<File <File
RelativePath="CParticlePointEmitter.h"> RelativePath="CParticlePointEmitter.h">
</File> </File>
<File
RelativePath=".\CParticleRingEmitter.cpp">
</File>
<File
RelativePath=".\CParticleRotationAffector.cpp">
</File>
<File
RelativePath=".\CParticleSphereEmitter.cpp">
</File>
<File <File
RelativePath="CParticleSystemSceneNode.cpp"> RelativePath="CParticleSystemSceneNode.cpp">
</File> </File>
...@@ -1610,6 +1613,22 @@ ...@@ -1610,6 +1613,22 @@
RelativePath=".\CSceneNodeAnimatorTexture.h"> RelativePath=".\CSceneNodeAnimatorTexture.h">
</File> </File>
</Filter> </Filter>
<Filter
Name="writers"
Filter="">
<File
RelativePath=".\CColladaMeshWriter.cpp">
</File>
<File
RelativePath=".\CColladaMeshWriter.h">
</File>
<File
RelativePath=".\CIrrMeshWriter.cpp">
</File>
<File
RelativePath=".\CIrrMeshWriter.h">
</File>
</Filter>
</Filter> </Filter>
<Filter <Filter
Name="io impl"> Name="io impl">
......
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