www.pudn.com > GameEngine.rar > GameEngine_Particle.h, change:2005-09-25,size:2363b
#ifndef GameEngine_Particle_Include
#define GameEngine_Particle_Include
#define PARTICLE_FVF D3DFVF_XYZ|D3DFVF_DIFFUSE
#define fRANDOM (((float)rand())/RAND_MAX)
#define HEIGHT_YELLOW D3DCOLOR_XRGB(255,255,0)
#define MIDDLE_YELLOW D3DCOLOR_XRGB(255,255,113)
#define LOW_YELLOW D3DCOLOR_XRGB(255,255,210)
class CGameEngine_SceneManager;
class CGameEngine_Texture;
struct PARTICLE_RENDERSTRUCT{ //对应于PARTICLE_FVF定义的结构
D3DXVECTOR3 m_vPosition; //位置
D3DCOLOR m_Color; //颜色
};
struct PARTICLE{
D3DXVECTOR3 m_vPosition; //位置
D3DCOLOR m_Color; //颜色
float m_fLife; //存活期
D3DXVECTOR3 m_vVelocity; //速度
float m_fSize; //大小
float m_fMass; //质量
float m_fFriction; //阻力
};
class CGameEngine_Particle{
private:
CGameEngine_SceneManager* m_pGameSceneManager; //场景管理器
CGameEngine_Texture* m_pParticleTexture; //粒子纹理
IDirect3DVertexBuffer9* m_pParticleVB; //顶点缓冲区
PARTICLE* m_pParticles; //粒子数组
int m_iNumParticle; //粒子个数
D3DXVECTOR3 m_vPosition; //粒子位置
float m_fLife; //粒子存活期
float m_fSize; //粒子大小
float m_fMass; //粒子质量
D3DCOLOR m_Color; //粒子颜色
float m_fFriction; //空气阻力
D3DXVECTOR3 m_vGravity; //重力
float m_fRadius; //爆炸范围半径
long m_lVBOffset; //渲染块头指针
long m_lBlockSize; //渲染分块大小(粒子数为单位)
public:
CGameEngine_Particle();
~CGameEngine_Particle();
//
bool Init(int iNumParticle,CGameEngine_SceneManager* pGameSceneManger,
TCHAR* szTextureFile);
inline void SetLife(float fLife){m_fLife=fLife;}
inline void SetSize(float fSize){m_fSize=fSize;}
inline void SetMass(float fMass){m_fMass=fMass;}
inline void SetPosition(float x,float y,float z){m_vPosition=D3DXVECTOR3(x,y,z);}
inline void SetColor(int red,int green,int blue){m_Color=D3DCOLOR_XRGB(red,green,blue);}
inline void SetFriction(float fFriction){m_fFriction=fFriction;}
inline void SetGravity(float x,float y,float z){m_vGravity=D3DXVECTOR3(x,y,z);}
inline void SetRadius(float fRadius){m_fRadius=fRadius;}
//
void CreateParticle(float fVX,float fVY,float fVZ);
void UpdateParticles();
void SetParticleRS();
void UnSetParticleRS();
void Render();
inline DWORD FToW(float f){return *((DWORD*)&f);}
void Explode(int iNumParticle);
void Closedown();
};
#endif