afxBillboard.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. enum TexFuncType {
  43. TexFuncReplace,
  44. TexFuncModulate,
  45. TexFuncAdd,
  46. };
  47. public:
  48. StringTableEntry txr_name;
  49. GFXTexHandle txr;
  50. LinearColorF color;
  51. Point2F texCoords[4];
  52. Point2F dimensions;
  53. S32 blendStyle;
  54. GFXBlend srcBlendFactor;
  55. GFXBlend dstBlendFactor;
  56. S32 texFunc;
  57. public:
  58. /*C*/ afxBillboardData();
  59. /*C*/ afxBillboardData(const afxBillboardData&, bool = false);
  60. virtual void packData(BitStream*);
  61. virtual void unpackData(BitStream*);
  62. bool preload(bool server, String &errorStr);
  63. virtual bool allowSubstitutions() const { return true; }
  64. static void initPersistFields();
  65. DECLARE_CONOBJECT(afxBillboardData);
  66. DECLARE_CATEGORY("AFX");
  67. };
  68. typedef afxBillboardData::BlendStyle afxBillboard_BlendStyle;
  69. DefineEnumType( afxBillboard_BlendStyle );
  70. typedef afxBillboardData::TexFuncType afxBillboard_TexFuncType;
  71. DefineEnumType( afxBillboard_TexFuncType );
  72. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  73. // afxBillboard
  74. class afxBillboard : public GameBase, public afxEffectDefs
  75. {
  76. typedef GameBase Parent;
  77. friend class afxEA_Billboard;
  78. private:
  79. afxBillboardData* mDataBlock;
  80. F32 fade_amt;
  81. bool is_visible;
  82. S8 sort_priority;
  83. LinearColorF live_color;
  84. GFXStateBlockRef normal_sb;
  85. GFXStateBlockRef reflected_sb;
  86. public:
  87. /*C*/ afxBillboard();
  88. /*D*/ ~afxBillboard();
  89. virtual bool onNewDataBlock(GameBaseData* dptr, bool reload);
  90. virtual bool onAdd();
  91. virtual void onRemove();
  92. void setFadeAmount(F32 amt) { fade_amt = amt; }
  93. void setSortPriority(S8 priority) { sort_priority = priority; }
  94. void setVisibility(bool flag) { is_visible = flag; }
  95. virtual void prepRenderImage(SceneRenderState*);
  96. void _renderBillboard(ObjectRenderInst*, SceneRenderState*, BaseMatInstance*);
  97. DECLARE_CONOBJECT(afxBillboard);
  98. DECLARE_CATEGORY("AFX");
  99. };
  100. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  101. #endif // _AFX_BILLBOARD_H_