OgreScriptTranslator.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __SCRIPTTRANSLATOR_H_
30 #define __SCRIPTTRANSLATOR_H_
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreScriptCompiler.h"
34 #include "OgreHeaderPrefix.h"
35 
36 namespace Ogre{
49  {
50  public:
56  virtual void translate(ScriptCompiler *compiler, const AbstractNodePtr &node) = 0;
57  protected:
58  // needs virtual destructor
59  virtual ~ScriptTranslator() {}
61  void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node);
62 
64  static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index);
66  static bool getBoolean(const AbstractNodePtr &node, bool *result);
68  static bool getString(const AbstractNodePtr &node, String *result);
70  static bool getReal(const AbstractNodePtr &node, Real *result);
72  static bool getFloat(const AbstractNodePtr &node, float *result);
74  static bool getInt(const AbstractNodePtr &node, int *result);
76  static bool getUInt(const AbstractNodePtr &node, uint32 *result);
78  static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries = 4);
80  static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf);
82  static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func);
84  static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m);
86  static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count);
88  static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count);
90  static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op);
92  static bool getConstantType(AbstractNodeList::const_iterator i, GpuConstantType *op);
93 
94  };
95 
102  {
103  public:
104  // required - virtual destructor
106 
108  virtual size_t getNumTranslators() const = 0;
111  };
112 
113  /**************************************************************************
114  * Material compilation section
115  *************************************************************************/
117  {
118  protected:
121  public:
123  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
124  };
125 
127  {
128  protected:
130  public:
132  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
133  };
134 
136  {
137  protected:
139  public:
141  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
142  protected:
153  };
154 
156  {
157  protected:
159  public:
161  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
162  };
163 
165  {
166  public:
168  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
169  };
170 
172  {
173  public:
175  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
176  protected:
180  public:
182  };
183 
185  {
186  public:
188  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
189  protected:
190  };
191 
192  /**************************************************************************
193  * Particle System section
194  *************************************************************************/
196  {
197  protected:
199  public:
201  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
202  };
204  {
205  protected:
207  public:
209  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
210  };
212  {
213  protected:
215  public:
217  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
218  };
219 
220  /**************************************************************************
221  * Compositor section
222  *************************************************************************/
224  {
225  protected:
227  public:
229  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
230  };
232  {
233  protected:
235  public:
237  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
238  };
240  {
241  protected:
243  public:
245  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
246  };
248  {
249  protected:
251  public:
253  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
254  };
255 
256  /**************************************************************************
257  * BuiltinScriptTranslatorManager
258  *************************************************************************/
261  {
262  private:
277  public:
280  virtual size_t getNumTranslators() const;
283  };
286 }
287 
288 #include "OgreHeaderSuffix.h"
289 
290 #endif
291 
#define _OgreExport
Definition: OgrePlatform.h:257
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
This class manages the builtin translators.
virtual ScriptTranslator * getTranslator(const AbstractNodePtr &node)
Returns a manager for the given object abstract node, or null if it is not supported.
ParticleSystemTranslator mParticleSystemTranslator
ParticleEmitterTranslator mParticleEmitterTranslator
CompositionPassTranslator mCompositionPassTranslator
CompositionTechniqueTranslator mCompositionTechniqueTranslator
SharedParamsTranslator mSharedParamsTranslator
TextureSourceTranslator mTextureSourceTranslator
CompositionTargetPassTranslator mCompositionTargetPassTranslator
virtual size_t getNumTranslators() const
Returns the number of translators being managed.
ParticleAffectorTranslator mParticleAffectorTranslator
Class representing colour.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Object representing one pass or operation in a composition sequence.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Object representing one render to a RenderTarget or Viewport in the Ogre Composition framework.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Base composition technique, can be subclassed in plugins.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Class representing a Compositor object.
void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj)
void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj)
void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj)
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj)
Ogre::AliasTextureNamePairList mTextureAliases
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:89
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
This specific abstract node represents a script object.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Ogre::ParticleAffector * mAffector
Abstract class defining the interface to be implemented by particle affectors.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Abstract class defining the interface to be implemented by particle emitters.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Class defining particle system based special effects.
void translateComputeProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateTesselationDomainProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateTesselationHullProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
void translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node)
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:81
This is the main class for the compiler.
The ScriptTranslatorManager manages the lifetime and access to script translators.
virtual size_t getNumTranslators() const =0
Returns the number of translators being managed.
virtual ScriptTranslator * getTranslator(const AbstractNodePtr &)=0
Returns a manager for the given object abstract node, or null if it is not supported.
This class translates script AST (abstract syntax tree) into Ogre resources.
static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count)
Converts the range of nodes to an array of ints and returns true if successful.
static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func)
Converts the node to a CompareFunction enum and returns true if successful.
static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count)
Converts the range of nodes to an array of floats and returns true if successful.
static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m)
Converts the range of nodes to a Matrix4 and returns true if successful.
static bool getUInt(const AbstractNodePtr &node, uint32 *result)
Converts the node to an unsigned integer and returns true if successful.
static bool getBoolean(const AbstractNodePtr &node, bool *result)
Converts the node to a boolean and returns true if successful.
static bool getReal(const AbstractNodePtr &node, Real *result)
Converts the node to a Real and returns true if successful.
virtual void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)=0
This function translates the given node into Ogre resource(s).
static bool getFloat(const AbstractNodePtr &node, float *result)
Converts the node to a float and returns true if successful.
static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf)
Converts the node to a SceneBlendFactor enum and returns true if successful.
static bool getInt(const AbstractNodePtr &node, int *result)
Converts the node to an integer and returns true if successful.
static bool getConstantType(AbstractNodeList::const_iterator i, GpuConstantType *op)
Converts the node to a GpuConstantType enum and returns true if successful.
static bool getString(const AbstractNodePtr &node, String *result)
Converts the node to a string and returns true if successful.
void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node)
Retrieves a new translator from the factories and uses it to process the give node.
static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index)
Retrieves the node iterator at the given index.
static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op)
Converts the node to a StencilOperation enum and returns true if successful.
static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries=4)
Converts the range of nodes to a ColourValue and returns true if successful.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Reference-counted shared pointer, used for objects where implicit destruction is required.
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:54
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
Class representing the state of a single texture unit during a Pass of a Technique,...
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node)
This function translates the given node into Ogre resource(s).
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:65
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:553
list< AbstractNodePtr >::type AbstractNodeList
SceneBlendFactor
Blending factors for manually blending objects with the scene.
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
StencilOperation
Enum describing the various actions which can be taken on the stencil buffer.
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:359
_StringBase String

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.