forked from themrdemonized/xray-monolith
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticleEffectDef.h
More file actions
175 lines (155 loc) · 5.39 KB
/
ParticleEffectDef.h
File metadata and controls
175 lines (155 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//---------------------------------------------------------------------------
#ifndef ParticleEffectDefH
#define ParticleEffectDefH
#include "Shader.h"
namespace PAPI
{
struct Particle;
struct ParticleEffect;
struct PAHeader;
struct ParticleAction;
DEFINE_VECTOR(ParticleAction*, PAVec, PAVecIt);
}
struct EParticleAction;
namespace PS
{
class CParticleEffect;
typedef BOOL ( * CollisionCallback)(CParticleEffect* E, PAPI::Particle& P, const Fvector& pt, const Fvector& norm);
// TRUE-continue collision exec
typedef void ( * DestroyCallback)(CParticleEffect* E, PAPI::Particle& P);
class PFunction;
struct SFrame
{
Fvector2 m_fTexSize;
Fvector2 reserved;
int m_iFrameDimX;
int m_iFrameCount;
float m_fSpeed;
void InitDefault()
{
m_fTexSize.set(32.f / 256.f, 64.f / 128.f);
m_iFrameDimX = 8;
m_iFrameCount = 16;
m_fSpeed = 24.f;
}
IC void CalculateTC(int frame, Fvector2& lt, Fvector2& rb)
{
lt.x = (float)((frame % m_iFrameDimX) * m_fTexSize.x);
lt.y = (float)((frame / m_iFrameDimX) * m_fTexSize.y);
rb.x = lt.x + m_fTexSize.x;
rb.y = lt.y + m_fTexSize.y;
}
};
class ECORE_API CPEDef
{
public:
enum
{
dfSprite = (1 << 0),
// dfObject = (1<<1),
dfFramed = (1 << 10),
dfAnimated = (1 << 11),
dfRandomFrame = (1 << 12),
dfRandomPlayback= (1 << 13),
dfTimeLimit = (1 << 14),
dfAlignToPath = (1 << 15),
dfCollision = (1 << 16),
dfCollisionDel = (1 << 17),
dfVelocityScale = (1 << 18),
dfCollisionDyn = (1 << 19),
dfWorldAlign = (1 << 20),
dfFaceAlign = (1 << 21),
dfCulling = (1 << 22),
dfCullCCW = (1 << 23),
};
shared_str m_Name;
Flags32 m_Flags;
// texture
shared_str m_ShaderName;
shared_str m_TextureName;
ref_shader m_CachedShader;
SFrame m_Frame;
// compiled actions
CMemoryWriter m_Actions;
// def
u32 m_uStep; // update rate of this effect in ms
float m_fStep; // update rate of this effect in s
float m_fTimeLimit; // time limit
int m_MaxParticles; // max particle count
Fvector m_VelocityScale; // velocity scale
Fvector m_APDefaultRotation; // align to path
// collision
float m_fCollideOneMinusFriction;
float m_fCollideResilience;
float m_fCollideSqrCutoff;
public:
BOOL SaveActionList(IWriter& F);
BOOL LoadActionList(IReader& F);
// execute
void ExecuteAnimate(PAPI::Particle* particles, u32 p_cnt, float dt);
void ExecuteCollision(PAPI::Particle* particles, u32 p_cnt, float dt, CParticleEffect* owner,
CollisionCallback cb);
public:
CPEDef();
~CPEDef();
u32 GetUStep();
float GetFStep();
void SetName(LPCSTR name);
IC LPCSTR Name() const { return *m_Name; }
void CreateShader();
void DestroyShader();
void Save(IWriter& F);
BOOL Load(IReader& F);
void Save2(CInifile& ini);
BOOL Load2(CInifile& ini);
// DIRTY HACK TO MAKE PARTICLE IMPORT AND EXPORT WORK #ifdef _EDITOR
// change Copy&Equal if variables changed
public:
DEFINE_VECTOR(EParticleAction*, EPAVec, EPAVecIt);
EPAVec m_EActionList;
#ifdef _EDITOR // DIRTY HACK TO MAKE PARTICLE IMPORT AND EXPORT WORK
public:
void __stdcall FindActionByName (LPCSTR new_name, bool& res);
bool __stdcall NameOnAfterEdit (PropValue* sender, shared_str& edit_val);
bool __stdcall CollisionFrictionOnAfterEdit (PropValue* sender, float& edit_val);
void __stdcall CollisionFrictionOnBeforeEdit (PropValue* sender, float& edit_val);
void __stdcall CollisionFrictionOnDraw (PropValue* sender, xr_string& draw_val);
bool __stdcall CollisionCutoffOnAfterEdit (PropValue* sender, float& edit_val);
void __stdcall CollisionCutoffOnBeforeEdit (PropValue* sender, float& edit_val);
void __stdcall CollisionCutoffOnDraw (PropValue* sender, xr_string& draw_val);
void __stdcall OnActionEditClick (ButtonValue* sender, bool& bDataModified, bool& bSafe);
void __stdcall OnFrameResize (PropValue* sender);
void __stdcall OnShaderChange (PropValue* sender);
void __stdcall OnFlagChange (PropValue* sender);
void __stdcall OnControlClick (ButtonValue* sender, bool& bDataModified, bool& bSafe);
void __stdcall OnActionsClick (ButtonValue* sender, bool& bDataModified, bool& bSafe);
bool __stdcall OnAfterActionNameEdit(PropValue* sender, shared_str& edit_val);
void FillProp (LPCSTR pref, ::PropItemVec& items, ::ListItem* owner);
void Copy (const CPEDef& src);
BOOL Equal (const CPEDef* pe);
void Render (const Fmatrix& parent);
static PFunction* FindCommandPrototype(LPCSTR src, LPCSTR& dest);
void __stdcall FillActionList (ChooseItemVec& items, void* param);
bool Validate (bool bMsg);
#endif // DIRTY HACK TO MAKE PARTICLE IMPORT AND EXPORT WORK
void Compile(EPAVec& v);
// DIRTY HACK TO MAKE PARTICLE IMPORT AND EXPORT WORK #endif
};
};
#define PED_VERSION 0x0001
#define PED_CHUNK_VERSION 0x0001
#define PED_CHUNK_NAME 0x0002
#define PED_CHUNK_EFFECTDATA 0x0003
#define PED_CHUNK_ACTIONLIST 0x0004
#define PED_CHUNK_FLAGS 0x0005
#define PED_CHUNK_FRAME 0x0006
#define PED_CHUNK_SPRITE 0x0007
#define PED_CHUNK_TIMELIMIT 0x0008
#define PED_CHUNK_TIMELIMIT2 0x0009
#define PED_CHUNK_SOURCETEXT_ 0x0020 // obsolete
#define PED_CHUNK_COLLISION 0x0021
#define PED_CHUNK_VEL_SCALE 0x0022
#define PED_CHUNK_EDATA 0x0024
#define PED_CHUNK_ALIGN_TO_PATH 0x0025
//---------------------------------------------------------------------------
#endif