Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# Ogre::MeshSerializer Class Reference

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

`#include <OgreMeshSerializer.h>`

Inheritance diagram for Ogre::MeshSerializer:

[legend]
List of all members.

## Public Methods

| MeshSerializer ()
virtual | ~MeshSerializer ()
void | exportMesh (const Mesh *pMesh, const String &filename)
| Exports a mesh to the file specified.
void | importMesh (DataChunk &chunk, Mesh *pDest)
| Imports Mesh and (optionally) Material data from a .mesh file DataChunk.

## Protected Types

typedef std::map< String, MeshSerializerImpl * > | MeshSerializerImplMap

## Protected Methods

virtual void | writeFileHeader (void)
virtual void | writeChunkHeader (unsigned short id, unsigned long size)
void | writeReals (const Real *pReal, size_t count)
void | writeShorts (const unsigned short *pShort, size_t count)
void | writeInts (const unsigned int *pInt, size_t count)
void | writeLongs (const unsigned long *pLong, size_t count)
void | writeBools (const bool *pLong, size_t count)
void | writeObject (const Vector3 &vec)
void | writeObject (const Quaternion &q)
void | writeString (const String &string)
void | writeData (const void *buf, size_t size, size_t count)
virtual void | readFileHeader (DataChunk &chunk)
virtual unsigned short | readChunk (DataChunk &chunk)
void | readBools (DataChunk &chunk, bool *pDest, size_t count)
void | readReals (DataChunk &chunk, Real *pDest, size_t count)
void | readShorts (DataChunk &chunk, unsigned short *pDest, size_t count)
void | readInts (DataChunk &chunk, unsigned int *pDest, size_t count)
void | readLongs (DataChunk &chunk, unsigned long *pDest, size_t count)
void | readObject (DataChunk &chunk, Vector3 *pDest)
void | readObject (DataChunk &chunk, Quaternion *pDest)
String | readString (DataChunk &chunk)
String | readString (DataChunk &chunk, size_t numChars)
virtual void | flipToLittleEndian (void *pData, size_t size, size_t count=1)
virtual void | flipFromLittleEndian (void *pData, size_t size, size_t count=1)
virtual void | flipEndian (void *pData, size_t size, size_t count)
virtual void | flipEndian (void *pData, size_t size)

## Protected Attributes

MeshSerializerImplMap | mImplementations
unsigned long | mCurrentChunkLen
FILE * | mpfFile
String | mVersion

## Static Protected Attributes

String | msCurrentVersion = "[MeshSerializer_v1.30]"

## 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 instatiated 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 58 of file OgreMeshSerializer.h.

## Member Typedef Documentation

typedef std::map<String, MeshSerializerImpl* > Ogre::MeshSerializer::MeshSerializerImplMap`[protected]`

| Definition at line 85 of file OgreMeshSerializer.h.

## Constructor & Destructor Documentation

Ogre::MeshSerializer::MeshSerializer | ( |  | ) |

| Definition at line 41 of file OgreMeshSerializer.cpp. References mImplementations, and msCurrentVersion.

Ogre::MeshSerializer::~MeshSerializer | ( |  | ) | `[virtual]`

| Definition at line 57 of file OgreMeshSerializer.cpp. References mImplementations.

## Member Function Documentation

void Ogre::MeshSerializer::exportMesh | ( | const Mesh * | pMesh,
|  | const String & | filename
| ) |

Exports a mesh to the file specified.

Remarks:
  This method takes an externally created Mesh object, and exports both it and optionally the Materials it uses to a .mesh file.

Parameters:

  pMesh | Pointer to the Mesh to export
  filename | The destination filename

Definition at line 69 of file OgreMeshSerializer.cpp.

References Except, mImplementations, msCurrentVersion, and Ogre::String.

void Ogre::Serializer::flipEndian | ( | void * | pData,
|  | size_t | size
| ) | `[protected, virtual, inherited]`

| Definition at line 310 of file OgreSerializer.cpp.

void Ogre::Serializer::flipEndian | ( | void * | pData,
|  | size_t | size,
|  | size_t | count
| ) | `[protected, virtual, inherited]`

| Definition at line 302 of file OgreSerializer.cpp. Referenced by Ogre::Serializer::flipFromLittleEndian(), and Ogre::Serializer::flipToLittleEndian().

void Ogre::Serializer::flipFromLittleEndian | ( | void * | pData,
|  | size_t | size,
|  | size_t | count = 1
| ) | `[protected, virtual, inherited]`

| Definition at line 295 of file OgreSerializer.cpp. References Ogre::Serializer::flipEndian(). Referenced by Ogre::Serializer::readInts(), Ogre::Serializer::readLongs(), Ogre::Serializer::readReals(), and Ogre::Serializer::readShorts().

void Ogre::Serializer::flipToLittleEndian | ( | void * | pData,
|  | size_t | size,
|  | size_t | count = 1
| ) | `[protected, virtual, inherited]`

| Definition at line 288 of file OgreSerializer.cpp. References Ogre::Serializer::flipEndian(). Referenced by Ogre::Serializer::writeInts(), Ogre::Serializer::writeLongs(), Ogre::Serializer::writeReals(), and Ogre::Serializer::writeShorts().

void Ogre::MeshSerializer::importMesh | ( | DataChunk & | chunk,
|  | Mesh * | pDest
| ) |

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

Remarks:
  This method imports data from a DataChunk opened from a .mesh file and places it's contents into the Mesh object which is passed in.

Parameters:

  chunk | The DataChunk holding the .mesh data. Must be initialised (pos at the start of the buffer).
  pDest | Pointer to the Mesh object which will receive the data. Should be blank already.

Definition at line 81 of file OgreMeshSerializer.cpp.

References Except, Ogre::Resource::getName(), Ogre::HEADER_CHUNK_ID, mImplementations, msCurrentVersion, Ogre::Serializer::readShorts(), Ogre::Serializer::readString(), Ogre::DataChunk::seek(), and Ogre::String.

Referenced by Ogre::Mesh::load().

void Ogre::Serializer::readBools | ( | DataChunk & | chunk,
|  | bool * | pDest,
|  | size_t | count
| ) | `[protected, inherited]`

| Definition at line 196 of file OgreSerializer.cpp. References free, malloc, and Ogre::DataChunk::read(). Referenced by Ogre::MeshSerializerImpl::readEdgeList(), Ogre::MeshSerializerImpl::readMesh(), Ogre::MeshSerializerImpl::readMeshLodInfo(), Ogre::MeshSerializerImpl::readMeshLodUsageGenerated(), and Ogre::MeshSerializerImpl::readSubMesh().

unsigned short Ogre::Serializer::readChunk | ( | DataChunk & | chunk | ) | `[protected, virtual, inherited]`

Definition at line 187 of file OgreSerializer.cpp.

References Ogre::Serializer::mCurrentChunkLen, Ogre::Serializer::readLongs(), and Ogre::Serializer::readShorts().

Referenced by Ogre::MeshSerializerImpl::importMesh(), Ogre::SkeletonSerializer::importSkeleton(), Ogre::SkeletonSerializer::readAnimation(), Ogre::SkeletonSerializer::readAnimationTrack(), Ogre::MeshSerializerImpl::readEdgeList(), Ogre::MeshSerializerImpl_v1_2::readGeometry(), Ogre::MeshSerializerImpl::readGeometry(), Ogre::MeshSerializerImpl::readGeometryVertexBuffer(), Ogre::MeshSerializerImpl::readGeometryVertexDeclaration(), Ogre::MeshSerializerImpl::readMesh(), Ogre::MeshSerializerImpl::readMeshLodInfo(), Ogre::MeshSerializerImpl::readMeshLodUsageGenerated(), Ogre::MeshSerializerImpl::readMeshLodUsageManual(), Ogre::MeshSerializerImpl::readSubMesh(), and Ogre::MeshSerializerImpl::readSubMeshNameTable().

void Ogre::Serializer::readFileHeader | ( | DataChunk & | chunk | ) | `[protected, virtual, inherited]`

| Definition at line 160 of file OgreSerializer.cpp. References Except, Ogre::HEADER_CHUNK_ID, Ogre::Serializer::mVersion, Ogre::Serializer::readShorts(), Ogre::Serializer::readString(), and Ogre::String. Referenced by Ogre::MeshSerializerImpl::importMesh(), and Ogre::SkeletonSerializer::importSkeleton().

void Ogre::Serializer::readInts | ( | DataChunk & | chunk,
|  | unsigned int * | pDest,
|  | size_t | count
| ) | `[protected, inherited]`

Definition at line 224 of file OgreSerializer.cpp.

References Ogre::Serializer::flipFromLittleEndian(), and Ogre::DataChunk::read().

Referenced by Ogre::MeshSerializerImpl_v1_2::readGeometry(), Ogre::MeshSerializerImpl::readGeometry(), Ogre::MeshSerializerImpl::readMeshBoneAssignment(), Ogre::MeshSerializerImpl::readMeshLodUsageGenerated(), Ogre::MeshSerializerImpl::readSubMesh(), and Ogre::MeshSerializerImpl::readSubMeshBoneAssignment().

void Ogre::Serializer::readLongs | ( | DataChunk & | chunk,
|  | unsigned long * | pDest,
|  | size_t | count
| ) | `[protected, inherited]`

| Definition at line 230 of file OgreSerializer.cpp. References Ogre::Serializer::flipFromLittleEndian(), and Ogre::DataChunk::read(). Referenced by Ogre::Serializer::readChunk(), Ogre::MeshSerializerImpl::readEdgeList(), and Ogre::MeshSerializerImpl_v1_2::readGeometryColours().

void Ogre::Serializer::readObject | ( | DataChunk & | chunk,
|  | Quaternion * | pDest
| ) | `[protected, inherited]`

| Definition at line 278 of file OgreSerializer.cpp. References Ogre::Serializer::readReals(), Ogre::Quaternion::w, Ogre::Quaternion::x, Ogre::Quaternion::y, and Ogre::Quaternion::z.

void Ogre::Serializer::readObject | ( | DataChunk & | chunk,
|  | Vector3 * | pDest
| ) | `[protected, inherited]`

| Definition at line 271 of file OgreSerializer.cpp. References Ogre::Serializer::readReals(), Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z. Referenced by Ogre::SkeletonSerializer::readBone(), and Ogre::SkeletonSerializer::readKeyFrame().

void Ogre::Serializer::readReals | ( | DataChunk & | chunk,
|  | Real * | pDest,
|  | size_t | count
| ) | `[protected, inherited]`

Definition at line 212 of file OgreSerializer.cpp.

References Ogre::Serializer::flipFromLittleEndian(), Ogre::DataChunk::read(), and Ogre::Real.

Referenced by Ogre::SkeletonSerializer::readAnimation(), Ogre::MeshSerializerImpl::readBoundsInfo(), Ogre::MeshSerializerImpl::readEdgeList(), Ogre::MeshSerializerImpl_v1_2::readGeometryNormals(), Ogre::MeshSerializerImpl_v1_2::readGeometryPositions(), Ogre::MeshSerializerImpl_v1_1::readGeometryTexCoords(), Ogre::MeshSerializerImpl_v1_2::readGeometryTexCoords(), Ogre::SkeletonSerializer::readKeyFrame(), Ogre::MeshSerializerImpl::readMeshBoneAssignment(), Ogre::MeshSerializerImpl::readMeshLodInfo(), Ogre::Serializer::readObject(), and Ogre::MeshSerializerImpl::readSubMeshBoneAssignment().

void Ogre::Serializer::readShorts | ( | DataChunk & | chunk,
|  | unsigned short * | pDest,
|  | size_t | count
| ) | `[protected, inherited]`

Definition at line 218 of file OgreSerializer.cpp.

References Ogre::Serializer::flipFromLittleEndian(), and Ogre::DataChunk::read().

Referenced by importMesh(), Ogre::SkeletonSerializer::readAnimationTrack(), Ogre::SkeletonSerializer::readBone(), Ogre::SkeletonSerializer::readBoneParent(), Ogre::Serializer::readChunk(), Ogre::MeshSerializerImpl::readEdgeList(), Ogre::Serializer::readFileHeader(), Ogre::MeshSerializerImpl_v1_1::readGeometryTexCoords(), Ogre::MeshSerializerImpl_v1_2::readGeometryTexCoords(), Ogre::MeshSerializerImpl::readGeometryVertexBuffer(), Ogre::MeshSerializerImpl::readGeometryVertexElement(), Ogre::MeshSerializerImpl::readMeshBoneAssignment(), Ogre::MeshSerializerImpl::readMeshLodInfo(), Ogre::MeshSerializerImpl::readMeshLodUsageGenerated(), Ogre::MeshSerializerImpl::readSubMesh(), Ogre::MeshSerializerImpl::readSubMeshBoneAssignment(), Ogre::MeshSerializerImpl::readSubMeshNameTable(), and Ogre::MeshSerializerImpl::readSubMeshOperation().

String Ogre::Serializer::readString | ( | DataChunk & | chunk,
|  | size_t | numChars
| ) | `[protected, inherited]`

| Definition at line 236 of file OgreSerializer.cpp. References Ogre::DataChunk::read(), and Ogre::String.

String Ogre::Serializer::readString | ( | DataChunk & | chunk | ) | `[protected, inherited]`

Definition at line 245 of file OgreSerializer.cpp.

References Ogre::DataChunk::readUpTo(), and Ogre::String.

Referenced by importMesh(), Ogre::SkeletonSerializer::readAnimation(), Ogre::SkeletonSerializer::readBone(), Ogre::Serializer::readFileHeader(), Ogre::MeshSerializerImpl::readMeshLodUsageManual(), Ogre::MeshSerializerImpl::readSkeletonLink(), Ogre::MeshSerializerImpl::readSubMesh(), and Ogre::MeshSerializerImpl::readSubMeshNameTable().

void Ogre::Serializer::writeBools | ( | const bool * | pLong,
|  | size_t | count
| ) | `[protected, inherited]`

| Definition at line 127 of file OgreSerializer.cpp. References free, malloc, and Ogre::Serializer::writeData(). Referenced by Ogre::MeshSerializerImpl::writeEdgeList(), Ogre::MeshSerializerImpl::writeLodSummary(), Ogre::MeshSerializerImpl::writeLodUsageGenerated(), Ogre::MeshSerializerImpl::writeMesh(), and Ogre::MeshSerializerImpl::writeSubMesh().

void Ogre::Serializer::writeChunkHeader | ( | unsigned short | id,
|  | unsigned long | size
| ) | `[protected, virtual, inherited]`

Definition at line 61 of file OgreSerializer.cpp.

References Ogre::Serializer::writeLongs(), and Ogre::Serializer::writeShorts().

Referenced by Ogre::SkeletonSerializer::writeAnimation(), Ogre::SkeletonSerializer::writeAnimationTrack(), Ogre::SkeletonSerializer::writeBone(), Ogre::SkeletonSerializer::writeBoneParent(), Ogre::MeshSerializerImpl::writeBoundsInfo(), Ogre::MeshSerializerImpl::writeEdgeList(), Ogre::MeshSerializerImpl::writeGeometry(), Ogre::SkeletonSerializer::writeKeyFrame(), Ogre::MeshSerializerImpl::writeLodSummary(), Ogre::MeshSerializerImpl::writeLodUsageGenerated(), Ogre::MeshSerializerImpl::writeLodUsageManual(), Ogre::MeshSerializerImpl::writeMesh(), Ogre::MeshSerializerImpl::writeMeshBoneAssignment(), Ogre::MeshSerializerImpl::writeSkeletonLink(), Ogre::MeshSerializerImpl::writeSubMesh(), Ogre::MeshSerializerImpl::writeSubMeshBoneAssignment(), Ogre::MeshSerializerImpl::writeSubMeshNameTable(), and Ogre::MeshSerializerImpl::writeSubMeshOperation().

void Ogre::Serializer::writeData | ( | const void * | buf,
|  | size_t | size,
|  | size_t | count
| ) | `[protected, inherited]`

| Definition at line 148 of file OgreSerializer.cpp. References Ogre::Serializer::mpfFile. Referenced by Ogre::Serializer::writeBools(), Ogre::MeshSerializerImpl::writeGeometry(), Ogre::Serializer::writeInts(), Ogre::Serializer::writeLongs(), Ogre::Serializer::writeReals(), and Ogre::Serializer::writeShorts().

void Ogre::Serializer::writeFileHeader | ( | void |  | ) | `[protected, virtual, inherited]`

| Definition at line 51 of file OgreSerializer.cpp. References Ogre::HEADER_CHUNK_ID, Ogre::Serializer::mVersion, Ogre::Serializer::writeShorts(), and Ogre::Serializer::writeString(). Referenced by Ogre::MeshSerializerImpl::exportMesh(), and Ogre::SkeletonSerializer::exportSkeleton().

void Ogre::Serializer::writeInts | ( | const unsigned int * | pInt,
|  | size_t | count
| ) | `[protected, inherited]`

Definition at line 97 of file OgreSerializer.cpp.

References Ogre::Serializer::flipToLittleEndian(), free, malloc, and Ogre::Serializer::writeData().

Referenced by Ogre::MeshSerializerImpl::writeGeometry(), Ogre::MeshSerializerImpl::writeLodUsageGenerated(), Ogre::MeshSerializerImpl::writeMeshBoneAssignment(), Ogre::MeshSerializerImpl::writeSubMesh(), and Ogre::MeshSerializerImpl::writeSubMeshBoneAssignment().

void Ogre::Serializer::writeLongs | ( | const unsigned long * | pLong,
|  | size_t | count
| ) | `[protected, inherited]`

| Definition at line 112 of file OgreSerializer.cpp. References Ogre::Serializer::flipToLittleEndian(), free, malloc, and Ogre::Serializer::writeData(). Referenced by Ogre::Serializer::writeChunkHeader(), and Ogre::MeshSerializerImpl::writeEdgeList().

void Ogre::Serializer::writeObject | ( | const Quaternion & | q | ) | `[protected, inherited]`

| Definition at line 263 of file OgreSerializer.cpp. References Ogre::Quaternion::w, Ogre::Serializer::writeReals(), Ogre::Quaternion::x, Ogre::Quaternion::y, and Ogre::Quaternion::z.

void Ogre::Serializer::writeObject | ( | const Vector3 & | vec | ) | `[protected, inherited]`

| Definition at line 255 of file OgreSerializer.cpp. References Ogre::Serializer::writeReals(), Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z. Referenced by Ogre::SkeletonSerializer::writeBone(), and Ogre::SkeletonSerializer::writeKeyFrame().

void Ogre::Serializer::writeReals | ( | const Real * | pReal,
|  | size_t | count
| ) | `[protected, inherited]`

Definition at line 67 of file OgreSerializer.cpp.

References Ogre::Serializer::flipToLittleEndian(), free, malloc, Ogre::Real, and Ogre::Serializer::writeData().

Referenced by Ogre::SkeletonSerializer::writeAnimation(), Ogre::MeshSerializerImpl::writeBoundsInfo(), Ogre::MeshSerializerImpl::writeEdgeList(), Ogre::SkeletonSerializer::writeKeyFrame(), Ogre::MeshSerializerImpl::writeLodUsageGenerated(), Ogre::MeshSerializerImpl::writeLodUsageManual(), Ogre::MeshSerializerImpl::writeMeshBoneAssignment(), Ogre::Serializer::writeObject(), and Ogre::MeshSerializerImpl::writeSubMeshBoneAssignment().

void Ogre::Serializer::writeShorts | ( | const unsigned short * | pShort,
|  | size_t | count
| ) | `[protected, inherited]`

Definition at line 82 of file OgreSerializer.cpp.

References Ogre::Serializer::flipToLittleEndian(), free, malloc, and Ogre::Serializer::writeData().

Referenced by Ogre::SkeletonSerializer::writeAnimationTrack(), Ogre::SkeletonSerializer::writeBone(), Ogre::SkeletonSerializer::writeBoneParent(), Ogre::Serializer::writeChunkHeader(), Ogre::MeshSerializerImpl::writeEdgeList(), Ogre::Serializer::writeFileHeader(), Ogre::MeshSerializerImpl::writeGeometry(), Ogre::MeshSerializerImpl::writeLodSummary(), Ogre::MeshSerializerImpl::writeLodUsageGenerated(), Ogre::MeshSerializerImpl::writeMeshBoneAssignment(), Ogre::MeshSerializerImpl::writeSubMesh(), Ogre::MeshSerializerImpl::writeSubMeshBoneAssignment(), Ogre::MeshSerializerImpl::writeSubMeshNameTable(), and Ogre::MeshSerializerImpl::writeSubMeshOperation().

void Ogre::Serializer::writeString | ( | const String & | string | ) | `[protected, inherited]`

Definition at line 153 of file OgreSerializer.cpp.

References Ogre::Serializer::mpfFile, and Ogre::String.

Referenced by Ogre::SkeletonSerializer::writeAnimation(), Ogre::SkeletonSerializer::writeBone(), Ogre::Serializer::writeFileHeader(), Ogre::MeshSerializerImpl::writeLodUsageManual(), Ogre::MeshSerializerImpl::writeSkeletonLink(), Ogre::MeshSerializerImpl::writeSubMesh(), and Ogre::MeshSerializerImpl::writeSubMeshNameTable().

## Member Data Documentation

unsigned long Ogre::Serializer::mCurrentChunkLen`[protected, inherited]`

| Definition at line 48 of file OgreSerializer.h. Referenced by Ogre::Serializer::readChunk(), Ogre::SkeletonSerializer::readKeyFrame(), and Ogre::MeshSerializerImpl::readMesh().

MeshSerializerImplMap Ogre::MeshSerializer::mImplementations`[protected]`

| Definition at line 86 of file OgreMeshSerializer.h. Referenced by exportMesh(), importMesh(), MeshSerializer(), and ~MeshSerializer().

FILE* Ogre::Serializer::mpfFile`[protected, inherited]`

| Definition at line 49 of file OgreSerializer.h. Referenced by Ogre::MeshSerializerImpl::exportMesh(), Ogre::SkeletonSerializer::exportSkeleton(), Ogre::Serializer::writeData(), and Ogre::Serializer::writeString().

String Ogre::MeshSerializer::msCurrentVersion = "[MeshSerializer_v1.30]"`[static, protected]`

| Definition at line 38 of file OgreMeshSerializer.cpp. Referenced by exportMesh(), importMesh(), and MeshSerializer().

String Ogre::Serializer::mVersion`[protected, inherited]`

| Definition at line 50 of file OgreSerializer.h. Referenced by Ogre::MeshSerializerImpl::MeshSerializerImpl(), Ogre::MeshSerializerImpl_v1_1::MeshSerializerImpl_v1_1(), Ogre::MeshSerializerImpl_v1_2::MeshSerializerImpl_v1_2(), Ogre::Serializer::readFileHeader(), Ogre::Serializer::Serializer(), Ogre::SkeletonSerializer::SkeletonSerializer(), and Ogre::Serializer::writeFileHeader().

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

- OgreMeshSerializer.h
- OgreMeshSerializer.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:51:13 2004