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-2013 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 
00029 #ifndef __SCRIPTTRANSLATOR_H_
00030 #define __SCRIPTTRANSLATOR_H_
00031 
00032 #include "OgrePrerequisites.h"
00033 #include "OgreScriptCompiler.h"
00034 #include "OgreHeaderPrefix.h"
00035 
00036 namespace Ogre{
00048     class _OgreExport ScriptTranslator : public ScriptTranslatorAlloc
00049     {
00050     public:
00056         virtual void translate(ScriptCompiler *compiler, const AbstractNodePtr &node) = 0;
00057     protected:
00058         // needs virtual destructor
00059         virtual ~ScriptTranslator() {}
00061         void processNode(ScriptCompiler *compiler, const AbstractNodePtr &node);
00062 
00064         static AbstractNodeList::const_iterator getNodeAt(const AbstractNodeList &nodes, int index);
00066         static bool getBoolean(const AbstractNodePtr &node, bool *result);
00068         static bool getString(const AbstractNodePtr &node, String *result);
00070         static bool getReal(const AbstractNodePtr &node, Real *result);
00072         static bool getFloat(const AbstractNodePtr &node, float *result);
00074         static bool getInt(const AbstractNodePtr &node, int *result); 
00076         static bool getUInt(const AbstractNodePtr &node, uint32 *result); 
00078         static bool getColour(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, ColourValue *result, int maxEntries = 4);
00080         static bool getSceneBlendFactor(const AbstractNodePtr &node, SceneBlendFactor *sbf);
00082         static bool getCompareFunction(const AbstractNodePtr &node, CompareFunction *func);
00084         static bool getMatrix4(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, Matrix4 *m);
00086         static bool getInts(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, int *vals, int count);
00088         static bool getFloats(AbstractNodeList::const_iterator i, AbstractNodeList::const_iterator end, float *vals, int count);
00090         static bool getStencilOp(const AbstractNodePtr &node, StencilOperation *op); 
00092         static bool getConstantType(AbstractNodeList::const_iterator i, GpuConstantType *op); 
00093 
00094     };
00095 
00101     class ScriptTranslatorManager : public ScriptTranslatorAlloc
00102     {
00103     public:
00104         // required - virtual destructor
00105         virtual ~ScriptTranslatorManager() {}
00106 
00108         virtual size_t getNumTranslators() const = 0;
00110         virtual ScriptTranslator *getTranslator(const AbstractNodePtr&) = 0;
00111     };
00112 
00113     /**************************************************************************
00114      * Material compilation section
00115      *************************************************************************/
00116     class _OgreExport MaterialTranslator : public ScriptTranslator
00117     {
00118     protected:
00119         Material *mMaterial;
00120         Ogre::AliasTextureNamePairList mTextureAliases;
00121     public:
00122         MaterialTranslator();
00123         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00124     };
00125         
00126     class _OgreExport TechniqueTranslator : public ScriptTranslator
00127     {
00128     protected:
00129         Technique *mTechnique;
00130     public:
00131         TechniqueTranslator();
00132         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00133     };
00134     
00135     class _OgreExport PassTranslator : public ScriptTranslator
00136     {
00137     protected:
00138         Pass *mPass;
00139     public:
00140         PassTranslator();
00141         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00142     protected:
00143         void translateVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00144         void translateGeometryProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00145         void translateFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00146         void translateTesselationHullProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00147         void translateTesselationDomainProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00148         void translateComputeProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00149         void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00150         void translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00151         void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00152         void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
00153     };
00154 
00155     class _OgreExport TextureUnitTranslator : public ScriptTranslator
00156     {
00157     protected:
00158         TextureUnitState *mUnit;
00159     public:
00160         TextureUnitTranslator();
00161         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00162     };
00163 
00164     class _OgreExport TextureSourceTranslator : public ScriptTranslator
00165     {
00166     public:
00167         TextureSourceTranslator();
00168         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00169     };
00170 
00171     class _OgreExport GpuProgramTranslator : public ScriptTranslator
00172     {   
00173     public:
00174         GpuProgramTranslator();
00175         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00176     protected:
00177         void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
00178         void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
00179         void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
00180     public:
00181         static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
00182     };
00183 
00184     class _OgreExport SharedParamsTranslator : public ScriptTranslator
00185     {   
00186     public:
00187         SharedParamsTranslator();
00188         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00189     protected:
00190     };
00191 
00192     /**************************************************************************
00193      * Particle System section
00194      *************************************************************************/
00195     class _OgreExport ParticleSystemTranslator : public ScriptTranslator
00196     {
00197     protected:
00198         Ogre::ParticleSystem *mSystem;
00199     public:
00200         ParticleSystemTranslator();
00201         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00202     };
00203     class _OgreExport ParticleEmitterTranslator : public ScriptTranslator
00204     {
00205     protected:
00206         Ogre::ParticleEmitter *mEmitter;
00207     public:
00208         ParticleEmitterTranslator();
00209         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00210     };
00211     class _OgreExport ParticleAffectorTranslator : public ScriptTranslator
00212     {
00213     protected:
00214         Ogre::ParticleAffector *mAffector;
00215     public:
00216         ParticleAffectorTranslator();
00217         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00218     };
00219 
00220     /**************************************************************************
00221      * Compositor section
00222      *************************************************************************/
00223     class _OgreExport CompositorTranslator : public ScriptTranslator
00224     {
00225     protected:
00226         Compositor *mCompositor;
00227     public:
00228         CompositorTranslator();
00229         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00230     };
00231     class _OgreExport CompositionTechniqueTranslator : public ScriptTranslator
00232     {
00233     protected:
00234         CompositionTechnique *mTechnique;
00235     public:
00236         CompositionTechniqueTranslator();
00237         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00238     };
00239     class _OgreExport CompositionTargetPassTranslator : public ScriptTranslator
00240     {
00241     protected:
00242         CompositionTargetPass *mTarget;
00243     public:
00244         CompositionTargetPassTranslator();
00245         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00246     };
00247     class _OgreExport CompositionPassTranslator : public ScriptTranslator
00248     {
00249     protected:
00250         CompositionPass *mPass;
00251     public:
00252         CompositionPassTranslator();
00253         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
00254     };
00255 
00256     /**************************************************************************
00257      * BuiltinScriptTranslatorManager
00258      *************************************************************************/
00260     class _OgreExport BuiltinScriptTranslatorManager : public ScriptTranslatorManager
00261     {
00262     private:
00263         MaterialTranslator mMaterialTranslator;
00264         TechniqueTranslator mTechniqueTranslator;
00265         PassTranslator mPassTranslator;
00266         TextureUnitTranslator mTextureUnitTranslator;
00267         TextureSourceTranslator mTextureSourceTranslator;
00268         GpuProgramTranslator mGpuProgramTranslator;
00269         SharedParamsTranslator mSharedParamsTranslator;
00270         ParticleSystemTranslator mParticleSystemTranslator;
00271         ParticleEmitterTranslator mParticleEmitterTranslator;
00272         ParticleAffectorTranslator mParticleAffectorTranslator;
00273         CompositorTranslator mCompositorTranslator;
00274         CompositionTechniqueTranslator mCompositionTechniqueTranslator;
00275         CompositionTargetPassTranslator mCompositionTargetPassTranslator;
00276         CompositionPassTranslator mCompositionPassTranslator;
00277     public:
00278         BuiltinScriptTranslatorManager();
00280         virtual size_t getNumTranslators() const;
00282         virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
00283     };
00286 }
00287 
00288 #include "OgreHeaderSuffix.h"
00289 
00290 #endif
00291 

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:45