PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 1ms

/src/renderer/particles.h

https://bitbucket.org/vivkin/gam3b00bs/
C++ Header | 72 lines | 57 code | 15 blank | 0 comment | 0 complexity | c617f586c6959995a1ba754cac9cdaff MD5 | raw file
 1#pragma once
 2
 3#include "common.h"
 4#include "renderer/device.h"
 5
 6#define PARTICLES_MAX         512
 7#define PARTICLE_EMITTERS_MAX 64
 8
 9struct particle_vertex_t
10{
11	FLOAT x, y, z;
12	DWORD color;
13	FLOAT u, v;
14};
15
16struct particle_t
17{
18	particle_vertex_t vertices[4];
19
20	D3DXVECTOR3 position, direction;
21	float size, life;
22};
23
24struct particle_emitter_t
25{
26	struct
27	{
28		texture_h texture;
29		vbuffer_h vb;
30	} visual;
31
32	particle_t particles[PARTICLES_MAX];
33	uint32_t   particles_count;
34
35	D3DXVECTOR3 position, direction;
36	float speed[2], life[2], size[2], color[2][3]; // min/max
37	float spawn_rate, spawn_last, spawn_time; // spawns per second
38};
39
40struct particle_system_t
41{
42	struct
43	{
44		ibuffer_h       ib;
45		vertex_layout_h vlayout;
46		D3DXMATRIX      transform;
47	} visual;
48
49	particle_emitter_t emitters[PARTICLE_EMITTERS_MAX];
50	uint32_t           emitters_count;
51};
52
53struct particle_desc_t
54{
55	texture_h   texture;
56	D3DXVECTOR3 position;
57	D3DXVECTOR3 direction;
58	float       speed[2];
59	float       life[2];
60	float       size[2];
61	float       color[2][3];
62	float       rate;
63	float       time;
64};
65
66void particle_system_create(particle_system_t *psys);
67
68void particle_system_add(particle_system_t *psys, const particle_desc_t *desc);
69
70void particle_system_update(particle_system_t *psys, const camera_t &camera, float dt);
71
72void particle_system_render(particle_system_t *psys, const camera_t &camera, LPDIRECT3DDEVICE9 device);