Xors3d Engine
Sprites

Functions

BillBoard * xCreateSprite (Entity *parent=NULL)
 Creates a sprite entity and returns its handle. Sprites are simple flat (usually textured) rectangles made from two triangles. The sprite will be positioned at 0, 0, 0 and extend from 1, -1 to +1, +1. Sprites have two real strengths. The first is that they consist of only two polygons; meaning you can use many of them at once. This makes them ideal for particle effects and 2D-using-3D games where you want lots of sprites on-screen at once. Secondly, sprites can be assigned a view mode using cSpriteViewMode(). By default this view mode is set to SPRITE_FIXED, which means the sprite will always face the camera. So no matter what the orientation of the camera is relative to the sprite, you will never actually notice that they are flat; by giving them a spherical texture, you can make them appear to look no different than a normal sphere. The parent parameter allow you to specify a parent entity for the sprite so that when the parent is moved the child sprite will move with it. However, this relationship is one way; applying movement commands to the child will not affect the parent. Specifying a parent entity will still result in the sprite being created at position 0, 0, 0 rather than at the parent entity's position. Note: Sprites have their own commands for rotation and scaling.
void xHandleSprite (BillBoard *sprite, float x, float y)
 Sets a sprite handle. Defaults to 0, 0.
BillBoard * xLoadSprite (const char *path, int flags=9, Entity *parent=NULL)
 Creates a sprite entity, assigns a texture to it, and retuns sprite handle.
void xRotateSprite (BillBoard *sprite, float angle)
 Rotates a sprite.
void xScaleSprite (BillBoard *sprite, float xScale, float yScale)
 Scales a sprite.
void xSpriteViewMode (BillBoard *sprite, int mode)
 Sets the view mode of a sprite.

Function Documentation

BillBoard* xCreateSprite ( Entity *  parent = NULL)

Creates a sprite entity and returns its handle. Sprites are simple flat (usually textured) rectangles made from two triangles. The sprite will be positioned at 0, 0, 0 and extend from 1, -1 to +1, +1. Sprites have two real strengths. The first is that they consist of only two polygons; meaning you can use many of them at once. This makes them ideal for particle effects and 2D-using-3D games where you want lots of sprites on-screen at once. Secondly, sprites can be assigned a view mode using cSpriteViewMode(). By default this view mode is set to SPRITE_FIXED, which means the sprite will always face the camera. So no matter what the orientation of the camera is relative to the sprite, you will never actually notice that they are flat; by giving them a spherical texture, you can make them appear to look no different than a normal sphere. The parent parameter allow you to specify a parent entity for the sprite so that when the parent is moved the child sprite will move with it. However, this relationship is one way; applying movement commands to the child will not affect the parent. Specifying a parent entity will still result in the sprite being created at position 0, 0, 0 rather than at the parent entity's position. Note: Sprites have their own commands for rotation and scaling.

Parameters:
parentParent entity handle
void xSpriteViewMode ( BillBoard *  sprite,
int  mode 
)

Sets the view mode of a sprite.

The view mode determines how a sprite alters its orientation in respect to the camera. This allows the sprite to in some instances give the impression that it is more than two dimensional. See 'Sprite view modes' for more infromation. Note that if you use sprite view mode SPRITE_FREE, then because it is independent from the camera, you will only be able to see it from one side unless you use xEntityFX() flag FX_DISABLECULLING with it to disable backface culling.

Parameters:
spriteSprite handle
modeView mode
void xHandleSprite ( BillBoard *  sprite,
float  x,
float  y 
)

Sets a sprite handle. Defaults to 0, 0.

By default sprite extends from -1, -1 to +1, +1.

Parameters:
spriteSprite handle
xx coordinate of the new sprite drawing handle location
yy coordinate of the new sprite drawing handle location
BillBoard* xLoadSprite ( const char *  path,
int  flags = 9,
Entity *  parent = NULL 
)

Creates a sprite entity, assigns a texture to it, and retuns sprite handle.

Parameters:
pathFilename of image file to be used as sprite
flagsTexture loading flags. See 'Texture loading flags' for more information
parentParent entity handle
void xRotateSprite ( BillBoard *  sprite,
float  angle 
)

Rotates a sprite.

Parameters:
spriteSprite handle
angleAbsolute angle of sprite roll rotation
void xScaleSprite ( BillBoard *  sprite,
float  xScale,
float  yScale 
)

Scales a sprite.

Parameters:
spriteSprite handle
xScalex scale of sprite
yScaley scale of sprite