Last change
on this file since 1131 was 1114, checked in by iritscen, 5 years ago |
Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1114] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
| 4 | namespace Oni.Physics
|
---|
| 5 | {
|
---|
| 6 | internal class ObjectAnimation
|
---|
| 7 | {
|
---|
| 8 | public string Name;
|
---|
| 9 | public ObjectAnimationFlags Flags;
|
---|
| 10 | public int Length;
|
---|
| 11 | public int Stop;
|
---|
| 12 | public ObjectAnimationKey[] Keys;
|
---|
| 13 |
|
---|
| 14 | public List<ObjectAnimationKey> Interpolate()
|
---|
| 15 | {
|
---|
| 16 | var result = new List<ObjectAnimationKey>(Length);
|
---|
| 17 |
|
---|
| 18 | for (int i = 1; i < Keys.Length; i++)
|
---|
| 19 | {
|
---|
| 20 | var key0 = Keys[i - 1];
|
---|
| 21 | var key1 = Keys[i];
|
---|
| 22 |
|
---|
| 23 | result.Add(key0);
|
---|
| 24 |
|
---|
| 25 | for (int j = key0.Time + 1; j < key1.Time; j++)
|
---|
| 26 | {
|
---|
| 27 | float k = (float)(j - key0.Time) / (key1.Time - key0.Time);
|
---|
| 28 |
|
---|
| 29 | result.Add(new ObjectAnimationKey {
|
---|
| 30 | Time = j,
|
---|
| 31 | Translation = Vector3.Lerp(key0.Translation, key1.Translation, k),
|
---|
| 32 | Rotation = Quaternion.Lerp(key0.Rotation, key1.Rotation, k),
|
---|
| 33 | Scale = Vector3.Lerp(key0.Scale, key1.Scale, k)
|
---|
| 34 | });
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | result.Add(Keys.Last());
|
---|
| 39 |
|
---|
| 40 | return result;
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.