sceneData.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 prepass render bin.
  47. /// @RenderPrePassMgr
  48. PrePassBin,
  49. };
  50. /// This defines when we're rendering a special bin
  51. /// type that the material or lighting system needs
  52. /// to know about.
  53. BinType binType;
  54. // textures
  55. GFXTextureObject *lightmap;
  56. GFXTextureObject *backBuffTex;
  57. GFXTextureObject *reflectTex;
  58. GFXTextureObject *miscTex;
  59. GFXTextureObject *accuTex;
  60. /// The current lights to use in rendering
  61. /// in order of the light importance.
  62. LightInfo* lights[8];
  63. ///
  64. ColorF ambientLightColor;
  65. // fog
  66. F32 fogDensity;
  67. F32 fogDensityOffset;
  68. F32 fogHeightFalloff;
  69. ColorF fogColor;
  70. // misc
  71. const MatrixF *objTrans;
  72. GFXCubemap *cubemap;
  73. F32 visibility;
  74. /// Enables wireframe rendering for the object.
  75. bool wireframe;
  76. /// A generic hint value passed from the game
  77. /// code down to the material for use by shader
  78. /// features.
  79. void *materialHint;
  80. /// Constructor.
  81. SceneData()
  82. {
  83. dMemset( this, 0, sizeof( SceneData ) );
  84. objTrans = &MatrixF::Identity;
  85. visibility = 1.0f;
  86. }
  87. /// Initializes the data with the scene state setting
  88. /// common scene wide parameters.
  89. inline void init( const SceneRenderState *state, BinType type = RegularBin )
  90. {
  91. dMemset( this, 0, sizeof( SceneData ) );
  92. setFogParams( state->getSceneManager()->getFogData() );
  93. wireframe = GFXDevice::getWireframe();
  94. binType = type;
  95. objTrans = &MatrixF::Identity;
  96. visibility = 1.0f;
  97. ambientLightColor = state->getAmbientLightColor();
  98. }
  99. inline void setFogParams( const FogData &data )
  100. {
  101. fogDensity = data.density;
  102. fogDensityOffset = data.densityOffset;
  103. if ( !mIsZero( data.atmosphereHeight ) )
  104. fogHeightFalloff = 1.0f / data.atmosphereHeight;
  105. else
  106. fogHeightFalloff = 0.0f;
  107. fogColor = data.color;
  108. }
  109. };
  110. #endif // _SCENEDATA_H_