Torque3D Documentation / _generateds / processedFFMaterial.h

processedFFMaterial.h

Engine/source/materials/processedFFMaterial.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23#ifndef _MATERIALS_PROCESSEDFFMATERIAL_H_
 24#define _MATERIALS_PROCESSEDFFMATERIAL_H_
 25
 26#ifndef _MATERIALS_PROCESSEDMATERIAL_H_
 27#include "materials/processedMaterial.h"
 28#endif
 29
 30class LightInfo;
 31struct GFXShaderConstDesc;
 32
 33
 34/// Fixed function rendering.  Does not load or use shaders.  Does not rely on GFXMaterialFeatureData.
 35/// Tries very hard to not rely on anything possibly related to shaders. 
 36///
 37/// @note Does not always succeed.
 38class ProcessedFFMaterial : public ProcessedMaterial
 39{
 40   typedef ProcessedMaterial Parent;
 41public:
 42   ProcessedFFMaterial();
 43   ProcessedFFMaterial(Material &mat, const bool isLightingMaterial = false);
 44   ~ProcessedFFMaterial();
 45   /// @name Render state setting
 46   ///
 47   /// @{
 48
 49   /// Sets necessary textures and texture ops for rendering
 50   virtual void setTextureStages(SceneRenderState *, const SceneData &sgData, U32 pass );
 51
 52   virtual MaterialParameters* allocMaterialParameters();   
 53   virtual MaterialParameterHandle* getMaterialParameterHandle(const String& name);
 54   virtual MaterialParameters* getDefaultMaterialParameters();      
 55   
 56   virtual void setTransforms(const MatrixSet &matrixSet, SceneRenderState *state, const U32 pass);
 57   virtual void setNodeTransforms(const MatrixF *address, const U32 numTransforms, const U32 pass) {;}
 58
 59   virtual void setSceneInfo(SceneRenderState *, const SceneData& sgData, U32 pass);
 60
 61   /// @}
 62
 63   virtual bool init(   const FeatureSet &features, 
 64                        const GFXVertexFormat *vertexFormat,
 65                        const MatFeaturesDelegate &featuresDelegate );
 66
 67   /// Sets up the given pass
 68   ///
 69   /// @returns false if the pass could not be set up
 70   virtual bool setupPass(SceneRenderState *, const SceneData& sgData, U32 pass);
 71
 72   /// Returns the number of stages we're using (not to be confused with the number of passes)
 73   virtual U32 getNumStages();
 74
 75protected:
 76
 77   MaterialParameterHandle* mDefaultHandle;
 78   MaterialParameters* mDefaultParameters;
 79
 80   struct FixedFuncFeatureData
 81   {
 82      enum
 83      {
 84         DiffuseMap,
 85         LightMap,
 86         ToneMap,
 87         NumFeatures
 88      };
 89      bool features[NumFeatures];
 90   };
 91
 92   bool mIsLightingMaterial;
 93
 94   Vector<GFXShaderConstDesc> mParamDesc;   
 95
 96   /// @name Internal functions
 97   ///
 98   /// @{
 99
100   /// Adds a pass for the given stage
101   virtual void _addPass(U32 stageNum, FixedFuncFeatureData& featData);
102
103   /// Chooses a blend op for the pass during pass creation
104   virtual void _setPassBlendOp();
105
106   /// Creates all necessary passes for the given stage
107   void _createPasses( U32 stageNum, const FeatureSet &features );
108
109   /// Determine what features we need
110   void _determineFeatures(   U32 stageNum, 
111                              FixedFuncFeatureData &featData, 
112                              const FeatureSet &features);
113
114   /// Sets light info for the first light
115   virtual void _setPrimaryLightInfo(const MatrixF &objTrans, LightInfo* light, U32 pass);
116
117   /// Sets light info for the second light
118   virtual void _setSecondaryLightInfo(const MatrixF &objTrans, LightInfo* light);
119
120   /// Does the base render state block setting, normally per pass
121   virtual void _initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc &result );
122   /// @}
123
124   void _construct();
125};
126
127#endif
128