sceneData.h 3.9 KB

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