Open 3D Engine MotionMatching 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::MotionMatching::Feature Class Referenceabstract

#include <Feature.h>

Inherited by EMotionFX::MotionMatching::FeatureAngularVelocity, EMotionFX::MotionMatching::FeaturePosition, EMotionFX::MotionMatching::FeatureTrajectory, and EMotionFX::MotionMatching::FeatureVelocity.

Classes

struct  ExtractFeatureContext
 
struct  FrameCostContext
 
struct  InitSettings
 
struct  QueryVectorContext
 

Public Types

enum  ResidualType { Absolute , Squared }
 

Public Member Functions

virtual bool Init (const InitSettings &settings)
 
virtual void ExtractFeatureValues (const ExtractFeatureContext &context)=0
 
virtual void FillQueryVector (QueryVector &queryVector, const QueryVectorContext &context)=0
 
virtual float CalculateFrameCost (size_t frameIndex, const FrameCostContext &context) const
 
void SetCostFactor (float costFactor)
 
float GetCostFactor () const
 
virtual void DebugDraw (AzFramework::DebugDisplayRequests &debugDisplay, const Pose &currentPose, const FeatureMatrix &featureMatrix, const FeatureMatrixTransformer *featureTransformer, size_t frameIndex)
 
void SetDebugDrawColor (const AZ::Color &color)
 
const AZ::Color & GetDebugDrawColor () const
 
void SetDebugDrawEnabled (bool enabled)
 
bool GetDebugDrawEnabled () const
 
void SetJointName (const AZStd::string &jointName)
 
const AZStd::string & GetJointName () const
 
void SetRelativeToJointName (const AZStd::string &jointName)
 
const AZStd::string & GetRelativeToJointName () const
 
void SetName (const AZStd::string &name)
 
const AZStd::string & GetName () const
 
virtual size_t GetNumDimensions () const =0
 
virtual AZStd::string GetDimensionName (size_t index) const
 
FeatureMatrix::Index GetColumnOffset () const
 
void SetColumnOffset (FeatureMatrix::Index offset)
 
const AZ::TypeId & GetId () const
 
size_t GetRelativeToNodeIndex () const
 
void SetRelativeToNodeIndex (size_t nodeIndex)
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Protected Member Functions

float GetNormalizedDirectionDifference (const AZ::Vector2 &directionA, const AZ::Vector2 &directionB) const
 
float GetNormalizedDirectionDifference (const AZ::Vector3 &directionA, const AZ::Vector3 &directionB) const
 
float CalcResidual (float value) const
 
float CalcResidual (const AZ::Vector3 &a, const AZ::Vector3 &b) const
 
virtual AZ::Crc32 GetCostFactorVisibility () const
 

Protected Attributes

AZ::TypeId m_id = AZ::TypeId::CreateRandom()
 
AZStd::string m_name
 
AZStd::string m_jointName
 
AZStd::string m_relativeToJointName
 
AZ::Color m_debugColor = AZ::Colors::Green
 
bool m_debugDrawEnabled = false
 
float m_costFactor = 1.0f
 
ResidualType m_residualType = ResidualType::Absolute
 
FeatureMatrix::Index m_featureColumnOffset
 
size_t m_relativeToNodeIndex = InvalidIndex
 
size_t m_jointIndex = InvalidIndex
 

Detailed Description

A feature is a property extracted from the animation data and is used by the motion matching algorithm to find the next best matching frame. Examples of features are the position of the feet joints, the linear or angular velocity of the knee joints or the trajectory history and future trajectory of the root joint. We can also encode environment sensations like obstacle positions and height, the location of the sword of an enemy character or a football's position and velocity. Their purpose is to describe a frame of the animation by their key characteristics and sometimes enhance the actual keyframe data (pos/rot/scale per joint) by e.g. taking the time domain into account and calculate the velocity or acceleration, or a whole trajectory to describe where the given joint came from to reach the frame and the path it moves along in the near future. @Note: Features are extracted and stored relative to a given joint, in most cases the motion extraction or root joint, and thus are in model-space. This makes the search algorithm invariant to the character location and orientation and the extracted features, like e.g. a joint position or velocity, translate and rotate along with the character.

Member Enumeration Documentation

◆ ResidualType

Specifies how the feature value differences (residuals), between the input query values and the frames in the motion database that sum up the feature cost, are calculated.

Member Function Documentation

◆ GetNormalizedDirectionDifference()

float EMotionFX::MotionMatching::Feature::GetNormalizedDirectionDifference ( const AZ::Vector2 &  directionA,
const AZ::Vector2 &  directionB 
) const
protected

Calculate a normalized direction vector difference between the two given vectors. A dot product of the two vectors is taken and the result in range [-1, 1] is scaled to [0, 1].

Returns
Normalized, absolute difference between the vectors. Angle difference dot result cost 0.0 degrees 1.0 0.0 90.0 degrees 0.0 0.5 180.0 degrees -1.0 1.0 270.0 degrees 0.0 0.5

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