Calculates the animated node transformations for a given scene and timestamp.
More...
Calculates the animated node transformations for a given scene and timestamp.
Create an instance for a aiScene you want to animate and set the current animation to play. You can then have the instance calculate the current pose for all nodes by calling Calculate() for a given timestamp. After this you can retrieve the present transformation for a given node by calling GetLocalTransform() or GetGlobalTransform(). A full set of bone matrices can be retrieved by GetBoneMatrices() for a given mesh.
◆ BoneMap
Name to node map to quickly find nodes for given bones by their name.
◆ NodeMap
Name to node map to quickly find nodes by their name.
◆ SceneAnimator()
SceneAnimator::SceneAnimator |
( |
const aiScene * |
pScene, |
|
|
size_t |
pAnimIndex = 0 |
|
) |
| |
Constructor for a given scene.
The object keeps a reference to the scene during its lifetime, but ownership stays at the caller.
- Parameters
-
pScene | The scene to animate. |
pAnimIndex | [optional] Index of the animation to play. Assumed to be 0 if not given. |
◆ ~SceneAnimator()
SceneAnimator::~SceneAnimator |
( |
| ) |
|
◆ Calculate()
void SceneAnimator::Calculate |
( |
double |
pTime | ) |
|
Calculates the node transformations for the scene.
Call this to get uptodate results before calling one of the getters.
- Parameters
-
pTime | Current time. Can be an arbitrary range. |
◆ CalculateGlobalTransform()
void SceneAnimator::CalculateGlobalTransform |
( |
SceneAnimNode * |
pInternalNode | ) |
|
|
protected |
Calculates the global transformation matrix for the given internal node.
◆ CreateNodeTree()
Recursively creates an internal node structure matching the current scene and animation.
◆ CurrentAnim()
aiAnimation* AssimpView::SceneAnimator::CurrentAnim |
( |
| ) |
const |
|
inline |
Get the current animation or NULL.
◆ CurrentAnimIndex()
size_t AssimpView::SceneAnimator::CurrentAnimIndex |
( |
| ) |
const |
|
inline |
Get the current animation index.
◆ GetBoneMatrices()
const std::vector< aiMatrix4x4 > & SceneAnimator::GetBoneMatrices |
( |
const aiNode * |
pNode, |
|
|
size_t |
pMeshIndex = 0 |
|
) |
| |
Calculates the bone matrices for the given mesh.
Each bone matrix transforms from mesh space in bind pose to mesh space in skinned pose, it does not contain the mesh's world matrix. Thus the usual matrix chain for using in the vertex shader is
boneMatrix * worldMatrix * viewMatrix * projMatrix
- Parameters
-
pNode | The node carrying the mesh. |
pMeshIndex | Index of the mesh in the node's mesh array. The NODE's mesh array, not the scene's mesh array! Leave out to use the first mesh of the node, which is usually also the only one. |
- Returns
- A reference to a vector of bone matrices. Stays stable till the next call to GetBoneMatrices();
◆ GetGlobalTransform()
Retrieves the most recent global transformation matrix for the given node.
The returned matrix is in world space, which is the same coordinate space as the transformation of the scene's root node. If the node is not animated, the node's original transformation is returned so that you can safely use or assign it to the node itsself. If there is no node with the given name, the identity matrix is returned. All transformations are updated whenever Calculate() is called.
- Parameters
-
pNodeName | Name of the node |
- Returns
- A reference to the node's most recently calculated global transformation matrix.
◆ GetLocalTransform()
Retrieves the most recent local transformation matrix for the given node.
The returned matrix is in the node's parent's local space, just like the original node's transformation matrix. If the node is not animated, the node's original transformation is returned so that you can safely use or assign it to the node itsself. If there is no node with the given name, the identity matrix is returned. All transformations are updated whenever Calculate() is called.
- Parameters
-
pNodeName | Name of the node |
- Returns
- A reference to the node's most recently calculated local transformation matrix.
◆ SetAnimIndex()
void SceneAnimator::SetAnimIndex |
( |
size_t |
pAnimIndex | ) |
|
Sets the animation to use for playback.
This also recreates the internal mapping structures, which might take a few cycles.
- Parameters
-
pAnimIndex | Index of the animation in the scene's animation array |
◆ UpdateTransforms()
Recursively updates the internal node transformations from the given matrix array.
◆ mAnimEvaluator
The AnimEvaluator we use to calculate the current pose for the current animation.
◆ mBoneNodesByName
BoneMap AssimpView::SceneAnimator::mBoneNodesByName |
|
protected |
◆ mCurrentAnimIndex
int AssimpView::SceneAnimator::mCurrentAnimIndex |
|
protected |
◆ mNodesByName
NodeMap AssimpView::SceneAnimator::mNodesByName |
|
protected |
◆ mRootNode
Root node of the internal scene structure.
◆ mScene
const aiScene* AssimpView::SceneAnimator::mScene |
|
protected |
The scene we're operating on.
◆ mTransforms
std::vector<aiMatrix4x4> AssimpView::SceneAnimator::mTransforms |
|
protected |
Array to return transformations results inside.
The documentation for this class was generated from the following files: