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;
110  virtual ScriptTranslator *getTranslator(const AbstractNodePtr&) = 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:
129  Technique *mTechnique;
130  public:
132  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
133  };
134 
136  {
137  protected:
138  Pass *mPass;
139  public:
140  PassTranslator();
141  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
142  protected:
143  void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
144  void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
145  void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
146  void translateTesselationHullProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
147  void translateTesselationDomainProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
148  void translateComputeProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
149  void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
150  void translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
151  void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
152  void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
153  };
154 
156  {
157  protected:
158  TextureUnitState *mUnit;
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:
177  void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
178  void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
179  void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
180  public:
181  static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
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:
198  Ogre::ParticleSystem *mSystem;
199  public:
201  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
202  };
204  {
205  protected:
206  Ogre::ParticleEmitter *mEmitter;
207  public:
209  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
210  };
212  {
213  protected:
214  Ogre::ParticleAffector *mAffector;
215  public:
217  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
218  };
219 
220  /**************************************************************************
221  * Compositor section
222  *************************************************************************/
224  {
225  protected:
226  Compositor *mCompositor;
227  public:
229  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
230  };
232  {
233  protected:
234  CompositionTechnique *mTechnique;
235  public:
237  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
238  };
240  {
241  protected:
242  CompositionTargetPass *mTarget;
243  public:
245  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
246  };
248  {
249  protected:
250  CompositionPass *mPass;
251  public:
253  void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
254  };
255 
256  /**************************************************************************
257  * BuiltinScriptTranslatorManager
258  *************************************************************************/
261  {
262  private:
263  MaterialTranslator mMaterialTranslator;
264  TechniqueTranslator mTechniqueTranslator;
265  PassTranslator mPassTranslator;
266  TextureUnitTranslator mTextureUnitTranslator;
267  TextureSourceTranslator mTextureSourceTranslator;
268  GpuProgramTranslator mGpuProgramTranslator;
269  SharedParamsTranslator mSharedParamsTranslator;
270  ParticleSystemTranslator mParticleSystemTranslator;
271  ParticleEmitterTranslator mParticleEmitterTranslator;
272  ParticleAffectorTranslator mParticleAffectorTranslator;
273  CompositorTranslator mCompositorTranslator;
274  CompositionTechniqueTranslator mCompositionTechniqueTranslator;
275  CompositionTargetPassTranslator mCompositionTargetPassTranslator;
276  CompositionPassTranslator mCompositionPassTranslator;
277  public:
280  virtual size_t getNumTranslators() const;
282  virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
283  };
286 }
287 
288 #include "OgreHeaderSuffix.h"
289 
290 #endif
291 
OgreHeaderSuffix.h
Ogre::CompositorTranslator
Definition: OgreScriptTranslator.h:220
OgreScriptCompiler.h
Ogre::ParticleEmitterTranslator
Definition: OgreScriptTranslator.h:201
Ogre::TextureUnitState
Class representing the state of a single texture unit during a Pass of a Technique,...
Definition: OgreTextureUnitState.h:62
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ScriptTranslator
This class translates script AST (abstract syntax tree) into Ogre resources.
Definition: OgreScriptTranslator.h:48
Ogre::MaterialTranslator
Definition: OgreScriptTranslator.h:115
Ogre::Compositor
Class representing a Compositor object.
Definition: OgreCompositor.h:50
Ogre::CompositionPass
Object representing one pass or operation in a composition sequence.
Definition: OgreCompositionPass.h:47
Ogre::BuiltinScriptTranslatorManager
This class manages the builtin translators.
Definition: OgreScriptTranslator.h:256
Ogre::CompositionPassTranslator
Definition: OgreScriptTranslator.h:244
Ogre::MaterialTranslator::mMaterial
Material * mMaterial
Definition: OgreScriptTranslator.h:119
Ogre::Material
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:88
Ogre::ObjectAbstractNode
This specific abstract node represents a script object.
Definition: OgreScriptCompiler.h:123
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::SharedParamsTranslator
Definition: OgreScriptTranslator.h:183
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Pass
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
Ogre::Technique
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
Ogre::CompositionTechnique
Base composition technique, can be subclassed in plugins.
Definition: OgreCompositionTechnique.h:45
Ogre::ScriptTranslatorManager::~ScriptTranslatorManager
virtual ~ScriptTranslatorManager()
Definition: OgreScriptTranslator.h:105
Ogre::CompareFunction
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:64
Ogre::StencilOperation
StencilOperation
Enum describing the various actions which can be taken on the stencil buffer.
Definition: OgreRenderSystem.h:81
OgreHeaderPrefix.h
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::SceneBlendFactor
SceneBlendFactor
Blending factors for manually blending objects with the scene.
Definition: OgreBlendMode.h:234
Ogre::GpuProgramTranslator
Definition: OgreScriptTranslator.h:170
Ogre::CompositionTargetPassTranslator
Definition: OgreScriptTranslator.h:236
Ogre::CompositionTargetPass
Object representing one render to a RenderTarget or Viewport in the Ogre Composition framework.
Definition: OgreCompositionTargetPass.h:45
OgrePrerequisites.h
Ogre::MaterialTranslator::mTextureAliases
Ogre::AliasTextureNamePairList mTextureAliases
Definition: OgreScriptTranslator.h:120
Ogre::ScriptCompiler
This is the main class for the compiler.
Definition: OgreScriptCompiler.h:188
Ogre::ScriptTranslatorManager
The ScriptTranslatorManager manages the lifetime and access to script translators.
Definition: OgreScriptTranslator.h:101
Ogre::PassTranslator
Definition: OgreScriptTranslator.h:134
Ogre::ParticleSystemTranslator
Definition: OgreScriptTranslator.h:193
Ogre::AliasTextureNamePairList
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:553
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::ParticleEmitter
Abstract class defining the interface to be implemented by particle emitters.
Definition: OgreParticleEmitter.h:72
Ogre::SharedPtr
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgrePrerequisites.h:310
Ogre::GpuConstantType
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
Definition: OgreGpuProgramParams.h:54
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::ParticleAffectorTranslator
Definition: OgreScriptTranslator.h:209
Ogre::AbstractNodeList
list< AbstractNodePtr >::type AbstractNodeList
Definition: OgreScriptCompiler.h:88
Ogre::TextureUnitTranslator
Definition: OgreScriptTranslator.h:154
Ogre::ParticleSystem
Class defining particle system based special effects.
Definition: OgreParticleSystem.h:67
Ogre::ScriptTranslator::~ScriptTranslator
virtual ~ScriptTranslator()
Definition: OgreScriptTranslator.h:59
Ogre::ScriptTranslatorManager::getTranslator
virtual ScriptTranslator * getTranslator(const AbstractNodePtr &)=0
Returns a manager for the given object abstract node, or null if it is not supported.
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::ParticleAffector
Abstract class defining the interface to be implemented by particle affectors.
Definition: OgreParticleAffector.h:64
Ogre::TextureSourceTranslator
Definition: OgreScriptTranslator.h:163
Ogre::ScriptTranslatorManager::getNumTranslators
virtual size_t getNumTranslators() const =0
Returns the number of translators being managed.
Ogre::CompositionTechniqueTranslator
Definition: OgreScriptTranslator.h:228
Ogre::TechniqueTranslator
Definition: OgreScriptTranslator.h:125

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