Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
particles.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "inexor/shared/ents.hpp"
4 #include "inexor/shared/geom.hpp"
5 
6 struct Texture;
7 
8 enum
9 {
26 };
27 
28 enum
29 {
30  PT_PART = 0,
40 
41  PT_MOD = 1<<8,
42  PT_RND4 = 1<<9,
43  PT_LERP = 1<<10, // use very sparingly - order of blending issues
44  PT_TRACK = 1<<11,
45  PT_GLARE = 1<<12,
46  PT_SOFT = 1<<13,
47  PT_HFLIP = 1<<14,
48  PT_VFLIP = 1<<15,
49  PT_ROT = 1<<16,
50  PT_CULL = 1<<17,
51  PT_FEW = 1<<18,
52  PT_ICON = 1<<19,
53  PT_NOTEX = 1<<20,
54  PT_SHADER = 1<<21,
56 };
57 
59 {
63  float radius;
66 
68  : ent(ent), bbmin(ent->o), bbmax(ent->o), maxfade(-1), lastemit(0), lastcull(0)
69  {}
70 
71  void finalize();
72 
73  void extendbb(const vec &o, float size = 0);
74 
75  void extendbb(float z, float size = 0);
76 };
77 
78 struct particle
79 {
80  vec o, d;
84  float size;
85  union
86  {
87  const char *text;
88  float val;
89  physent *owner;
90  struct
91  {
92  uchar color2[3];
94  };
95  };
96 };
97 
98 struct partvert
99 {
103 };
104 
105 #define COLLIDERADIUS 8.0f
106 #define COLLIDEERROR 1.0f
107 
109 {
111  const char *texname;
112  int texclamp;
114  int collide;
115  string info;
116 
117  partrenderer(const char *texname, int texclamp, int type, int collide = 0)
118  : tex(nullptr), texname(texname), texclamp(texclamp), type(type), collide(collide)
119  {
120  }
121  partrenderer(int type, int collide = 0)
122  : tex(nullptr), texname(nullptr), texclamp(0), type(type), collide(collide)
123  {
124  }
125  virtual ~partrenderer()
126  {
127  }
128 
129  virtual void init(int n) { }
130  virtual void reset() = 0;
131  virtual void resettracked(physent *owner) { }
132  virtual particle *addpart(const vec &o, const vec &d, int fade, int color, float size, int gravity = 0) = 0;
133  virtual int adddepthfx(vec &bbmin, vec &bbmax) { return 0; }
134  virtual void update() { }
135  virtual void render() = 0;
136  virtual bool haswork() = 0;
137  virtual int count() = 0; //for debug
138  virtual void cleanup() {}
139 
140  virtual void seedemitter(particleemitter &pe, const vec &o, const vec &d, int fade, float size, int gravity)
141  {
142  }
143 
144  //blend = 0 => remove it
145  void calc(particle *p, int &blend, int &ts, vec &o, vec &d, bool step = true);
146 
147  const char *debuginfo();
148 };
149 extern partrenderer *parts[24];
150 
152 {
154 };
155 
156 
158 {
161 
162  listrenderer(const char *texname, int texclamp, int type, int collide = 0)
163  : partrenderer(texname, texclamp, type, collide), list(nullptr)
164  {
165  }
166  listrenderer(int type, int collide = 0)
167  : partrenderer(type, collide), list(nullptr)
168  {
169  }
170 
171  ~listrenderer() override
172  {
173  }
174 
175  virtual void killpart(listparticle *p)
176  {
177  }
178 
179  void reset() override;
180 
181  void resettracked(physent *owner) override;
182 
183  particle *addpart(const vec &o, const vec &d, int fade, int color, float size, int gravity) override;
184 
185  int count() override;
186 
187  bool haswork() override;
188 
189  virtual void startrender() = 0;
190  virtual void endrender() = 0;
191  virtual void renderpart(listparticle *p, const vec &o, const vec &d, int blend, int ts) = 0;
192 
193  void render() override;
194 };
Definition: particles.hpp:108
Texture * tex
Definition: particles.hpp:110
Definition: particles.hpp:33
void resettracked(physent *owner) override
Definition: renderparticles.cpp:201
Definition: particles.hpp:17
void extendbb(const vec &o, float size=0)
Definition: renderparticles.cpp:82
void reset() override
Definition: renderparticles.cpp:186
virtual void cleanup()
Definition: particles.hpp:138
particle * addpart(const vec &o, const vec &d, int fade, int color, float size, int gravity) override
Definition: renderparticles.cpp:216
unsigned int uint
Definition: cube_types.hpp:9
Definition: particles.hpp:16
Definition: particles.hpp:45
virtual int count()=0
listparticle * next
Definition: particles.hpp:153
uchar flags
Definition: particles.hpp:83
Definition: particles.hpp:17
~listrenderer() override
Definition: particles.hpp:171
Definition: particles.hpp:15
virtual void resettracked(physent *owner)
Definition: particles.hpp:131
Definition: particles.hpp:21
float size
Definition: particles.hpp:84
vec center
Definition: particles.hpp:62
Definition: particles.hpp:58
Definition: particles.hpp:38
Definition: particles.hpp:13
Definition: particles.hpp:32
2-dimensional float vectors
Definition: geom.hpp:38
ivec cullmin
Definition: particles.hpp:64
Definition: particles.hpp:19
partrenderer * parts[24]
Definition: renderparticles.cpp:735
Definition: particles.hpp:42
Definition: particles.hpp:47
Definition: particles.hpp:46
Definition: particles.hpp:20
Definition: particles.hpp:25
Definition: ents.hpp:128
const char * debuginfo()
Definition: renderparticles.cpp:164
virtual void init(int n)
Definition: particles.hpp:129
Definition: particles.hpp:53
vec2 tc
Definition: particles.hpp:102
virtual bool haswork()=0
particleemitter(extentity *ent)
Definition: particles.hpp:67
Definition: particles.hpp:35
Definition: particles.hpp:39
Definition: particles.hpp:78
float radius
Definition: particles.hpp:63
bvec color
Definition: particles.hpp:82
Definition: particles.hpp:49
Definition: particles.hpp:15
int gravity
Definition: particles.hpp:81
Definition: particles.hpp:10
vec bbmax
Definition: particles.hpp:61
partrenderer(const char *texname, int texclamp, int type, int collide=0)
Definition: particles.hpp:117
vec d
Definition: particles.hpp:80
Definition: ents.hpp:102
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
int lastemit
Definition: particles.hpp:65
Definition: particles.hpp:52
Definition: particles.hpp:24
Definition: particles.hpp:55
int fade
Definition: particles.hpp:81
virtual void reset()=0
Definition: particles.hpp:157
Definition: particles.hpp:48
Definition: particles.hpp:151
virtual void seedemitter(particleemitter &pe, const vec &o, const vec &d, int fade, float size, int gravity)
Definition: particles.hpp:140
3-dimensional UNSIGNED CHAR vector.
Definition: geom.hpp:1398
Definition: particles.hpp:41
int count() override
Definition: renderparticles.cpp:241
virtual void killpart(listparticle *p)
Definition: particles.hpp:175
Definition: particles.hpp:18
Definition: particles.hpp:20
bvec4 color
Definition: particles.hpp:101
int d
Definition: octaedit.cpp:1749
int texclamp
Definition: particles.hpp:112
Definition: particles.hpp:15
Definition: particles.hpp:54
vec o
Definition: particles.hpp:80
Definition: particles.hpp:34
int millis
Definition: particles.hpp:81
virtual int adddepthfx(vec &bbmin, vec &bbmax)
Definition: particles.hpp:133
unsigned char uchar
Basic type definitions.
Definition: cube_types.hpp:7
bool haswork() override
Definition: renderparticles.cpp:249
Definition: particles.hpp:37
const char * texname
Definition: particles.hpp:111
Definition: particles.hpp:30
Definition: particles.hpp:22
listparticle * list
Definition: particles.hpp:160
GLuint GLuint GLintptr GLsizeiptr size
Definition: glexts.hpp:412
string info
Definition: particles.hpp:115
Definition: particles.hpp:20
Definition: particles.hpp:51
Definition: particles.hpp:18
Definition: particles.hpp:14
virtual void render()=0
virtual ~partrenderer()
Definition: particles.hpp:125
Definition: particles.hpp:11
Definition: particles.hpp:24
int maxfade
Definition: particles.hpp:65
void calc(particle *p, int &blend, int &ts, vec &o, vec &d, bool step=true)
Definition: renderparticles.cpp:122
void render() override
Definition: renderparticles.cpp:254
Definition: particles.hpp:31
#define progress(s)
Definition: octarender.cpp:556
Definition: particles.hpp:43
static map entities ("entity") and dynamic entities (players/monsters, "dynent") the gamecode extends...
Definition: particles.hpp:36
mathmatics for vectors, matrices, quaterions and more
ivec cullmax
Definition: particles.hpp:64
static void color(const bvec &v, uchar alpha=255)
Definition: glemu.hpp:71
virtual void update()
Definition: particles.hpp:134
virtual void renderpart(listparticle *p, const vec &o, const vec &d, int blend, int ts)=0
vec pos
Definition: particles.hpp:100
listrenderer(const char *texname, int texclamp, int type, int collide=0)
Definition: particles.hpp:162
partrenderer(int type, int collide=0)
Definition: particles.hpp:121
3-dimensional INTEGER vectors
Definition: geom.hpp:1226
Definition: particles.hpp:44
int lastcull
Definition: particles.hpp:65
static listparticle * parempty
Definition: particles.hpp:159
Definition: geom.hpp:1455
Definition: particles.hpp:98
extentity * ent
Definition: particles.hpp:60
virtual void endrender()=0
Definition: particles.hpp:16
Definition: particles.hpp:12
int collide
Definition: particles.hpp:114
listrenderer(int type, int collide=0)
Definition: particles.hpp:166
Definition: particles.hpp:50
uint type
Definition: particles.hpp:113
virtual particle * addpart(const vec &o, const vec &d, int fade, int color, float size, int gravity=0)=0
Definition: particles.hpp:23
vec bbmin
Definition: particles.hpp:61
virtual void startrender()=0
A Texture entry, holding info about a texture on the GPU.
Definition: texture.hpp:27
void finalize()
Definition: renderparticles.cpp:73