/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
- #pragma once
-
- #include "common.h"
- #include "renderer/device.h"
-
- #define PARTICLES_MAX 512
- #define PARTICLE_EMITTERS_MAX 64
-
- struct particle_vertex_t
- {
- FLOAT x, y, z;
- DWORD color;
- FLOAT u, v;
- };
-
- struct particle_t
- {
- particle_vertex_t vertices[4];
-
- D3DXVECTOR3 position, direction;
- float size, life;
- };
-
- struct particle_emitter_t
- {
- struct
- {
- texture_h texture;
- vbuffer_h vb;
- } visual;
-
- particle_t particles[PARTICLES_MAX];
- uint32_t particles_count;
-
- D3DXVECTOR3 position, direction;
- float speed[2], life[2], size[2], color[2][3]; // min/max
- float spawn_rate, spawn_last, spawn_time; // spawns per second
- };
-
- struct particle_system_t
- {
- struct
- {
- ibuffer_h ib;
- vertex_layout_h vlayout;
- D3DXMATRIX transform;
- } visual;
-
- particle_emitter_t emitters[PARTICLE_EMITTERS_MAX];
- uint32_t emitters_count;
- };
-
- struct particle_desc_t
- {
- texture_h texture;
- D3DXVECTOR3 position;
- D3DXVECTOR3 direction;
- float speed[2];
- float life[2];
- float size[2];
- float color[2][3];
- float rate;
- float time;
- };
-
- void particle_system_create(particle_system_t *psys);
-
- void particle_system_add(particle_system_t *psys, const particle_desc_t *desc);
-
- void particle_system_update(particle_system_t *psys, const camera_t &camera, float dt);
-
- void particle_system_render(particle_system_t *psys, const camera_t &camera, LPDIRECT3DDEVICE9 device);