ObjectBillboards Class
Billboards class is used to bake billboards with the same material into one object. (A texture atlas can be applied, if necessary.) This allows you to optimize application performance when rendering a big number of billboards: as the number of texture fetches is reduced and the spatial tree is less cluttered, rendering is sped up.
The following samples demonstrate the ObjectBillboards class usage:
ObjectBillboards Class
Members
ObjectBillboards ()
Constructor. Creates a new Billboards object.vec3 getPosition (int num)
Returns the position of the given billboard.Arguments
- int num - Billboard number.
Return value
Billboard position coordinates.void removeBillboard (int num)
Deletes a given billboard from Billboards object.Arguments
- int num - Billboard number.
void setPosition (int num, vec3 position)
Sets the position for the given billboard.Arguments
- int num - Billboard number.
- vec3 position - Billboard position coordinates.
int getNumBillboards ()
Returns the total number of billboards contained in and managed by Billboards object.Return value
Number of billboards.float getHeight (int num)
Returns the current height of a given billboard.Arguments
- int num - Billboard number.
Return value
Height of the billboard in units.int addBillboard (float width, float height)
Adds a new billboard to be managed by Billboards object.Arguments
- float width - Width of the billboard in units.
- float height - Height of the billboard in units.
Return value
Added billboard number.int getDepthSort ()
Returns a value indicating whether depth sorting (in the back-to-front order) is enabled for billboards. This option should be enabled, if alpha blending is used for the billboard material (except for the additive blending).Return value
1 if the depth sorting is enabled; otherwise, 0.void setAngle (int num, float angle)
Sets the orientation of a given billboard.Arguments
- int num - Billboard number.
- float angle - Angle in degrees to set the billboard orientation. Positive values rotate the billboard clockwise, negative ones rotate it counter-clockwise.
void setWidth (int num, float width)
Sets the width of a given billboard.Arguments
- int num - Billboard number.
- float width - Width of the billboard in units.
vec3 getNormal (int num)
Returns the normal vector of a given billboard (used only with billboards_impostor_base material).Arguments
- int num - Billboard number in range from 0 to the total number of billboards.
Return value
Billboard normal coordinates local to the object.float getAngle (int num)
Returns the current orientation of a given billboard. Positive values mean clockwise rotated billboard, negative ones mean counter-clockwise rotation.Arguments
- int num - Billboard number.
Return value
Angle in degrees.void allocateBillboards (int num)
Allocate a buffer for a given number of billboards to be created. With this function, memory can be allocated once rather than in chunks, making the creation faster.Arguments
- int num - The number of billboards that will be stored in a buffer.
void setHeight (int num, float height)
Sets the height of a given billboard.Arguments
- int num - Billboard number.
- float height - Height of the billboard in units.
void setDepthSort (int sort)
Sets a value indicating if billboards should be sorted in the back-to-front order according to their position. This option should be enabled, if alpha blending is used for the billboard material (except for the additive blending).Arguments
- int sort - Positive number to enable depth sorting; 0 to disable.
vec4 getTexCoord (int num)
Returns the texture coordinates for for a given billboard (a texture atlas can be used).- The first pair of coordinates (x and y) set texture scale by X and Y axes. For example, by the scale of 2 the texture is repeated twice on the billboard.
- The second pair (z and w) set texture offset along X and Y axes. For example, by the offset of 0.5 along X axis the texture is repositioned to the right (so that the edge of the texture is rendered in the center).
Arguments
- int num - Billboard number.
Return value
Texture coordinates.void setTexCoord (int num, vec4 texcoord)
Sets texture coordinates for a given billboard (a texture atlas can be used).- The first pair of coordinates (x and y) set texture scale by X and Y axes. For example, by the scale of 2 the texture is repeated twice on the billboard.
- The second pair (z and w) set texture offset along X and Y axes. For example, by the offset of 0.5 along X axis the texture is repositioned to the right (so that the edge of the texture is rendered in the center).
Arguments
- int num - Billboard number.
- vec4 texcoord - Texture coordinates.
void clearBillboards ()
Deletes all billboards from Billboards object.void setNormal (int num, vec3 normal)
Updates a normal vector of a given billboard, which is used to orient billboard (used only with billboards_impostor_base material).Arguments
- int num - Billboard number in range from 0 to the total number of billboards.
- vec3 normal - Billboard normal coordinates local to the object.
float getWidth (int num)
Returns the current width of a given billboard.Arguments
- int num - Billboard number.
Return value
Width of the billboard in units.Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)