OgreScriptTranslator.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 
00024 You may alternatively use this source under the terms of a specific version of
00025 the OGRE Unrestricted License provided you have obtained such a license from
00026 Torus Knot Software Ltd.
00027 -----------------------------------------------------------------------------
00028 */
00029 
00030 #ifndef __SCRIPTTRANSLATOR_H_
00031 #define __SCRIPTTRANSLATOR_H_
00032 
00033 #include "OgrePrerequisites.h"
00034 #include "OgreScriptCompiler.h"
00035 
00036 namespace Ogre{
00042     class _OgreExport ScriptTranslator : public ScriptTranslatorAlloc
00043     {
00044     public:
00050         virtual void translate(ScriptCompiler *compiler, const AbstractNodePtr &node) = 0;
00051     protected:
00053         void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node);
00054 
00056         static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index);
00058         static bool getBoolean(const AbstractNodePtr &node, bool *result);
00060         static bool getString(const AbstractNodePtr &node, String *result);
00062         static bool getReal(const AbstractNodePtr &node, Real *result);
00064         static bool getFloat(const AbstractNodePtr &node, float *result);
00066         static bool getInt(const AbstractNodePtr &node, int *result); 
00068         static bool getUInt(const AbstractNodePtr &node, uint32 *result); 
00070         static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries = 4);
00072         static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf);
00074         static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func);
00076         static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m);
00078         static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count);
00080         static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count);
00082         static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op); 
00083     };
00084 
00090     class ScriptTranslatorManager : public ScriptTranslatorAlloc
00091     {
00092     public:
00094         virtual size_t getNumTranslators() const = 0;
00096         virtual ScriptTranslator *getTranslator(const AbstractNodePtr&) = 0;
00097     };
00098 
00099     /**************************************************************************
00100      * Material compilation section
00101      *************************************************************************/
00102     class _OgreExport MaterialTranslator : public ScriptTranslator
00103     {
00104     protected:
00105         Material *mMaterial;
00106         Ogre::AliasTextureNamePairList mTextureAliases;
00107     public:
00108         MaterialTranslator();
00109         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00110     };
00111         
00112     class _OgreExport TechniqueTranslator : public ScriptTranslator
00113     {
00114     protected:
00115         Technique *mTechnique;
00116     public:
00117         TechniqueTranslator();
00118         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00119     };
00120     
00121     class _OgreExport PassTranslator : public ScriptTranslator
00122     {
00123     protected:
00124         Pass *mPass;
00125     public:
00126         PassTranslator();
00127         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00128     protected:
00129         void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00130         void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00131         void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00132         void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00133         void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00134         void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00135     };
00136 
00137     class _OgreExport TextureUnitTranslator : public ScriptTranslator
00138     {
00139     protected:
00140         TextureUnitState *mUnit;
00141     public:
00142         TextureUnitTranslator();
00143         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00144     };
00145 
00146     class _OgreExport GpuProgramTranslator : public ScriptTranslator
00147     {   
00148     public:
00149         GpuProgramTranslator();
00150         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00151     protected:
00152         void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
00153         void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
00154         void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
00155     public:
00156         static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
00157     };
00158 
00159     /**************************************************************************
00160      * Particle System section
00161      *************************************************************************/
00162     class _OgreExport ParticleSystemTranslator : public ScriptTranslator
00163     {
00164     protected:
00165         Ogre::ParticleSystem *mSystem;
00166     public:
00167         ParticleSystemTranslator();
00168         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00169     };
00170     class _OgreExport ParticleEmitterTranslator : public ScriptTranslator
00171     {
00172     protected:
00173         Ogre::ParticleEmitter *mEmitter;
00174     public:
00175         ParticleEmitterTranslator();
00176         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00177     };
00178     class _OgreExport ParticleAffectorTranslator : public ScriptTranslator
00179     {
00180     protected:
00181         Ogre::ParticleAffector *mAffector;
00182     public:
00183         ParticleAffectorTranslator();
00184         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00185     };
00186 
00187     /**************************************************************************
00188      * Compositor section
00189      *************************************************************************/
00190     class _OgreExport CompositorTranslator : public ScriptTranslator
00191     {
00192     protected:
00193         Compositor *mCompositor;
00194     public:
00195         CompositorTranslator();
00196         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00197     };
00198     class _OgreExport CompositionTechniqueTranslator : public ScriptTranslator
00199     {
00200     protected:
00201         CompositionTechnique *mTechnique;
00202     public:
00203         CompositionTechniqueTranslator();
00204         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00205     };
00206     class _OgreExport CompositionTargetPassTranslator : public ScriptTranslator
00207     {
00208     protected:
00209         CompositionTargetPass *mTarget;
00210     public:
00211         CompositionTargetPassTranslator();
00212         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00213     };
00214     class _OgreExport CompositionPassTranslator : public ScriptTranslator
00215     {
00216     protected:
00217         CompositionPass *mPass;
00218     public:
00219         CompositionPassTranslator();
00220         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00221     };
00222 
00223     /**************************************************************************
00224      * BuiltinScriptTranslatorManager
00225      *************************************************************************/
00227     class _OgreExport BuiltinScriptTranslatorManager : public ScriptTranslatorManager
00228     {
00229     private:
00230         MaterialTranslator mMaterialTranslator;
00231         TechniqueTranslator mTechniqueTranslator;
00232         PassTranslator mPassTranslator;
00233         TextureUnitTranslator mTextureUnitTranslator;
00234         GpuProgramTranslator mGpuProgramTranslator;
00235         ParticleSystemTranslator mParticleSystemTranslator;
00236         ParticleEmitterTranslator mParticleEmitterTranslator;
00237         ParticleAffectorTranslator mParticleAffectorTranslator;
00238         CompositorTranslator mCompositorTranslator;
00239         CompositionTechniqueTranslator mCompositionTechniqueTranslator;
00240         CompositionTargetPassTranslator mCompositionTargetPassTranslator;
00241         CompositionPassTranslator mCompositionPassTranslator;
00242     public:
00243         BuiltinScriptTranslatorManager();
00245         virtual size_t getNumTranslators() const;
00247         virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
00248     };
00249 }
00250 
00251 
00252 #endif
00253 

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Aug 28 20:53:52 2008