WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
particle.h
Go to the documentation of this file.
1#pragma once
2
3class WoWModel;
5class RibbonEmitter;
6
7#include "animated.h"
8
9#include <iostream>
10#include <list>
11#include <glad/gl.h>
12#include "glm/glm.hpp"
13
14class Bone;
15
18{
19 glm::vec3 pos, speed, down, origin, dir;
20 glm::vec3 corners[4];
21 glm::vec3 tpos;
22 float size, life, maxlife;
23 size_t tile;
24 glm::vec4 color;
25};
26
27typedef std::list<Particle> ParticleList;
28
31{
32protected:
34
35public:
39
41 virtual Particle newParticle(size_t anim, size_t time, float w, float l, float spd, float var, float spr,
42 float spr2) = 0;
43
44 virtual ~ParticleEmitter() = default;
45};
46
49{
50public:
54
55 Particle newParticle(size_t anim, size_t time, float w, float l, float spd, float var, float spr, float spr2);
56};
57
60{
61public:
65
66 Particle newParticle(size_t anim, size_t time, float w, float l, float spd, float var, float spr, float spr2);
67};
68
71{
72 glm::vec2 tc[4];
73};
74
77{
79 glm::vec3 pos, tpos;
84 size_t manim, mtime;
85 int rows, cols;
86 std::vector<TexCoordSet> tiles;
87 void initTile(glm::vec2* tc, int num);
89 float rem;
90 //bool transform;
91 // unknown parameters omitted for now ...
95
96public:
97 int blend;
99 float tofs;
102 //Animated<float> deacceleration;
103 glm::vec4 colors[3];
104 float sizes[3];
108 // Start, Mid and End colours, for cases where the model's particle colours
109 // are overridden by values from ParticleColor.dbc, indexed from CreatureDisplayInfo:
110 typedef std::vector<glm::vec4> particleColorSet;
111 // The particle will get its replacement colour set from 0, 1 or 2, depending on
112 // whether its ParticleColorIndex is set to 11, 12 or 13:
113 std::vector<particleColorSet> particleColorReplacements;
114
116 : mid(0), slowdown(0), rotation(0), pos(), tpos(),
117 texture(0), texture2(0), texture3(0),
118 emitter(nullptr), order(0), ParticleType(0),
119 manim(0), mtime(0), rows(0), cols(0),
120 tiles(), billboard(false), rem(0),
121 flags(0), EmitterType(0), parent(nullptr),
122 blend(0), model(nullptr), tofs(0),
123 enabled(), speed(), variation(), spread(), lat(), gravity(), lifespan(), rate(), areal(), areaw(),
126{
127 // Optionally, initialize arrays and vectors if needed
128 for (int i = 0; i < 3; ++i) {
129 colors[i] = glm::vec4(0.0f);
130 sizes[i] = 0.0f;
131 }
132}
133
135
136 void init(GameFile* f, M2ParticleDef& mta, std::vector<uint32>& globals);
137 void update(float dt);
138
139 void setup(size_t anim, size_t time);
140 void draw();
141
144 //int BlendValueForMode(int mode);
145
146 friend std::ostream& operator<<(std::ostream& out, const ParticleSystem& v)
147 {
148 out << " <colors>" << v.colors[0].x << " " << v.colors[0].y << " " << v.colors[0].z << "</colors>" <<
149 std::endl;
150 out << " <colors>" << v.colors[1].x << " " << v.colors[1].y << " " << v.colors[1].z << "</colors>" <<
151 std::endl;
152 out << " <colors>" << v.colors[2].x << " " << v.colors[2].y << " " << v.colors[2].z << "</colors>" <<
153 std::endl;
154 out << " <sizes>" << v.sizes[0] << "</sizes>" << std::endl;
155 out << " <sizes>" << v.sizes[1] << "</sizes>" << std::endl;
156 out << " <sizes>" << v.sizes[2] << "</sizes>" << std::endl;
157 out << " <mid>" << v.mid << "</mid>" << std::endl;
158 out << " <slowdown>" << v.slowdown << "</slowdown>" << std::endl;
159 out << " <rotation>" << v.rotation << "</rotation>" << std::endl;
160 out << " <pos>" << v.pos.x << " " << v.pos.y << " " << v.pos.z << "</pos>" << std::endl;
161 out << " <texture>" << v.texture << "</texture>" << std::endl;
162 out << " <blend>" << v.blend << "</blend>" << std::endl;
163 out << " <order>" << v.order << "</order>" << std::endl;
164 out << " <ParticleType>" << v.ParticleType << "</ParticleType>" << std::endl;
165 out << " <manim>" << v.manim << "</manim>" << std::endl;
166 out << " <mtime>" << v.mtime << "</mtime>" << std::endl;
167 out << " <rows>" << v.rows << "</rows>" << std::endl;
168 out << " <cols>" << v.cols << "</cols>" << std::endl;
169 out << " <billboard>" << v.billboard << "</billboard>" << std::endl;
170 out << " <rem>" << v.rem << "</rem>" << std::endl;
171 out << " <flags>" << v.flags << "</flags>" << std::endl;
172 out << " <EmitterType>" << v.EmitterType << "</EmitterType>" << std::endl;
173 out << " <tofs>" << v.tofs << "</tofs>" << std::endl;
174 return out;
175 }
176
177 static void useDoNotTrailInfo()
178 {
180 }
181
182 static bool useDoNotTrail;
183};
184
187{
188 glm::vec3 pos, up, back;
189 float len, len0;
190};
191
194{
198
200
201 glm::vec3 pos;
202
203 size_t manim, mtime;
206
207 glm::vec3 tpos;
208 glm::vec4 tcolor;
210
211 GLuint texture;
212
213 std::list<RibbonSegment> segs;
214
215public:
217
218 void init(GameFile* f, ModelRibbonEmitterDef& mta, std::vector<uint32>& globals);
219 void setup(size_t anim, size_t time);
220 void draw();
221};
Generic animated value class that reads keyframe data from M2 files.
Definition animated.h:161
Represents a single bone in a WoW M2 model skeleton.
Definition Bone.h:20
Abstract base class representing a file within the game data archive.
Definition GameFile.h:12
Abstract base class for particle emitters.
Definition particle.h:31
ParticleSystem * sys
Owning particle system.
Definition particle.h:33
virtual ~ParticleEmitter()=default
virtual Particle newParticle(size_t anim, size_t time, float w, float l, float spd, float var, float spr, float spr2)=0
Create a new particle with the given emission parameters.
ParticleEmitter(ParticleSystem *sys)
Definition particle.h:36
M2 particle system — manages emission, simulation, and rendering of particles.
Definition particle.h:77
GLuint texture
Definition particle.h:80
float rotation
Definition particle.h:78
ParticleEmitter * emitter
Definition particle.h:81
Bone * parent
Definition particle.h:94
size_t manim
Definition particle.h:84
void setup(size_t anim, size_t time)
Definition particle.cpp:269
Animated< float > speed
Definition particle.h:101
int16 EmitterType
Definition particle.h:93
bool replaceParticleColors
Definition particle.h:107
glm::vec3 pos
Definition particle.h:79
void init(GameFile *f, M2ParticleDef &mta, std::vector< uint32 > &globals)
Definition particle.cpp:28
bool multitexture
Definition particle.h:105
Animated< float > areal
Definition particle.h:101
float slowdown
Definition particle.h:78
std::vector< particleColorSet > particleColorReplacements
Definition particle.h:113
GLuint texture3
Definition particle.h:80
Animated< float > rate
Definition particle.h:101
ParticleList particles
Definition particle.h:82
glm::vec3 tpos
Definition particle.h:79
void update(float dt)
Definition particle.cpp:148
std::vector< glm::vec4 > particleColorSet
Definition particle.h:110
glm::vec4 colors[3]
Definition particle.h:103
Animated< float > spread
Definition particle.h:101
Animated< float > lat
Definition particle.h:101
std::vector< TexCoordSet > tiles
Definition particle.h:86
void initTile(glm::vec2 *tc, int num)
Definition particle.cpp:124
GLuint texture2
Definition particle.h:80
friend std::ostream & operator<<(std::ostream &out, const ParticleSystem &v)
Definition particle.h:146
size_t mtime
Definition particle.h:84
Animated< float > gravity
Definition particle.h:101
Animated< uint16 > enabled
Definition particle.h:100
static void useDoNotTrailInfo()
Definition particle.h:177
WoWModel * model
Definition particle.h:98
static bool useDoNotTrail
Definition particle.h:182
Animated< float > lifespan
Definition particle.h:101
Animated< float > areaw
Definition particle.h:101
float sizes[3]
Definition particle.h:104
Animated< float > variation
Definition particle.h:101
Emits particles from a rectangular plane.
Definition particle.h:49
Particle newParticle(size_t anim, size_t time, float w, float l, float spd, float var, float spr, float spr2)
Create a new particle with the given emission parameters.
Definition particle.cpp:546
PlaneParticleEmitter(ParticleSystem *sys)
Definition particle.h:51
M2 ribbon emitter — produces trailing ribbon effects attached to bones.
Definition particle.h:194
Animated< glm::vec3 > color
Definition particle.h:195
WoWModel * model
Definition particle.h:216
Animated< float > below
Definition particle.h:197
glm::vec3 pos
Definition particle.h:201
size_t mtime
Definition particle.h:203
glm::vec4 tcolor
Definition particle.h:208
size_t manim
Definition particle.h:203
void setup(size_t anim, size_t time)
Definition particle.cpp:774
Bone * parent
Definition particle.h:199
glm::vec3 tpos
Definition particle.h:207
AnimatedShort opacity
Definition particle.h:196
GLuint texture
Definition particle.h:211
std::list< RibbonSegment > segs
Definition particle.h:213
Animated< float > above
Definition particle.h:197
void init(GameFile *f, ModelRibbonEmitterDef &mta, std::vector< uint32 > &globals)
Definition particle.cpp:746
Emits particles from the surface of a sphere.
Definition particle.h:60
SphereParticleEmitter(ParticleSystem *sys)
Definition particle.h:62
Particle newParticle(size_t anim, size_t time, float w, float l, float spd, float var, float spr, float spr2)
Create a new particle with the given emission parameters.
Definition particle.cpp:632
Core WoW .m2 model: geometry, animation, textures, and character data.
Definition WoWModel.h:50
std::list< Particle > ParticleList
Definition particle.h:27
On-disk particle emitter definition in an M2 file.
A single particle instance in a particle system.
Definition particle.h:18
glm::vec3 dir
Position, velocity, gravity, origin, and direction.
Definition particle.h:19
float life
Definition particle.h:22
glm::vec3 origin
Definition particle.h:19
glm::vec3 corners[4]
Billboard corner positions.
Definition particle.h:20
float maxlife
Current size, remaining life, and maximum lifespan.
Definition particle.h:22
float size
Definition particle.h:22
size_t tile
Current texture tile index.
Definition particle.h:23
glm::vec3 speed
Definition particle.h:19
glm::vec3 pos
Definition particle.h:19
glm::vec3 tpos
Transformed position.
Definition particle.h:21
glm::vec4 color
Current RGBA colour.
Definition particle.h:24
glm::vec3 down
Definition particle.h:19
A single segment in a ribbon trail.
Definition particle.h:187
glm::vec3 up
Definition particle.h:188
float len0
Current length and initial length.
Definition particle.h:189
glm::vec3 pos
Definition particle.h:188
glm::vec3 back
Segment position, up vector, and back vector.
Definition particle.h:188
A set of 4 texture coordinates for a particle tile.
Definition particle.h:71
glm::vec2 tc[4]
Texture coordinates for the four corners.
Definition particle.h:72
int16_t int16
Definition types.h:33
int32_t int32
Definition types.h:35