| 1 |
#ifndef CPARTICLE_H_INCLUDED |
| 2 |
#define CPARTICLE_H_INCLUDED |
| 3 |
|
| 4 |
class CNamedObject; |
| 5 |
class CModelPlugin; |
| 6 |
class CParticle; |
| 7 |
class CParticleState; |
| 8 |
class CScene; |
| 9 |
|
| 10 |
/* |
| 11 |
* パーティクルインスタンス |
| 12 |
*/ |
| 13 |
class CParticleInst{ |
| 14 |
private: |
| 15 |
float m_CameraDist; // カメラからの距離 |
| 16 |
CParticle *m_Emitter; // エミッタ |
| 17 |
VEC3 m_Pos; // 座標 |
| 18 |
VEC3 m_Dir; // 速度 |
| 19 |
float m_InitRadius; // 初期半径 |
| 20 |
float m_FinRadius; // 最終半径 |
| 21 |
float m_Alpha; // アルファ |
| 22 |
float m_Angle; // 角度 |
| 23 |
D3DCOLOR m_Color; // 色 |
| 24 |
int m_Lifetime; // 寿命 |
| 25 |
int m_Timer; // 経過時間 |
| 26 |
CScene *m_Scene; // シーン |
| 27 |
public: |
| 28 |
CParticleInst(CParticle *, VEC3, VEC3, float, float, int, CScene *); |
| 29 |
void CalcDist(){ m_CameraDist = V3Len(&(GetVPos()-m_Pos)); } |
| 30 |
bool operator<(const CParticleInst &rhs){ return m_CameraDist>rhs.m_CameraDist; } |
| 31 |
void Render(); |
| 32 |
bool Simulate(); |
| 33 |
}; |
| 34 |
|
| 35 |
// 反復子 |
| 36 |
typedef list<CParticleInst>::iterator IParticleInst; |
| 37 |
|
| 38 |
/* |
| 39 |
* パーティクルエミッタ状態 |
| 40 |
*/ |
| 41 |
class CParticleState{ |
| 42 |
friend class CParticle; |
| 43 |
private: |
| 44 |
bool m_ApplyFlag; // 適用フラグ |
| 45 |
float m_EmissionCredit; // 放出残り個数 |
| 46 |
float m_OldSpeed; // 前回速度 |
| 47 |
VEC3 m_OldPos; // 前回基準座標 |
| 48 |
public: |
| 49 |
CParticleState(){ Reset(); } |
| 50 |
void Reset(){ m_EmissionCredit = -1.0f; } |
| 51 |
void Confirm(){ if(!m_ApplyFlag) m_EmissionCredit = -1.0f; } |
| 52 |
char *Read(char *); |
| 53 |
void Save(FILE *, char *); |
| 54 |
}; |
| 55 |
|
| 56 |
// 反復子 |
| 57 |
typedef list<CParticleState>::iterator IParticleState; |
| 58 |
|
| 59 |
/* |
| 60 |
* パーティクルエミッタ |
| 61 |
*/ |
| 62 |
class CParticle{ |
| 63 |
friend class CParticleInst; |
| 64 |
private: |
| 65 |
static list<CParticleInst> ms_RenderList; // レンダリングリスト |
| 66 |
string m_TextureFileName; // テクスチャファイル名 |
| 67 |
LPTEX8 m_Texture; // テクスチャ |
| 68 |
CNamedObject *m_Link; // 接続先オブジェクト |
| 69 |
float m_MinQty, m_MaxQty; // 最小・最大放射量 |
| 70 |
float m_VelocityRel; // 速度比例成分 |
| 71 |
float m_AccelerationRel; // 加速度比例成分 |
| 72 |
float m_DecelerationRel; // 減速度比例成分 |
| 73 |
float m_EmissionQuantity[3]; // 1 秒当たり放射量 |
| 74 |
float m_Lifetime[2]; // 寿命 [秒] |
| 75 |
VEC3 m_SourceCoord; // 位置 |
| 76 |
VEC3 m_Direction[2]; // 方向 |
| 77 |
float m_InitialRadius[2]; // 初期半径 |
| 78 |
float m_FinalRadius[2]; // 最終半径 |
| 79 |
D3DCOLOR m_Color[2]; // 色 |
| 80 |
int m_BlendMode; // ブレンドモード |
| 81 |
float m_AirResistance; // 空気抵抗 |
| 82 |
float m_Gravity; // 重力 |
| 83 |
float m_Turbulence; // 乱気流 |
| 84 |
CParticleState *m_LinkState; // 状態変数 |
| 85 |
public: |
| 86 |
static void InitRenderList(); |
| 87 |
static void RenderAll(); |
| 88 |
static void SimulateAll(); |
| 89 |
char *Read(char *, CModelPlugin *); |
| 90 |
void LoadData(); |
| 91 |
void Link(CParticleState *); |
| 92 |
void Register(CScene *); |
| 93 |
}; |
| 94 |
|
| 95 |
// 反復子 |
| 96 |
typedef list<CParticle>::iterator IParticle; |
| 97 |
|
| 98 |
// 外部グローバル |
| 99 |
extern VEC3 g_WindDir; |
| 100 |
extern VEC3 g_WindDirNorm; |
| 101 |
|
| 102 |
#endif |