OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-2014 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"
34 #include "OgreScriptCompiler.h"
35 #include "OgreBlendMode.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre{
39  struct IdString;
40  class TextureDefinitionBase;
41 
54  {
55  public:
61  virtual void translate(ScriptCompiler *compiler, const AbstractNodePtr &node) = 0;
62  protected:
63  // needs virtual destructor
64  virtual ~ScriptTranslator() {}
66  void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node);
67 
69  static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index);
71  static bool getBoolean(const AbstractNodePtr &node, bool *result);
73  static bool getString(const AbstractNodePtr &node, String *result);
75  static bool getIdString(const AbstractNodePtr &node, IdString *result);
77  static bool getReal(const AbstractNodePtr &node, Real *result);
79  static bool getFloat(const AbstractNodePtr &node, float *result);
81  static bool getDouble(const AbstractNodePtr &node, double *result);
83  static bool getInt(const AbstractNodePtr &node, int *result);
85  static bool getUInt(const AbstractNodePtr &node, uint32 *result);
87  static bool getHex(const AbstractNodePtr &node, uint32 *result);
89  static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries = 4);
91  static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf);
93  static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func);
95  static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m);
97  static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count);
99  static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count);
101  static bool getDoubles(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, double *vals, int count);
103  static bool getUInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, uint *vals, int count);
105  static bool getBooleans(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, uint *vals, int count);
107  static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op);
109  static bool getConstantType(AbstractNodeList::const_iterator i, GpuConstantType *op);
110 
111  };
112 
119  {
120  public:
121  // required - virtual destructor
123 
125  virtual size_t getNumTranslators() const = 0;
127  virtual ScriptTranslator *getTranslator(const AbstractNodePtr&) = 0;
128  };
129 
130  /**************************************************************************
131  * Material compilation section
132  *************************************************************************/
134  {
135  protected:
138  public:
140  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
141  };
142 
144  {
145  protected:
147  public:
149  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
150  };
151 
153  {
154  protected:
156  public:
157  PassTranslator();
158  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
159  protected:
160  void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
161  void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
162  void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
163  void translateTessellationHullProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
164  void translateTessellationDomainProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
165  void translateComputeProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
166  void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
167  void translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
168  };
169 
171  {
172  protected:
174  public:
176  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
177  };
178 
180  {
181  public:
183  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
184  };
185 
187  {
188  public:
190  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
191  protected:
192  void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
193  void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
194  void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
195  public:
196  static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
197  };
198 
200  {
201  public:
203  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
204  template <class T>
205  void translateSharedParamNamed(ScriptCompiler *compiler, GpuSharedParameters *sharedParams, PropertyAbstractNode *prop, String pName, BaseConstantType baseType, GpuConstantType constType);
206  protected:
207  };
208 
209  /**************************************************************************
210  * Particle System section
211  *************************************************************************/
213  {
214  protected:
216  public:
218  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
219  };
221  {
222  protected:
224  public:
226  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
227  };
229  {
230  protected:
232  public:
234  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
235  };
236 
237  /**************************************************************************
238  * Compositor section
239  *************************************************************************/
241  {
242  protected:
243  void translateTextureProperty( TextureDefinitionBase *defBase, PropertyAbstractNode *prop,
244  ScriptCompiler *compiler ) const;
245  };
247  {
248  protected:
250  public:
252  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
253  };
255  {
256  protected:
258  public:
260  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
261  };
263  {
264  protected:
266  void translateShadowMapProperty( PropertyAbstractNode *prop, ScriptCompiler *compiler,
267  bool isAtlas, const ShadowTextureDefinition &defaultParams ) const;
268  public:
270  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
271  };
273  {
274  protected:
276  public:
278  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
279  };
281  {
282  protected:
284  public:
286  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
287  };
289  {
290  protected:
292 
293  void translateClear( ScriptCompiler *compiler, const AbstractNodePtr &node,
294  CompositorTargetDef *targetDef );
295  void translateQuad( ScriptCompiler *compiler, const AbstractNodePtr &node,
296  CompositorTargetDef *targetDef );
297  void translateScene( ScriptCompiler *compiler, const AbstractNodePtr &node,
298  CompositorTargetDef *targetDef );
299  void translateStencil( ScriptCompiler *compiler, const AbstractNodePtr &node,
300  CompositorTargetDef *targetDef );
301 
302  public:
304  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
305  };
306 
307  /**************************************************************************
308  * BuiltinScriptTranslatorManager
309  *************************************************************************/
312  {
313  private:
330  public:
333  virtual size_t getNumTranslators() const;
335  virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
336  };
339 }
340 
341 #include "OgreHeaderSuffix.h"
342 
343 #endif
344 
Class defining particle system based special effects.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
The ScriptTranslatorManager manages the lifetime and access to script translators.
ParticleEmitterTranslator mParticleEmitterTranslator
CompositorNodeTranslator mCompositorNodeTranslator
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
Compositor nodes are the core subject of compositing.
Class representing colour.
Ogre::ParticleAffector * mAffector
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:84
Definition of container that holds the current bool constants.
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:50
SceneBlendFactor
Blending factors for manually blending objects with the scene.
ParticleAffectorTranslator mParticleAffectorTranslator
CompositorWorkspaceTranslator mCompositorWorkspaceTranslator
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:78
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.
Centralized class for dealing with declarations of textures in Node & Workspace definitions.
SharedParamsTranslator mSharedParamsTranslator
This abstract node represents a script property.
This specific abstract node represents a script object.
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
virtual ScriptTranslator * getTranslator(const AbstractNodePtr &)=0
Returns a manager for the given object abstract node, or null if it is not supported.
CompositorShadowNodeDef * mShadowNodeDef
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.
Hashed string.
Definition: OgreIdString.h:94
Shadow Nodes are special nodes (not to be confused with.
Abstract class defining the interface to be implemented by particle emitters.
TextureSourceTranslator mTextureSourceTranslator
Ogre::AliasTextureNamePairList mTextureAliases
StencilOperation
Enum describing the various actions which can be taken on the stencil buffer.
Definition: OgreCommon.h:87
CompositorShadowMapTargetTranslator mCompositorShadowMapTargetTranslator
Abstract class defining the interface to be implemented by particle affectors.
Interface to abstract all types of pass definitions (.
CompositorShadowNodeTranslator mCompositorShadowNodeTranslator
CompositorPassTranslator mCompositorPassTranslator
CompositorTargetTranslator mCompositorTargetTranslator
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
Definition: OgreCommon.h:53
This is the main class for the compiler.
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:583
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:74
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
unsigned int uint