1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2014 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 29 #ifndef __BUILTIN_SCRIPTTRANSLATORS_H_ 30 #define __BUILTIN_SCRIPTTRANSLATORS_H_ 31 32 #include "OgreScriptTranslator.h" 33 34 namespace Ogre{ 35 /************************************************************************** 36 * Material compilation section 37 *************************************************************************/ 38 class MaterialTranslator : public ScriptTranslator 39 { 40 protected: 41 Material *mMaterial; 42 Ogre::AliasTextureNamePairList mTextureAliases; 43 public: 44 MaterialTranslator(); 45 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 46 }; 47 48 class TechniqueTranslator : public ScriptTranslator 49 { 50 protected: 51 Technique *mTechnique; 52 public: 53 TechniqueTranslator(); 54 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 55 }; 56 57 class PassTranslator : public ScriptTranslator 58 { 59 protected: 60 Pass *mPass; 61 public: 62 PassTranslator(); 63 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 64 protected: 65 void translateProgramRef(GpuProgramType type, ScriptCompiler *compiler, ObjectAbstractNode *node); 66 void translateShadowCasterVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node); 67 void translateShadowCasterFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node); 68 void translateShadowReceiverVertexProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node); 69 void translateShadowReceiverFragmentProgramRef(ScriptCompiler *compiler, ObjectAbstractNode *node); 70 }; 71 72 class TextureUnitTranslator : public ScriptTranslator 73 { 74 protected: 75 TextureUnitState *mUnit; 76 public: 77 TextureUnitTranslator(); 78 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 79 }; 80 81 struct SamplerTranslator : public ScriptTranslator 82 { 83 static void translateSamplerParam(ScriptCompiler *compiler, const SamplerPtr& sampler, PropertyAbstractNode* node); 84 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 85 }; 86 87 class TextureSourceTranslator : public ScriptTranslator 88 { 89 public: 90 TextureSourceTranslator(); 91 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 92 }; 93 94 class GpuProgramTranslator : public ScriptTranslator 95 { 96 public: 97 GpuProgramTranslator(); 98 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 99 protected: 100 void translateGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj); 101 void translateHighLevelGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj); 102 void translateUnifiedGpuProgram(ScriptCompiler *compiler, ObjectAbstractNode *obj); 103 public: 104 static void translateProgramParameters(ScriptCompiler *compiler, GpuProgramParametersSharedPtr params, ObjectAbstractNode *obj); 105 }; 106 107 class SharedParamsTranslator : public ScriptTranslator 108 { 109 public: 110 SharedParamsTranslator(); 111 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 112 protected: 113 }; 114 115 /************************************************************************** 116 * Particle System section 117 *************************************************************************/ 118 class ParticleSystemTranslator : public ScriptTranslator 119 { 120 protected: 121 Ogre::ParticleSystem *mSystem; 122 public: 123 ParticleSystemTranslator(); 124 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 125 }; 126 class ParticleEmitterTranslator : public ScriptTranslator 127 { 128 protected: 129 Ogre::ParticleEmitter *mEmitter; 130 public: 131 ParticleEmitterTranslator(); 132 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 133 }; 134 class ParticleAffectorTranslator : public ScriptTranslator 135 { 136 protected: 137 Ogre::ParticleAffector *mAffector; 138 public: 139 ParticleAffectorTranslator(); 140 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 141 }; 142 143 /************************************************************************** 144 * Compositor section 145 *************************************************************************/ 146 class CompositorTranslator : public ScriptTranslator 147 { 148 protected: 149 Compositor *mCompositor; 150 public: 151 CompositorTranslator(); 152 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 153 }; 154 class CompositionTechniqueTranslator : public ScriptTranslator 155 { 156 protected: 157 CompositionTechnique *mTechnique; 158 public: 159 CompositionTechniqueTranslator(); 160 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 161 }; 162 class CompositionTargetPassTranslator : public ScriptTranslator 163 { 164 protected: 165 CompositionTargetPass *mTarget; 166 public: 167 CompositionTargetPassTranslator(); 168 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 169 }; 170 class CompositionPassTranslator : public ScriptTranslator 171 { 172 protected: 173 CompositionPass *mPass; 174 public: 175 CompositionPassTranslator(); 176 void translate(ScriptCompiler *compiler, const AbstractNodePtr &node); 177 }; 178 /************************************************************************** 179 * BuiltinScriptTranslatorManager 180 *************************************************************************/ 181 /// This class manages the builtin translators 182 class BuiltinScriptTranslatorManager : public ScriptTranslatorManager 183 { 184 private: 185 MaterialTranslator mMaterialTranslator; 186 TechniqueTranslator mTechniqueTranslator; 187 PassTranslator mPassTranslator; 188 TextureUnitTranslator mTextureUnitTranslator; 189 SamplerTranslator mSamplerTranslator; 190 TextureSourceTranslator mTextureSourceTranslator; 191 GpuProgramTranslator mGpuProgramTranslator; 192 SharedParamsTranslator mSharedParamsTranslator; 193 ParticleSystemTranslator mParticleSystemTranslator; 194 ParticleEmitterTranslator mParticleEmitterTranslator; 195 ParticleAffectorTranslator mParticleAffectorTranslator; 196 CompositorTranslator mCompositorTranslator; 197 CompositionTechniqueTranslator mCompositionTechniqueTranslator; 198 CompositionTargetPassTranslator mCompositionTargetPassTranslator; 199 CompositionPassTranslator mCompositionPassTranslator; 200 public: 201 BuiltinScriptTranslatorManager(); 202 /// Returns a manager for the given object abstract node, or null if it is not supported 203 virtual ScriptTranslator *getTranslator(const AbstractNodePtr &node); 204 }; 205 } 206 207 #endif 208 209