tsRenderState.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _TSRENDERDATA_H_
  23. #define _TSRENDERDATA_H_
  24. #ifndef _MMATRIX_H_
  25. #include "math/mMatrix.h"
  26. #endif
  27. class SceneRenderState;
  28. class GFXCubemap;
  29. class Frustum;
  30. class LightQuery;
  31. /// A simple class for passing render state through the pre-render pipeline.
  32. ///
  33. /// @section TSRenderState_intro Introduction
  34. ///
  35. /// TSRenderState holds on to certain pieces of data that may be
  36. /// set at the preparation stage of rendering (prepRengerImage etc.)
  37. /// which are needed further along in the process of submitting
  38. /// a render instance for later rendering by the RenderManager.
  39. ///
  40. /// It was created to clean up and refactor the DTS rendering
  41. /// from having a large number of static data that would be used
  42. /// in varying places. These statics were confusing and would often
  43. /// cause problems when not properly cleaned up by various objects after
  44. /// submitting their RenderInstances.
  45. ///
  46. /// @section TSRenderState_functionality What Does TSRenderState Do?
  47. ///
  48. /// TSRenderState is a simple class that performs the function of passing along
  49. /// (from the prep function(s) to the actual submission) the data
  50. /// needed for the desired state of rendering.
  51. ///
  52. /// @section TSRenderState_example Usage Example
  53. ///
  54. /// TSRenderState is very easy to use. Merely create a TSRenderState object (in prepRenderImage usually)
  55. /// and set any of the desired data members (SceneRenderState, camera transform etc.), and pass the address of
  56. /// your TSRenderState to your render function.
  57. ///
  58. class TSRenderState
  59. {
  60. protected:
  61. const SceneRenderState *mState;
  62. GFXCubemap *mCubemap;
  63. /// Used to override the normal
  64. /// fade value of an object.
  65. /// This is multiplied by the current
  66. /// fade value of the instance
  67. /// to gain the resulting visibility fade (see TSMesh::render()).
  68. F32 mFadeOverride;
  69. /// These are used in some places
  70. /// TSShapeInstance::render, however,
  71. /// it appears they are never set to anything
  72. /// other than false. We provide methods
  73. /// for setting them regardless.
  74. bool mNoRenderTranslucent;
  75. bool mNoRenderNonTranslucent;
  76. /// A generic hint value passed from the game
  77. /// code down to the material for use by shader
  78. /// features.
  79. void *mMaterialHint;
  80. /// An optional object space frustum used to cull
  81. /// subobjects within the shape.
  82. const Frustum *mCuller;
  83. /// Use the origin point of the mesh for distance
  84. /// sorting for transparency instead of the nearest
  85. /// bounding box point.
  86. bool mUseOriginSort;
  87. /// The lighting query object used if any materials
  88. /// are forward lit and need lights.
  89. LightQuery *mLightQuery;
  90. public:
  91. TSRenderState();
  92. TSRenderState( const TSRenderState &state );
  93. /// @name Get/Set methods.
  94. /// @{
  95. ///@see mState
  96. const SceneRenderState* getSceneState() const { return mState; }
  97. void setSceneState( const SceneRenderState *state ) { mState = state; }
  98. ///@see mCubemap
  99. GFXCubemap* getCubemap() const { return mCubemap; }
  100. void setCubemap( GFXCubemap *cubemap ) { mCubemap = cubemap; }
  101. ///@see mFadeOverride
  102. F32 getFadeOverride() const { return mFadeOverride; }
  103. void setFadeOverride( F32 fade ) { mFadeOverride = fade; }
  104. ///@see mNoRenderTranslucent
  105. bool isNoRenderTranslucent() const { return mNoRenderTranslucent; }
  106. void setNoRenderTranslucent( bool noRenderTrans ) { mNoRenderTranslucent = noRenderTrans; }
  107. ///@see mNoRenderNonTranslucent
  108. bool isNoRenderNonTranslucent() const { return mNoRenderNonTranslucent; }
  109. void setNoRenderNonTranslucent( bool noRenderNonTrans ) { mNoRenderNonTranslucent = noRenderNonTrans; }
  110. ///@see mMaterialHint
  111. void* getMaterialHint() const { return mMaterialHint; }
  112. void setMaterialHint( void *materialHint ) { mMaterialHint = materialHint; }
  113. ///@see mCuller
  114. const Frustum* getCuller() const { return mCuller; }
  115. void setCuller( const Frustum *culler ) { mCuller = culler; }
  116. ///@see mUseOriginSort
  117. void setOriginSort( bool enable ) { mUseOriginSort = enable; }
  118. bool useOriginSort() const { return mUseOriginSort; }
  119. ///@see mLightQuery
  120. void setLightQuery( LightQuery *query ) { mLightQuery = query; }
  121. LightQuery* getLightQuery() const { return mLightQuery; }
  122. /// @}
  123. };
  124. #endif // _TSRENDERDATA_H_