BillBoard.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright © 2011-2020 Frictional Games
  3. *
  4. * This file is part of Amnesia: A Machine For Pigs.
  5. *
  6. * Amnesia: A Machine For Pigs is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. * Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef HPL_BILLBOARD_H
  19. #define HPL_BILLBOARD_H
  20. #include "math/MathTypes.h"
  21. #include "graphics/GraphicsTypes.h"
  22. #include "system/SystemTypes.h"
  23. #include "scene/Entity3D.h"
  24. #include "graphics/Renderable.h"
  25. namespace hpl {
  26. class cMaterialManager;
  27. class cResources;
  28. class cGraphics;
  29. class iLowLevelGraphics;
  30. class cMaterial;
  31. class iVertexBuffer;
  32. //------------------------------------------
  33. class cBillboard : public iRenderable
  34. {
  35. #ifdef __GNUC__
  36. typedef iRenderable __super;
  37. #endif
  38. public:
  39. cBillboard(const tString asName,const cVector2f& avSize,eBillboardType aType, cResources *apResources,cGraphics *apGraphics);
  40. ~cBillboard();
  41. void SetMaterial(cMaterial * apMaterial);
  42. void SetSize(const cVector2f& avSize);
  43. cVector2f GetSize(){ return mvSize;}
  44. eBillboardType GetType(){ return mType;}
  45. void SetAxis(const cVector3f& avAxis);
  46. cVector3f GetAxis(){ return mvAxis;}
  47. void SetForwardOffset(float afOffset);
  48. float GetForwardOffset(){ return mfForwardOffset;}
  49. void SetColor(const cColor &aColor);
  50. const cColor& GetColor(){ return mColor;}
  51. void SetHaloAlpha(float afX);
  52. float GetHaloAlpha(){ return mfHaloAlpha;}
  53. /////////////////////////////////
  54. //Halo stuff
  55. void SetIsHalo(bool abX);
  56. bool IsHalo(){ return mbIsHalo;}
  57. void SetHaloSourceSize(const cVector3f &avSize);
  58. cVector3f GetHaloSourceSize(){return mvHaloSourceSize;}
  59. bool UsesOcclusionQuery();
  60. void AssignOcclusionQuery(iRenderer *apRenderer);
  61. bool RetrieveOcculsionQuery(iRenderer *apRenderer);
  62. /////////////////////////////////
  63. //Entity implementation
  64. tString GetEntityType(){ return "Billboard";}
  65. bool IsVisible();
  66. bool IsFullyTranslucent();
  67. //Renderable implementations
  68. cMaterial *GetMaterial(){ return mpMaterial;}
  69. iVertexBuffer* GetVertexBuffer(){return mpVtxBuffer;}
  70. cMatrixf* GetModelMatrix(cFrustum *apFrustum);
  71. int GetMatrixUpdateCount();
  72. eRenderableType GetRenderType(){ return eRenderableType_Billboard;}
  73. private:
  74. cMaterialManager* mpMaterialManager;
  75. iLowLevelGraphics* mpLowLevelGraphics;
  76. cMaterial *mpMaterial;
  77. iVertexBuffer* mpVtxBuffer;
  78. cMatrixf m_mtxHaloOcclusionMatrix;
  79. cMatrixf m_mtxTempTransform;
  80. eBillboardType mType;
  81. cVector2f mvSize;
  82. cVector3f mvAxis;
  83. int mlLastRenderCount;
  84. bool mbIsHalo;
  85. cVector3f mvHaloSourceSize;
  86. cBoundingVolume *mpHaloSourceBV;
  87. int mbHaloSizeUpdated;
  88. int mlHaloBVMatrixCount;
  89. float mfForwardOffset;
  90. cColor mColor;
  91. float mfHaloAlpha;
  92. };
  93. };
  94. #endif // HPL_BILLBOARD_H