#include <MotionSystem.h>
Inherits MCore::RefCounted.
Inherited by EMotionFX::MotionLayerSystem.
The motion system base class. A motion system has to manage how motions are being mixed and blended together. When we make a call to Actor::PlayMotion(...) this system will have to handle the things which need to happen in order to play this motion. Also when motions are stopped it has to handle this. Smooth transitions between motions also have to be handled by this class, as well as the mixing of motions, where specific parts of the body are overwritten by a given motion. The motion system also contains a motion queue, which is responsible for some very basic scheduling of motions.
◆ MotionSystem()
EMotionFX::MotionSystem::MotionSystem |
( |
ActorInstance * |
actorInstance | ) |
|
|
protected |
Constructor.
- Parameters
-
actorInstance | The actor to which this layer belongs to. |
◆ ~MotionSystem()
virtual EMotionFX::MotionSystem::~MotionSystem |
( |
| ) |
|
|
protectedvirtual |
◆ AddMotionInstance()
void EMotionFX::MotionSystem::AddMotionInstance |
( |
MotionInstance * |
instance | ) |
|
Add a given motion instance to this motion system.
- Parameters
-
instance | The motion instance to add. |
◆ AddMotionQueue()
void EMotionFX::MotionSystem::AddMotionQueue |
( |
MotionQueue * |
motionQueue | ) |
|
Add a motion queue to the motion system. All motions in the given motion queue will be put after the existing ones.
- Parameters
-
motionQueue | The motion queue to add. |
◆ CheckIfIsPlayingMotion()
bool EMotionFX::MotionSystem::CheckIfIsPlayingMotion |
( |
Motion * |
motion, |
|
|
bool |
ignorePausedMotions = false |
|
) |
| const |
Check if there is a motion instance playing which is an instance of a specified motion. This can be used to check if for example there currently is playing a 'walk' motion on a given actor.
- Parameters
-
motion | A pointer to the motion we want to check. So this method will answer the question "Is there still an Actor::PlayMotion( motion ) active?" |
ignorePausedMotions | Ignore paused motions and make sure to only return true in case there is an actually playing motion. |
- Returns
- Returns true when there still is a motion instance active, which uses the specified motion, otherwise false is returned.
◆ CheckIfIsValidMotionInstance()
bool EMotionFX::MotionSystem::CheckIfIsValidMotionInstance |
( |
MotionInstance * |
instance | ) |
const |
Checks if a given motion instance is still valid. With valid we mean if it has not been deleted from memory yet. Because when a motion is stopped the motion instance will automatically be deleted from the Actor as well as from memory. You can validate if a given motion instance is still valid by passing it to this method. NOTE: Be sure to pass only motion instances which are returned by the PlayMotion method of this actor! Here follows some example code:
ActorInstance* human = .....; // assuming that human now contains a valid Actor.
ActorInstance* orc = ....; // assuming that orc now contains a valid Actor.
Motion* walkMotion = ....; // assuming that walkMotion now contains a valid Motion.
// start playing the walk motion on the human
MotionInstance* humanWalk = human->GetMotionSystem()->PlayMotion( walkMotion );
// this is valid to execute, so no problems with this
// isValid will be 'true' at this moment
bool isValid = human->GetMotionSystem()->IsValidMotionInfo( humanWalk );
// this is VERY WRONG! :)
// you cannot validate a motion instance returned by the human on the orc
// isValid2 will now contain 'false', while the motion is really still valid!
// but it's simply not valid inside the orc...
bool isValid2 = orc->GetMotionSystem()->IsValidMotionInfo( humanWalk );
◆ CreateMotionInstance()
Create the motion instance and add the motion info the parent actor. It also creates the motion links.
- Parameters
-
motion | The motion from which the system creates the instance from. |
info | A pointer to the playback information. |
- Returns
- A pointer to the created motion instance.
◆ FindFirstNonMixingMotionInstance()
virtual MotionInstance* EMotionFX::MotionSystem::FindFirstNonMixingMotionInstance |
( |
| ) |
const |
|
pure virtual |
Recursively search for the first non mixing motion and return the motion instance.
- Returns
- A pointer to the motion instance.
Implemented in EMotionFX::MotionLayerSystem.
◆ GetActorInstance()
ActorInstance* EMotionFX::MotionSystem::GetActorInstance |
( |
| ) |
const |
Return the actor instance to which this motion system belongs to.
- Returns
- The actor instance to which this motion system belongs to.
◆ GetIsPlaying()
bool EMotionFX::MotionSystem::GetIsPlaying |
( |
| ) |
const |
Test if there is currently a motion playing or active. Motions which are in pause mode will also count as playing. So in case of motions being paused a value of "true" will be returned as well.
- Returns
- True if there is a motion playing, false if not.
◆ GetMotionInstance()
MotionInstance* EMotionFX::MotionSystem::GetMotionInstance |
( |
size_t |
nr | ) |
const |
Get a given motion instance. Every motion instance inside an actor represents a motion which is currently playing or active inside the actor. Motion instances are automatically removed from the actor once they are not used anymore. This for example happens when a motion instance has finished playing. Before you do any calls to methods of a given motion instance, always first use the IsValidMotionInstance() method to check if the motion instance has not yet been removed from the actor (and from memory).
- Parameters
-
nr | The motion instance number to get. |
- Returns
- A pointer to the motion instance.
- See also
- IsValidMotionInstance
◆ GetMotionQueue()
MotionQueue* EMotionFX::MotionSystem::GetMotionQueue |
( |
| ) |
const |
Return motion queue pointer.
- Returns
- A pointer to the motion queue.
◆ GetNumMotionInstances()
size_t EMotionFX::MotionSystem::GetNumMotionInstances |
( |
| ) |
const |
Get the number of active motion instances inside this actor. Every motion instance inside an actor represents a motion which is currently playing or active inside the actor. Motion instances are automatically removed from the actor once they are not used anymore. This for example happens when a motion instance has finished playing. Before you do any calls to methods of a given motion instance, always first use the IsValidMotionInstance() method to check if the motion instance has not yet been removed from the actor (and from memory).
- Returns
- The number of active motion instances inside this actor.
- See also
- IsValidMotionInstance
◆ GetType()
virtual uint32 EMotionFX::MotionSystem::GetType |
( |
| ) |
const |
|
pure virtual |
◆ GetTypeString()
virtual const char* EMotionFX::MotionSystem::GetTypeString |
( |
| ) |
const |
|
pure virtual |
Get the type identification string. This can be a description or the class name of the motion system.
- Returns
- A pointer to the string containing the name.
Implemented in EMotionFX::MotionLayerSystem.
◆ PlayMotion()
Start playing the specified motion on this actor.
- Parameters
-
motion | The motion to play. |
info | A pointer to an object containing playback information. This pointer is NOT allowed to be nullptr here. |
- Returns
- A pointer to a created motion instance object. You can use this motion instance object to adjust and retrieve playback information at any time.
- See also
- PlayBackInfo
◆ RemoveMotion() [1/2]
void EMotionFX::MotionSystem::RemoveMotion |
( |
MotionInstance * |
motion, |
|
|
bool |
delMem = true |
|
) |
| |
Remove a given motion.
- Parameters
-
motion | The motion to remove. |
delMem | If true the allocated memory of the motion will be deleted. |
◆ RemoveMotion() [2/2]
void EMotionFX::MotionSystem::RemoveMotion |
( |
size_t |
nr, |
|
|
bool |
deleteMem = true |
|
) |
| |
Remove a given motion.
- Parameters
-
nr | The motion to remove. |
deleteMem | If true the allocated memory of the motion will be deleted. |
◆ RemoveMotionInstance()
virtual bool EMotionFX::MotionSystem::RemoveMotionInstance |
( |
MotionInstance * |
instance | ) |
|
|
virtual |
Removes a given motion instance from the actor, including all motion links in the nodes inside this Actor.
- Parameters
-
instance | The motion instance to remove. |
- Returns
- Returns true when everything went fine and will return false when the instance could not be removed from any of these nodes or from this actor itself.
◆ SetMotionQueue()
void EMotionFX::MotionSystem::SetMotionQueue |
( |
MotionQueue * |
motionQueue | ) |
|
Set a new motion queue. Old one will be deleted.
- Parameters
-
motionQueue | The motion queue to set. |
◆ StartMotion()
Start playing the specified motion on this actor. The difference with PlayMotion is that PlayMotion takes care of the calls to CreateMotionInstance, and handles the insertion into the motion queue, etc. This method should purely start the motion.
- Parameters
-
motion | The motion to play. |
info | A pointer to an object containing playback information. This pointer is NOT allowed to be nullptr here. |
- Returns
- A pointer to a created motion instance object. You can use this motion instance object to adjust and retrieve playback information at any time.
- See also
- PlayBackInfo
◆ StopAllMotions() [1/2]
void EMotionFX::MotionSystem::StopAllMotions |
( |
| ) |
|
Stop playing all motion instances. The fade-out times used are the ones setup in the motion instances.
◆ StopAllMotions() [2/2]
void EMotionFX::MotionSystem::StopAllMotions |
( |
Motion * |
motion | ) |
|
Stop playing all motion instances using a given motion object. The fade-out times used are the ones setup in the motion instances.
- Parameters
-
motion | All motion instances that use this given motion will be stopped. |
◆ Update()
virtual void EMotionFX::MotionSystem::Update |
( |
float |
timePassed, |
|
|
bool |
updateNodes |
|
) |
| |
|
pure virtual |
Update this character motions, if updateNodes is false only time values are updated. If it's true, the heavy calcs (forward kinematics and other transformations) are performed.
- Parameters
-
timePassed | The time passed since the last call. |
updateNodes | If true the nodes will be updated. |
Implemented in EMotionFX::MotionLayerSystem.
◆ UpdateMotionInstances()
void EMotionFX::MotionSystem::UpdateMotionInstances |
( |
float |
timePassed | ) |
|
|
protected |
Update the motion instances.
- Parameters
-
timePassed | The time passed since the last call. |
◆ m_actorInstance
The actor instance where this motion system belongs to.
◆ m_motionInstances
AZStd::vector<MotionInstance*> EMotionFX::MotionSystem::m_motionInstances |
|
protected |
The collection of motion instances.
◆ m_motionQueue
The documentation for this class was generated from the following file:
- Gems/EMotionFX/Code/EMotionFX/Source/MotionSystem.h