Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Ogre::MeshSerializer Class Reference

Class for serialising mesh data to/from an OGRE .mesh file. More...

#include <OgreMeshSerializer.h>

Inheritance diagram for Ogre::MeshSerializer:
Inheritance graph
[legend]

Classes

class  MeshVersionData
 

Public Types

enum  Endian { ENDIAN_NATIVE , ENDIAN_BIG , ENDIAN_LITTLE }
 The endianness of written files. More...
 

Public Member Functions

 MeshSerializer ()
 
virtual ~MeshSerializer ()
 
void exportMesh (const Mesh *pMesh, const String &filename, Endian endianMode=ENDIAN_NATIVE)
 Exports a mesh to the file specified, in the latest format. More...
 
void exportMesh (const Mesh *pMesh, const String &filename, MeshVersion version, Endian endianMode=ENDIAN_NATIVE)
 Exports a mesh to the file specified, in a specific version format. More...
 
void exportMesh (const Mesh *pMesh, DataStreamPtr stream, Endian endianMode=ENDIAN_NATIVE)
 Exports a mesh to the stream specified, in the latest format. More...
 
void exportMesh (const Mesh *pMesh, DataStreamPtr stream, MeshVersion version, Endian endianMode=ENDIAN_NATIVE)
 Exports a mesh to the stream specified, in a specific version format. More...
 
MeshSerializerListenergetListener ()
 Returns the current listener. More...
 
void importMesh (DataStreamPtr &stream, Mesh *pDest)
 Imports Mesh and (optionally) Material data from a .mesh file DataStream. More...
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete (void *ptr, void *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info More...
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
void setListener (MeshSerializerListener *listener)
 Sets the listener for this serializer. More...
 

Protected Types

typedef vector< MeshVersionData * >::type MeshVersionDataList
 

Protected Member Functions

virtual void determineEndianness (DataStreamPtr &stream)
 Determine the endianness of the incoming stream compared to native. More...
 
virtual void determineEndianness (Endian requestedEndian)
 Determine the endianness to write with based on option. More...
 
virtual void flipEndian (void *pData, size_t size)
 
virtual void flipEndian (void *pData, size_t size, size_t count)
 
virtual void flipFromLittleEndian (void *pData, size_t size, size_t count=1)
 
virtual void flipToLittleEndian (void *pData, size_t size, size_t count=1)
 
void readBools (DataStreamPtr &stream, bool *pDest, size_t count)
 
virtual unsigned short readChunk (DataStreamPtr &stream)
 
virtual void readFileHeader (DataStreamPtr &stream)
 
void readFloats (DataStreamPtr &stream, double *pDest, size_t count)
 
void readFloats (DataStreamPtr &stream, float *pDest, size_t count)
 
void readInts (DataStreamPtr &stream, uint32 *pDest, size_t count)
 
void readObject (DataStreamPtr &stream, Quaternion &pDest)
 
void readObject (DataStreamPtr &stream, Vector3 &pDest)
 
void readShorts (DataStreamPtr &stream, uint16 *pDest, size_t count)
 
String readString (DataStreamPtr &stream)
 
String readString (DataStreamPtr &stream, size_t numChars)
 
void writeBools (const bool *const pLong, size_t count)
 
virtual void writeChunkHeader (uint16 id, size_t size)
 
void writeData (const void *const buf, size_t size, size_t count)
 
virtual void writeFileHeader (void)
 Default to native endian, derive from header. More...
 
void writeFloats (const double *const pfloat, size_t count)
 
void writeFloats (const float *const pfloat, size_t count)
 
void writeInts (const uint32 *const pInt, size_t count)
 
void writeObject (const Quaternion &q)
 
void writeObject (const Vector3 &vec)
 
void writeShorts (const uint16 *const pShort, size_t count)
 
void writeString (const String &string)
 

Protected Attributes

uint32 mCurrentstreamLen
 
bool mFlipEndian
 
MeshSerializerListenermListener
 
DataStreamPtr mStream
 
String mVersion
 
MeshVersionDataList mVersionData
 

Detailed Description

Class for serialising mesh data to/from an OGRE .mesh file.

Remarks
This class allows exporters to write OGRE .mesh files easily, and allows the OGRE engine to import .mesh files into instantiated OGRE Meshes. Note that a .mesh file can include not only the Mesh, but also definitions of any Materials it uses (although this is optional, the .mesh can rely on the Material being loaded from another source, especially useful if you want to take advantage of OGRE's advanced Material properties which may not be available in your modeller).
To export a Mesh:
  1. Use the MaterialManager methods to create any dependent Material objects, if you want to export them with the Mesh.
  2. Create a Mesh object and populate it using it's methods.
  3. Call the exportMesh method
It's important to realise that this exporter uses OGRE terminology. In this context, 'Mesh' means a top-level mesh structure which can actually contain many SubMeshes, each of which has only one Material. Modelling packages may refer to these differently, for example in Milkshape, it says 'Model' instead of 'Mesh' and 'Mesh' instead of 'SubMesh', but the theory is the same.

Definition at line 89 of file OgreMeshSerializer.h.

Member Typedef Documentation

◆ MeshVersionDataList

Definition at line 178 of file OgreMeshSerializer.h.

Member Enumeration Documentation

◆ Endian

enum Ogre::Serializer::Endian
inherited

The endianness of written files.

Enumerator
ENDIAN_NATIVE 

Use the platform native endian.

ENDIAN_BIG 

Use big endian (0x1000 is serialised as 0x10 0x00)

ENDIAN_LITTLE 

Use little endian (0x1000 is serialised as 0x00 0x10)

Definition at line 57 of file OgreSerializer.h.

Constructor & Destructor Documentation

◆ MeshSerializer()

Ogre::MeshSerializer::MeshSerializer ( )

◆ ~MeshSerializer()

virtual Ogre::MeshSerializer::~MeshSerializer ( )
virtual

Member Function Documentation

◆ determineEndianness() [1/2]

virtual void Ogre::Serializer::determineEndianness ( DataStreamPtr stream)
protectedvirtualinherited

Determine the endianness of the incoming stream compared to native.

◆ determineEndianness() [2/2]

virtual void Ogre::Serializer::determineEndianness ( Endian  requestedEndian)
protectedvirtualinherited

Determine the endianness to write with based on option.

◆ exportMesh() [1/4]

void Ogre::MeshSerializer::exportMesh ( const Mesh pMesh,
const String filename,
Endian  endianMode = ENDIAN_NATIVE 
)

Exports a mesh to the file specified, in the latest format.

Remarks
This method takes an externally created Mesh object, and exports it to a .mesh file in the latest format version available.
Parameters
pMeshPointer to the Mesh to export
filenameThe destination filename
endianModeThe endian mode of the written file

◆ exportMesh() [2/4]

void Ogre::MeshSerializer::exportMesh ( const Mesh pMesh,
const String filename,
MeshVersion  version,
Endian  endianMode = ENDIAN_NATIVE 
)

Exports a mesh to the file specified, in a specific version format.

Remarks
This method takes an externally created Mesh object, and exports it to a .mesh file in the specified format version. Note that picking a format version other that the latest will cause some information to be lost.
Parameters
pMeshPointer to the Mesh to export
filenameThe destination filename
versionMesh version to write
endianModeThe endian mode of the written file

◆ exportMesh() [3/4]

void Ogre::MeshSerializer::exportMesh ( const Mesh pMesh,
DataStreamPtr  stream,
Endian  endianMode = ENDIAN_NATIVE 
)

Exports a mesh to the stream specified, in the latest format.

Remarks
This method takes an externally created Mesh object, and exports it to a .mesh file in the latest format version.
Parameters
pMeshPointer to the Mesh to export
streamWriteable stream
endianModeThe endian mode of the written file

◆ exportMesh() [4/4]

void Ogre::MeshSerializer::exportMesh ( const Mesh pMesh,
DataStreamPtr  stream,
MeshVersion  version,
Endian  endianMode = ENDIAN_NATIVE 
)

Exports a mesh to the stream specified, in a specific version format.

Remarks
This method takes an externally created Mesh object, and exports it to a .mesh file in the specified format version. Note that picking a format version other that the latest will cause some information to be lost.
Parameters
pMeshPointer to the Mesh to export
streamWriteable stream
versionMesh version to write
endianModeThe endian mode of the written file

◆ flipEndian() [1/2]

virtual void Ogre::Serializer::flipEndian ( void *  pData,
size_t  size 
)
protectedvirtualinherited

◆ flipEndian() [2/2]

virtual void Ogre::Serializer::flipEndian ( void *  pData,
size_t  size,
size_t  count 
)
protectedvirtualinherited

◆ flipFromLittleEndian()

virtual void Ogre::Serializer::flipFromLittleEndian ( void *  pData,
size_t  size,
size_t  count = 1 
)
protectedvirtualinherited

◆ flipToLittleEndian()

virtual void Ogre::Serializer::flipToLittleEndian ( void *  pData,
size_t  size,
size_t  count = 1 
)
protectedvirtualinherited

◆ getListener()

MeshSerializerListener * Ogre::MeshSerializer::getListener ( )

Returns the current listener.

◆ importMesh()

void Ogre::MeshSerializer::importMesh ( DataStreamPtr stream,
Mesh pDest 
)

Imports Mesh and (optionally) Material data from a .mesh file DataStream.

Remarks
This method imports data from a DataStream opened from a .mesh file and places it's contents into the Mesh object which is passed in.
Parameters
streamThe DataStream holding the .mesh data. Must be initialised (pos at the start of the buffer).
pDestPointer to the Mesh object which will receive the data. Should be blank already.

◆ operator delete() [1/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

◆ operator delete() [2/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

◆ operator delete() [3/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

◆ operator delete[]() [1/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

◆ operator delete[]() [2/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

◆ operator new() [1/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

◆ operator new() [2/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

◆ operator new() [3/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
)
inherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

◆ operator new[]() [1/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

◆ operator new[]() [2/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

◆ readBools()

void Ogre::Serializer::readBools ( DataStreamPtr stream,
bool *  pDest,
size_t  count 
)
protectedinherited

◆ readChunk()

virtual unsigned short Ogre::Serializer::readChunk ( DataStreamPtr stream)
protectedvirtualinherited

◆ readFileHeader()

virtual void Ogre::Serializer::readFileHeader ( DataStreamPtr stream)
protectedvirtualinherited

Reimplemented in Ogre::SkeletonSerializer.

◆ readFloats() [1/2]

void Ogre::Serializer::readFloats ( DataStreamPtr stream,
double *  pDest,
size_t  count 
)
protectedinherited

◆ readFloats() [2/2]

void Ogre::Serializer::readFloats ( DataStreamPtr stream,
float *  pDest,
size_t  count 
)
protectedinherited

◆ readInts()

void Ogre::Serializer::readInts ( DataStreamPtr stream,
uint32 pDest,
size_t  count 
)
protectedinherited

◆ readObject() [1/2]

void Ogre::Serializer::readObject ( DataStreamPtr stream,
Quaternion pDest 
)
protectedinherited

◆ readObject() [2/2]

void Ogre::Serializer::readObject ( DataStreamPtr stream,
Vector3 pDest 
)
protectedinherited

◆ readShorts()

void Ogre::Serializer::readShorts ( DataStreamPtr stream,
uint16 pDest,
size_t  count 
)
protectedinherited

◆ readString() [1/2]

String Ogre::Serializer::readString ( DataStreamPtr stream)
protectedinherited

◆ readString() [2/2]

String Ogre::Serializer::readString ( DataStreamPtr stream,
size_t  numChars 
)
protectedinherited

◆ setListener()

void Ogre::MeshSerializer::setListener ( MeshSerializerListener listener)

Sets the listener for this serializer.

◆ writeBools()

void Ogre::Serializer::writeBools ( const bool *const  pLong,
size_t  count 
)
protectedinherited

◆ writeChunkHeader()

virtual void Ogre::Serializer::writeChunkHeader ( uint16  id,
size_t  size 
)
protectedvirtualinherited

◆ writeData()

void Ogre::Serializer::writeData ( const void *const  buf,
size_t  size,
size_t  count 
)
protectedinherited

◆ writeFileHeader()

virtual void Ogre::Serializer::writeFileHeader ( void  )
protectedvirtualinherited

Default to native endian, derive from header.

◆ writeFloats() [1/2]

void Ogre::Serializer::writeFloats ( const double *const  pfloat,
size_t  count 
)
protectedinherited

◆ writeFloats() [2/2]

void Ogre::Serializer::writeFloats ( const float *const  pfloat,
size_t  count 
)
protectedinherited

◆ writeInts()

void Ogre::Serializer::writeInts ( const uint32 *const  pInt,
size_t  count 
)
protectedinherited

◆ writeObject() [1/2]

void Ogre::Serializer::writeObject ( const Quaternion q)
protectedinherited

◆ writeObject() [2/2]

void Ogre::Serializer::writeObject ( const Vector3 vec)
protectedinherited

◆ writeShorts()

void Ogre::Serializer::writeShorts ( const uint16 *const  pShort,
size_t  count 
)
protectedinherited

◆ writeString()

void Ogre::Serializer::writeString ( const String string)
protectedinherited

Member Data Documentation

◆ mCurrentstreamLen

uint32 Ogre::Serializer::mCurrentstreamLen
protectedinherited

Definition at line 70 of file OgreSerializer.h.

◆ mFlipEndian

bool Ogre::Serializer::mFlipEndian
protectedinherited

Definition at line 73 of file OgreSerializer.h.

◆ mListener

MeshSerializerListener* Ogre::MeshSerializer::mListener
protected

Definition at line 181 of file OgreMeshSerializer.h.

◆ mStream

DataStreamPtr Ogre::Serializer::mStream
protectedinherited

Definition at line 71 of file OgreSerializer.h.

◆ mVersion

String Ogre::Serializer::mVersion
protectedinherited

Definition at line 72 of file OgreSerializer.h.

◆ mVersionData

MeshVersionDataList Ogre::MeshSerializer::mVersionData
protected

Definition at line 179 of file OgreMeshSerializer.h.


The documentation for this class was generated from the following file:

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.