skyBox.h 3.3 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 _SKYBOX_H_
  23. #define _SKYBOX_H_
  24. #ifndef _SCENEOBJECT_H_
  25. #include "scene/sceneObject.h"
  26. #endif
  27. #ifndef _GFXDEVICE_H_
  28. #include "gfx/gfxDevice.h"
  29. #endif
  30. #ifndef _CUBEMAPDATA_H_
  31. #include "gfx/sim/cubemapData.h"
  32. #endif
  33. #ifndef _MATERIALLIST_H_
  34. #include "materials/materialList.h"
  35. #endif
  36. #ifndef _GFXVERTEXBUFFER_H_
  37. #include "gfx/gfxVertexBuffer.h"
  38. #endif
  39. #ifndef _GFXPRIMITIVEBUFFER_H_
  40. #include "gfx/gfxPrimitiveBuffer.h"
  41. #endif
  42. #include "T3D/assets/MaterialAsset.h"
  43. GFXDeclareVertexFormat( GFXSkyVertex )
  44. {
  45. Point3F point;
  46. Point3F normal;
  47. GFXVertexColor color;
  48. };
  49. struct SkyMatParams
  50. {
  51. void init( BaseMatInstance *matInst ) {};
  52. };
  53. class MatrixSet;
  54. class SkyBox : public SceneObject
  55. {
  56. typedef SceneObject Parent;
  57. public:
  58. SkyBox();
  59. virtual ~SkyBox();
  60. DECLARE_CONOBJECT( SkyBox );
  61. // SimObject
  62. void onStaticModified( const char *slotName, const char *newValue );
  63. // ConsoleObject
  64. virtual bool onAdd();
  65. virtual void onRemove();
  66. static void initPersistFields();
  67. virtual void inspectPostApply();
  68. // NetObject
  69. virtual U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
  70. virtual void unpackUpdate( NetConnection *conn, BitStream *stream );
  71. // SceneObject
  72. void prepRenderImage( SceneRenderState* state );
  73. /// Our render delegate.
  74. void _renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi );
  75. /// Prepares rendering structures and geometry.
  76. void _initRender();
  77. protected:
  78. // Material
  79. DECLARE_MATERIALASSET(SkyBox, Material);
  80. DECLARE_ASSET_NET_SETGET(SkyBox, Material, -1);
  81. BaseMatInstance *mMatInstance;
  82. SkyMatParams mMatParamHandle;
  83. GFXVertexBufferHandle<GFXVertexPNT> mVB;
  84. GFXVertexBufferHandle<GFXVertexPC> mFogBandVB;
  85. Material *mFogBandMat;
  86. BaseMatInstance *mFogBandMatInst;
  87. LinearColorF mLastFogColor;
  88. bool mDrawBottom;
  89. bool mIsVBDirty;
  90. U32 mPrimCount;
  91. MatrixSet *mMatrixSet;
  92. F32 mFogBandHeight;
  93. void _updateMaterial();
  94. void _initMaterial();
  95. BaseMatInstance* _getMaterialInstance();
  96. };
  97. #endif // _SKYBOX_H_