basicClouds.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. #include "T3D/assets/ImageAsset.h"
  43. class BaseMatInstance;
  44. class BasicClouds : public SceneObject
  45. {
  46. typedef SceneObject Parent;
  47. enum
  48. {
  49. BasicCloudsMask = Parent::NextFreeMask,
  50. NextFreeMask = Parent::NextFreeMask << 1,
  51. };
  52. #define TEX_COUNT 3
  53. public:
  54. BasicClouds();
  55. virtual ~BasicClouds() {}
  56. DECLARE_CONOBJECT( BasicClouds );
  57. // ConsoleObject
  58. virtual bool onAdd();
  59. virtual void onRemove();
  60. static void initPersistFields();
  61. virtual void inspectPostApply();
  62. // NetObject
  63. virtual U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
  64. virtual void unpackUpdate( NetConnection *conn, BitStream *stream );
  65. // SceneObject
  66. virtual void prepRenderImage( SceneRenderState *state );
  67. void renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi );
  68. protected:
  69. void _initTexture();
  70. void _initBuffers();
  71. void _initBuffer( F32 height, GFXVertexBufferHandle<GFXVertexPT> *vb, GFXPrimitiveBufferHandle *pb );
  72. protected:
  73. static U32 smVertStride;
  74. static U32 smStrideMinusOne;
  75. static U32 smVertCount;
  76. static U32 smTriangleCount;
  77. DECLARE_IMAGEASSET_ARRAY(BasicClouds, Texture, TEX_COUNT);
  78. DECLARE_IMAGEASSET_ARRAY_NET_SETGET(BasicClouds, Texture, -1);
  79. GFXStateBlockRef mStateblock;
  80. GFXShaderRef mShader;
  81. GFXShaderConstBufferRef mShaderConsts;
  82. GFXShaderConstHandle *mTimeSC;
  83. GFXShaderConstHandle *mModelViewProjSC;
  84. GFXShaderConstHandle *mTexScaleSC;
  85. GFXShaderConstHandle *mTexDirectionSC;
  86. GFXShaderConstHandle *mTexOffsetSC;
  87. GFXShaderConstHandle *mDiffuseMapSC;
  88. GFXVertexBufferHandle<GFXVertexPT> mVB[TEX_COUNT];
  89. GFXPrimitiveBufferHandle mPB;
  90. // Fields...
  91. bool mLayerEnabled[TEX_COUNT];
  92. F32 mTexScale[TEX_COUNT];
  93. Point2F mTexDirection[TEX_COUNT];
  94. F32 mTexSpeed[TEX_COUNT];
  95. Point2F mTexOffset[TEX_COUNT];
  96. F32 mHeight[TEX_COUNT];
  97. };
  98. #endif // _BASICCLOUDS_H_