Smudge.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // FILE: Smudge.h /////////////////////////////////////////////////////////
  19. #pragma once
  20. #ifndef _SMUDGE_H_
  21. #define _SMUDGE_H_
  22. #include "WW3D2/dllist.h"
  23. #include "WWMATH/Vector2.h"
  24. #include "WWMATH/Vector3.h"
  25. #define SET_SMUDGE_PARAMETERS(smudge,pos,offset,size,opacity) (smudge->m_pos=pos;smudge->m_offset=offset;smudge->m_size=size;smudge->m_opacity=opacity;)
  26. struct Smudge : public DLNodeClass<Smudge>
  27. {
  28. W3DMPO_GLUE(Smudge)
  29. Vector3 m_pos; //position of smudge center
  30. Vector2 m_offset; // difference in position between "texture" extraction and re-insertion for center vertex
  31. Real m_size; //size of smudge in world space.
  32. Real m_opacity; //alpha of center vertex, corners are assumed at 0
  33. struct smudgeVertex
  34. { Vector3 pos; //world-space position of vertex
  35. Vector2 uv; //uv coordinates of vertex
  36. };
  37. smudgeVertex m_verts[5]; //5 vertices of this smudge (in counter-clockwise order, starting at top-left, ending in center.)
  38. };
  39. struct SmudgeSet : public DLNodeClass<SmudgeSet>
  40. {
  41. W3DMPO_GLUE(SmudgeSet)
  42. public:
  43. friend class SmudgeManager;
  44. SmudgeSet( void );
  45. virtual ~SmudgeSet();
  46. void reset(void);
  47. Smudge *addSmudgeToSet(void);
  48. void removeSmudgeFromSet ( Smudge &mySmudge);
  49. DLListClass<Smudge> &getUsedSmudgeList( void ) { return m_usedSmudgeList;}
  50. Int getUsedSmudgeCount(void) { return m_usedSmudgeCount; } ///<active smudges that need rendering.
  51. private:
  52. DLListClass<Smudge> m_usedSmudgeList; ///<list of smudges in this set.
  53. static DLListClass<Smudge> m_freeSmudgeList; ///<list of unused smudges for use by SmudgeSets.
  54. Int m_usedSmudgeCount;
  55. };
  56. class SmudgeManager
  57. {
  58. public:
  59. SmudgeManager( void );
  60. virtual ~SmudgeManager();
  61. virtual void init(void);
  62. virtual void reset (void);
  63. virtual void ReleaseResources(void) {}
  64. virtual void ReAcquireResources(void) {}
  65. SmudgeSet *addSmudgeSet(void);
  66. void removeSmudgeSet(SmudgeSet &mySmudge);
  67. inline Int getSmudgeCountLastFrame(void) {return m_smudgeCountLastFrame;} ///<return number of smudges submitted last frame.
  68. inline void setSmudgeCountLastFrame(Int count) { m_smudgeCountLastFrame = count;}
  69. inline Bool getHardwareSupport(void) { return m_hardwareSupportStatus != SMUDGE_SUPPORT_NO;}
  70. protected:
  71. enum HardwareSmudgeSupport {SMUDGE_SUPPORT_UNKNOWN,SMUDGE_SUPPORT_NO,SMUDGE_SUPPORT_YES};
  72. HardwareSmudgeSupport m_hardwareSupportStatus;///< flag whether we verified that the effect is supported by hardware.
  73. DLListClass<SmudgeSet> m_usedSmudgeSetList; ///<used SmudgeSets
  74. DLListClass<SmudgeSet> m_freeSmudgeSetList; ///<unused SmudgeSets ready for re-use.
  75. Int m_smudgeCountLastFrame; //number of total smudges in manager last frame.
  76. };
  77. extern SmudgeManager *TheSmudgeManager; ///<singleton
  78. #endif //_SMUDGE_H_