CUGL 3.0
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Public Attributes | List of all members
cugl::graphics::ParticleVertex Class Reference

#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)
 
ParticleVertexset (const std::shared_ptr< JsonValue > &json)
 

Public Attributes

Vec2 position
 
Vec2 texCoord
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ParticleVertex() [1/4]

cugl::graphics::ParticleVertex::ParticleVertex ( )
inline

Creates a default particle vertex

◆ ParticleVertex() [2/4]

cugl::graphics::ParticleVertex::ParticleVertex ( const Vec2  pos,
const Vec2  coord 
)
inline

Creates a particle vertex with the given position and texture coord

Parameters
posThe vertex position
coordThe vertex texture coordinate

◆ ParticleVertex() [3/4]

cugl::graphics::ParticleVertex::ParticleVertex ( float  x,
float  y,
float  u,
float  v 
)
inline

Creates a particle vertex with the given position and texture coord

Parameters
xThe x-coordinate of the vertex position
yThe y-coordinate of the vertex position
uThe u-coordinate of the texture coordinate
vThe v-coordinate of the texture coordinate

◆ ParticleVertex() [4/4]

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.

Parameters
jsonThe JSON object specifying the vertex

Member Function Documentation

◆ set()

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.

Parameters
jsonThe JSON object specifying the vertex
Returns
a reference to this particle vertex for chaining

Member Data Documentation

◆ position

Vec2 cugl::graphics::ParticleVertex::position

The position of this vertex

◆ texCoord

Vec2 cugl::graphics::ParticleVertex::texCoord

The texture coordinate of this vertex


The documentation for this class was generated from the following file: