OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2011 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 
35 namespace Ogre{
48  {
49  public:
55  virtual void translate(ScriptCompiler *compiler, const AbstractNodePtr &node) = 0;
56  protected:
57  // needs virtual destructor
58  virtual ~ScriptTranslator() {}
60  void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node);
61 
63  static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index);
65  static bool getBoolean(const AbstractNodePtr &node, bool *result);
67  static bool getString(const AbstractNodePtr &node, String *result);
69  static bool getReal(const AbstractNodePtr &node, Real *result);
71  static bool getFloat(const AbstractNodePtr &node, float *result);
73  static bool getInt(const AbstractNodePtr &node, int *result);
75  static bool getUInt(const AbstractNodePtr &node, uint32 *result);
77  static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries = 4);
79  static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf);
81  static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func);
83  static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m);
85  static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count);
87  static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count);
89  static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op);
91  static bool getConstantType(AbstractNodeList::const_iterator i, GpuConstantType *op);
92 
93  };
94 
101  {
102  public:
103  // required - virtual destructor
105 
107  virtual size_t getNumTranslators() const = 0;
109  virtual ScriptTranslator *getTranslator(const AbstractNodePtr&) = 0;
110  };
111 
112  /**************************************************************************
113  * Material compilation section
114  *************************************************************************/
116  {
117  protected:
120  public:
122  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
123  };
124 
126  {
127  protected:
129  public:
131  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
132  };
133 
135  {
136  protected:
138  public:
139  PassTranslator();
140  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
141  protected:
142  void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
143  void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
144  void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
145  void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
146  void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
147  void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
148  };
149 
151  {
152  protected:
154  public:
156  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
157  };
158 
160  {
161  public:
163  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
164  };
165 
167  {
168  public:
170  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
171  protected:
172  void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
173  void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
174  void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
175  public:
176  static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
177  };
178 
180  {
181  public:
183  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
184  protected:
185  };
186 
187  /**************************************************************************
188  * Particle System section
189  *************************************************************************/
191  {
192  protected:
194  public:
196  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
197  };
199  {
200  protected:
202  public:
204  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
205  };
207  {
208  protected:
210  public:
212  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
213  };
214 
215  /**************************************************************************
216  * Compositor section
217  *************************************************************************/
219  {
220  protected:
222  public:
224  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
225  };
227  {
228  protected:
230  public:
232  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
233  };
235  {
236  protected:
238  public:
240  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
241  };
243  {
244  protected:
246  public:
248  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
249  };
251  {
252  protected:
254  public:
256  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
257  };
259  {
260  protected:
262  public:
264  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
265  };
266 
267  /**************************************************************************
268  * BuiltinScriptTranslatorManager
269  *************************************************************************/
272  {
273  private:
290  public:
293  virtual size_t getNumTranslators() const;
295  virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
296  };
299 }
300 
301 
302 #endif
303 
Class defining particle system based special effects.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
The ScriptTranslatorManager manages the lifetime and access to script translators.
ParticleEmitterTranslator mParticleEmitterTranslator
float Real
Software floating point type.
CompositionTechniqueTranslator mCompositionTechniqueTranslator
unsigned int uint32
Definition: OgrePlatform.h:246
#define _OgreExport
Definition: OgrePlatform.h:203
Class representing colour.
Ogre::ParticleAffector * mAffector
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:88
Class representing a Compositor object.
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
Object representing one pass or operation in a composition sequence.
SceneBlendFactor
Blending factors for manually blending objects with the scene.
ParticleAffectorTranslator mParticleAffectorTranslator
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
ParticleSystemTranslator mParticleSystemTranslator
virtual size_t getNumTranslators() const =0
Returns the number of translators being managed.
This class translates script AST (abstract syntax tree) into Ogre resources.
SharedParamsTranslator mSharedParamsTranslator
This specific abstract node represents a script object.
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
CompositionTargetPassTranslator mCompositionTargetPassTranslator
virtual ScriptTranslator * getTranslator(const AbstractNodePtr &)=0
Returns a manager for the given object abstract node, or null if it is not supported.
CompositionPassClearTranslator mCompositionPassClearTranslator
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
list< AbstractNodePtr >::type AbstractNodeList
This class manages the builtin translators.
Abstract class defining the interface to be implemented by particle emitters.
TextureSourceTranslator mTextureSourceTranslator
Base composition technique, can be subclassed in plugins.
Ogre::AliasTextureNamePairList mTextureAliases
Abstract class defining the interface to be implemented by particle affectors.
CompositionPassTranslator mCompositionPassTranslator
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgreSharedPtr.h:60
_StringBase String
This is the main class for the compiler.
StencilOperation
Enum describing the various actions which can be taken onthe stencil buffer.
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:527
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:65
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
CompositionPassStencilTranslator mCompositionPassStencilTranslator
Object representing one render to a RenderTarget or Viewport in the Ogre Composition framework...