ezEngine Release 26.3
Loading...
Searching...
No Matches
ezAnimController Class Reference

#include <AnimController.h>

Classes

struct  AnimClipInfo
 

Public Member Functions

void Initialize (const ezSkeletonResourceHandle &hSkeleton, ezAnimPoseGenerator &ref_poseGenerator, const ezSharedPtr< ezBlackboard > &pBlackboard=nullptr)
 
bool Update (ezTime diff, ezGameObject *pTarget, bool bEnableIK)
 
void GetRootMotion (ezVec3 &ref_vTranslation, ezAngle &ref_rotationX, ezAngle &ref_rotationY, ezAngle &ref_rotationZ) const
 
const ezSharedPtr< ezBlackboard > & GetBlackboard ()
 
ezAnimPoseGeneratorGetPoseGenerator ()
 
void SetOutputModelTransform (ezAnimGraphPinDataModelTransforms *pModelTransform)
 
void SetRootMotion (const ezVec3 &vTranslation, ezAngle rotationX, ezAngle rotationY, ezAngle rotationZ)
 
void AddOutputLocalTransforms (ezAnimGraphPinDataLocalTransforms *pLocalTransforms)
 
ezAnimGraphPinDataBoneWeightsAddPinDataBoneWeights ()
 
ezAnimGraphPinDataLocalTransformsAddPinDataLocalTransforms ()
 
ezAnimGraphPinDataModelTransformsAddPinDataModelTransforms ()
 
void AddAnimGraph (const ezAnimGraphResourceHandle &hGraph)
 
const AnimClipInfoGetAnimationClipInfo (ezTempHashedString sClipName) const
 
void SetAnimationClipInfo (const ezHashedString &sClipName, const AnimClipInfo &info)
 

Static Public Member Functions

static ezSharedPtr< ezAnimGraphSharedBoneWeightsCreateBoneWeights (const char *szUniqueName, const ezSkeletonResource &skeleton, ezDelegate< void(ezAnimGraphSharedBoneWeights &)> fill)
 

Friends

class ezAnimGraphTriggerOutputPin
 
class ezAnimGraphTriggerInputPin
 
class ezAnimGraphBoneWeightsInputPin
 
class ezAnimGraphBoneWeightsOutputPin
 
class ezAnimGraphLocalPoseInputPin
 
class ezAnimGraphLocalPoseOutputPin
 
class ezAnimGraphNumberInputPin
 
class ezAnimGraphNumberOutputPin
 
class ezAnimGraphBoolInputPin
 
class ezAnimGraphBoolOutputPin
 

Detailed Description

Manages and updates animation graph instances to generate animation poses.

This is the runtime bridge between animation graphs (ezAnimGraph) and the pose generation system (ezAnimPoseGenerator). It owns graph instances, manages their execution, handles data flow between graph nodes, and forwards the final pose to the renderer.

Responsibilities

  • Creates and updates an ezAnimGraphInstance object for each loaded graph
  • Allocates and manages pin data storage (bone weights, local poses, model poses)
  • Accumulates root motion from animations for character movement
  • Forwards the provided blackboard for data sharing between graph nodes and gameplay code
  • Maps animation clip names to actual animation clip resources
  • Manages shared bone weight masks across all characters

Usage Pattern

Typically owned by ezAnimationControllerComponent. The component calls Initialize() once, then Update() every frame to generate new animation poses.

Basic workflow:

ezAnimController controller;
controller.Initialize(skeletonHandle, poseGenerator, blackboard);
controller.AddAnimGraph(animGraphHandle);
controller.SetAnimationClipInfo("Walk", walkClipInfo);
// Each frame:
controller.Update(deltaTime, pGameObject, bEnableIK);
controller.GetRootMotion(translation, rotX, rotY, rotZ);
Definition AnimController.h:103
void GetRootMotion(ezVec3 &ref_vTranslation, ezAngle &ref_rotationX, ezAngle &ref_rotationY, ezAngle &ref_rotationZ) const
Definition AnimController.cpp:42
void AddAnimGraph(const ezAnimGraphResourceHandle &hGraph)
Definition AnimController.cpp:335
void SetAnimationClipInfo(const ezHashedString &sClipName, const AnimClipInfo &info)
Definition AnimController.cpp:380
void Initialize(const ezSkeletonResourceHandle &hSkeleton, ezAnimPoseGenerator &ref_poseGenerator, const ezSharedPtr< ezBlackboard > &pBlackboard=nullptr)
Definition AnimController.cpp:19
bool Update(ezTime diff, ezGameObject *pTarget, bool bEnableIK)
Definition AnimController.cpp:50

Blackboard Integration

The blackboard is used for communication between gameplay code and animation graphs. Nodes can read blackboard values (movement speed, aim direction) to drive blending, and write values (footstep events, animation state) back to gameplay.

Multiple Graphs

Multiple animation graphs can be added to create layered animations (e.g., base locomotion

  • upper body aim).

Member Function Documentation

◆ AddAnimGraph()

void ezAnimController::AddAnimGraph ( const ezAnimGraphResourceHandle hGraph)

Loads an animation graph and creates a runtime instance for it.

Multiple graphs can be added to layer animations. They are evaluated in the order added.

◆ CreateBoneWeights()

ezSharedPtr< ezAnimGraphSharedBoneWeights > ezAnimController::CreateBoneWeights ( const char *  szUniqueName,
const ezSkeletonResource skeleton,
ezDelegate< void(ezAnimGraphSharedBoneWeights &)>  fill 
)
static

Creates or retrieves a shared bone weight mask.

Bone weights are shared globally across all characters to save memory. The fill delegate is called only once when the weights are first created. Subsequent calls with the same name return the cached weights.

◆ GetRootMotion()

void ezAnimController::GetRootMotion ( ezVec3 ref_vTranslation,
ezAngle ref_rotationX,
ezAngle ref_rotationY,
ezAngle ref_rotationZ 
) const

Retrieves accumulated root motion from the last Update().

Root motion is the translation and rotation extracted from animations, used to move characters based on their animation. This could be applied to the character controller or entity.

◆ Initialize()

void ezAnimController::Initialize ( const ezSkeletonResourceHandle hSkeleton,
ezAnimPoseGenerator ref_poseGenerator,
const ezSharedPtr< ezBlackboard > &  pBlackboard = nullptr 
)

Initializes the controller with a skeleton and pose generator.

Must be called before adding graphs or updating. The optional blackboard is used for data sharing between animation graphs and gameplay code.

◆ SetAnimationClipInfo()

void ezAnimController::SetAnimationClipInfo ( const ezHashedString sClipName,
const AnimClipInfo info 
)

Sets which animation clip is used for the named animation.

Should only be called right at the start or when it is absolutely certain that an animation clip isn't in use right now, otherwise the running animation playback may produce weird results.

◆ Update()

bool ezAnimController::Update ( ezTime  diff,
ezGameObject pTarget,
bool  bEnableIK 
)

Updates all animation graph instances and generates the final pose.

Steps all nodes in all graphs, accumulates results, forwards the final pose to the pose generator, and sends ezMsgAnimationPoseUpdated to the target object and its children.

Returns false if the target requested to stop animating via msg.m_bContinueAnimating.


The documentation for this class was generated from the following files: