OGRE  1.8
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-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 
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 translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
147  void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
148  void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
149  };
150 
152  {
153  protected:
155  public:
157  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
158  };
159 
161  {
162  public:
164  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
165  };
166 
168  {
169  public:
171  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
172  protected:
173  void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
174  void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
175  void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
176  public:
177  static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
178  };
179 
181  {
182  public:
184  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
185  protected:
186  };
187 
188  /**************************************************************************
189  * Particle System section
190  *************************************************************************/
192  {
193  protected:
195  public:
197  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
198  };
200  {
201  protected:
203  public:
205  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
206  };
208  {
209  protected:
211  public:
213  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
214  };
215 
216  /**************************************************************************
217  * Compositor section
218  *************************************************************************/
220  {
221  protected:
223  public:
225  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
226  };
228  {
229  protected:
231  public:
233  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
234  };
236  {
237  protected:
239  public:
241  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
242  };
244  {
245  protected:
247  public:
249  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
250  };
251 
252  /**************************************************************************
253  * BuiltinScriptTranslatorManager
254  *************************************************************************/
257  {
258  private:
273  public:
276  virtual size_t getNumTranslators() const;
278  virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
279  };
282 }
283 
284 
285 #endif
286 
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:270
#define _OgreExport
Definition: OgrePlatform.h:233
Class representing colour.
Ogre::ParticleAffector * mAffector
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:89
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.
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:556
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:67
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
Object representing one render to a RenderTarget or Viewport in the Ogre Composition framework...