# 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:
    00052         // needs virtual destructor
    00053         virtual ~ScriptTranslator() {}
    00055         void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00056
    00058         static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index);
    00060         static bool getBoolean(const AbstractNodePtr &node, bool *result);
    00062         static bool getString(const AbstractNodePtr &node, String *result);
    00064         static bool getReal(const AbstractNodePtr &node, Real *result);
    00066         static bool getFloat(const AbstractNodePtr &node, float *result);
    00068         static bool getInt(const AbstractNodePtr &node, int *result);
    00070         static bool getUInt(const AbstractNodePtr &node, uint32 *result);
    00072         static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries = 4);
    00074         static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf);
    00076         static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func);
    00078         static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m);
    00080         static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count);
    00082         static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count);
    00084         static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op);
    00085     };
    00086
    00092     class ScriptTranslatorManager : public ScriptTranslatorAlloc
    00093     {
    00094     public:
    00095         // required - virtual destructor
    00096         virtual ~ScriptTranslatorManager() {}
    00097
    00099         virtual size_t getNumTranslators() const = 0;
    00101         virtual ScriptTranslator *getTranslator(const AbstractNodePtr&) = 0;
    00102     };
    00103
    00104     /**************************************************************************
    00105      * Material compilation section
    00106      *************************************************************************/
    00107     class _OgreExport MaterialTranslator : public ScriptTranslator
    00108     {
    00109     protected:
    00110         Material *mMaterial;
    00111         Ogre::AliasTextureNamePairList mTextureAliases;
    00112     public:
    00113         MaterialTranslator();
    00114         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00115     };
    00116
    00117     class _OgreExport TechniqueTranslator : public ScriptTranslator
    00118     {
    00119     protected:
    00120         Technique *mTechnique;
    00121     public:
    00122         TechniqueTranslator();
    00123         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00124     };
    00125
    00126     class _OgreExport PassTranslator : public ScriptTranslator
    00127     {
    00128     protected:
    00129         Pass *mPass;
    00130     public:
    00131         PassTranslator();
    00132         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00133     protected:
    00134         void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00135         void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00136         void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00137         void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00138         void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00139         void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00140     };
    00141
    00142     class _OgreExport TextureUnitTranslator : public ScriptTranslator
    00143     {
    00144     protected:
    00145         TextureUnitState *mUnit;
    00146     public:
    00147         TextureUnitTranslator();
    00148         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00149     };
    00150
    00151     class _OgreExport TextureSourceTranslator : public ScriptTranslator
    00152     {
    00153     public:
    00154         TextureSourceTranslator();
    00155         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00156     };
    00157
    00158     class _OgreExport GpuProgramTranslator : public ScriptTranslator
    00159     {
    00160     public:
    00161         GpuProgramTranslator();
    00162         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00163     protected:
    00164         void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
    00165         void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
    00166         void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
    00167     public:
    00168         static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
    00169     };
    00170
    00171     /**************************************************************************
    00172      * Particle System section
    00173      *************************************************************************/
    00174     class _OgreExport ParticleSystemTranslator : public ScriptTranslator
    00175     {
    00176     protected:
    00177         Ogre::ParticleSystem *mSystem;
    00178     public:
    00179         ParticleSystemTranslator();
    00180         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00181     };
    00182     class _OgreExport ParticleEmitterTranslator : public ScriptTranslator
    00183     {
    00184     protected:
    00185         Ogre::ParticleEmitter *mEmitter;
    00186     public:
    00187         ParticleEmitterTranslator();
    00188         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00189     };
    00190     class _OgreExport ParticleAffectorTranslator : public ScriptTranslator
    00191     {
    00192     protected:
    00193         Ogre::ParticleAffector *mAffector;
    00194     public:
    00195         ParticleAffectorTranslator();
    00196         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00197     };
    00198
    00199     /**************************************************************************
    00200      * Compositor section
    00201      *************************************************************************/
    00202     class _OgreExport CompositorTranslator : public ScriptTranslator
    00203     {
    00204     protected:
    00205         Compositor *mCompositor;
    00206     public:
    00207         CompositorTranslator();
    00208         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00209     };
    00210     class _OgreExport CompositionTechniqueTranslator : public ScriptTranslator
    00211     {
    00212     protected:
    00213         CompositionTechnique *mTechnique;
    00214     public:
    00215         CompositionTechniqueTranslator();
    00216         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00217     };
    00218     class _OgreExport CompositionTargetPassTranslator : public ScriptTranslator
    00219     {
    00220     protected:
    00221         CompositionTargetPass *mTarget;
    00222     public:
    00223         CompositionTargetPassTranslator();
    00224         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00225     };
    00226     class _OgreExport CompositionPassTranslator : public ScriptTranslator
    00227     {
    00228     protected:
    00229         CompositionPass *mPass;
    00230     public:
    00231         CompositionPassTranslator();
    00232         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00233     };
    00234     class _OgreExport CompositionPassClearTranslator : public ScriptTranslator
    00235     {
    00236     protected:
    00237         CompositionPass *mPass;
    00238     public:
    00239         CompositionPassClearTranslator();
    00240         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00241     };
    00242     class _OgreExport CompositionPassStencilTranslator : public ScriptTranslator
    00243     {
    00244     protected:
    00245         CompositionPass *mPass;
    00246     public:
    00247         CompositionPassStencilTranslator();
    00248         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00249     };
    00250
    00251     /**************************************************************************
    00252      * BuiltinScriptTranslatorManager
    00253      *************************************************************************/
    00255     class _OgreExport BuiltinScriptTranslatorManager : public ScriptTranslatorManager
    00256     {
    00257     private:
    00258         MaterialTranslator mMaterialTranslator;
    00259         TechniqueTranslator mTechniqueTranslator;
    00260         PassTranslator mPassTranslator;
    00261         TextureUnitTranslator mTextureUnitTranslator;
    00262         TextureSourceTranslator mTextureSourceTranslator;
    00263         GpuProgramTranslator mGpuProgramTranslator;
    00264         ParticleSystemTranslator mParticleSystemTranslator;
    00265         ParticleEmitterTranslator mParticleEmitterTranslator;
    00266         ParticleAffectorTranslator mParticleAffectorTranslator;
    00267         CompositorTranslator mCompositorTranslator;
    00268         CompositionTechniqueTranslator mCompositionTechniqueTranslator;
    00269         CompositionTargetPassTranslator mCompositionTargetPassTranslator;
    00270         CompositionPassTranslator mCompositionPassTranslator;
    00271         CompositionPassClearTranslator mCompositionPassClearTranslator;
    00272         CompositionPassStencilTranslator mCompositionPassStencilTranslator;
    00273     public:
    00274         BuiltinScriptTranslatorManager();
    00276         virtual size_t getNumTranslators() const;
    00278         virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
    00279     };
    00280 }
    00281
    00282
    00283 #endif
    00284

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat Apr 11 14:26:47 2009