Description

Serialization functions for objects (meshes, textures etc.)

Conversion between objects and streams. There are static functions for

  • loading a single mesh from a stream,

  • saving a single mesh to a stream,

  • loading a single texture from a stream,

  • saving a single texture to a stream,

  • loading a generic description from a stream and

  • saving a generic description to a stream.

Author: Benjamin Eikel

Date: 2011-02-03

Classes

   
class Rendering::Serialization::AbstractRenderingStreamer
struct Rendering::Serialization::MD2Frame
struct Rendering::Serialization::MD2FrameData
struct Rendering::Serialization::MD2Header
struct Rendering::Serialization::MD2Skin
struct Rendering::Serialization::MD2TexCoord
struct Rendering::Serialization::MD2Triangle
struct Rendering::Serialization::MD2Vertex
class Rendering::Serialization::StreamerMD2
class Rendering::Serialization::StreamerMMF
class Rendering::Serialization::StreamerMTL
class Rendering::Serialization::StreamerMVBO
class Rendering::Serialization::StreamerNGC
class Rendering::Serialization::StreamerOBJ
class Rendering::Serialization::StreamerPKM
class Rendering::Serialization::StreamerPLY
class Rendering::Serialization::StreamerXYZ

Typedefs

   
   
typedef Util::ReferenceAttribute < Mesh > MeshAttribute_t
   
typedef Util::ReferenceAttribute < Mesh > MeshWrapper_t

Variables

   
   
const Util::StringIdentifier DESCRIPTION_TYPE
   
const char *const DESCRIPTION_TYPE_MESH
   
const char *const DESCRIPTION_TYPE_MATERIAL
   
const Util::StringIdentifier DESCRIPTION_FILE
   
const Util::StringIdentifier DESCRIPTION_DATA
   
const Util::StringIdentifier DESCRIPTION_TEXTURE_FILE
   
const Util::StringIdentifier DESCRIPTION_MATERIAL_NAME
   
const Util::StringIdentifier DESCRIPTION_MATERIAL_AMBIENT
   
const Util::StringIdentifier DESCRIPTION_MATERIAL_DIFFUSE
   
const Util::StringIdentifier DESCRIPTION_MATERIAL_SPECULAR
   
const Util::StringIdentifier DESCRIPTION_MATERIAL_SHININESS

Functions

   
   
bool initGenericAttributeSerialization()
   
const std::string GATypeNameMesh(“Mesh” void)
   
const std::string embeddedMeshPrefix(“$” void)
   
std::pair< std::string, std::string > serializeGAMesh(const std::pair< const Util::GenericAttribute *, const Util::GenericAttributeMap * > & attributeAndContext)
   
MeshAttribute_t * unserializeGAMesh(const std::pair< std::string, const Util::GenericAttributeMap * > & contentAndContext)
   
Mesh * loadMesh(const Util::FileName & url)
   
Mesh * loadMesh(const std::string & extension, const std::string & data)
   
bool saveMesh( Mesh * mesh, const Util::FileName & url)
   
bool saveMesh( Mesh * mesh, const std::string & extension, std::ostream & output)
   
Util::Reference < Texture > loadTexture(const Util::FileName & url, TextureType tType, uint32_t numLayers)
   
Util::Reference < Texture > loadTexture(const std::string & extension, const std::string & data, TextureType tType, uint32_t numLayers)
   
bool saveTexture( RenderingContext & context, Texture * texture, const Util::FileName & url)
   
bool saveTexture( RenderingContext & context, Texture * texture, const std::string & extension, std::ostream & output)
   
Util::GenericAttributeList * loadGeneric(const Util::FileName & url)
   
Util::GenericAttributeList * loadGeneric(const std::string & extension, const std::string & data)
   
Util::GenericAttributeMap * createMeshDescription( Mesh * m)

Documentation

typedef
Rendering::Serialization::MeshAttribute_t

public
 
 
typedef Util::ReferenceAttribute < Mesh > MeshAttribute_t

Defined in Rendering/Serialization/GenericAttributeSerialization.h:31


typedef
Rendering::Serialization::MeshWrapper_t

public
 
 
typedef Util::ReferenceAttribute < Mesh > MeshWrapper_t

Defined in Rendering/Serialization/Serialization.h:48


variable
Rendering::Serialization::DESCRIPTION_TYPE

public
 
 
const Util::StringIdentifier DESCRIPTION_TYPE

Defined in Rendering/Serialization/Serialization.h:50


variable
Rendering::Serialization::DESCRIPTION_TYPE_MESH

public
 
 
const char *const DESCRIPTION_TYPE_MESH

Defined in Rendering/Serialization/Serialization.h:51


variable
Rendering::Serialization::DESCRIPTION_TYPE_MATERIAL

public
 
 
const char *const DESCRIPTION_TYPE_MATERIAL

Defined in Rendering/Serialization/Serialization.h:52


variable
Rendering::Serialization::DESCRIPTION_FILE

public
 
 
const Util::StringIdentifier DESCRIPTION_FILE

Defined in Rendering/Serialization/Serialization.h:53


variable
Rendering::Serialization::DESCRIPTION_DATA

public
 
 
const Util::StringIdentifier DESCRIPTION_DATA

Defined in Rendering/Serialization/Serialization.h:54


variable
Rendering::Serialization::DESCRIPTION_TEXTURE_FILE

public
 
 
const Util::StringIdentifier DESCRIPTION_TEXTURE_FILE

Defined in Rendering/Serialization/Serialization.h:55


variable
Rendering::Serialization::DESCRIPTION_MATERIAL_NAME

public
 
 
const Util::StringIdentifier DESCRIPTION_MATERIAL_NAME

Defined in Rendering/Serialization/Serialization.h:56


variable
Rendering::Serialization::DESCRIPTION_MATERIAL_AMBIENT

public
 
 
const Util::StringIdentifier DESCRIPTION_MATERIAL_AMBIENT

Defined in Rendering/Serialization/Serialization.h:57


variable
Rendering::Serialization::DESCRIPTION_MATERIAL_DIFFUSE

public
 
 
const Util::StringIdentifier DESCRIPTION_MATERIAL_DIFFUSE

Defined in Rendering/Serialization/Serialization.h:58


variable
Rendering::Serialization::DESCRIPTION_MATERIAL_SPECULAR

public
 
 
const Util::StringIdentifier DESCRIPTION_MATERIAL_SPECULAR

Defined in Rendering/Serialization/Serialization.h:59


variable
Rendering::Serialization::DESCRIPTION_MATERIAL_SHININESS

public
 
 
const Util::StringIdentifier DESCRIPTION_MATERIAL_SHININESS

Defined in Rendering/Serialization/Serialization.h:60


function
Rendering::Serialization::initGenericAttributeSerialization

public
   
   
bool initGenericAttributeSerialization( )

Adds a handler for Util::_CounterAttribute to [Util::GenericAttributeSerialization](classUtil_1_1GenericAttributeSerialization) . Should be called at least once before a GenericAttribute is serialized which may contain a [Mesh](classRendering_1_1Mesh) .

Note: Texture-Serialization may be added here when needed.

Note: The return value is always true and can be used for static initialization.

Defined in Rendering/Serialization/GenericAttributeSerialization.h:29


function
Rendering::Serialization::GATypeNameMesh

public
     
     
const std::string GATypeNameMesh( “Mesh” void )

Defined in Rendering/Serialization/GenericAttributeSerialization.h:32


function
Rendering::Serialization::embeddedMeshPrefix

public
     
     
const std::string embeddedMeshPrefix( ”$” void )

Defined in Rendering/Serialization/GenericAttributeSerialization.h:33


function
Rendering::Serialization::serializeGAMesh

public
     
     
std::pair< std::string, std::string > serializeGAMesh( const std::pair< const Util::GenericAttribute *, const Util::GenericAttributeMap * > & attributeAndContext )

Defined in Rendering/Serialization/GenericAttributeSerialization.h:34


function
Rendering::Serialization::unserializeGAMesh

public
     
     
MeshAttribute_t * unserializeGAMesh( const std::pair< std::string, const Util::GenericAttributeMap * > & contentAndContext )

Defined in Rendering/Serialization/GenericAttributeSerialization.h:36


function
Rendering::Serialization::loadMesh

public
     
     
Mesh * loadMesh( const Util::FileName & url )

Load a single mesh from the given address. The type of the mesh is determined by the file extension.

Parameters

file
Address to the file containing the mesh data

Returns

A single mesh

Defined in Rendering/Serialization/Serialization.h:69


function
Rendering::Serialization::loadMesh

public
     
     
Mesh * loadMesh( const std::string & extension,
  const std::string & data
)    

Create a single mesh from the given data. The type of the mesh has to be given as parameter.

Parameters

extension
File extension specifying the type of the mesh
data
Mesh data

Returns

A single mesh

Defined in Rendering/Serialization/Serialization.h:79


function
Rendering::Serialization::saveMesh

public
     
     
bool saveMesh( Mesh * mesh,
  const Util::FileName & url
)    

Write a single mesh to the given address. The type of the mesh is determined by the file extension.

Parameters

mesh
Mesh object to save
file
Address to the file that shall be written

Returns

trueif successful,falseotherwise

Defined in Rendering/Serialization/Serialization.h:89


function
Rendering::Serialization::saveMesh

public
     
     
bool saveMesh( Mesh * mesh,
  const std::string & extension,
  std::ostream & output
)    

Write a single mesh to the given stream. The type of the mesh has to be given as parameter.

Parameters

mesh
Mesh object to save
extension
File extension specifying the type of the mesh
output
Stream to which the data shall be written

Returns

trueif successful,falseotherwise

Defined in Rendering/Serialization/Serialization.h:100


function
Rendering::Serialization::loadTexture

public
     
     
Util::Reference < Texture > loadTexture( const Util::FileName & url,
  TextureType tType,
  uint32_t numLayers
)    

Load a single texture from the given address. The type of the texture is determined by the file extension.

Parameters

file
Address to the file containing the texture data

Returns

A single texture

Defined in Rendering/Serialization/Serialization.h:109


function
Rendering::Serialization::loadTexture

public
     
     
Util::Reference < Texture > loadTexture( const std::string & extension,
  const std::string & data,
  TextureType tType,
  uint32_t numLayers
)    

Create a single texture from the given data. The type of the texture has to be given as parameter.

Parameters

extension
File extension specifying the type of the texture
data
Texture data

Returns

A single texture

Defined in Rendering/Serialization/Serialization.h:119


function
Rendering::Serialization::saveTexture

public
     
     
bool saveTexture( RenderingContext & context,
  Texture * texture,
  const Util::FileName & url
)    

Write a single texture to the given address. The type of the texture is determined by the file extension.

Parameters

texture
Texture object to save
file
Address to the file that shall be written

Returns

trueif successful,falseotherwise

Defined in Rendering/Serialization/Serialization.h:129


function
Rendering::Serialization::saveTexture

public
     
     
bool saveTexture( RenderingContext & context,
  Texture * texture,
  const std::string & extension,
  std::ostream & output
)    

Write a single texture to the given stream. The type of the texture has to be given as parameter.

Parameters

texture
Texture object to save
extension
File extension specifying the type of the texture
output
Stream to which the data shall be written

Returns

trueif successful,falseotherwise

Defined in Rendering/Serialization/Serialization.h:140


function
Rendering::Serialization::loadGeneric

public
     
     
Util::GenericAttributeList * loadGeneric( const Util::FileName & url )

Load mesh descriptions from the given address. The type of the mesh is determined by the file extension.

Parameters

file
Address to the file containing the mesh data

Returns

A list of mesh descriptions

Note: A description list could look like this:

[
  { // begin first entry
   DESCRIPTION_TYPE         : "mesh",          // type of entry (e.g. "mesh", "material", "keyFrameAnimation")
   DESCRIPTION_FILE         : "dings.obj",     // the path to the file the mesh originates from
   DESCRIPTION_DATA         : MeshWrapper_t *, // capsule for the mesh itself
   DESCRIPTION_TEXTURE_FILE : "dings.png"      // (optional) path to a texture file that is used by the mesh
  } // end first entry
  // additional descriptions may follow here if more than one object was loaded
 ]

Defined in Rendering/Serialization/Serialization.h:161


function
Rendering::Serialization::loadGeneric

public
     
     
Util::GenericAttributeList * loadGeneric( const std::string & extension,
  const std::string & data
)    

Create mesh descriptions from the given data. The type of the mesh has to be given as parameter.

Parameters

extension
File extension specifying the type of the mesh
data
Mesh data

Returns

A list of mesh descriptions

Defined in Rendering/Serialization/Serialization.h:171


function
Rendering::Serialization::createMeshDescription

public
     
     
Util::GenericAttributeMap * createMeshDescription( Mesh * m )

Helper function which creates a description map for a single mesh.

Parameters

mesh
The mesh that will be wrapped into the description

Defined in Rendering/Serialization/Serialization.h:178