Open 3D Engine EMotionFX Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
EMotionFX::MotionEventTrack Class Reference

#include <MotionEventTrack.h>

Inherited by EMotionFX::AnimGraphSyncTrack.

Public Member Functions

 MotionEventTrack (Motion *motion)
 
 MotionEventTrack (const char *name, Motion *motion)
 
 MotionEventTrack (const MotionEventTrack &other)
 
MotionEventTrackoperator= (const MotionEventTrack &other)
 
void SetName (const char *name)
 
size_t AddEvent (float timeValue, EventDataPtr &&data)
 
size_t AddEvent (float timeValue, EventDataSet &&datas)
 
size_t AddEvent (float startTimeValue, float endTimeValue, EventDataPtr &&data)
 
size_t AddEvent (float startTimeValue, float endTimeValue, EventDataSet &&data)
 
void ProcessEvents (float startTime, float endTime, const MotionInstance *motionInstance) const
 
void ExtractEvents (float startTime, float endTime, const MotionInstance *motionInstance, AnimGraphEventBuffer *outEventBuffer) const
 
size_t GetNumEvents () const
 
const MotionEventGetEvent (size_t eventNr) const
 
MotionEventGetEvent (size_t eventNr)
 
void RemoveEvent (size_t eventNr)
 
void RemoveAllEvents ()
 
void Clear ()
 
const char * GetName () const
 
const AZStd::string & GetNameString () const
 
void SetIsEnabled (bool enabled)
 
bool GetIsEnabled () const
 
bool GetIsDeletable () const
 
void SetIsDeletable (bool isDeletable)
 
MotionGetMotion () const
 
void SetMotion (Motion *newMotion)
 
void CopyTo (MotionEventTrack *targetTrack) const
 
void ReserveNumEvents (size_t numEvents)
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
static MotionEventTrackCreate (Motion *motion)
 
static MotionEventTrackCreate (const char *name, Motion *motion)
 

Protected Attributes

AZStd::vector< MotionEventm_events
 
AZStd::string m_name
 
Motionm_motion
 The motion where this track belongs to.
 
bool m_enabled = true
 Is this track enabled?
 
bool m_deletable = true
 

Friends

class MotionEvent
 

Detailed Description

The motion event track, which stores all events and their data on a memory efficient way. Events have three generic properties: a time value, an event type string and a parameter string. Unique strings are only stored once in memory, so if you have for example ten events of the type "SOUND" only 1 string will be stored in memory, and the events will index into the table to retrieve the string. The event table can also figure out what events to process within a given time range. The handling of those events is done by the MotionEventHandler class that you specify to the MotionEventManager singleton.

Constructor & Destructor Documentation

◆ MotionEventTrack() [1/2]

EMotionFX::MotionEventTrack::MotionEventTrack ( Motion motion)

The constructor.

Parameters
motionThe motion object this track belongs to.

◆ MotionEventTrack() [2/2]

EMotionFX::MotionEventTrack::MotionEventTrack ( const char *  name,
Motion motion 
)

Extended constructor.

Parameters
nameThe name of the track.
motionThe motion object this track belongs to.

Member Function Documentation

◆ AddEvent() [1/2]

size_t EMotionFX::MotionEventTrack::AddEvent ( float  startTimeValue,
float  endTimeValue,
EventDataPtr &&  data 
)

Add an event to the event table. The events can be ordered in any order on time. So you do not need to add them in a sorted order based on time. This is already done automatically. The events will internally be stored sorted on time value.

Parameters
startTimeValueThe start time, in seconds, at which the event should occur.
endTimeValueThe end time, in seconds, at which this event should stop.
eventTypeIDThe unique event ID that you wish to add. Please keep in mind that you need to have the events registered with the EMotion FX event manager before you can add them!
parametersThe parameters of the event, which could be the filename of a sound file or anything else.
Returns
Returns the index to the event inside the table.
Note
Please beware that when you use this method, the event numbers/indices might change! This is because the events are stored in an ordered way, sorted on their time value. Adding events might insert events somewhere in the middle of the array, changing all event numbers.

◆ AddEvent() [2/2]

size_t EMotionFX::MotionEventTrack::AddEvent ( float  timeValue,
EventDataPtr &&  data 
)

Add a tick event to the event table.

A tick event is an event whose start time and end time are the same. The events can be ordered in any order on time. So you do not need to add them in a sorted order based on time. This is already done automatically. The events will internally be stored sorted on time value.

Parameters
timeValueThe time, in seconds, at which the event should occur.
eventTypeThe string describing the type of the event, this could for example be "SOUND" or whatever your game can process.
parametersThe parameters of the event, which could be the filename of a sound file or anything else.
Returns
Returns the index to the event inside the table.
Note
Please beware that when you use this method, the event numbers/indices might change! This is because the events are stored in an ordered way, sorted on their time value. Adding events might insert events somewhere in the middle of the array, changing all event numbers.

◆ Clear()

void EMotionFX::MotionEventTrack::Clear ( )

Remove all motion events and parameters from the table.

◆ Create() [1/2]

static MotionEventTrack * EMotionFX::MotionEventTrack::Create ( const char *  name,
Motion motion 
)
static

Extended creation.

Parameters
nameThe name of the track.
motionThe motion object this track belongs to.

◆ Create() [2/2]

static MotionEventTrack * EMotionFX::MotionEventTrack::Create ( Motion motion)
static

Creation method.

Parameters
motionThe motion object this track belongs to.

◆ GetEvent() [1/2]

MotionEvent & EMotionFX::MotionEventTrack::GetEvent ( size_t  eventNr)
inline

Get a given event from the table.

Parameters
eventNrThe event number you wish to retrieve. This must be in range of 0..GetNumEvents() - 1.
Returns
A reference to the event.

◆ GetEvent() [2/2]

const MotionEvent & EMotionFX::MotionEventTrack::GetEvent ( size_t  eventNr) const
inline

Get a given event from the table.

Parameters
eventNrThe event number you wish to retrieve. This must be in range of 0..GetNumEvents() - 1.
Returns
A const reference to the event.

◆ GetNumEvents()

size_t EMotionFX::MotionEventTrack::GetNumEvents ( ) const

Get the number of events stored inside the table.

Returns
The number of events stored inside this table.
See also
GetEvent

◆ ProcessEvents()

void EMotionFX::MotionEventTrack::ProcessEvents ( float  startTime,
float  endTime,
const MotionInstance motionInstance 
) const

Process all events within a given time range.

Parameters
startTimeThe start time of the range, in seconds.
endTimeThe end time of the range, in seconds.
actorInstanceThe actor instance on which to trigger the event.
motionInstanceThe motion instance which triggers the event.
Note
The end time is also allowed to be smaller than the start time.

◆ RemoveAllEvents()

void EMotionFX::MotionEventTrack::RemoveAllEvents ( )

Remove all motion events from the table. Does not remove the parameters.

◆ RemoveEvent()

void EMotionFX::MotionEventTrack::RemoveEvent ( size_t  eventNr)

Remove a given event from the table.

Parameters
eventNrThe event number to remove. This must be in range of 0..GetNumEvents() - 1.

◆ SetName()

void EMotionFX::MotionEventTrack::SetName ( const char *  name)

Set the name of the motion event track.

Parameters
nameThe name of the motion event track.

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