sceneData.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 _SCENEDATA_H_
  23. #define _SCENEDATA_H_
  24. #ifndef _SCENERENDERSTATE_H_
  25. #include "scene/sceneRenderState.h"
  26. #endif
  27. #ifndef _LIGHTMANAGER_H_
  28. #include "lighting/lightManager.h"
  29. #endif
  30. #ifndef _GFXDEVICE_H_
  31. #include "gfx/gfxDevice.h"
  32. #endif
  33. class GFXTexHandle;
  34. class GFXCubemap;
  35. struct SceneData
  36. {
  37. /// The special bin types.
  38. enum BinType
  39. {
  40. /// A normal render bin that isn't one of
  41. /// the special bins we care about.
  42. RegularBin = 0,
  43. /// The glow render bin.
  44. /// @see RenderGlowMgr
  45. GlowBin,
  46. /// The deferred render bin.
  47. /// @RenderDeferredMgr
  48. DeferredBin,
  49. /// The selection-highlight render bin.
  50. /// @afxRenderHighlightMgr
  51. HighlightBin,
  52. };
  53. /// This defines when we're rendering a special bin
  54. /// type that the material or lighting system needs
  55. /// to know about.
  56. BinType binType;
  57. // textures
  58. GFXTextureObject *lightmap;
  59. GFXTextureObject *backBuffTex;
  60. GFXTextureObject *reflectTex;
  61. GFXTextureObject *miscTex;
  62. GFXTextureObject *accuTex;
  63. /// The current lights to use in rendering
  64. /// in order of the light importance.
  65. LightInfo* lights[8];
  66. ///
  67. LinearColorF ambientLightColor;
  68. // fog
  69. F32 fogDensity;
  70. F32 fogDensityOffset;
  71. F32 fogHeightFalloff;
  72. LinearColorF fogColor;
  73. // misc
  74. const MatrixF *objTrans;
  75. GFXCubemap *cubemap;
  76. F32 visibility;
  77. /// Enables wireframe rendering for the object.
  78. bool wireframe;
  79. /// A generic hint value passed from the game
  80. /// code down to the material for use by shader
  81. /// features.
  82. void *materialHint;
  83. /// Constructor.
  84. SceneData()
  85. {
  86. dMemset( this, 0, sizeof( SceneData ) );
  87. objTrans = &MatrixF::Identity;
  88. visibility = 1.0f;
  89. }
  90. /// Initializes the data with the scene state setting
  91. /// common scene wide parameters.
  92. inline void init( const SceneRenderState *state, BinType type = RegularBin )
  93. {
  94. dMemset( this, 0, sizeof( SceneData ) );
  95. setFogParams( state->getSceneManager()->getFogData() );
  96. wireframe = GFXDevice::getWireframe();
  97. binType = type;
  98. objTrans = &MatrixF::Identity;
  99. visibility = 1.0f;
  100. ambientLightColor = state->getAmbientLightColor();
  101. }
  102. inline void setFogParams( const FogData &data )
  103. {
  104. fogDensity = data.density;
  105. fogDensityOffset = data.densityOffset;
  106. if ( !mIsZero( data.atmosphereHeight ) )
  107. fogHeightFalloff = 1.0f / data.atmosphereHeight;
  108. else
  109. fogHeightFalloff = 0.0f;
  110. fogColor = data.color;
  111. }
  112. };
  113. #endif // _SCENEDATA_H_