| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# iSpriteCal3DState Struct Reference
[Mesh plugins]

This interface describes the API for changing the Cal3D sprite mesh object's animations playing and other current traits. More...

`#include <imesh/spritecal3d.h>`

Inheritance diagram for iSpriteCal3DState:

[legend]
List of all members.

## Animation management
enum |
| List of current animation types, used for introspection mostly. More...
virtual bool | AddAnimCycle (int idx, float weight, float delay)=0
| Uses the specified index directly to add the anim cycle.
virtual bool | AddAnimCycle (const char *name, float weight, float delay)=0
| This adds the specified animation to the ones already being blended by cal3d.
virtual void | ClearAllAnims ()=0
| This resets all currently blended animations and stops the sprite.
virtual bool | ClearAnimCycle (const char *name, float delay)=0
| This removes the named animation from the current blend set over the period of time specifed by "delay" parm in seconds.
virtual bool | ClearAnimCycle (int idx, float delay)=0
| This removes the animation at index `idx' from the current blend set over the period of time specifed by "delay" parm in seconds.
virtual int | FindAnim (const char *name)=0
| Find the index of the named animation. Returns -1 if not found.
virtual size_t | GetActiveAnimCount ()=0
| Returns the count of currently playing animation cycles.
virtual bool | GetActiveAnims (csSpriteCal3DActiveAnim *buffer, size_t max_length)=0
| Fills the supplied buffer with the information to reconstruct the exact animation mix currently playing in the model.
virtual int | GetAnimCount ()=0
| Returns the number of animations currently loaded for the core model.
virtual const char * | GetAnimName (int idx)=0
| Returns the name, from the xml file, of the indexed anim, or 0 if out of bounds.
virtual int | GetAnimType (int idx)=0
| Returns the type from the enum above, as specified in the XML.
virtual void | SetActiveAnims (const csSpriteCal3DActiveAnim *buffer, size_t anim_count)=0
| Uses the supplied buffer (created by GetActiveAnims) to recreate an exact mix of animation cycles and weights.
virtual bool | SetAnimAction (int idx, float delayIn, float delayOut)=0
| This adds a non-looping animation to the blend set for the cal3d Mixer.
virtual bool | SetAnimAction (const char *name, float delayIn, float delayOut)=0
| This adds a non-looping animation to the blend set for the cal3d Mixer.
virtual bool | SetAnimCycle (int idx, float weight)=0
| This clears the active anims for this sprite and sets it to use only the specified anim, where the anim is specified by index.
virtual bool | SetAnimCycle (const char *name, float weight)=0
| This clears the active anims for this sprite and sets it to use only the specified anim, where the anim is specified by name.
virtual void | SetDefaultIdleAnim (const char *name)=0
| This function sets the name to use when SetVelocity(0) is called.
virtual bool | SetVelocity (float vel, csRandomGen *rng=0)=0
| This function searches all actions specified as type TRAVEL for actions with a base velocity matching "vel", and blends them into a travel action.
## Public Member Functions
virtual iShaderVariableContext * | GetCoreMeshShaderVarContext (const char *meshName)=0
| Get the shader variable context for the attached mesh identified by name.
virtual bool | SetMaterial (const char *mesh_name, iMaterialWrapper *mat)=0
| Change the material on a named submesh. Returns true if successful.
virtual void | SetUserData (void *data)=0
| Set user data in the model, for access from the callback later, mostly.
Mesh attaching
virtual bool | AttachCoreMesh (int mesh_id, iMaterialWrapper *iMatWrap=0)=0
| This attaches a mesh with the specified calCoreModel id (as returned by iSpriteCal3DFactoryState::FindMeshName() to the instance of the model.
virtual bool | AttachCoreMesh (const char *meshname)=0
| This attaches a mesh with the specified name (from xml) to the instance of the model.
virtual bool | DetachCoreMesh (int mesh_id)=0
| This detaches a mesh with the specified calCoreModel id to the instance of the model.
virtual bool | DetachCoreMesh (const char *meshname)=0
| This detaches a mesh with the specified name (from xml) to the instance of the model.
Morph targets
virtual bool | BlendMorphTarget (int morph_animation_id, float weight, float delay)=0
| Blends the morph target.
virtual bool | ClearMorphTarget (int morph_animation_id, float delay)=0
| Clears the morph target.
Sockets
virtual iSpriteCal3DSocket * | FindSocket (const char *name) const =0
| find a named socket into the sprite.
virtual iSpriteCal3DSocket * | FindSocket (iMeshWrapper *mesh) const =0
| find a socked based on the sprite attached to it.
Time
virtual float | GetAnimationDuration ()=0
| Return whole animation duration.
virtual float | GetAnimationTime ()=0
| Return current animation time.
virtual float | GetTimeFactor ()=0
| Return the current time factor of the model.
virtual void | SetAnimationTime (float animationTime)=0
| Set current animation time.
virtual void | SetAnimTimeUpdateHandler (iAnimTimeUpdateHandler *)=0
| This gives you ability to update the internal Cal3d model directly rather than relying upon the default behavior which merely invokes CalModel::update().
virtual void | SetTimeFactor (float timeFactor)=0
| Set the animation time adjustment factor. 1=normal speed.
Direct Cal3d model manipulation
You can get access to the internal Cal3d Model class which sprcal3d wraps. Warning: If you use it directly, you run the risk of making sprcal3d and CalModel get out of sync. Use carefully!
virtual CalModel * | GetCal3DModel ()=0
| Gives access to the internal Cal3d Model instance.
LOD
virtual void | SetLOD (float lod)=0
| This function sets the Level of Detail used by the sprite.

## Detailed Description

This interface describes the API for changing the Cal3D sprite mesh object's animations playing and other current traits.

Definition at line 361 of file spritecal3d.h.

## Member Enumeration Documentation

anonymous enum

List of current animation types, used for introspection mostly.

Definition at line 369 of file spritecal3d.h.

## Member Function Documentation

virtual bool iSpriteCal3DState::AddAnimCycle | ( | int | idx,
|  | float | weight,
|  | float | delay |
| ) |  |  | `[pure virtual]`

Uses the specified index directly to add the anim cycle.

virtual bool iSpriteCal3DState::AddAnimCycle | ( | const char * | name,
|  | float | weight,
|  | float | delay |
| ) |  |  | `[pure virtual]`

This adds the specified animation to the ones already being blended by cal3d.

The weight value is dependent on other weights used, and is only relative. The delay is the period in seconds over which the blended weight will be interpolated from 0 to "weight" value. A cal3d anim cycle, by definition, is a looping animation (see SetAnimAction for non-looping anims).

virtual bool iSpriteCal3DState::AttachCoreMesh | ( | int | mesh_id,
|  | iMaterialWrapper * | iMatWrap = `0` |
| ) |  |  | `[pure virtual]`

This attaches a mesh with the specified calCoreModel id (as returned by iSpriteCal3DFactoryState::FindMeshName() to the instance of the model.

It is expected this function is only called by the mesh object itself under normal circumstances. Callers should normally refer to meshes by name to prevent behavior changes when xml order is updated. iMatWrap is the iMaterialWrapper to be used in rendering.

virtual bool iSpriteCal3DState::AttachCoreMesh | ( | const char * | meshname | ) | `[pure virtual]`

This attaches a mesh with the specified name (from xml) to the instance of the model.

virtual bool iSpriteCal3DState::BlendMorphTarget | ( | int | morph_animation_id,
|  | float | weight,
|  | float | delay |
| ) |  |  | `[pure virtual]`

Blends the morph target.

Parameters:

  | morph_animation_id | The id of the morph animation we want to blend.
  | weight | The weight of the morph target.
  | delay | The delay untill the full weight is reached.

Returns:
  False if something went wrong.

virtual void iSpriteCal3DState::ClearAllAnims | ( |  | ) | `[pure virtual]`

This resets all currently blended animations and stops the sprite.

virtual bool iSpriteCal3DState::ClearAnimCycle | ( | const char * | name,
|  | float | delay |
| ) |  |  | `[pure virtual]`

This removes the named animation from the current blend set over the period of time specifed by "delay" parm in seconds.

Returns true if the named animation was found; else false.

virtual bool iSpriteCal3DState::ClearAnimCycle | ( | int | idx,
|  | float | delay |
| ) |  |  | `[pure virtual]`

This removes the animation at index `idx' from the current blend set over the period of time specifed by "delay" parm in seconds.

virtual bool iSpriteCal3DState::ClearMorphTarget | ( | int | morph_animation_id,
|  | float | delay |
| ) |  |  | `[pure virtual]`

Clears the morph target.

Parameters:

  | morph_animation_id | The id of the morph animation we want to clear.
  | delay | The delay untill the morph target is cleared.

Returns:
  False if something went wrong.

virtual bool iSpriteCal3DState::DetachCoreMesh | ( | int | mesh_id | ) | `[pure virtual]`

This detaches a mesh with the specified calCoreModel id to the instance of the model.

It is expected this function is only called by the mesh object itself under normal circumstances. Callers should normally refer to meshes by name to prevent behavior changes when xml order is updated.

virtual bool iSpriteCal3DState::DetachCoreMesh | ( | const char * | meshname | ) | `[pure virtual]`

This detaches a mesh with the specified name (from xml) to the instance of the model.

Remarks:
  Note that changes made to the mesh's shader variable context will get lost.

virtual int iSpriteCal3DState::FindAnim | ( | const char * | name | ) | `[pure virtual]`

Find the index of the named animation. Returns -1 if not found.

virtual iSpriteCal3DSocket* iSpriteCal3DState::FindSocket | ( | const char * | name | ) | const`[pure virtual]`

find a named socket into the sprite.

virtual iSpriteCal3DSocket* iSpriteCal3DState::FindSocket | ( | iMeshWrapper * | mesh | ) | const`[pure virtual]`

find a socked based on the sprite attached to it.

virtual size_t iSpriteCal3DState::GetActiveAnimCount | ( |  | ) | `[pure virtual]`

Returns the count of currently playing animation cycles.

This should be used to allocate the buffer required by GetActiveAnims below.

virtual bool iSpriteCal3DState::GetActiveAnims | ( | csSpriteCal3DActiveAnim * | buffer,
|  | size_t | max_length |
| ) |  |  | `[pure virtual]`

Fills the supplied buffer with the information to reconstruct the exact animation mix currently playing in the model.

It does NOT include any non-repeating actions. Those must be handled separately, due to the timing issues.

Parameters:

  | buffer | Buffer receiving information about active animations.
  | max_length | Maximum number of entries that fit into buffer.

Returns:
  Whether the buffer was successfully filled.

virtual float iSpriteCal3DState::GetAnimationDuration | ( |  | ) | `[pure virtual]`

Return whole animation duration.

virtual float iSpriteCal3DState::GetAnimationTime | ( |  | ) | `[pure virtual]`

Return current animation time.

virtual int iSpriteCal3DState::GetAnimCount | ( |  | ) | `[pure virtual]`

Returns the number of animations currently loaded for the core model.

virtual const char* iSpriteCal3DState::GetAnimName | ( | int | idx | ) | `[pure virtual]`

Returns the name, from the xml file, of the indexed anim, or 0 if out of bounds.

virtual int iSpriteCal3DState::GetAnimType | ( | int | idx | ) | `[pure virtual]`

Returns the type from the enum above, as specified in the XML.

virtual CalModel* iSpriteCal3DState::GetCal3DModel | ( |  | ) | `[pure virtual]`

Gives access to the internal Cal3d Model instance.

virtual iShaderVariableContext* iSpriteCal3DState::GetCoreMeshShaderVarContext | ( | const char * | meshName | ) | `[pure virtual]`

Get the shader variable context for the attached mesh identified by name.

Returns:
  Shader variable context for the attached mesh name, 0 if the mesh is not attached.

virtual float iSpriteCal3DState::GetTimeFactor | ( |  | ) | `[pure virtual]`

Return the current time factor of the model.

virtual void iSpriteCal3DState::SetActiveAnims | ( | const csSpriteCal3DActiveAnim * | buffer,
|  | size_t | anim_count |
| ) |  |  | `[pure virtual]`

Uses the supplied buffer (created by GetActiveAnims) to recreate an exact mix of animation cycles and weights.

virtual bool iSpriteCal3DState::SetAnimAction | ( | int | idx,
|  | float | delayIn,
|  | float | delayOut |
| ) |  |  | `[pure virtual]`

This adds a non-looping animation to the blend set for the cal3d Mixer.

This animation will play one time overlaid on top of the other currently active animations. delayIn and delayOut allow you to fade in and fade out the action for smoothness of response.

virtual bool iSpriteCal3DState::SetAnimAction | ( | const char * | name,
|  | float | delayIn,
|  | float | delayOut |
| ) |  |  | `[pure virtual]`

This adds a non-looping animation to the blend set for the cal3d Mixer.

This animation will play one time overlaid on top of the other currently active animations. delayIn and delayOut allow you to fade in and fade out the action for smoothness of response.

virtual void iSpriteCal3DState::SetAnimationTime | ( | float | animationTime | ) | `[pure virtual]`

Set current animation time.

virtual bool iSpriteCal3DState::SetAnimCycle | ( | int | idx,
|  | float | weight |
| ) |  |  | `[pure virtual]`

This clears the active anims for this sprite and sets it to use only the specified anim, where the anim is specified by index.

virtual bool iSpriteCal3DState::SetAnimCycle | ( | const char * | name,
|  | float | weight |
| ) |  |  | `[pure virtual]`

This clears the active anims for this sprite and sets it to use only the specified anim, where the anim is specified by name.

virtual void iSpriteCal3DState::SetAnimTimeUpdateHandler | ( | iAnimTimeUpdateHandler * |  | ) | `[pure virtual]`

This gives you ability to update the internal Cal3d model directly rather than relying upon the default behavior which merely invokes CalModel::update().

You may need to do this, for example, when you want to move Cal3d skeleton from your own code (to implement rag-doll physics, for instance).

virtual void iSpriteCal3DState::SetDefaultIdleAnim | ( | const char * | name | ) | `[pure virtual]`

This function sets the name to use when SetVelocity(0) is called.

virtual void iSpriteCal3DState::SetLOD | ( | float | lod | ) | `[pure virtual]`

This function sets the Level of Detail used by the sprite.

This is used to reduce the polygon count and simplify the scene for the renderer.

virtual bool iSpriteCal3DState::SetMaterial | ( | const char * | mesh_name,
|  | iMaterialWrapper * | mat |
| ) |  |  | `[pure virtual]`

Change the material on a named submesh. Returns true if successful.

virtual void iSpriteCal3DState::SetTimeFactor | ( | float | timeFactor | ) | `[pure virtual]`

Set the animation time adjustment factor. 1=normal speed.

virtual void iSpriteCal3DState::SetUserData | ( | void * | data | ) | `[pure virtual]`

Set user data in the model, for access from the callback later, mostly.

virtual bool iSpriteCal3DState::SetVelocity | ( | float | vel,
|  | csRandomGen * | rng = `0` |
| ) |  |  | `[pure virtual]`

This function searches all actions specified as type TRAVEL for actions with a base velocity matching "vel", and blends them into a travel action.

If no animation is found with a base animation that exactly matches "vel" It selects animations with an appropriate velocity range and blends them to create the travel animation. The calling program is still responsible for actually moving the sprite.

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

- imesh/spritecal3d.h