forked from abartlett139/Omni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PSYS.h
81 lines (64 loc) · 1.39 KB
/
PSYS.h
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
#pragma once
#ifndef PSYS_H
#define PSYS_H
#include "Graphics.h"
#include "Camera.h"
#include "GameTimer.h"
#include <list>
namespace PSYS {
struct Particle {
D3DXVECTOR3 position;
D3DCOLOR color;
static const DWORD FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
};
struct Attribute {
Attribute() {
lifeTime = 0.0f;
age = 0.0f;
isAlive = true;
}
D3DXVECTOR3 position;
D3DXVECTOR3 velocity;
D3DXVECTOR3 acceleration;
float lifeTime;
float age;
D3DXCOLOR color;
D3DXCOLOR colorFade;
bool isAlive;
};
class ParticleSystem {
public:
ParticleSystem();
virtual ~ParticleSystem();
virtual bool Init(char * fileName);
virtual void Reset();
virtual void ResetParticle(Attribute* attribute) = 0;
virtual void AddParticle();
virtual void Update() = 0;
virtual void PreRender();
virtual void Render();
virtual void PostRender();
bool isEmpty();
bool isDead();
virtual void RemoveDeadParticles();
D3DXVECTOR3 origin;
D3D::BoundingBox box;
float emitRate;
float size;
IDirect3DTexture9* texture;
IDirect3DVertexBuffer9* vertexBuffer;
std::list<Attribute> particles;
int maxParticles;
DWORD vertexBufferSize;
DWORD vertexBufferOffset;
DWORD vertexBufferBatchSize;
};
class ParticleGun : public ParticleSystem {
public:
ParticleGun(Camera* camera);
void ResetParticle(Attribute* attribute);
void Update();
Camera* camera;
};
}
#endif