28 #ifndef __MaterialSerializer_H__
29 #define __MaterialSerializer_H__
136 { (void)ser; (void)event; (void)skip; (void)mat; }
147 { (void)ser; (void)event; (void)skip; (void)tech; }
158 { (void)ser; (void)event; (void)skip; (void)pass; }
212 bool parseScriptLine(
String& line);
218 void finishProgramDefinition(
void);
244 void writeTechnique(
const Technique* pTech);
245 void writePass(
const Pass* pPass);
246 void writeVertexProgramRef(
const Pass* pPass);
247 void writeShadowCasterVertexProgramRef(
const Pass* pPass);
248 void writeShadowCasterFragmentProgramRef(
const Pass* pPass);
249 void writeShadowReceiverVertexProgramRef(
const Pass* pPass);
250 void writeShadowReceiverFragmentProgramRef(
const Pass* pPass);
251 void writeFragmentProgramRef(
const Pass* pPass);
253 void writeGpuPrograms(
void);
255 const unsigned short level = 4,
const bool useMainBuffer =
true);
257 const unsigned short level = 4,
const bool useMainBuffer =
true);
259 const unsigned short level = 4,
const bool useMainBuffer =
true);
260 void writeGpuProgramParameter(
264 bool isFloat,
bool isDouble,
size_t physicalIndex,
size_t physicalSize,
266 const unsigned short level,
const bool useMainBuffer);
273 void writeColourValue(
const ColourValue &colour,
bool writeAlpha =
false);
331 void queueForExport(
const MaterialPtr& pMat,
bool clearQueued =
false,
332 bool exportDefaults =
false,
const String& materialName =
"");
342 void exportQueued(
const String& filename,
const bool includeProgDef =
false,
const String& programFilename =
"");
354 void exportMaterial(
const MaterialPtr& pMat,
const String& filename,
bool exportDefaults =
false,
355 const bool includeProgDef =
false,
const String& programFilename =
"",
356 const String& materialName =
"");
358 const String &getQueuedAsString()
const;
369 void addListener(Listener* listener);
374 void removeListener(Listener* listener);
385 void beginSection(
unsigned short level,
const bool useMainBuffer =
true)
387 String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer);
389 for (
unsigned short i = 0; i < level; ++i)
395 void endSection(
unsigned short level,
const bool useMainBuffer =
true)
397 String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer);
399 for (
unsigned short i = 0; i < level; ++i)
408 String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer);
410 for (
unsigned short i = 0; i < level; ++i)
419 String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer);
420 buffer += (
" " + val);
425 if (val.find_first_of(
" \t") != String::npos)
426 return (
"\"" + val +
"\"");
433 String& buffer = (useMainBuffer ? mBuffer : mGpuProgramBuffer);
435 for (
unsigned short i = 0; i < level; ++i)
439 buffer +=
"// " + comment;
size_t lineNo
Error reporting state.
AttribParserList mPassAttribParsers
Parsers for the pass section of a script.
AttribParserList mMaterialAttribParsers
Parsers for the material section of a script.
MaterialScriptSection section
Class for serializing Materials to / from a .material script.
Class defining a single pass of a Technique (of a Material), i.e.
bool(* ATTRIBUTE_PARSER)(String ¶ms, MaterialScriptContext &context)
Function def for material attribute parser; return value determines if the next line should be {...
LayerBlendSource
List of valid sources of values for blending operations used in TextureUnitState::setColourOperation ...
set< String >::type GpuProgramDefinitionContainer
ushort supportsPoseAnimation
AttribParserList mProgramRefAttribParsers
Parsers for the program reference section of a script.
virtual void passEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const Pass *pass)
Called when pass section event raised.
bool supportsSkeletalAnimation
Class that allows listening in on the various stages of material serialization process.
Class representing colour.
vector< String >::type StringVector
MaterialScriptProgramDefinition * programDef
AttribParserList mRootAttribParsers
Parsers for the root of the material script.
Structure recording the use of an automatic parameter.
virtual void textureUnitStateEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const TextureUnitState *textureUnit)
Called when texture unit state section event raised.
bool supportsMorphAnimation
bool isFragmentProgramShadowReceiver
When referencing, are we in context of shadow caster.
map< String, ATTRIBUTE_PARSER >::type AttribParserList
Keyword-mapped attribute parsers.
bool isFragmentProgramShadowCaster
When referencing, are we in context of shadow caster.
AliasTextureNamePairList textureAliases
ListenerList::const_iterator ListenerListConstIterator
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
String quoteWord(const String &val)
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
GpuProgramParametersSharedPtr programParams
When referencing, are we in context of shadow caster.
StringVector defaultParamLines
TextureUnitState * textureUnit
multimap< TextureUnitState::TextureEffectType, TextureUnitState::TextureEffect >::type EffectMap
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
vector< std::pair< String, String > >::type customParameters
GpuProgramDefinitionContainer::iterator GpuProgramDefIterator
AttribParserList mProgramDefaultParamAttribParsers
Parsers for the program definition section of a script.
virtual ~MaterialSerializer()
default destructor
vector< Listener * >::type ListenerList
Listeners list of this Serializer.
Struct for holding the script context while parsing.
MaterialScriptContext mScriptContext
AttribParserList mProgramAttribParsers
Parsers for the program definition section of a script.
GpuProgramType
Enumerates the types of programs which can run on the GPU.
void writeValue(const String &val, const bool useMainBuffer=true)
MaterialScriptSection
Enum to identify material sections.
void gpuProgramRefEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const String &attrib, const GpuProgramPtr &program, const GpuProgramParametersSharedPtr ¶ms, GpuProgramParameters *defaultParams)
Called when GPU program reference section event raised.
void beginSection(unsigned short level, const bool useMainBuffer=true)
std::multimap< K, V, P, A > type
LayerBlendOperationEx
Expert list of valid texture blending operations, for use with TextureUnitState::setColourOperationEx...
void writeAttribute(unsigned short level, const String &att, const bool useMainBuffer=true)
SceneBlendFactor
Blending factors for manually blending objects with the scene.
FilterOptions
Filtering options for textures / mipmaps.
GpuProgramDefinitionContainer mGpuProgramDefinitionContainer
Class encapsulates rendering properties of an object.
AttribParserList mTechniqueAttribParsers
Parsers for the technique section of a script.
bool isVertexProgramShadowCaster
Used when referencing a program, not when defining it.
bool usesVertexTextureFetch
Class representing an approach to rendering this particular Material.
virtual void techniqueEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const Technique *tech)
Called when technique section event raised.
void endSection(unsigned short level, const bool useMainBuffer=true)
ListenerList::iterator ListenerListIterator
AttribParserList mTextureUnitAttribParsers
Parsers for the texture unit section of a script.
ushort numAnimationParametrics
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
bool isVertexProgramShadowReceiver
When referencing, are we in context of shadow caster.
int techLev
This is used while defining a program.
Collects together the program parameters used for a GpuProgram.
Struct for holding a program definition which is in progress.
void writeComment(unsigned short level, const String &comment, const bool useMainBuffer=true)
virtual void materialEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const Material *mat)
Called when material section event raised.
Internal structure defining a texture effect.