Particle.h
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:11k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. /******************************************************************************************************************
  2.                                                                                                                    
  3. 葛碘疙:
  4. 累己磊:
  5. 累己老:
  6. [老磊][荐沥磊] : 荐沥 郴侩
  7.                                                                                                                    
  8. *******************************************************************************************************************/
  9. #ifndef _CPARTICLE_H
  10. #define _CPARTICLE_H
  11. #define _RAND_FLOAT ((FLOAT)(rand()%1000)/1000.0f)
  12. /******************************************************************************************************************
  13. CParticle Class
  14. *******************************************************************************************************************/
  15. class CParticle
  16. {
  17. public:
  18. //------------------------------------------------------------------------------------------------------------------
  19. // 涝磊包访 沥焊.
  20. WORD m_wLife; // 荐疙.
  21. WORD m_wCurrLife; // 泅犁荐疙.
  22. D3DVECTOR m_vecPos; // 谅钎.
  23. D3DVECTOR m_vecOldPos; // 谅钎 焊包.
  24. D3DVECTOR m_vecVel; // 加档.
  25. D3DVECTOR m_vecAccel; // 啊加档.
  26. D3DVECTOR m_vecLocalForce; // 颇萍努俊 俺喊 康氢阑 林绰 塞.
  27. FLOAT m_fMass; // 龙樊.
  28. FLOAT m_fSize; // 农扁.
  29. BOOL m_bIsDead; // 颇萍努狼 粮犁咯何.
  30. BYTE m_bRed, m_bGreen, m_bBlue; // 祸.
  31. BYTE m_bOpa;
  32. FLOAT m_fOriSize; // 贸澜农扁.
  33. BYTE m_bFstRed, m_bFstGreen, m_bFstBlue; // 颇萍努 积己矫痢狼祸.
  34. BYTE m_bEndRed, m_bEndGreen, m_bEndBlue; // 颇萍努 辆丰矫痢狼祸.
  35. //------------------------------------------------------------------------------------------------------------------
  36. //------------------------------------------------------------------------------------------------------------------
  37. // 涝磊 Frame包访 沥焊.
  38. WORD m_wDelay; // Animation Delay.
  39. WORD m_wCurrDelay;
  40. WORD m_wCurrFrame;
  41. //------------------------------------------------------------------------------------------------------------------
  42. public:
  43. __inline CParticle()
  44. {
  45. Init();
  46. }
  47. __inline VOID Init()
  48. {
  49. m_wLife = 0;
  50. m_vecPos = D3DVECTOR(0, 0, 0);
  51. m_vecOldPos = D3DVECTOR(0, 0, 0);
  52. m_vecVel = D3DVECTOR(0, 0, 0);
  53. m_vecAccel = D3DVECTOR(0, 0, 0);
  54. m_vecLocalForce = D3DVECTOR(0, 0, 0);
  55. m_fMass = 0.0f;
  56. m_fSize = 0.0f;
  57. m_fOriSize = 0.0f;
  58. m_bIsDead = TRUE;
  59. m_bRed = m_bGreen =  m_bBlue = 255;
  60. m_bFstRed = m_bFstGreen = m_bFstBlue = 255;
  61. m_bEndRed = m_bEndGreen = m_bEndBlue = 255;
  62. m_wDelay = 0;
  63. m_wCurrDelay = 0;
  64. m_wCurrFrame = 0;
  65. m_wCurrLife = 0;
  66. m_bOpa = 255;
  67. }
  68. };
  69. /******************************************************************************************************************
  70. CParticleSystem Class
  71. 颇萍努 包府 Base Class
  72. *******************************************************************************************************************/
  73. class CParticleSystem
  74. {
  75. protected:
  76. // FLOAT m_fAirFiction; // 傍扁付蔓俺荐.(官恩.)
  77. // D3DVECTOR m_vecEnvironment; // 涝磊俊 累侩窍绰 券版函荐(吝仿, 官恩).
  78. D3DVECTOR m_vecBounding[2]; // 面倒眉农康开 汲沥.
  79. WORD m_wNum; // 涝磊狼 肮荐.
  80. CParticle* m_pxParticle; // 涝磊 俺眉.
  81.     D3DVERTEX m_avShape[4]; // Vertex.
  82. FLOAT m_fDeltaTime;
  83. public:
  84. D3DVECTOR m_vecEnvironment; // 涝磊俊 累侩窍绰 券版函荐(吝仿, 官恩).
  85. FLOAT m_fAirFiction; // 傍扁付蔓俺荐.(官恩.)
  86. CParticleSystem();
  87. ~CParticleSystem();
  88. VOID UpdateAirFiction(WORD wNum); // 傍扁付蔓拌荐 利侩.
  89. VOID UpdateMove(WORD wNum); // 吝仿厘 利侩.
  90. VOID UpdateCrash(WORD wNum); // 面倒馆惯仿 利侩.
  91. __inline VOID SetEnvFactor(FLOAT fAirFriction = -0.05f, 
  92.    D3DVECTOR vecEnvironment = D3DVECTOR(0, 300, 0), 
  93.    D3DVECTOR vecMinBound = D3DVECTOR(0, 0, 0), 
  94.    D3DVECTOR vecMaxBound = D3DVECTOR(0, 0, 0))
  95. {
  96. m_fAirFiction  = fAirFriction;
  97. m_vecEnvironment = vecEnvironment;
  98. m_vecBounding[0] = vecMinBound;
  99. m_vecBounding[1] = vecMaxBound;
  100. }
  101. virtual VOID InitSystem();
  102. virtual VOID SetupSystem(WORD wCnt = 200);
  103. virtual VOID DestroySystem();
  104. virtual VOID LoadTextr()  = 0;
  105.     virtual HRESULT RenderSystem(LPDIRECT3DDEVICE7 lpDevice) = 0;
  106. virtual VOID UpdateSystem(INT nLoopTime, D3DVECTOR vecGenPos) = 0;
  107. virtual VOID SetParticleDefault(WORD wNum, D3DVECTOR vecGenPos) = 0;
  108. };
  109. /******************************************************************************************************************
  110. CSnow Class
  111. *******************************************************************************************************************/
  112. #define _MAX_SNOWFRAME 1
  113. class CSnow : public CParticleSystem
  114. {
  115. private:
  116. CHAR m_szSnowFile[_MAX_SNOWFRAME][MAX_PATH];
  117.     FLOAT m_fWidth, m_fGround;
  118. public:
  119.     CSnow();
  120.     ~CSnow();
  121. virtual VOID LoadTextr();
  122. virtual VOID InitSystem();
  123. virtual VOID DestroySystem();
  124. virtual VOID SetupSystem(WORD wCnt = 500, FLOAT fWidth = 800, FLOAT fGround = 600);
  125.     virtual HRESULT RenderSystem(LPDIRECT3DDEVICE7 lpDevice);
  126. virtual VOID UpdateSystem(INT nLoopTime, D3DVECTOR vecGenPos = D3DVECTOR(0.0f, 0.0f, 0.0f));
  127. virtual VOID SetParticleDefault(WORD wNum, D3DVECTOR vecGenPos = D3DVECTOR(0.0f, 0.0f, 0.0f));
  128. };
  129. /******************************************************************************************************************
  130. CRain Class
  131. *******************************************************************************************************************/
  132. #define _MAX_RAINFRAME 1
  133. #define _MAX_RAINDROPFRAME 5
  134. class CRain : public CParticleSystem
  135. {
  136. private:
  137. CHAR m_pszRainFile[_MAX_RAINFRAME][MAX_PATH];
  138. CHAR m_pszRainDropFile[_MAX_RAINDROPFRAME][MAX_PATH];
  139.     FLOAT m_fWidth, m_fGround;
  140. BYTE m_bRainIntensity; // 厚狼碍档.
  141. public:
  142. BYTE m_bGenCnt;
  143.     CRain();
  144.     ~CRain();
  145. virtual VOID LoadTextr();
  146. virtual VOID InitSystem();
  147. virtual VOID DestroySystem();
  148. virtual VOID SetupSystem(WORD wCnt = 400, FLOAT fWidth = 800, FLOAT fGround = 600);
  149.     virtual HRESULT RenderSystem(LPDIRECT3DDEVICE7 lpDevice);
  150. virtual VOID UpdateSystem(INT nLoopTime, D3DVECTOR vecGenPos = D3DVECTOR(0.0f, 0.0f, 0.0f));
  151. virtual VOID SetParticleDefault(WORD wNum, D3DVECTOR vecGenPos = D3DVECTOR(0.0f, 0.0f, 0.0f));
  152. };
  153. /******************************************************************************************************************
  154. CFly Class
  155. 朝酒啊绰 屈怕狼 Praticle包府.(蜡己狼 部府)
  156. *******************************************************************************************************************/
  157. #define _MAX_FLYFRAME 10
  158. class CFly : public CParticleSystem
  159. {
  160. private:
  161. CHAR m_pszFlyFile[_MAX_FLYFRAME][MAX_PATH];
  162. BYTE m_bGenCnt;
  163. public:
  164. CFly();
  165. ~CFly();
  166. virtual VOID LoadTextr();
  167. virtual VOID InitSystem();
  168. virtual VOID DestroySystem();
  169. virtual VOID SetupSystem(WORD wCnt = 100);
  170.     virtual HRESULT RenderSystem(LPDIRECT3DDEVICE7 lpDevice);
  171. virtual VOID UpdateSystem(INT nLoopTime, D3DVECTOR vecGenPos);
  172. virtual VOID SetParticleDefault(WORD wNum, D3DVECTOR vecGenPos);
  173. };
  174. /******************************************************************************************************************
  175. CBoom
  176. 气惯 屈怕狼 Praticle包府.
  177. *******************************************************************************************************************/
  178. #define _MAX_BOOMFRAME 10
  179. class CBoom : public CParticleSystem
  180. {
  181. private:
  182. CHAR m_pszBoomFile[_MAX_BOOMFRAME][MAX_PATH];
  183. SHORT m_shPartNum;
  184. public:
  185. CBoom();
  186. ~CBoom();
  187. virtual VOID LoadTextr();
  188. virtual VOID InitSystem();
  189. virtual VOID DestroySystem();
  190. virtual VOID SetupSystem(WORD wCnt = 1000);
  191.     virtual HRESULT RenderSystem(LPDIRECT3DDEVICE7 lpDevice);
  192. VOID SetBoomParticle(D3DVECTOR vecGenPos);
  193. virtual VOID UpdateSystem(INT nLoopTime, D3DVECTOR  vecGenPos = D3DVECTOR(0, 0, 0));
  194. virtual VOID SetParticleDefault(WORD wNum, D3DVECTOR vecGenPos);
  195. };
  196. /******************************************************************************************************************
  197. CFlyingTail
  198. 朝酒啊绰 屈怕狼 Praticle包府.
  199. *******************************************************************************************************************/
  200. #define _MAX_FLYTAILFRAME 10
  201. class CFlyingTail : public CParticleSystem
  202. {
  203. private:
  204. CHAR m_pszFlyingTailFile[_MAX_FLYTAILFRAME][MAX_PATH];
  205. SHORT m_shPartNum;
  206. public:
  207. CFlyingTail();
  208. ~CFlyingTail();
  209. virtual VOID LoadTextr();
  210. virtual VOID InitSystem();
  211. virtual VOID DestroySystem();
  212. virtual VOID SetupSystem(WORD wCnt = 500);
  213.     virtual HRESULT RenderSystem(LPDIRECT3DDEVICE7 lpDevice);
  214. VOID SetFlyTailParticle(D3DVECTOR vecGenPos);
  215. virtual VOID UpdateSystem(INT nLoopTime, D3DVECTOR vecGenPos = D3DVECTOR(0, 0, 0));
  216. virtual VOID SetParticleDefault(WORD wNum, D3DVECTOR vecGenPos);
  217. };
  218. /******************************************************************************************************************
  219. CSmoke
  220. *******************************************************************************************************************/
  221. #define _MAX_SMOKEFRAME 1
  222. class CSmoke : public CParticleSystem
  223. {
  224. private:
  225. CHAR m_pszSmokeFile[_MAX_SMOKEFRAME][MAX_PATH];
  226. SHORT m_shPartNum;
  227. public:
  228. CSmoke();
  229. ~CSmoke();
  230. virtual VOID LoadTextr();
  231. virtual VOID InitSystem();
  232. virtual VOID DestroySystem();
  233. virtual VOID SetupSystem(WORD wCnt = 100);
  234.     virtual HRESULT RenderSystem(LPDIRECT3DDEVICE7 lpDevice);
  235. VOID SetSmokeParticle(D3DVECTOR vecGenPos);
  236. virtual VOID UpdateSystem(INT nLoopTime, D3DVECTOR vecGenPos = D3DVECTOR(0, 0, 0));
  237. virtual VOID SetParticleDefault(WORD wNum, D3DVECTOR vecGenPos);
  238. };
  239. /******************************************************************************************************************
  240. CElec
  241. 傈扁 颇厘 Praticle包府.
  242. *******************************************************************************************************************/
  243. #define _MAX_ELECFRAME 1
  244. #define _MAX_ELEC_NODEX 2
  245. #define _MAX_ELEC_NODEY 10
  246. #define _ELEC_INDICES _MAX_ELEC_NODEX*_MAX_ELEC_NODEY*3*2
  247. #define _ELEC_VERTICES (_MAX_ELEC_NODEX+1)*(_MAX_ELEC_NODEY+1)
  248. class CElec
  249. {
  250. private:
  251. CHAR m_szElecFile[_MAX_ELECFRAME][MAX_PATH];
  252. SHORT m_shPosX, m_shPosY;
  253. SHORT m_shDstPosX, m_shDstPosY;
  254. FLOAT m_fSize;
  255. FLOAT m_fRadian;
  256. D3DVERTEX m_avElec[_MAX_ELEC_NODEY+1][_MAX_ELEC_NODEX+1];
  257. D3DVERTEX m_avSaveElec[_MAX_ELEC_NODEY+1][_MAX_ELEC_NODEX+1];
  258. // D3DLVERTEX m_avElec[_MAX_ELEC_NODE+1][2];
  259. WORD m_pwElecIndices[_ELEC_INDICES];
  260. public:
  261. CElec();
  262. ~CElec();
  263. VOID LoadTextr();
  264. VOID InitElec();
  265. VOID DestroyElec();
  266. VOID SetupElec();
  267. VOID UpdateElec(SHORT shPosX, SHORT shPosY, SHORT shDstPosX, SHORT shDstPosY);
  268. HRESULT RenderElec(LPDIRECT3DDEVICE7 lpDevice);
  269. };
  270. #endif // _CPARTICLE_H