In file include/csengine/cssprite.h:

## class csSprite3D : public csObject

> A 3D sprite based on a triangle mesh with a single texture

## Inheritance:

### Public Fields

  static float | cfg_lod_detail Configuration value for global LOD
  csObjVector | sectors List of sectors where this sprite is.

### Public Methods

  void | AddBoundingBox (csBspContainer* container) Calculate a bounding box for this sprite in world space and add the resulting polygons to the given container
  void | AddDynamicLight (csLightHitsSprite *lp) Add a light-hits-sprite to the list
  void | AddVertexColor (int i, const csColor& col) Add a color for a vertex
  | csSprite3D ()
  void | DeferUpdateLighting (int flags, int num_lights) Update lighting as soon as the sprite becomes visible
  void | Draw (csRenderView& rview) Draw this sprite given a camera transformation
  void | FixVertexColors () Clamp all vertice colors to 2
  void | GenerateSpriteLOD (int num_vts) Fill the static mesh with the current sprite for a given LOD level
  csSpriteAction* | GetCurAction () Get the current frame number
  int | GetCurFrame () Get the current frame number
  csSpriteCallback* | GetDrawCallback () Get the draw callback
  csLightHitsSprite* | GetDynamicLights () Get the list of dynamic lights that hit this sprite
  int | GetNumFrames () Get the number of frames
  csVector3* | GetObjectVerts (csFrame* fr) Get an array of object vertices which is valid for the given frame
  csSkeletonState* | GetSkeletonState () Get the skeleton state for this sprite.
  csSpriteTemplate* | GetTemplate ()
  inline csMatrix3 | GetW2T () Get world to local transformation matrix
  inline csVector3 | GetW2TTranslation () Get world to local translation
  void | InitSprite () Initialize a sprite
  bool | IsVisible () Return if this sprite is visible.
  void | MarkInvisible () Mark this sprite as invisible.
  void | MarkVisible () Mark this sprite as visible.
  void | Move (float dx, float dy, float dz) Relative move
  void | Move (csVector3& v) Relative move
  bool | MoveTo (float x, float y, float z) The same as above
  bool | MoveTo (const csVector3& v) Absolute move
  void | MoveToSector (csSector* s) Move this sprite to one sector (conveniance function).
  bool | NextFrame (long current_time, bool onestep = false, bool stoptoend = false) Go to the next frame depending on the current time in milliseconds
  void | RemoveFromSectors () Remove this sprite from all sectors it is in (but not from the world).
  void | ResetVertexColors () Reset the color list
  void | SetAction (const char * name) Select an action
  void | SetDrawCallback (csSpriteCallback* callback) Set a callback which is called just before the sprite is drawn
  void | SetFrame (int f) Go to a specified frame
  void | SetMixmode (UInt m) Sets the mode that is used, when drawing that sprite.
  void | SetMove (float x, float y, float z) Set the transformation vector to move sprite to some position
  void | SetMove (const csVector3& v) Set the transformation vector to move sprite to some position
  void | SetTemplate (csSpriteTemplate* tmpl)
  void | SetTexture (char * name, csTextureList* textures) force a new texture skin other than default
  void | SetTransform (const csMatrix3& matrix) Set the transformation matrix to rotate the sprite in some orientation
  void | SetVertexColor (int i, const csColor& col) Set a color for a vertex
  void | Transform (csMatrix3& matrix) Relative transform
  void | UnlinkDynamicLight (csLightHitsSprite* lp) Unlink a light-hits-sprite from the list
  void | UnsetTexture ()
  void | UpdateLighting (csLight** lights, int num_lights) Light sprite according to the given array of lights (i
  virtual | ~csSprite3D ()

### Private Fields

  csTextureHandle* | cstxt The texture handle as returned by ITextureManager.
  csSpriteAction* | cur_action The current action.
  int | cur_frame The current frame number.
  int | defered_lighting_flags Flags to use for defered lighting.
  int | defered_num_lights Defered lighting. If > 0 then we have defered lighting.
  csSpriteCallback* | draw_callback The callback which is called just before drawing.
  csLightHitsSprite* | dynamiclights List of light-hits-sprites for this sprite
  bool | force_otherskin
  bool | is_visible Flag which is set to true when the sprite is visible
  int | last_time The last frame time action
  static csLight** | light_worktable Array for lighting.
  csMatrix3 | m_obj2world Object to world transformation.
  csMatrix3 | m_world2obj World to object transformation.
  static csTriangleMesh | mesh A mesh which contains a number of triangles as generated by the LOD algorithm
  static csVector2* | persp The perspective corrected vertices.
  csSkeletonState* | skeleton_state Skeleton state (optional).
  csSpriteTemplate* | tpl The template.
  static csVector3* | tr_verts Static vertex array.
  static csVector2* | uv_verts Static uv array.
  csVector3 | v_obj2world Object to world transformation.
  csColor* | vertex_colors Array of colors for the vertices
  static bool* | visible Array which indicates which vertices are visible and which are not.
  static float* | z_verts Static z array.

### Private Methods

  void | UpdateDeferedLighting () Update defered lighting.
  static void | UpdateWorkTables (int max_size) Update the above tables with a new size.

### Inherited from csObject:

### Public Methods

CS_ID GetID()
csObject* GetObj(const csIdType& objtype)
virtual csObject* GetObjectParent()
void ObjAdd(csObject* obj)
csObjIterator ObjGet(const csIdType& objtype)
void ObjRelease(csObject* obj)
void ObjRemove(csObject* obj)

### Private Fields

CS_ID csid_value
csObjTree* objtree

### Private Methods

virtual void SetObjectParent(csObject* parent)

## Documentation

> A 3D sprite based on a triangle mesh with a single texture. Animation is done with frames (a frame may be controlled by a skeleton).

`static csVector3* tr_verts`
  Static vertex array.

`static float* z_verts`
  Static z array.

`static csVector2* uv_verts`
  Static uv array.

`static csVector2* persp`
  The perspective corrected vertices.

`static bool* visible`
  Array which indicates which vertices are visible and which are not.

`static csLight** light_worktable`
  Array for lighting.

`static void UpdateWorkTables(int max_size)`
  Update the above tables with a new size.

`void UpdateDeferedLighting()`
  Update defered lighting.

`csObjVector sectors`
  List of sectors where this sprite is.

`static float cfg_lod_detail`
  Configuration value for global LOD. 0 is lowest detail, 1 is maximum. If negative then the base mesh is used and no LOD reduction/computation is done.

`csVector3 v_obj2world`
  Object to world transformation.

`csMatrix3 m_obj2world`
  Object to world transformation.

`csMatrix3 m_world2obj`
  World to object transformation.

`static csTriangleMesh mesh`
  A mesh which contains a number of triangles as generated by the LOD algorithm. This is static since it will likely change every frame anyway. We hold it static also since we don't want to allocate it again every time.

`csColor* vertex_colors`
  Array of colors for the vertices. If not set then this sprite does not have colored vertices.

`csSpriteTemplate* tpl`
  The template.

`csTextureHandle* cstxt`
  The texture handle as returned by ITextureManager.

`int cur_frame`
  The current frame number.

`csSpriteAction* cur_action`
  The current action.

`int last_time`
  The last frame time action

`bool force_otherskin`

`csLightHitsSprite* dynamiclights`
  List of light-hits-sprites for this sprite

`csSkeletonState* skeleton_state`
  Skeleton state (optional).

`int defered_num_lights`
  Defered lighting. If > 0 then we have defered lighting.

`int defered_lighting_flags`
  Flags to use for defered lighting.

`csSpriteCallback* draw_callback`
  The callback which is called just before drawing.

`bool is_visible`
  Flag which is set to true when the sprite is visible. This is used by the c-buffer/bsp routines. The sprite itself will not use this flag in any way at all. It is simply intended for external visibility culling routines.

`csSprite3D()`

`virtual ~csSprite3D()`

`void SetTemplate(csSpriteTemplate* tmpl)`

`csSpriteTemplate* GetTemplate()`

`csSkeletonState* GetSkeletonState()`
  Get the skeleton state for this sprite.

`void SetTexture(char * name, csTextureList* textures)`
  force a new texture skin other than default

`void MarkVisible()`
  Mark this sprite as visible.

`void MarkInvisible()`
  Mark this sprite as invisible.

`bool IsVisible()`
  Return if this sprite is visible.

`void SetVertexColor(int i, const csColor& col)`
  Set a color for a vertex. As soon as you use this function this sprite will be rendered using gouraud shading. Calling this function for the first time will initialize all colors to black.

`void AddVertexColor(int i, const csColor& col)`
  Add a color for a vertex. As soon as you use this function this sprite will be rendered using gouraud shading. Calling this function for the first time will initialize all colors to black.

`void ResetVertexColors()`
  Reset the color list. If you call this function then the sprite will no longer use gouraud shading.

`void FixVertexColors()`
  Clamp all vertice colors to 2.0. This is called inside csSprite3D::UpdateLighting() so that 3D renderer doesn't have to deal with brightness lighter than 2.0

`void UpdateLighting(csLight** lights, int num_lights)`
  Light sprite according to the given array of lights (i.e. fill the vertex color array). No shadow calculation will be done. This is assumed to have been done earlier. This is a primitive lighting process based on the lights which hit one point of the sprite (usually the center). More elaborate lighting systems are possible but this will do for now.

`void DeferUpdateLighting(int flags, int num_lights)`
  Update lighting as soon as the sprite becomes visible. This will call world->GetNearestLights with the supplied parameters.

`void UnsetTexture()`

`void SetMixmode(UInt m)`
  Sets the mode that is used, when drawing that sprite.

`void SetMove(const csVector3& v)`
  Set the transformation vector to move sprite to some position

`void SetMove(float x, float y, float z)`
  Set the transformation vector to move sprite to some position

`void SetTransform(const csMatrix3& matrix)`
  Set the transformation matrix to rotate the sprite in some orientation

`void Move(float dx, float dy, float dz)`
  Relative move

`void Move(csVector3& v)`
  Relative move

`bool MoveTo(const csVector3& v)`
  Absolute move

`bool MoveTo(float x, float y, float z)`
  The same as above

`void Transform(csMatrix3& matrix)`
  Relative transform

`void AddBoundingBox(csBspContainer* container)`
  Calculate a bounding box for this sprite in world space and add the resulting polygons to the given container

`void GenerateSpriteLOD(int num_vts)`
  Fill the static mesh with the current sprite for a given LOD level

`void Draw(csRenderView& rview)`
  Draw this sprite given a camera transformation. If needed the skeleton state will first be updated. Optionally update lighting if needed (DeferUpdateLighting()).

`void SetDrawCallback(csSpriteCallback* callback)`
  Set a callback which is called just before the sprite is drawn. This is useful to do some expensive computations which only need to be done on a visible sprite.

`csSpriteCallback* GetDrawCallback()`
  Get the draw callback. If there are multiple draw callbacks you can use this function to chain.

`bool NextFrame(long current_time, bool onestep = false, bool stoptoend = false)`
  Go to the next frame depending on the current time in milliseconds

`void SetFrame(int f)`
  Go to a specified frame

`int GetCurFrame()`
  Get the current frame number

`csSpriteAction* GetCurAction()`
  Get the current frame number

`int GetNumFrames()`
  Get the number of frames

`void SetAction(const char * name)`
  Select an action

`void InitSprite()`
  Initialize a sprite. This function is called automatically from within 'load'. However you should call it directly if you created the sprite on the fly (without 'load').

`inline csMatrix3 GetW2T()`
  Get world to local transformation matrix

`inline csVector3 GetW2TTranslation()`
  Get world to local translation

`void MoveToSector(csSector* s)`
  Move this sprite to one sector (conveniance function).

`void RemoveFromSectors()`
  Remove this sprite from all sectors it is in (but not from the world).

`csVector3* GetObjectVerts(csFrame* fr)`
  Get an array of object vertices which is valid for the given frame. This function correcty acounts for sprites which use skeletons. In that case it will use the current transformation state of the skeleton to compute object space vertices.
  Warning! The returned array should be used immediatelly or copied. It points to a private static array in the sprite class and can be reused if other calls to the sprite happen.

`void UnlinkDynamicLight(csLightHitsSprite* lp)`
  Unlink a light-hits-sprite from the list. Warning! This function does not test if it is really on the list!

`void AddDynamicLight(csLightHitsSprite *lp)`
  Add a light-hits-sprite to the list

`csLightHitsSprite* GetDynamicLights()`
  Get the list of dynamic lights that hit this sprite

This class has no child classes.

alphabetic index hierarchy of classes

this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de