forked from vixorien/AdvancedDX11Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmitter.h
68 lines (51 loc) · 1.28 KB
/
Emitter.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
#pragma once
#include <wrl/client.h>
#include <DirectXMath.h>
#include <d3d11.h>
#include "SimpleShader.h"
#include "Camera.h"
struct Particle
{
float emitTime;
DirectX::XMFLOAT3 initPos; //16 Bytes
};
class Emitter
{
public:
Emitter(
int maxParticles,
int particlesPerSecond,
float lifetime,
Microsoft::WRL::ComPtr<ID3D11Device> device,
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context,
SimpleVertexShader* vs,
SimplePixelShader* ps,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> texture
);
~Emitter();
void Update(float dt, float currentTime);
void Draw(Camera* camera, float currentTime);
private:
Particle* particles;
int maxParticles;
int livingStart;
int deadStart;
int livingCount;
//Emission
int particlesPerSecond;
float secondsPerParticle;
float dtSinceLastEmit;
//System
float particleLifeSpan;
//GPU
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context;
Microsoft::WRL::ComPtr<ID3D11Buffer> particleDataBuffer;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> particleDataSRV;
Microsoft::WRL::ComPtr<ID3D11Buffer> indexBuffer;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> texture;
SimpleVertexShader* vs;
SimplePixelShader* ps;
//Methods
void UpdateParticle(float currentTime, int index);
void EmitParticle(float currentTime);
};