Torque3D Documentation / _generateds / tsRenderState.h

tsRenderState.h

Engine/source/ts/tsRenderState.h

More...

Classes:

class

A simple class for passing render state through the pre-render pipeline.

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
 24#ifndef _TSRENDERDATA_H_
 25#define _TSRENDERDATA_H_
 26
 27#ifndef _MMATRIX_H_
 28#include "math/mMatrix.h"
 29#endif
 30
 31#ifndef _GFXDEVICE_H_
 32#include "gfx/gfxDevice.h"
 33#endif
 34
 35#ifndef _BASEMATINSTANCE_H_
 36#include "materials/baseMatInstance.h"
 37#endif
 38
 39class SceneRenderState;
 40class GFXCubemap;
 41class Frustum;
 42class LightQuery;
 43class TSShape;
 44
 45/// A simple class for passing render state through the pre-render pipeline.
 46///
 47/// @section TSRenderState_intro Introduction
 48///
 49/// TSRenderState holds on to certain pieces of data that may be
 50/// set at the preparation stage of rendering (prepRengerImage etc.)
 51/// which are needed further along in the process of submitting
 52/// a render instance for later rendering by the RenderManager.
 53///
 54/// It was created to clean up and refactor the DTS rendering
 55/// from having a large number of static data that would be used
 56/// in varying places.  These statics were confusing and would often
 57/// cause problems when not properly cleaned up by various objects after
 58/// submitting their RenderInstances.
 59///
 60/// @section TSRenderState_functionality What Does TSRenderState Do?
 61///
 62/// TSRenderState is a simple class that performs the function of passing along
 63/// (from the prep function(s) to the actual submission) the data 
 64/// needed for the desired state of rendering.
 65///
 66/// @section TSRenderState_example Usage Example
 67///
 68/// TSRenderState is very easy to use.  Merely create a TSRenderState object (in prepRenderImage usually)
 69/// and set any of the desired data members (SceneRenderState, camera transform etc.), and pass the address of
 70/// your TSRenderState to your render function.
 71///
 72class TSRenderState
 73{
 74protected:
 75   
 76   const SceneRenderState *mState;
 77
 78   GFXCubemap *mCubemap;
 79
 80   /// Used to override the normal
 81   /// fade value of an object.
 82   /// This is multiplied by the current
 83   /// fade value of the instance
 84   /// to gain the resulting visibility fade (see TSMesh::render()).
 85   F32 mFadeOverride;
 86
 87   /// These are used in some places
 88   /// TSShapeInstance::render, however,
 89   /// it appears they are never set to anything
 90   /// other than false.  We provide methods
 91   /// for setting them regardless.
 92   bool mNoRenderTranslucent;
 93   bool mNoRenderNonTranslucent;
 94
 95   /// A generic hint value passed from the game
 96   /// code down to the material for use by shader 
 97   /// features.
 98   void *mMaterialHint;
 99
100   /// An optional object space frustum used to cull
101   /// subobjects within the shape.
102   const Frustum *mCuller;
103
104   /// Use the origin point of the mesh for distance
105   /// sorting for transparency instead of the nearest
106   /// bounding box point.
107   bool mUseOriginSort;
108
109   /// The lighting query object used if any materials
110   /// are forward lit and need lights.
111   LightQuery *mLightQuery;
112
113   // The accumulation texture provided by an accumulation
114   // volume. This is passed down per-object.
115   GFXTextureObject* mAccuTex;
116
117   /// List of matrices to use for hardware skinning
118   MatrixF *mNodeTransforms;
119
120   /// Count of matrices in the mNodeTransforms list
121   U32 mNodeTransformCount;
122
123   //Custom Shader data
124   Vector<CustomShaderBindingData> mCustomShaderData;
125
126public:
127   TSRenderState();
128   TSRenderState( const TSRenderState &state );
129
130   /// @name Get/Set methods.
131   /// @{
132
133   ///@see mState
134   const SceneRenderState* getSceneState() const { return mState; }
135   void setSceneState( const SceneRenderState *state ) { mState = state; }
136
137   ///@see mCubemap
138   GFXCubemap* getCubemap() const { return mCubemap; }
139   void setCubemap( GFXCubemap *cubemap ) { mCubemap = cubemap; }
140
141   ///@see mFadeOverride
142   F32 getFadeOverride() const { return mFadeOverride; }
143   void setFadeOverride( F32 fade ) { mFadeOverride = fade; }
144
145   ///@see mNoRenderTranslucent
146   bool isNoRenderTranslucent() const { return mNoRenderTranslucent; }
147   void setNoRenderTranslucent( bool noRenderTrans ) { mNoRenderTranslucent = noRenderTrans; }
148
149   ///@see mNoRenderNonTranslucent
150   bool isNoRenderNonTranslucent() const { return mNoRenderNonTranslucent; }
151   void setNoRenderNonTranslucent( bool noRenderNonTrans ) { mNoRenderNonTranslucent = noRenderNonTrans; }
152
153   ///@see mMaterialHint
154   void* getMaterialHint() const { return mMaterialHint; }
155   void setMaterialHint( void *materialHint ) { mMaterialHint = materialHint; }
156
157   ///@see mCuller
158   const Frustum* getCuller() const { return mCuller; }
159   void setCuller( const  Frustum *culler ) { mCuller = culler; }
160
161   ///@see mUseOriginSort
162   void setOriginSort( bool enable ) { mUseOriginSort = enable; }
163   bool useOriginSort() const { return mUseOriginSort; }
164
165   ///@see mLightQuery
166   void setLightQuery( LightQuery *query ) { mLightQuery = query; }
167   LightQuery* getLightQuery() const { return mLightQuery; }
168
169   ///@see mAccuTex
170   void setAccuTex( GFXTextureObject* query ) { mAccuTex = query; }
171   GFXTextureObject* getAccuTex() const { return mAccuTex; }
172
173   void addCustomShaderBinding(CustomShaderBindingData data)
174   {
175      mCustomShaderData.push_back(data);
176   }
177   Vector<CustomShaderBindingData> getCustomShaderBinding() const 
178   { 
179      return mCustomShaderData; 
180   }
181
182   ///@ see mNodeTransforms, mNodeTransformCount
183   void setNodeTransforms(MatrixF *list, U32 count) { mNodeTransforms = list; mNodeTransformCount = count; }
184   void getNodeTransforms(MatrixF **list, U32 *count) const { *list = mNodeTransforms; *count = mNodeTransformCount; }
185
186   /// @}
187};
188
189#endif // _TSRENDERDATA_H_
190