ParticleEmitter_UserData.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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_PARTICLE_EMITTER_USER_DATA_H
  19. #define HPL_PARTICLE_EMITTER_USER_DATA_H
  20. #include "scene/ParticleEmitter.h"
  21. #include "physics/PhysicsTypes.h"
  22. class TiXmlElement;
  23. namespace hpl {
  24. class cXmlElement;
  25. enum ePEStartPosType
  26. {
  27. ePEStartPosType_Box,
  28. ePEStartPosType_Sphere,
  29. ePEStartPosType_LastEnum,
  30. };
  31. enum ePEDeathType
  32. {
  33. ePEDeathType_Age,
  34. ePEDeathType_Color,
  35. ePEDeathType_LastEnum,
  36. };
  37. enum ePEGravityType
  38. {
  39. ePEGravityType_None, //No gravity added
  40. ePEGravityType_Vector, //Vector is used.
  41. ePEGravityType_Center, //Y axis used. heading equals center.
  42. ePEGravityType_LastEnum,
  43. };
  44. enum ePESubDivType
  45. {
  46. ePESubDivType_Random,
  47. ePESubDivType_Animation,
  48. ePESubDivType_LastEnum,
  49. };
  50. enum ePEPartSpinType
  51. {
  52. ePEPartSpinType_Constant,
  53. ePEPartSpinType_Movement,
  54. ePEPartSpinType_LastEnum,
  55. };
  56. //------------------------------------
  57. class iPhysicsWorld;
  58. //------------------------------------
  59. class cParticleEmitterData_UserData : public iParticleEmitterData, public iPhysicsRayCallback
  60. {
  61. friend class cParticleEmitter_UserData;
  62. public:
  63. cParticleEmitterData_UserData(const tString &asName,cResources* apResources,cGraphics *apGraphics);
  64. iParticleEmitter* Create(tString asName, cVector3f avSize);
  65. void LoadFromElement(cXmlElement *apElement);
  66. bool CheckCollision(const cVector3f& avStart, const cVector3f &avEnd,
  67. iPhysicsWorld *apPhysicsWorld,
  68. cVector3f *apNormalVec,
  69. cVector3f *apPosVec);
  70. private:
  71. bool OnIntersect(iPhysicsBody *pBody,cPhysicsRayParams *apParams);
  72. float mfShortestDist;
  73. bool mbIntersected;
  74. cVector3f *mpIntersectNormal;
  75. cVector3f *mpIntersectPos;
  76. ///////// GENERAL /////////////
  77. // NEW
  78. ePEType mPEType;
  79. // ---
  80. int mlMaxParticleNum;
  81. bool mbRespawn;
  82. float mfParticlesPerSecond;
  83. float mfStartTimeOffset;
  84. float mfMinPauseLength;
  85. float mfMaxPauseLength;
  86. float mfMinPauseInterval;
  87. float mfMaxPauseInterval;
  88. cVector3f mvPosOffset;
  89. cVector3f mvAngleOffset;
  90. float mfFrameStep;
  91. float mfMaxFrameTime;
  92. ///////// MATERIAL //////////
  93. cVector2l mvSubDiv;
  94. ePESubDivType mSubDivType;
  95. ///////// START POS //////////
  96. ePEStartPosType mStartPosType;
  97. cVector3f mvMinStartPos;
  98. cVector3f mvMaxStartPos;
  99. cVector2f mvMinStartAngles;
  100. cVector2f mvMaxStartAngles;
  101. float mfMinStartRadius;
  102. float mfMaxStartRadius;
  103. /////////// MOVEMENT ////////
  104. ePEStartPosType mStartVelType;
  105. cVector3f mvMinStartVel;
  106. cVector3f mvMaxStartVel;
  107. cVector2f mvMinStartVelAngles;
  108. cVector2f mvMaxStartVelAngles;
  109. float mfMinStartVelSpeed;
  110. float mfMaxStartVelSpeed;
  111. float mfMinSpeedMultiply;
  112. float mfMaxSpeedMultiply;
  113. cVector3f mvMinStartAcc;
  114. cVector3f mvMaxStartAcc;
  115. float mfMinVelMaximum;
  116. float mfMaxVelMaximum;
  117. bool mbUsesDirection;
  118. ePEGravityType mGravityType;
  119. cVector3f mvGravityAcc;
  120. eParticleEmitterCoordSystem mCoordSystem;
  121. // NEW
  122. bool mbUsePartSpin;
  123. ePEPartSpinType mPartSpinType;
  124. float mfMinSpinRange;
  125. float mfMaxSpinRange;
  126. bool mbUseRevolution;
  127. cVector3f mvMinRevVel;
  128. cVector3f mvMaxRevVel;
  129. // iVertexBuffer *mVBMeshData;
  130. // float *mpfMeshVtxData;
  131. // ---
  132. /////////// LIFESPAN ////////
  133. float mfMinLifeSpan;
  134. float mfMaxLifeSpan;
  135. ePEDeathType mDeathType;
  136. tString msDeathPS;
  137. /////////// RENDERING ////////
  138. eParticleEmitterType mDrawType;
  139. cVector2f mvMinStartSize;
  140. cVector2f mvMaxStartSize;
  141. float mfStartRelSize;
  142. float mfMiddleRelSize;
  143. float mfMiddleRelSizeTime;
  144. float mfMiddleRelSizeLength;
  145. float mfEndRelSize;
  146. bool mbMultiplyRGBWithAlpha;
  147. /////////// COLOR ////////
  148. cColor mMinStartColor;
  149. cColor mMaxStartColor;
  150. cColor mStartRelColor;
  151. cColor mMiddleRelColor;
  152. float mfMiddleRelColorTime;
  153. float mfMiddleRelColorLength;
  154. cColor mEndRelColor;
  155. /////////// COLLISION ////////
  156. bool mbCollides;
  157. float mfMinBounceAmount;
  158. float mfMaxBounceAmount;
  159. int mlMinCollisionMax;
  160. int mlMaxCollisionMax;
  161. int mlCollisionUpdateRate;
  162. // NEW
  163. /////// BEAM SPECIFIC ///////
  164. bool mbUseBeamNoise;
  165. int mlLowFreqPoints;
  166. std::vector<unsigned int> mvLFIndices;
  167. cVector3f mvMinLowFreqNoise;
  168. cVector3f mvMaxLowFreqNoise;
  169. int mlHighFreqPoints;
  170. cVector3f mvMinHighFreqNoise;
  171. cVector3f mvMaxHighFreqNoise;
  172. std::vector<tBeamNoisePoint> mvBeamNoisePoints;
  173. // ---
  174. };
  175. //----------------------------------------------------------
  176. class cParticleEmitter_UserData : public iParticleEmitter
  177. {
  178. public:
  179. cParticleEmitter_UserData( tString asName,tMaterialVec* avMaterials,
  180. cVector3f avSize, cGraphics* apGraphics,cResources *apResources,
  181. cParticleEmitterData_UserData *apData
  182. );
  183. ~cParticleEmitter_UserData(void);
  184. void Kill();
  185. bool IsDying();
  186. private:
  187. void UpdateMotion(float afTimeStep);
  188. void SetParticleDefaults(cParticle *apParticle);
  189. cParticleEmitterData_UserData *mpData;
  190. float mfTime;
  191. float mfCreateCount;
  192. float mfCollideCount;
  193. float mfPauseCount;
  194. float mfPauseWaitCount;
  195. bool mbPaused;
  196. bool mbRespawn;
  197. };
  198. };
  199. #endif // HPL_PARTICLE_EMITTER_USER_DATA_H