Skip to content

Commit 2b1e8f4

Browse files
author
Roberto De Ioris
authored
Update SnippetsForStaticAndSkeletalMeshes.md
1 parent 01e15d6 commit 2b1e8f4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tutorials/SnippetsForStaticAndSkeletalMeshes.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,30 @@ for idx, import_index in enumerate(import_map):
12381238
...
12391239
```
12401240

1241+
Finally, animations in Unreal have a fixed number of frames, while often we have only keyframes (tuple of time and value).
1242+
1243+
For this reason a common operation is to generate a new keyframe from a non linear series of keyframes. The numpy.interp() function is really handy, the following snippets show how we get a vector at specific time from a series of non-linear vector-based keyframes.
1244+
1245+
```python
1246+
def interpolate_vector(self, timeline, t):
1247+
keys = []
1248+
x_values = []
1249+
y_values = []
1250+
z_values = []
1251+
for key, value in timeline:
1252+
keys.append(key)
1253+
x_values.append(value[0])
1254+
y_values.append(value[1])
1255+
z_values.append(value[2])
1256+
1257+
x = numpy.interp(t, keys, x_values)
1258+
y = numpy.interp(t, keys, y_values)
1259+
z = numpy.interp(t, keys, z_values)
1260+
return FVector(x, y, z)
1261+
```
1262+
1263+
Remember, you can use the same approach with quaternions, but NOT with rotators !
1264+
12411265
## Animations: Getting curves from BVH files
12421266

1243-
BVH files are interesting for lot of reasons. First of all, BVH is basically the standard de-facto for motion capture devices. It is a textual human-readable format. And, maybe more important for this page, will heavily push your linear-algebra skills...
1267+
BVH files are interesting for lot of reasons. First of all, BVH is basically the de-facto standard for motion capture devices. It is a textual human-readable format. And, maybe more important for this page, will heavily push your linear-algebra skills...

0 commit comments

Comments
 (0)