Navigation
API > API/Plugins > API/Plugins/MLDeformerFrameworkEditor
The training model base class. This class is used to interface with Python by providing some methods you can call inside your python training code. For example it allows you to get all the sampled data, such as the deltas, bones and curve values. When you create a new model you need to create a class inherited from this base class, and define a Train method inside it as follows:
//Doesn'tneedanimplementationinsidecpp,justadeclarationintheheaderfile.int32Train()const;
Now inside your Python class you do something like:
@unreal.uclass()classYourModelPythonTrainingModel(unreal.YourTrainingModel):@unreal.ufunction(override=True)deftrain(self):#...dotraininghere...return0#Avalueof0issuccess,1meansaborted,seeETrainingResult.
The editor will execute the Train method, which will trigger the "train" method in your Python class to be executed. Keep in mind that in Unreal Engine all python code is lower case. So a "Train" method inside c++ will need to be called "train" inside the python code. Or if you have something called "PerformMyTraining" it will need to be called "perform_my_training" inside Python.
| Name | UMLDeformerTrainingModel |
| Type | class |
| Header File | /Engine/Plugins/Animation/MLDeformer/MLDeformerFramework/Source/MLDeformerFrameworkEditor/Public/MLDeformerTrainingModel.h |
| Include Path | #include "MLDeformerTrainingModel.h" |
Syntax
UCLASS (MinimalAPI, Blueprintable)
class UMLDeformerTrainingModel : public UObject
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UMLDeformerTrainingModel
Derived Classes
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| DefaultMaskName | FName | The default mask name. | MLDeformerTrainingModel.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| MaskIndexPerSample | TArray< int32 > | The mask index for each sample. | MLDeformerTrainingModel.h |
|
| SampleBoneRotations | TArray< float > | The bone rotations in bone (local) space for this sample. This is updated after NextSample is called and is 6 floats per bone (2 columns of 3x3 rotation matrix). | MLDeformerTrainingModel.h |
|
| SampleCurveValues | TArray< float > | The curve weights. This is updated after NextSample is called. | MLDeformerTrainingModel.h |
|
| SampleDeltas | TArray< float > | The delta values per vertex for this sample. This is updated after NextSample is called. Contains an xyz (3 floats) for each vertex. | MLDeformerTrainingModel.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TArray< int32 > GetMaskIndexPerSampleArray() |
For each sample we took, this contains the index inside the mask as returned by the GetTrainingInputAnimMasks() array. | MLDeformerTrainingModel.h |
|
UMLDeformerModel * GetModel() |
Get the runtime ML Deformer model object. | MLDeformerTrainingModel.h |
|
bool GetNeedsResampling () |
Check whether we need to resample the inputs and outputs, or if we can use a cached version. | MLDeformerTrainingModel.h |
|
int32 GetNumberSampleCurves() |
Get number of input curves. | MLDeformerTrainingModel.h |
|
int32 GetNumberSampleDeltas() |
Get the number of vertex deltas. | MLDeformerTrainingModel.h |
|
int32 GetNumberSampleTransforms() |
Get the number of input transforms. This is the number of bones. | MLDeformerTrainingModel.h |
|
TArray< float > GetTrainingInputAnimMaskData
(
FName MaskName |
Get the per vertex data for a given mask name. | MLDeformerTrainingModel.h |
|
| Get the names of all valid training animation masks. | MLDeformerTrainingModel.h |
|
|
virtual void Init
(
UE::MLDeformer::FMLDeformerEditorModel* InEditorModel |
Initialize the training model. This is automatically called by the editor. | MLDeformerTrainingModel.h | |
bool NextSample () |
Take the next sample. | MLDeformerTrainingModel.h |
|
int32 NumSamples () |
Get the number of samples in this data set. | MLDeformerTrainingModel.h |
|
void ResetSampling () |
This will make the sampling start again from the beginning. | MLDeformerTrainingModel.h |
|
bool SetCurrentSampleIndex
(
int32 Index |
Set the current sample frame. | MLDeformerTrainingModel.h |
|
| Set the list of possible training devices. | MLDeformerTrainingModel.h |
|
|
void SetNeedsResampling
(
bool bNeedsResampling |
Specify whether we need to resample any cached data or not, because our input assets, or any other relevant settings changed that would invalidate the cached data. | MLDeformerTrainingModel.h |
|
void SetNumFloatsPerCurve
(
int32 NumFloatsPerCurve |
Set the number of floats per curve. On default this is one. | MLDeformerTrainingModel.h |
|
void UpdateAvailableDevices() |
MLDeformerTrainingModel.h |
|
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual bool FindNextAnimToSample
(
int32& OutNextAnimIndex |
Find the next input animation to sample from. | MLDeformerTrainingModel.h | |
UE::MLDeformer::FMLDeformerEditorModel * GetEditorModel() |
Get a pointer to the editor model. | MLDeformerTrainingModel.h | |
int32 GetMaskIndexForAnimIndex
(
int32 AnimIndex |
Get the mask index for a given input training animation. | MLDeformerTrainingModel.h | |
virtual bool SampleFrame
(
int32 Index |
This updates the sample deltas, curves, and bone rotations. | MLDeformerTrainingModel.h | |
virtual bool SampleNextFrame() |
Sample the next frame in the sequence of samples. | MLDeformerTrainingModel.h | |
void SetEditorModel
(
UE::MLDeformer::FMLDeformerEditorModel* InModel |
Change the pointer to the editor model. | MLDeformerTrainingModel.h |