basicClouds.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 _BASICCLOUDS_H_
  23. #define _BASICCLOUDS_H_
  24. #ifndef _SCENEOBJECT_H_
  25. #include "scene/sceneObject.h"
  26. #endif
  27. #ifndef _GFXTEXTUREHANDLE_H_
  28. #include "gfx/gfxTextureHandle.h"
  29. #endif
  30. #ifndef _GFXVERTEXBUFFER_H_
  31. #include "gfx/gfxVertexBuffer.h"
  32. #endif
  33. #ifndef _GFXPRIMITIVEBUFFER_H_
  34. #include "gfx/gfxPrimitiveBuffer.h"
  35. #endif
  36. #ifndef _GFXSTATEBLOCK_H_
  37. #include "gfx/gfxStateBlock.h"
  38. #endif
  39. #ifndef _GFXSHADER_H_
  40. #include "gfx/gfxShader.h"
  41. #endif
  42. class BaseMatInstance;
  43. class BasicClouds : public SceneObject
  44. {
  45. typedef SceneObject Parent;
  46. enum
  47. {
  48. BasicCloudsMask = Parent::NextFreeMask,
  49. NextFreeMask = Parent::NextFreeMask << 1,
  50. };
  51. #define TEX_COUNT 3
  52. public:
  53. BasicClouds();
  54. virtual ~BasicClouds() {}
  55. DECLARE_CONOBJECT( BasicClouds );
  56. // ConsoleObject
  57. virtual bool onAdd();
  58. virtual void onRemove();
  59. static void initPersistFields();
  60. virtual void inspectPostApply();
  61. // NetObject
  62. virtual U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
  63. virtual void unpackUpdate( NetConnection *conn, BitStream *stream );
  64. // SceneObject
  65. virtual void prepRenderImage( SceneRenderState *state );
  66. void renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi );
  67. protected:
  68. void _initTexture();
  69. void _initBuffers();
  70. void _initBuffer( F32 height, GFXVertexBufferHandle<GFXVertexPT> *vb, GFXPrimitiveBufferHandle *pb );
  71. protected:
  72. static U32 smVertStride;
  73. static U32 smStrideMinusOne;
  74. static U32 smVertCount;
  75. static U32 smTriangleCount;
  76. GFXTexHandle mTexture[TEX_COUNT];
  77. GFXStateBlockRef mStateblock;
  78. GFXShaderRef mShader;
  79. GFXShaderConstBufferRef mShaderConsts;
  80. GFXShaderConstHandle *mTimeSC;
  81. GFXShaderConstHandle *mModelViewProjSC;
  82. GFXShaderConstHandle *mTexScaleSC;
  83. GFXShaderConstHandle *mTexDirectionSC;
  84. GFXShaderConstHandle *mTexOffsetSC;
  85. GFXShaderConstHandle *mDiffuseMapSC;
  86. GFXVertexBufferHandle<GFXVertexPT> mVB[TEX_COUNT];
  87. GFXPrimitiveBufferHandle mPB;
  88. // Fields...
  89. bool mLayerEnabled[TEX_COUNT];
  90. String mTexName[TEX_COUNT];
  91. F32 mTexScale[TEX_COUNT];
  92. Point2F mTexDirection[TEX_COUNT];
  93. F32 mTexSpeed[TEX_COUNT];
  94. Point2F mTexOffset[TEX_COUNT];
  95. F32 mHeight[TEX_COUNT];
  96. };
  97. #endif // _BASICCLOUDS_H_