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

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52