Repository navigation
Expand file tree
/
Copy pathParticle.cpp
More file actions
96 lines (77 loc) · 1.89 KB
/
Copy pathParticle.cpp
File metadata and controls
96 lines (77 loc) · 1.89 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
#include "Particle.h"
#include "SRVBatch.h"
#include "Utility.h"
#include "Vertice.h"
#include "RenderSystem.h"
Particle::Particle()
{
type = PARTICLE;
m_bFirstRun=TRUE;
timeStep=0;
age=0;
m_nMaxParticles=500;
drawVB = NULL;
streamOutVB = NULL;
texRV = NULL;
randomTexRV = NULL;
emitDirW = XMFLOAT4(0.0f, 1.0f, 1.0f, 0.0f);
}
Particle::~Particle()
{
SafeRelease(drawVB);
SafeRelease(streamOutVB);
texRV = NULL;
randomTexRV = NULL;
}
void Particle::Update(float time)
{
time /= 1000;
timeStep = time;
age += time;
}
void Particle::Release()
{
SafeRelease(drawVB);
SafeRelease(streamOutVB);
texRV = NULL;
randomTexRV = NULL;
}
BOOL Particle::Init(const string &filePath, const string &file)
{
texRV = SRVBatch::GetInstance()->LoadSRV(filePath, file);
randomTexRV = SRVBatch::GetInstance()->GetRandomSRV1D();
InitBuffers();
return TRUE;
}
XMFLOAT4 Particle::GetWorldVertex()
{
return XMFLOAT4(x, y, z, 1.0f);
}
void Particle::SetEmitDirect(XMFLOAT4 &emitDir)
{
emitDirW = emitDir;
}
BOOL Particle::InitBuffers()
{
D3D11_BUFFER_DESC vbd;
vbd.Usage = D3D11_USAGE_DEFAULT;
vbd.ByteWidth = InputLayouts::pPStride * 1;
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
VERTICE::ParticleVertex p;
ZeroMemory(&p, sizeof(VERTICE::ParticleVertex));
p.age = 0.0f;
p.type = 0;
D3D11_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = &p;
RenderSystem::GetInstance()->CreateBuffer(vbd, vinitData, verticesBuffer);
vbd.ByteWidth = InputLayouts::pPStride * m_nMaxParticles;
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_STREAM_OUTPUT;
RenderSystem::GetInstance()->getDevice()->CreateBuffer(&vbd, NULL, &drawVB);
RenderSystem::GetInstance()->getDevice()->CreateBuffer(&vbd, NULL, &streamOutVB);
return TRUE;
}
void Particle::AssembleShadowMapVertices()
{
}