afxBillboard.h 3.9 KB

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