afxBillboard.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #ifndef _AFX_BILLBOARD_H_
  25. #define _AFX_BILLBOARD_H_
  26. #include "afx/afxEffectDefs.h"
  27. #define BLEND_UNDEFINED GFXBlend_COUNT
  28. class afxBillboardData : public GameBaseData, public afxEffectDefs
  29. {
  30. typedef GameBaseData Parent;
  31. public:
  32. // This enum specifies common blend settings with predefined values
  33. // for src/dst blend factors.
  34. enum BlendStyle {
  35. BlendUndefined,
  36. BlendNormal,
  37. BlendAdditive,
  38. BlendSubtractive,
  39. BlendPremultAlpha,
  40. BlendUser,
  41. };
  42. public:
  43. DECLARE_IMAGEASSET(afxBillboardData, Texture, onChangeTexture, GFXStaticTextureSRGBProfile);
  44. DECLARE_ASSET_SETGET(afxBillboardData, Texture);
  45. LinearColorF color;
  46. Point2F texCoords[4];
  47. Point2F dimensions;
  48. S32 blendStyle;
  49. GFXBlend srcBlendFactor;
  50. GFXBlend dstBlendFactor;
  51. public:
  52. /*C*/ afxBillboardData();
  53. /*C*/ afxBillboardData(const afxBillboardData&, bool = false);
  54. virtual void packData(BitStream*);
  55. virtual void unpackData(BitStream*);
  56. bool preload(bool server, String &errorStr);
  57. virtual bool allowSubstitutions() const { return true; }
  58. static void initPersistFields();
  59. void onChangeTexture() {}
  60. DECLARE_CONOBJECT(afxBillboardData);
  61. DECLARE_CATEGORY("AFX");
  62. };
  63. typedef afxBillboardData::BlendStyle afxBillboard_BlendStyle;
  64. DefineEnumType( afxBillboard_BlendStyle );
  65. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  66. // afxBillboard
  67. class afxBillboard : public GameBase, public afxEffectDefs
  68. {
  69. typedef GameBase Parent;
  70. friend class afxEA_Billboard;
  71. private:
  72. afxBillboardData* mDataBlock;
  73. F32 fade_amt;
  74. bool is_visible;
  75. S8 sort_priority;
  76. LinearColorF live_color;
  77. GFXStateBlockRef normal_sb;
  78. GFXStateBlockRef reflected_sb;
  79. public:
  80. /*C*/ afxBillboard();
  81. /*D*/ ~afxBillboard();
  82. virtual bool onNewDataBlock(GameBaseData* dptr, bool reload);
  83. virtual bool onAdd();
  84. virtual void onRemove();
  85. void setFadeAmount(F32 amt) { fade_amt = amt; }
  86. void setSortPriority(S8 priority) { sort_priority = priority; }
  87. void setVisibility(bool flag) { is_visible = flag; }
  88. virtual void prepRenderImage(SceneRenderState*);
  89. void _renderBillboard(ObjectRenderInst*, SceneRenderState*, BaseMatInstance*);
  90. DECLARE_CONOBJECT(afxBillboard);
  91. DECLARE_CATEGORY("AFX");
  92. };
  93. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  94. #endif // _AFX_BILLBOARD_H_