hi,
with unreal engine 5.0.3, i wanna create any blendshape curve of animation sequenece from json data.
codes :
import unreal
import os,json,sys,math,time
def _tv_float_curves(self,anim_sequence,node,curve_dict):
times=unreal.Array(float)
values=unreal.Array(float)
node_name = node.split(':')[-1]
for _index in curve_dict.keys():
curve_name = curve_dict[_index]['DisplayName']
tvp = curve_dict[_index]['Keys']
times=tvp['Time']
values=tvp['Value']
# default from time 0 to end
if times == []:
for n in range(len(values)):
times.append(n/self.frame_rate)
self.first_time = times[0]
if len(list(set(values)))==1:
times=[times[0]-self.first_time]
values=[values[0]]
floatCurve=unreal.AnimationLibrary.add_curve(anim_sequence,
curve_name, curve_type=unreal.RawCurveTrackTypes.RCT_FLOAT,
meta_data_curve=False)
#print(curve_name, times, values)
new_times = self._move_times_to_zero(times)
unreal.AnimationLibrary.add_float_curve_keys(anim_sequence, curve_name, new_times, values)
unreal.log_flush()
return
It is very very slowly more than UE4.
in the source code
\UnrealEngine\Engine\Source\Runtime\Engine\Private\Animation\AnimSequence.cpp
Anyone be removed like old modules FloatCurve.AddKey(args).
We need to loop through this statement, adding any curves.Restore the performance with UE4 old version,please!
unreal.AnimationLibrary.add_float_curve_keys(anim_sequence, curve_name, new_times, values)