![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CUParticleSystem.h>
Public Member Functions | |
ParticleVertex () | |
ParticleVertex (const Vec2 pos, const Vec2 coord) | |
ParticleVertex (float x, float y, float u, float v) | |
ParticleVertex (const std::shared_ptr< JsonValue > &json) | |
ParticleVertex & | set (const std::shared_ptr< JsonValue > &json) |
Public Attributes | |
Vec2 | position |
Vec2 | texCoord |
This class is a struct representing a particle vertex.
Particles are typically a quad of four vertices, but this is not required. In fact, a tighter fit to the sprite can aid with transparency issues.
The texture coordinates may change per instance (in the case of animation). That is achieved by adding a texture offset to the base texture coordinate.
Particle Vertices are used by InstanceBuffer
to render the particle template. So we do not refer to them with shared pointers, or have fancy constructor for them.
|
inline |
Creates a default particle vertex
Creates a particle vertex with the given position and texture coord
pos | The vertex position |
coord | The vertex texture coordinate |
|
inline |
Creates a particle vertex with the given position and texture coord
x | The x-coordinate of the vertex position |
y | The y-coordinate of the vertex position |
u | The u-coordinate of the texture coordinate |
v | The v-coordinate of the texture coordinate |
cugl::graphics::ParticleVertex::ParticleVertex | ( | const std::shared_ptr< JsonValue > & | json | ) |
Creates a new ParticleVertex from the given JSON value.
A particle vertex can be described as an array of floats or a JSON object. If it is a JSON object, then it supports the following attributes.
"position": An array of float arrays of length two "texcoord": An array of float arrays of length two
Again, all attributes are optional, as all values resolve to the origin.
If the particle vertex is represented as an array, then it should be an array of length no more than 4. These float are assigned to the attributes position (2) and texCoord (2) in that order. Missing values are replaced with a 0.
json | The JSON object specifying the vertex |
ParticleVertex & cugl::graphics::ParticleVertex::set | ( | const std::shared_ptr< JsonValue > & | json | ) |
Sets this ParticleVertex to have the data in the given JSON value.
A particle vertex can be described as an array of floats or a JSON object. If it is a JSON object, then it supports the following attributes.
"position": An array of float arrays of length two "texcoord": An array of float arrays of length two
Again, all attributes are optional, as all values resolve to the origin.
If the particle vertex is represented as an array, then it should be an array of length no more than 4. These float are assigned to the attributes position (2) and texCoord (2) in that order. Missing values are replaced with a 0.
json | The JSON object specifying the vertex |
Vec2 cugl::graphics::ParticleVertex::position |
The position of this vertex
Vec2 cugl::graphics::ParticleVertex::texCoord |
The texture coordinate of this vertex