Commit fbd4188b authored by irrlicht's avatar irrlicht

added loader for the new .irrmesh format. (CIrrMeshFileLoader)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@931 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c02aca00
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() - Irrlicht now has its own file format for static meshes. It is based on xml and has the
extension .irrmesh. Irrlicht is able to write every IMesh to this file format, and of course to
read it back again.
- Irrlicht is now able to write Meshes out into files. Use ISceneManager::createMeshWriter()
to obtain an interface with which you can write out meshes. Currently, an own .irrmesh to obtain an interface with which you can write out meshes. Currently, an own .irrmesh
file format is supported as well as COLLADA. file format is supported as well as the COLLADA file format.
- 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
......
...@@ -154,7 +154,8 @@ public: ...@@ -154,7 +154,8 @@ public:
virtual void clear() = 0; virtual void clear() = 0;
//! Reads attributes from a xml file. //! Reads attributes from a xml file.
//! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'. //! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes' or
//! the name specified using elementName.
//! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken. //! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken.
//! If set to false, the first appearing list of attributes are read. //! If set to false, the first appearing list of attributes are read.
virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false, const wchar_t* elementName=0) = 0; virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false, const wchar_t* elementName=0) = 0;
...@@ -163,7 +164,6 @@ public: ...@@ -163,7 +164,6 @@ public:
//! \param writer: The XML writer to write to //! \param writer: The XML writer to write to
//! \param writeXMLHeader: Writes a header to the XML file, required if at the beginning of the file //! \param writeXMLHeader: Writes a header to the XML file, required if at the beginning of the file
//! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken. //! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken.
//! and you haven't already written one with writer->writeXMLHeader()
virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false, const wchar_t* elementName=0) = 0; virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false, const wchar_t* elementName=0) = 0;
......
...@@ -227,6 +227,9 @@ B3D, MS3D or X meshes */ ...@@ -227,6 +227,9 @@ B3D, MS3D or X meshes */
#define _IRR_COMPILE_WITH_X_LOADER_ #define _IRR_COMPILE_WITH_X_LOADER_
#endif #endif
//! Define _IRR_COMPILE_WITH_IRR_MESH_LOADER_ if you want to load Irrlicht Engine .irrmesh files
#define _IRR_COMPILE_WITH_IRR_MESH_LOADER_
//! Define _IRR_COMPILE_WITH_MD2_LOADER_ if you want to load Quake 2 animated files //! Define _IRR_COMPILE_WITH_MD2_LOADER_ if you want to load Quake 2 animated files
#define _IRR_COMPILE_WITH_MD2_LOADER_ #define _IRR_COMPILE_WITH_MD2_LOADER_
//! Define _IRR_COMPILE_WITH_MD3_LOADER_ if you want to load Quake 3 animated files //! Define _IRR_COMPILE_WITH_MD3_LOADER_ if you want to load Quake 3 animated files
......
This diff is collapsed.
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_IRR_MESH_FILE_LOADER_H_INCLUDED__
#define __C_IRR_MESH_FILE_LOADER_H_INCLUDED__
#include "IMeshLoader.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "irrString.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "ISceneManager.h"
namespace irr
{
namespace scene
{
//! Meshloader capable of loading .irrmesh meshes, the Irrlicht Engine mesh format for static meshes
class CIrrMeshFileLoader : public IMeshLoader
{
public:
//! Constructor
CIrrMeshFileLoader(video::IVideoDriver* driver,
scene::ISceneManager* smgr, io::IFileSystem* fs);
//! destructor
virtual ~CIrrMeshFileLoader();
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".cob")
virtual bool isALoadableFileExtension(const c8* fileName);
//! creates/loads an animated mesh from the file.
//! \return Pointer to the created mesh. Returns 0 if loading failed.
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
//! See IReferenceCounted::drop() for more information.
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
private:
//! reads a mesh sections and creates a mesh from it
IAnimatedMesh* readMesh(io::IXMLReader* reader);
//! reads a mesh sections and creates a mesh buffer from it
IMeshBuffer* readMeshBuffer(io::IXMLReader* reader);
//! skips an (unknown) section in the irrmesh file
void skipSection(io::IXMLReader* reader, bool reportSkipping);
//! reads a <material> element and stores it in the material section
void readMaterial(io::IXMLReader* reader);
//! parses a float from a char pointer and moves the pointer to
//! the end of the parsed float
inline f32 readFloat(const c8** p);
//! parses an int from a char pointer and moves the pointer to
//! the end of the parsed float
inline s32 readInt(const c8** p);
//! places pointer to next begin of a token
void findNextNoneWhiteSpace(const c8** p);
//! places pointer to next begin of a token
void skipCurrentNoneWhiteSpace(const c8** p);
//! reads floats from inside of xml element until end of xml element
void readFloatsInsideElement(io::IXMLReader* reader, f32* floats, u32 count);
//! read all 3 types of mesh buffers
void readMeshBuffer(io::IXMLReader* reader, int vertexCount, SMeshBuffer* sbuffer);
void readMeshBuffer(io::IXMLReader* reader, int vertexCount, SMeshBufferLightMap* sbuffer);
void readMeshBuffer(io::IXMLReader* reader, int vertexCount, SMeshBufferTangents* sbuffer);
//! read indices
void readIndices(io::IXMLReader* reader, int indexCount, core::array<u16>& indices);
// member variables
video::IVideoDriver* Driver;
scene::ISceneManager* SceneManager;
io::IFileSystem* FileSystem;
};
} // end namespace scene
} // end namespace irr
#endif
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include "CGeometryCreator.h" #include "CGeometryCreator.h"
#ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
#include "CIrrMeshFileLoader.h"
#endif
#ifdef _IRR_COMPILE_WITH_BSP_LOADER_ #ifdef _IRR_COMPILE_WITH_BSP_LOADER_
#include "CBSPMeshFileLoader.h" #include "CBSPMeshFileLoader.h"
#endif #endif
...@@ -169,7 +173,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, ...@@ -169,7 +173,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
// add file format loaders // add file format loaders
#ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
MeshLoaderList.push_back(new CIrrMeshFileLoader(Driver, this, FileSystem));
#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(FileSystem, Driver, this));
#endif #endif
......
...@@ -1276,6 +1276,12 @@ ...@@ -1276,6 +1276,12 @@
<File <File
RelativePath=".\CDMFLoader.h"> RelativePath=".\CDMFLoader.h">
</File> </File>
<File
RelativePath=".\CIrrMeshFileLoader.cpp">
</File>
<File
RelativePath=".\CIrrMeshFileLoader.h">
</File>
<File <File
RelativePath=".\CLMTSMeshFileLoader.cpp"> RelativePath=".\CLMTSMeshFileLoader.cpp">
</File> </File>
......
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