- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Ogre::MaterialSerializer Class Reference

Class for serializing Materials to / from a .material script. More...

`#include <OgreMaterialSerializer.h>`

List of all members.

## Public Member Functions
| MaterialSerializer ()
| default constructor
virtual | ~MaterialSerializer ()
| default destructor
void | queueForExport (const MaterialPtr &pMat, bool clearQueued=false, bool exportDefaults=false)
| Queue an in-memory Material to the internal buffer for export.
void | exportQueued (const String &filename, const bool includeProgDef=false, const String &programFilename="")
| Exports queued material(s) to a named material script file.
void | exportMaterial (const MaterialPtr &pMat, const String &filename, bool exportDefaults=false, const bool includeProgDef=false, const String &programFilename="")
| Exports a single in-memory Material to the named material script file.
const String & | getQueuedAsString () const
| Returns a string representing the parsed material(s).
void | clearQueue ()
| Clears the internal buffer.
void | parseScript (DataStreamPtr &stream, const String &groupName)
| Parses a Material script file passed as a stream.
## Protected Types
typedef std::map < String, ATTRIBUTE_PARSER > | AttribParserList
| Keyword-mapped attribute parsers.
typedef std::multimap < TextureUnitState::TextureEffectType, TextureUnitState::TextureEffect > | EffectMap
## Protected Member Functions
bool | parseScriptLine (String &line)
| internal method for parsing a material
bool | invokeParser (String &line, AttribParserList &parsers)
| internal method for finding & invoking an attribute parser.
void | finishProgramDefinition (void)
| Internal method for saving a program definition which has been built up.
void | writeMaterial (const MaterialPtr &pMat)
void | writeTechnique (const Technique *pTech)
void | writePass (const Pass *pPass)
void | writeVertexProgramRef (const Pass *pPass)
void | writeShadowCasterVertexProgramRef (const Pass *pPass)
void | writeShadowReceiverVertexProgramRef (const Pass *pPass)
void | writeShadowReceiverFragmentProgramRef (const Pass *pPass)
void | writeFragmentProgramRef (const Pass *pPass)
void | writeGpuProgramRef (const String &attrib, const GpuProgramPtr &program, const GpuProgramParametersSharedPtr &params)
void | writeGpuPrograms (void)
void | writeGPUProgramParameters (const GpuProgramParametersSharedPtr &params, GpuProgramParameters *defaultParams, const int level=4, const bool useMainBuffer=true)
void | writeNamedGpuProgramParameters (const GpuProgramParametersSharedPtr &params, GpuProgramParameters *defaultParams, const int level=4, const bool useMainBuffer=true)
void | writeLowLevelGpuProgramParameters (const GpuProgramParametersSharedPtr &params, GpuProgramParameters *defaultParams, const int level=4, const bool useMainBuffer=true)
void | writeGpuProgramParameter (const String &commandName, const String &identifier, const GpuProgramParameters::AutoConstantEntry *autoEntry, const GpuProgramParameters::AutoConstantEntry *defaultAutoEntry, bool isFloat, size_t physicalIndex, size_t physicalSize, const GpuProgramParametersSharedPtr &params, GpuProgramParameters *defaultParams, const int level, const bool useMainBuffer)
void | writeTextureUnit (const TextureUnitState *pTex)
void | writeSceneBlendFactor (const SceneBlendFactor sbf_src, const SceneBlendFactor sbf_dest)
void | writeSceneBlendFactor (const SceneBlendFactor sbf)
void | writeCompareFunction (const CompareFunction cf)
void | writeColourValue (const ColourValue &colour, bool writeAlpha=false)
void | writeLayerBlendOperationEx (const LayerBlendOperationEx op)
void | writeLayerBlendSource (const LayerBlendSource lbs)
void | writeRotationEffect (const TextureUnitState::TextureEffect &effect, const TextureUnitState *pTex)
void | writeTransformEffect (const TextureUnitState::TextureEffect &effect, const TextureUnitState *pTex)
void | writeScrollEffect (const TextureUnitState::TextureEffect &effect, const TextureUnitState *pTex)
void | writeEnvironmentMapEffect (const TextureUnitState::TextureEffect &effect, const TextureUnitState *pTex)
String | convertFiltering (FilterOptions fo)
## Protected Attributes
MaterialScriptContext | mScriptContext
AttribParserList | mRootAttribParsers
| Parsers for the root of the material script.
AttribParserList | mMaterialAttribParsers
| Parsers for the material section of a script.
AttribParserList | mTechniqueAttribParsers
| Parsers for the technique section of a script.
AttribParserList | mPassAttribParsers
| Parsers for the pass section of a script.
AttribParserList | mTextureUnitAttribParsers
| Parsers for the texture unit section of a script.
AttribParserList | mProgramRefAttribParsers
| Parsers for the program reference section of a script.
AttribParserList | mProgramAttribParsers
| Parsers for the program definition section of a script.
AttribParserList | mProgramDefaultParamAttribParsers
| Parsers for the program definition section of a script.
## Private Types
typedef std::set < String > | GpuProgramDefinitionContainer
typedef GpuProgramDefinitionContainer::iterator | GpuProgramDefIterator
## Private Member Functions
void | beginSection (unsigned short level, const bool useMainBuffer=true)
void | endSection (unsigned short level, const bool useMainBuffer=true)
void | writeAttribute (unsigned short level, const String &att, const bool useMainBuffer=true)
void | writeValue (const String &val, const bool useMainBuffer=true)
void | writeComment (unsigned short level, const String &comment, const bool useMainBuffer=true)
## Private Attributes
String | mBuffer
String | mGpuProgramBuffer
GpuProgramDefinitionContainer | mGpuProgramDefinitionContainer
bool | mDefaults

## Detailed Description

Class for serializing Materials to / from a .material script.

Definition at line 99 of file OgreMaterialSerializer.h.

## Member Typedef Documentation

typedef std::map<String, ATTRIBUTE_PARSER> Ogre::MaterialSerializer::AttribParserList`[protected]`

Keyword-mapped attribute parsers.

Definition at line 103 of file OgreMaterialSerializer.h.

typedef std::multimap<TextureUnitState::TextureEffectType, TextureUnitState::TextureEffect> Ogre::MaterialSerializer::EffectMap`[protected]`

Definition at line 165 of file OgreMaterialSerializer.h.

typedef std::set<String> Ogre::MaterialSerializer::GpuProgramDefinitionContainer`[private]`

Definition at line 222 of file OgreMaterialSerializer.h.

typedef GpuProgramDefinitionContainer::iterator Ogre::MaterialSerializer::GpuProgramDefIterator`[private]`

Definition at line 223 of file OgreMaterialSerializer.h.

## Constructor & Destructor Documentation

Ogre::MaterialSerializer::MaterialSerializer | ( |  | ) |

default constructor

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

default destructor

Definition at line 177 of file OgreMaterialSerializer.h.

## Member Function Documentation

bool Ogre::MaterialSerializer::parseScriptLine | ( | String & | line | ) | `[protected]`

internal method for parsing a material

Returns:
  true if it expects the next line to be a {

bool Ogre::MaterialSerializer::invokeParser | ( | String & | line,
|  | AttribParserList & | parsers |
| ) |  |  | `[protected]`

internal method for finding & invoking an attribute parser.

void Ogre::MaterialSerializer::finishProgramDefinition | ( | void |  | ) | `[protected]`

Internal method for saving a program definition which has been built up.

void Ogre::MaterialSerializer::writeMaterial | ( | const MaterialPtr & | pMat | ) | `[protected]`

void Ogre::MaterialSerializer::writeTechnique | ( | const Technique * | pTech | ) | `[protected]`

void Ogre::MaterialSerializer::writePass | ( | const Pass * | pPass | ) | `[protected]`

void Ogre::MaterialSerializer::writeVertexProgramRef | ( | const Pass * | pPass | ) | `[protected]`

void Ogre::MaterialSerializer::writeShadowCasterVertexProgramRef | ( | const Pass * | pPass | ) | `[protected]`

void Ogre::MaterialSerializer::writeShadowReceiverVertexProgramRef | ( | const Pass * | pPass | ) | `[protected]`

void Ogre::MaterialSerializer::writeShadowReceiverFragmentProgramRef | ( | const Pass * | pPass | ) | `[protected]`

void Ogre::MaterialSerializer::writeFragmentProgramRef | ( | const Pass * | pPass | ) | `[protected]`

void Ogre::MaterialSerializer::writeGpuProgramRef | ( | const String & | attrib,
|  | const GpuProgramPtr & | program,
|  | const GpuProgramParametersSharedPtr & | params |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeGpuPrograms | ( | void |  | ) | `[protected]`

void Ogre::MaterialSerializer::writeGPUProgramParameters | ( | const GpuProgramParametersSharedPtr & | params,
|  | GpuProgramParameters * | defaultParams,
|  | const int | level = `4`,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeNamedGpuProgramParameters | ( | const GpuProgramParametersSharedPtr & | params,
|  | GpuProgramParameters * | defaultParams,
|  | const int | level = `4`,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeLowLevelGpuProgramParameters | ( | const GpuProgramParametersSharedPtr & | params,
|  | GpuProgramParameters * | defaultParams,
|  | const int | level = `4`,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeGpuProgramParameter | ( | const String & | commandName,
|  | const String & | identifier,
|  | const GpuProgramParameters::AutoConstantEntry * | autoEntry,
|  | const GpuProgramParameters::AutoConstantEntry * | defaultAutoEntry,
|  | bool | isFloat,
|  | size_t | physicalIndex,
|  | size_t | physicalSize,
|  | const GpuProgramParametersSharedPtr & | params,
|  | GpuProgramParameters * | defaultParams,
|  | const int | level,
|  | const bool | useMainBuffer |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeTextureUnit | ( | const TextureUnitState * | pTex | ) | `[protected]`

void Ogre::MaterialSerializer::writeSceneBlendFactor | ( | const SceneBlendFactor | sbf_src,
|  | const SceneBlendFactor | sbf_dest |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeSceneBlendFactor | ( | const SceneBlendFactor | sbf | ) | `[protected]`

void Ogre::MaterialSerializer::writeCompareFunction | ( | const CompareFunction | cf | ) | `[protected]`

void Ogre::MaterialSerializer::writeColourValue | ( | const ColourValue & | colour,
|  | bool | writeAlpha = `false` |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeLayerBlendOperationEx | ( | const LayerBlendOperationEx | op | ) | `[protected]`

void Ogre::MaterialSerializer::writeLayerBlendSource | ( | const LayerBlendSource | lbs | ) | `[protected]`

void Ogre::MaterialSerializer::writeRotationEffect | ( | const TextureUnitState::TextureEffect & | effect,
|  | const TextureUnitState * | pTex |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeTransformEffect | ( | const TextureUnitState::TextureEffect & | effect,
|  | const TextureUnitState * | pTex |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeScrollEffect | ( | const TextureUnitState::TextureEffect & | effect,
|  | const TextureUnitState * | pTex |
| ) |  |  | `[protected]`

void Ogre::MaterialSerializer::writeEnvironmentMapEffect | ( | const TextureUnitState::TextureEffect & | effect,
|  | const TextureUnitState * | pTex |
| ) |  |  | `[protected]`

String Ogre::MaterialSerializer::convertFiltering | ( | FilterOptions | fo | ) | `[protected]`

void Ogre::MaterialSerializer::queueForExport | ( | const MaterialPtr & | pMat,
|  | bool | clearQueued = `false`,
|  | bool | exportDefaults = `false` |
| ) |  |  |

Queue an in-memory Material to the internal buffer for export.

Parameters:

  | pMat | Material pointer
  | clearQueued | If true, any materials already queued will be removed
  | exportDefaults | If true, attributes which are defaulted will be included in the script exported, otherwise they will be omitted

void Ogre::MaterialSerializer::exportQueued | ( | const String & | filename,
|  | const bool | includeProgDef = `false`,
|  | const String & | programFilename = `""` |
| ) |  |  |

Exports queued material(s) to a named material script file.

Parameters:

  | filename | the file name of the material script to be exported
  | includeProgDef | If true, vertex program and fragment program definitions will be written at the top of the material script
  | programFilename | the file name of the vertex / fragment program script to be exported. This is only used if there are program definitions to be exported and includeProgDef is false when calling queueForExport.

void Ogre::MaterialSerializer::exportMaterial | ( | const MaterialPtr & | pMat,
|  | const String & | filename,
|  | bool | exportDefaults = `false`,
|  | const bool | includeProgDef = `false`,
|  | const String & | programFilename = `""` |
| ) |  |  |

Exports a single in-memory Material to the named material script file.

Parameters:

  | exportDefaults | if true then exports all values including defaults
  | includeProgDef | if true includes Gpu shader program definitions in the export material script otherwise if false then program definitions will be exported to a seperate file with name programFilename if programFilename is not empty
  | programFilename | the file name of the vertex / fragment program script to be exported. This is only used if includeProgDef is false.

const String& Ogre::MaterialSerializer::getQueuedAsString | ( |  | ) | const

Returns a string representing the parsed material(s).

void Ogre::MaterialSerializer::clearQueue | ( |  | ) |

Clears the internal buffer.

void Ogre::MaterialSerializer::parseScript | ( | DataStreamPtr & | stream,
|  | const String & | groupName |
| ) |  |  |

Parses a Material script file passed as a stream.

void Ogre::MaterialSerializer::beginSection | ( | unsigned short | level,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[private]`

Definition at line 227 of file OgreMaterialSerializer.h.

void Ogre::MaterialSerializer::endSection | ( | unsigned short | level,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[private]`

Definition at line 237 of file OgreMaterialSerializer.h.

void Ogre::MaterialSerializer::writeAttribute | ( | unsigned short | level,
|  | const String & | att,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[private]`

Definition at line 248 of file OgreMaterialSerializer.h.

void Ogre::MaterialSerializer::writeValue | ( | const String & | val,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[private]`

Definition at line 259 of file OgreMaterialSerializer.h.

void Ogre::MaterialSerializer::writeComment | ( | unsigned short | level,
|  | const String & | comment,
|  | const bool | useMainBuffer = `true` |
| ) |  |  | `[private]`

Definition at line 265 of file OgreMaterialSerializer.h.

## Member Data Documentation

MaterialScriptContext Ogre::MaterialSerializer::mScriptContext`[protected]`

Definition at line 105 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mRootAttribParsers`[protected]`

Parsers for the root of the material script.

Definition at line 118 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mMaterialAttribParsers`[protected]`

Parsers for the material section of a script.

Definition at line 120 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mTechniqueAttribParsers`[protected]`

Parsers for the technique section of a script.

Definition at line 122 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mPassAttribParsers`[protected]`

Parsers for the pass section of a script.

Definition at line 124 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mTextureUnitAttribParsers`[protected]`

Parsers for the texture unit section of a script.

Definition at line 126 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mProgramRefAttribParsers`[protected]`

Parsers for the program reference section of a script.

Definition at line 128 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mProgramAttribParsers`[protected]`

Parsers for the program definition section of a script.

Definition at line 130 of file OgreMaterialSerializer.h.

AttribParserList Ogre::MaterialSerializer::mProgramDefaultParamAttribParsers`[protected]`

Parsers for the program definition section of a script.

Definition at line 132 of file OgreMaterialSerializer.h.

String Ogre::MaterialSerializer::mBuffer`[private]`

Definition at line 220 of file OgreMaterialSerializer.h.

String Ogre::MaterialSerializer::mGpuProgramBuffer`[private]`

Definition at line 221 of file OgreMaterialSerializer.h.

GpuProgramDefinitionContainer Ogre::MaterialSerializer::mGpuProgramDefinitionContainer`[private]`

Definition at line 224 of file OgreMaterialSerializer.h.

bool Ogre::MaterialSerializer::mDefaults`[private]`

Definition at line 225 of file OgreMaterialSerializer.h.

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

- OgreMaterialSerializer.h

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Mon Jun 16 12:50:29 2008