afxBillboard.h 4.0 KB

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