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;
void writeAttribute(unsigned short level, const String &att, const bool useMainBuffer=true)
bool isVertexProgramShadowReceiver
When referencing, are we in context of shadow caster.
AttribParserList mMaterialAttribParsers
Parsers for the material section of a script.
virtual ~MaterialSerializer()
default destructor
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.
std::multimap< K, V, P, A > type
AliasTextureNamePairList textureAliases
Struct for holding a program definition which is in progress.
void writeValue(const String &val, const bool useMainBuffer=true)
bool isFragmentProgramShadowCaster
When referencing, are we in context of shadow caster.
ListenerList::const_iterator ListenerListConstIterator
AttribParserList mProgramRefAttribParsers
Parsers for the program reference section of a script.
Class that allows listening in on the various stages of material serialization process.
virtual void textureUnitStateEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const TextureUnitState *textureUnit)
Called when texture unit state section event raised.
Class representing colour.
ushort numAnimationParametrics
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Internal structure defining a texture effect.
set< String >::type GpuProgramDefinitionContainer
Class encapsulates rendering properties of an object.
int techLev
This is used while defining a program.
vector< Listener * >::type ListenerList
Listeners list of this Serializer.
vector< std::pair< String, String > >::type customParameters
Class representing an approach to rendering this particular Material.
SceneBlendFactor
Blending factors for manually blending objects with the scene.
MaterialScriptProgramDefinition * programDef
MaterialScriptContext mScriptContext
Class defining a single pass of a Technique (of a Material), i.e.
void writeComment(unsigned short level, const String &comment, const bool useMainBuffer=true)
bool(* ATTRIBUTE_PARSER)(String ¶ms, MaterialScriptContext &context)
Function def for material attribute parser; return value determines if the next line should be {...
Class for serializing Materials to / from a .material script.
Structure recording the use of an automatic parameter.
Struct for holding the script context while parsing.
MaterialScriptSection section
virtual void techniqueEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const Technique *tech)
Called when technique section event raised.
TextureUnitState * textureUnit
size_t lineNo
Error reporting state.
StringVector defaultParamLines
virtual void passEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const Pass *pass)
Called when pass section event raised.
AttribParserList mProgramAttribParsers
Parsers for the program definition section of a script.
AttribParserList mTextureUnitAttribParsers
Parsers for the texture unit section of a script.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Collects together the program parameters used for a GpuProgram.
map< String, ATTRIBUTE_PARSER >::type AttribParserList
Keyword-mapped attribute parsers.
bool usesVertexTextureFetch
ListenerList::iterator ListenerListIterator
vector< String >::type StringVector
GpuProgramDefinitionContainer mGpuProgramDefinitionContainer
bool supportsSkeletalAnimation
bool supportsMorphAnimation
LayerBlendSource
List of valid sources of values for blending operations used in TextureUnitState::setColourOperation ...
AttribParserList mPassAttribParsers
Parsers for the pass section of a script.
multimap< TextureUnitState::TextureEffectType, TextureUnitState::TextureEffect >::type EffectMap
GpuProgramDefinitionContainer::iterator GpuProgramDefIterator
void beginSection(unsigned short level, const bool useMainBuffer=true)
virtual void materialEventRaised(MaterialSerializer *ser, SerializeEvent event, bool &skip, const Material *mat)
Called when material section event raised.
AttribParserList mRootAttribParsers
Parsers for the root of the material script.
bool isFragmentProgramShadowReceiver
When referencing, are we in context of shadow caster.
AttribParserList mProgramDefaultParamAttribParsers
Parsers for the program definition section of a script.
String quoteWord(const String &val)
bool isVertexProgramShadowCaster
Used when referencing a program, not when defining it.
LayerBlendOperationEx
Expert list of valid texture blending operations, for use with TextureUnitState::setColourOperationEx...
FilterOptions
Filtering options for textures / mipmaps.
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.
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
void endSection(unsigned short level, const bool useMainBuffer=true)
AttribParserList mTechniqueAttribParsers
Parsers for the technique section of a script.
ushort supportsPoseAnimation