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-2012 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 translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00147         void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00148         void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node);
    00149     };
    00150
    00151     class _OgreExport TextureUnitTranslator : public ScriptTranslator
    00152     {
    00153     protected:
    00154         TextureUnitState *mUnit;
    00155     public:
    00156         TextureUnitTranslator();
    00157         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00158     };
    00159
    00160     class _OgreExport TextureSourceTranslator : public ScriptTranslator
    00161     {
    00162     public:
    00163         TextureSourceTranslator();
    00164         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00165     };
    00166
    00167     class _OgreExport GpuProgramTranslator : public ScriptTranslator
    00168     {
    00169     public:
    00170         GpuProgramTranslator();
    00171         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00172     protected:
    00173         void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
    00174         void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
    00175         void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj);
    00176     public:
    00177         static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj);
    00178     };
    00179
    00180     class _OgreExport SharedParamsTranslator : public ScriptTranslator
    00181     {
    00182     public:
    00183         SharedParamsTranslator();
    00184         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00185     protected:
    00186     };
    00187
    00188     /**************************************************************************
    00189      * Particle System section
    00190      *************************************************************************/
    00191     class _OgreExport ParticleSystemTranslator : public ScriptTranslator
    00192     {
    00193     protected:
    00194         Ogre::ParticleSystem *mSystem;
    00195     public:
    00196         ParticleSystemTranslator();
    00197         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00198     };
    00199     class _OgreExport ParticleEmitterTranslator : public ScriptTranslator
    00200     {
    00201     protected:
    00202         Ogre::ParticleEmitter *mEmitter;
    00203     public:
    00204         ParticleEmitterTranslator();
    00205         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00206     };
    00207     class _OgreExport ParticleAffectorTranslator : public ScriptTranslator
    00208     {
    00209     protected:
    00210         Ogre::ParticleAffector *mAffector;
    00211     public:
    00212         ParticleAffectorTranslator();
    00213         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00214     };
    00215
    00216     /**************************************************************************
    00217      * Compositor section
    00218      *************************************************************************/
    00219     class _OgreExport CompositorTranslator : public ScriptTranslator
    00220     {
    00221     protected:
    00222         Compositor *mCompositor;
    00223     public:
    00224         CompositorTranslator();
    00225         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00226     };
    00227     class _OgreExport CompositionTechniqueTranslator : public ScriptTranslator
    00228     {
    00229     protected:
    00230         CompositionTechnique *mTechnique;
    00231     public:
    00232         CompositionTechniqueTranslator();
    00233         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00234     };
    00235     class _OgreExport CompositionTargetPassTranslator : public ScriptTranslator
    00236     {
    00237     protected:
    00238         CompositionTargetPass *mTarget;
    00239     public:
    00240         CompositionTargetPassTranslator();
    00241         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00242     };
    00243     class _OgreExport CompositionPassTranslator : public ScriptTranslator
    00244     {
    00245     protected:
    00246         CompositionPass *mPass;
    00247     public:
    00248         CompositionPassTranslator();
    00249         void translate(ScriptCompiler *compiler, const AbstractNodePtr &node);
    00250     };
    00251
    00252     /**************************************************************************
    00253      * BuiltinScriptTranslatorManager
    00254      *************************************************************************/
    00256     class _OgreExport BuiltinScriptTranslatorManager : public ScriptTranslatorManager
    00257     {
    00258     private:
    00259         MaterialTranslator mMaterialTranslator;
    00260         TechniqueTranslator mTechniqueTranslator;
    00261         PassTranslator mPassTranslator;
    00262         TextureUnitTranslator mTextureUnitTranslator;
    00263         TextureSourceTranslator mTextureSourceTranslator;
    00264         GpuProgramTranslator mGpuProgramTranslator;
    00265         SharedParamsTranslator mSharedParamsTranslator;
    00266         ParticleSystemTranslator mParticleSystemTranslator;
    00267         ParticleEmitterTranslator mParticleEmitterTranslator;
    00268         ParticleAffectorTranslator mParticleAffectorTranslator;
    00269         CompositorTranslator mCompositorTranslator;
    00270         CompositionTechniqueTranslator mCompositionTechniqueTranslator;
    00271         CompositionTargetPassTranslator mCompositionTargetPassTranslator;
    00272         CompositionPassTranslator mCompositionPassTranslator;
    00273     public:
    00274         BuiltinScriptTranslatorManager();
    00276         virtual size_t getNumTranslators() const;
    00278         virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node);
    00279     };
    00282 }
    00283
    00284
    00285 #endif
    00286

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:23