OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Particle::DrawingData Struct Reference

#include <C4Particles.h>

Collaboration diagram for C4Particle::DrawingData:
[legend]

Classes

struct  Vertex
 

Public Member Functions

void SetOffset (float x, float y)
 
void SetPointer (Vertex *startingVertex, bool initial=false)
 
void SetColor (float r, float g, float b, float a=1.0f)
 
void SetPosition (float x, float y, float size, float rotation=0.f, float stretch=1.f)
 
void SetPhase (int phase, C4ParticleDef *sourceDef)
 
 DrawingData ()
 

Public Attributes

Vertexvertices
 
int phase
 
float currentStretch
 
float originalSize
 
float sizeX
 
float sizeY
 
float aspect
 
float offsetX
 
float offsetY
 

Static Public Attributes

static const int vertexCountPerParticle
 

Detailed Description

Definition at line 239 of file C4Particles.h.


Class Documentation

struct C4Particle::DrawingData::Vertex

Definition at line 243 of file C4Particles.h.

Class Members
float alpha
float b
float g
float r
float u
float v
float x
float y

Constructor & Destructor Documentation

C4Particle::DrawingData::DrawingData ( )
inline

Definition at line 304 of file C4Particles.h.

304  : currentStretch(1.f), originalSize(0.0001f), aspect(1.f), offsetX(0.f), offsetY(0.f)
305  {
306  }

Member Function Documentation

void C4Particle::DrawingData::SetColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Definition at line 290 of file C4Particles.h.

References a, C4Particle::DrawingData::Vertex::alpha, C4Particle::DrawingData::Vertex::b, b, C4Particle::DrawingData::Vertex::g, and C4Particle::DrawingData::Vertex::r.

Referenced by C4ParticleSystem::Create(), C4Particle::Exec(), and SetPointer().

291  {
292  for (int vertex = 0; vertex < 4; ++vertex)
293  {
294  vertices[vertex].r = r;
295  vertices[vertex].g = g;
296  vertices[vertex].b = b;
297  vertices[vertex].alpha = a;
298  }
299  }
#define b
#define a

Here is the caller graph for this function:

void C4Particle::DrawingData::SetOffset ( float  x,
float  y 
)
inline

Definition at line 267 of file C4Particles.h.

Referenced by C4ParticleSystem::Create().

268  {
269  offsetX = x;
270  offsetY = y;
271  }

Here is the caller graph for this function:

void C4Particle::DrawingData::SetPhase ( int  phase,
C4ParticleDef sourceDef 
)

Definition at line 189 of file C4Particles.cpp.

References C4ParticleDef::Length, and C4ParticleDef::PhasesX.

Referenced by C4ParticleSystem::Create(), and C4Particle::Exec().

190 {
191  this->phase = phase;
192  phase = phase % sourceDef->Length;
193  int offsetY = phase / sourceDef->PhasesX;
194  int offsetX = phase % sourceDef->PhasesX;
195  float wdt = 1.0f / (float)sourceDef->PhasesX;
196  int numOfLines = sourceDef->Length / sourceDef->PhasesX;
197  float hgt = 1.0f / (float)numOfLines;
198 
199  float x = wdt * (float)offsetX;
200  float y = hgt * (float)offsetY;
201  float xr = x + wdt;
202  float yr = y + hgt;
203 
204  vertices[0].u = x; vertices[0].v = yr;
205  vertices[1].u = x; vertices[1].v = y;
206  vertices[2].u = xr; vertices[2].v = yr;
207  vertices[3].u = xr; vertices[3].v = y;
208 }
int32_t PhasesX
Definition: C4Particles.h:92
int32_t Length
Definition: C4Particles.h:91

Here is the caller graph for this function:

void C4Particle::DrawingData::SetPointer ( Vertex startingVertex,
bool  initial = false 
)
inline

Definition at line 273 of file C4Particles.h.

References SetColor(), C4Particle::DrawingData::Vertex::u, and C4Particle::DrawingData::Vertex::v.

Referenced by C4ParticleChunk::AddNewParticle(), and C4ParticleChunk::ReserveSpace().

274  {
275  vertices = startingVertex;
276 
277  if (initial)
278  {
279  vertices[0].u = 0.f; vertices[0].v = 1.f;
280  vertices[1].u = 0.f; vertices[1].v = 0.f;
281  vertices[2].u = 1.f; vertices[2].v = 1.f;
282  vertices[3].u = 1.f; vertices[3].v = 0.f;
283 
284  SetColor(1.f, 1.f, 1.f, 1.f);
285 
286  phase = -1;
287  }
288  }
void SetColor(float r, float g, float b, float a=1.0f)
Definition: C4Particles.h:290

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Particle::DrawingData::SetPosition ( float  x,
float  y,
float  size,
float  rotation = 0.f,
float  stretch = 1.f 
)

Definition at line 152 of file C4Particles.cpp.

References aspect, currentStretch, offsetX, offsetY, originalSize, sizeX, sizeY, vertices, C4Particle::DrawingData::Vertex::x, and C4Particle::DrawingData::Vertex::y.

Referenced by C4Particle::Exec(), and C4Particle::SetPosition().

153 {
154  if (size != originalSize || stretch != currentStretch)
155  {
156  currentStretch = stretch;
157  originalSize = std::max(size, 0.0001f); // a size of zero results in undefined behavior
160  }
161 
162  if (rotation == 0.f)
163  {
164  vertices[0].x = x - sizeX + offsetX;
165  vertices[0].y = y + sizeY + offsetY;
166  vertices[1].x = x - sizeX + offsetX;
167  vertices[1].y = y - sizeY + offsetY;
168  vertices[2].x = x + sizeX + offsetX;
169  vertices[2].y = y + sizeY + offsetY;
170  vertices[3].x = x + sizeX + offsetX;
171  vertices[3].y = y - sizeY + offsetY;
172  }
173  else
174  {
175  float sine = sinf(rotation);
176  float cosine = cosf(rotation);
177 
178  vertices[0].x = x + ((-sizeX) * cosine - (+sizeY) * sine) + offsetX;
179  vertices[0].y = y + ((-sizeX) * sine + (+sizeY) * cosine) + offsetY;
180  vertices[1].x = x + ((-sizeX) * cosine - (-sizeY) * sine) + offsetX;
181  vertices[1].y = y + ((-sizeX) * sine + (-sizeY) * cosine) + offsetY;
182  vertices[2].x = x + ((+sizeX) * cosine - (+sizeY) * sine) + offsetX;
183  vertices[2].y = y + ((+sizeX) * sine + (+sizeY) * cosine) + offsetY;
184  vertices[3].x = x + ((+sizeX) * cosine - (-sizeY) * sine) + offsetX;
185  vertices[3].y = y + ((+sizeX) * sine + (-sizeY) * cosine) + offsetY;
186  }
187 }

Here is the caller graph for this function:

Member Data Documentation

float C4Particle::DrawingData::aspect

Definition at line 263 of file C4Particles.h.

Referenced by C4ParticleSystem::Create(), and SetPosition().

float C4Particle::DrawingData::currentStretch

Definition at line 260 of file C4Particles.h.

Referenced by SetPosition().

float C4Particle::DrawingData::offsetX

Definition at line 265 of file C4Particles.h.

Referenced by SetPosition().

float C4Particle::DrawingData::offsetY

Definition at line 265 of file C4Particles.h.

Referenced by SetPosition().

float C4Particle::DrawingData::originalSize

Definition at line 261 of file C4Particles.h.

Referenced by SetPosition().

int C4Particle::DrawingData::phase

Definition at line 258 of file C4Particles.h.

Referenced by C4Particle::Exec().

float C4Particle::DrawingData::sizeX

Definition at line 262 of file C4Particles.h.

Referenced by SetPosition().

float C4Particle::DrawingData::sizeY

Definition at line 262 of file C4Particles.h.

Referenced by SetPosition().

const int C4Particle::DrawingData::vertexCountPerParticle
static
Vertex* C4Particle::DrawingData::vertices

Definition at line 256 of file C4Particles.h.

Referenced by SetPosition().


The documentation for this struct was generated from the following files: