unreal.MLDeformerTrainingModel
¶
- class unreal.MLDeformerTrainingModel(outer: Object | None = None, name: Name | str = 'None')¶
Bases:
Object
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: code{.cpp}: // Doesn’t need an implementation inside cpp, just a declaration in the header file. UFUNCTION(BlueprintImplementableEvent, Category = “Training Model”) int32 Train() const; endcode: Now inside your Python class you do something like: code{.py}: unreal.uclass(): class YourModelPythonTrainingModel(unreal.YourTrainingModel): unreal.ufunction(override=True): def train(self): # …do training here… return 0 # A value of 0 is success, 1 means aborted, see ETrainingResult. endcode: 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.
C++ Source:
Plugin: MLDeformerFramework
Module: MLDeformerFrameworkEditor
File: MLDeformerTrainingModel.h
Editor Properties: (see get_editor_property/set_editor_property)
sample_bone_rotations
(Array[float]): [Read-Write] The bone rotations in bone (local) space for this sample. This is updated after SetCurrentSampleIndex is called and is 6 floats per bone (2 columns of 3x3 rotation matrix).sample_curve_values
(Array[float]): [Read-Write] The curve weights. This is updated after SetCurrentSampleIndex is called.sample_deltas
(Array[float]): [Read-Write] The delta values per vertex for this sample. This is updated after SetCurrentSampleIndex is called. Contains an xyz (3 floats) for each vertex.
- get_model() MLDeformerModel ¶
Get the runtime ML Deformer model object.
- Return type:
- get_needs_resampling() bool ¶
Check whether we need to resample the inputs and outputs, or if we can use a cached version. This will return true if any inputs changed, that indicate that we should regenerate any cached data.
- Returns:
Returns true when we need to regenerate any cached data, otherwise false is returned.
- Return type:
- get_number_sample_curves() int32 ¶
Get number of input curves.
- Return type:
int32
- get_number_sample_deltas() int32 ¶
Get the number of vertex deltas.
- Return type:
int32
- get_number_sample_transforms() int32 ¶
Get the number of input transforms. This is the number of bones.
- Return type:
int32
- num_samples() int32 ¶
Get the number of samples in this data set. This is the number of sample frames we want to train on.
- Return type:
int32
- property sample_bone_rotations: None¶
[Read-Write] The bone rotations in bone (local) space for this sample. This is updated after SetCurrentSampleIndex is called and is 6 floats per bone (2 columns of 3x3 rotation matrix).
- property sample_curve_values: None¶
[Read-Write] The curve weights. This is updated after SetCurrentSampleIndex is called.
- property sample_deltas: None¶
[Read-Write] The delta values per vertex for this sample. This is updated after SetCurrentSampleIndex is called. Contains an xyz (3 floats) for each vertex.
- set_current_sample_index(index) bool ¶
Set the current sample frame. This will internally call the SampleFrame method, which will update the deltas, curve values and bone rotations. You call this before getting the input bone/curve and vertex delta values.
- Parameters:
index (int32) – The training data frame/sample number.
- Returns:
Returns true when successful, or false when the specified sample index is out of range.
- Return type: