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