OgreScriptTranslator.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __SCRIPTTRANSLATOR_H_
#define __SCRIPTTRANSLATOR_H_
#include "OgrePrerequisites.h"
#include "OgreScriptCompiler.h"
#include "OgreHeaderPrefix.h"
namespace Ogre{
class _OgreExport ScriptTranslator : public ScriptTranslatorAlloc
{
public:
virtual void translate(ScriptCompiler *compiler, const AbstractNodePtr &node) = 0;
protected:
// needs virtual destructor
virtual ~ScriptTranslator() {}
void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node);
static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index);
static bool getBoolean(const AbstractNodePtr &node, bool *result);
static bool getString(const AbstractNodePtr &node, String *result);
static bool getReal(const AbstractNodePtr &node, Real *result);
static bool getFloat(const AbstractNodePtr &node, float *result);
static bool getInt(const AbstractNodePtr &node, int *result);
static bool getUInt(const AbstractNodePtr &node, uint32 *result);
static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries = 4);
static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf);
static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func);
static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m);
static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count);
static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count);
static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op);
static bool getConstantType(AbstractNodeList::const_iterator i, GpuConstantType *op);
};
class ScriptTranslatorManager : public ScriptTranslatorAlloc
{
public:
// required - virtual destructor
virtual ~ScriptTranslatorManager() {}
virtual size_t getNumTranslators() const = 0;
virtual ScriptTranslator *getTranslator(const AbstractNodePtr&) = 0;
};
/**************************************************************************
* Material compilation section
*************************************************************************/
class _OgreExport MaterialTranslator : public ScriptTranslator
{
protected:
Material *mMaterial;
Ogre::AliasTextureNamePairList mTextureAliases;
public:
MaterialTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport TechniqueTranslator : public ScriptTranslator
{
protected:
Technique *mTechnique;
public:
TechniqueTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport PassTranslator : public ScriptTranslator
{
protected:
Pass *mPass;
public:
PassTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
protected:
void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateTesselationHullProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateTesselationDomainProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateComputeProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
};
class _OgreExport TextureUnitTranslator : public ScriptTranslator
{
protected:
TextureUnitState *mUnit;
public:
TextureUnitTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport TextureSourceTranslator : public ScriptTranslator
{
public:
TextureSourceTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport GpuProgramTranslator : public ScriptTranslator
{
public:
GpuProgramTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
protected:
void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
public:
static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
};
class _OgreExport SharedParamsTranslator : public ScriptTranslator
{
public:
SharedParamsTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
protected:
};
/**************************************************************************
* Particle System section
*************************************************************************/
class _OgreExport ParticleSystemTranslator : public ScriptTranslator
{
protected:
Ogre::ParticleSystem *mSystem;
public:
ParticleSystemTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport ParticleEmitterTranslator : public ScriptTranslator
{
protected:
Ogre::ParticleEmitter *mEmitter;
public:
ParticleEmitterTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport ParticleAffectorTranslator : public ScriptTranslator
{
protected:
Ogre::ParticleAffector *mAffector;
public:
ParticleAffectorTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
/**************************************************************************
* Compositor section
*************************************************************************/
class _OgreExport CompositorTranslator : public ScriptTranslator
{
protected:
Compositor *mCompositor;
public:
CompositorTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport CompositionTechniqueTranslator : public ScriptTranslator
{
protected:
CompositionTechnique *mTechnique;
public:
CompositionTechniqueTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport CompositionTargetPassTranslator : public ScriptTranslator
{
protected:
CompositionTargetPass *mTarget;
public:
CompositionTargetPassTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
class _OgreExport CompositionPassTranslator : public ScriptTranslator
{
protected:
CompositionPass *mPass;
public:
CompositionPassTranslator();
void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
};
/**************************************************************************
* BuiltinScriptTranslatorManager
*************************************************************************/
class _OgreExport BuiltinScriptTranslatorManager : public ScriptTranslatorManager
{
private:
MaterialTranslator mMaterialTranslator;
TechniqueTranslator mTechniqueTranslator;
PassTranslator mPassTranslator;
TextureUnitTranslator mTextureUnitTranslator;
TextureSourceTranslator mTextureSourceTranslator;
GpuProgramTranslator mGpuProgramTranslator;
SharedParamsTranslator mSharedParamsTranslator;
ParticleSystemTranslator mParticleSystemTranslator;
ParticleEmitterTranslator mParticleEmitterTranslator;
ParticleAffectorTranslator mParticleAffectorTranslator;
CompositorTranslator mCompositorTranslator;
CompositionTechniqueTranslator mCompositionTechniqueTranslator;
CompositionTargetPassTranslator mCompositionTargetPassTranslator;
CompositionPassTranslator mCompositionPassTranslator;
public:
BuiltinScriptTranslatorManager();
virtual size_t getNumTranslators() const;
virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::MaterialTranslator::mMaterial
Material * mMaterial
Definition: OgreScriptTranslator.h:119
Ogre::PassTranslator::mPass
Pass * mPass
Definition: OgreScriptTranslator.h:138
Ogre::TextureUnitTranslator
Definition: OgreScriptTranslator.h:155
Ogre::Pass
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
Ogre::ParticleEmitterTranslator::mEmitter
Ogre::ParticleEmitter * mEmitter
Definition: OgreScriptTranslator.h:206
Ogre::GpuProgramTranslator
Definition: OgreScriptTranslator.h:171
Ogre::ScriptTranslatorManager
The ScriptTranslatorManager manages the lifetime and access to script translators.
Definition: OgreScriptTranslator.h:101
Ogre::TechniqueTranslator
Definition: OgreScriptTranslator.h:126
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::BuiltinScriptTranslatorManager::mTechniqueTranslator
TechniqueTranslator mTechniqueTranslator
Definition: OgreScriptTranslator.h:264
Ogre::BuiltinScriptTranslatorManager::mPassTranslator
PassTranslator mPassTranslator
Definition: OgreScriptTranslator.h:265
Ogre::CompositionTargetPass
Object representing one render to a RenderTarget or Viewport in the Ogre Composition framework...
Definition: OgreCompositionTargetPass.h:45
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::CompositionPassTranslator::mPass
CompositionPass * mPass
Definition: OgreScriptTranslator.h:250
Ogre::CompositionPass
Object representing one pass or operation in a composition sequence.
Definition: OgreCompositionPass.h:47
Ogre::CompositorTranslator
Definition: OgreScriptTranslator.h:223
Ogre::ScriptTranslator
This class translates script AST (abstract syntax tree) into Ogre resources.
Definition: OgreScriptTranslator.h:48
Ogre::BuiltinScriptTranslatorManager::mCompositorTranslator
CompositorTranslator mCompositorTranslator
Definition: OgreScriptTranslator.h:273
OgreScriptCompiler.h
Ogre::ParticleEmitterTranslator
Definition: OgreScriptTranslator.h:203
Ogre::ParticleAffector
Abstract class defining the interface to be implemented by particle affectors.
Definition: OgreParticleAffector.h:64
Ogre::ParticleAffectorTranslator
Definition: OgreScriptTranslator.h:211
Ogre::ParticleAffectorTranslator::mAffector
Ogre::ParticleAffector * mAffector
Definition: OgreScriptTranslator.h:214
Ogre::BuiltinScriptTranslatorManager::mGpuProgramTranslator
GpuProgramTranslator mGpuProgramTranslator
Definition: OgreScriptTranslator.h:268
Ogre::ParticleSystemTranslator::mSystem
Ogre::ParticleSystem * mSystem
Definition: OgreScriptTranslator.h:198
Ogre::CompositionTechniqueTranslator
Definition: OgreScriptTranslator.h:231
Ogre::CompositionTechnique
Base composition technique, can be subclassed in plugins.
Definition: OgreCompositionTechnique.h:45
Ogre::BuiltinScriptTranslatorManager::mMaterialTranslator
MaterialTranslator mMaterialTranslator
Definition: OgreScriptTranslator.h:263
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Compositor
Class representing a Compositor object.
Definition: OgreCompositor.h:50
Ogre::TextureUnitState
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
Definition: OgreTextureUnitState.h:62
OgrePrerequisites.h
Ogre::BuiltinScriptTranslatorManager::mTextureUnitTranslator
TextureUnitTranslator mTextureUnitTranslator
Definition: OgreScriptTranslator.h:266
Ogre::AliasTextureNamePairList
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:553
Ogre::BuiltinScriptTranslatorManager::mCompositionTechniqueTranslator
CompositionTechniqueTranslator mCompositionTechniqueTranslator
Definition: OgreScriptTranslator.h:274
Ogre::CompositionTargetPassTranslator
Definition: OgreScriptTranslator.h:239
Ogre::CompareFunction
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:64
Ogre::BuiltinScriptTranslatorManager::mTextureSourceTranslator
TextureSourceTranslator mTextureSourceTranslator
Definition: OgreScriptTranslator.h:267
Ogre::CompositionTargetPassTranslator::mTarget
CompositionTargetPass * mTarget
Definition: OgreScriptTranslator.h:242
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::CompositionTechniqueTranslator::mTechnique
CompositionTechnique * mTechnique
Definition: OgreScriptTranslator.h:234
Ogre::AbstractNodeList
list< AbstractNodePtr >::type AbstractNodeList
Definition: OgreScriptCompiler.h:88
Ogre::PassTranslator
Definition: OgreScriptTranslator.h:135
Ogre::MaterialTranslator::mTextureAliases
Ogre::AliasTextureNamePairList mTextureAliases
Definition: OgreScriptTranslator.h:120
Ogre::BuiltinScriptTranslatorManager::mParticleEmitterTranslator
ParticleEmitterTranslator mParticleEmitterTranslator
Definition: OgreScriptTranslator.h:271
Ogre::SharedParamsTranslator
Definition: OgreScriptTranslator.h:184
OgreHeaderSuffix.h
Ogre::BuiltinScriptTranslatorManager
This class manages the builtin translators.
Definition: OgreScriptTranslator.h:260
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::CompositorTranslator::mCompositor
Compositor * mCompositor
Definition: OgreScriptTranslator.h:226
Ogre::BuiltinScriptTranslatorManager::mCompositionPassTranslator
CompositionPassTranslator mCompositionPassTranslator
Definition: OgreScriptTranslator.h:276
Ogre::SceneBlendFactor
SceneBlendFactor
Blending factors for manually blending objects with the scene.
Definition: OgreBlendMode.h:234
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Material
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:88
Ogre::CompositionPassTranslator
Definition: OgreScriptTranslator.h:247
Ogre::ParticleEmitter
Abstract class defining the interface to be implemented by particle emitters.
Definition: OgreParticleEmitter.h:72
Ogre::MaterialTranslator
Definition: OgreScriptTranslator.h:116
Ogre::BuiltinScriptTranslatorManager::mParticleAffectorTranslator
ParticleAffectorTranslator mParticleAffectorTranslator
Definition: OgreScriptTranslator.h:272
Ogre::BuiltinScriptTranslatorManager::mSharedParamsTranslator
SharedParamsTranslator mSharedParamsTranslator
Definition: OgreScriptTranslator.h:269
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
OgreHeaderPrefix.h
Ogre::StencilOperation
StencilOperation
Enum describing the various actions which can be taken on the stencil buffer.
Definition: OgreRenderSystem.h:81
Ogre::ScriptTranslatorManager::~ScriptTranslatorManager
virtual ~ScriptTranslatorManager()
Definition: OgreScriptTranslator.h:105
Ogre::Technique
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
Ogre::ObjectAbstractNode
This specific abstract node represents a script object.
Definition: OgreScriptCompiler.h:123
Ogre::ParticleSystem
Class defining particle system based special effects.
Definition: OgreParticleSystem.h:67
Ogre::ParticleSystemTranslator
Definition: OgreScriptTranslator.h:195
Ogre::BuiltinScriptTranslatorManager::mCompositionTargetPassTranslator
CompositionTargetPassTranslator mCompositionTargetPassTranslator
Definition: OgreScriptTranslator.h:275
Ogre::TechniqueTranslator::mTechnique
Technique * mTechnique
Definition: OgreScriptTranslator.h:129
Ogre::TextureUnitTranslator::mUnit
TextureUnitState * mUnit
Definition: OgreScriptTranslator.h:158
Ogre::TextureSourceTranslator
Definition: OgreScriptTranslator.h:164
Ogre::BuiltinScriptTranslatorManager::mParticleSystemTranslator
ParticleSystemTranslator mParticleSystemTranslator
Definition: OgreScriptTranslator.h:270
Ogre::ScriptCompiler
This is the main class for the compiler.
Definition: OgreScriptCompiler.h:188
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::ScriptTranslator::~ScriptTranslator
virtual ~ScriptTranslator()
Definition: OgreScriptTranslator.h:59

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