-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
92 lines (75 loc) · 2.8 KB
/
Copy pathProgram.cs
File metadata and controls
92 lines (75 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using OpenTK.Mathematics;
using PAPrefabToolkit;
using PAPrefabToolkit.Data;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using Assimp;
using Quaternion = OpenTK.Mathematics.Quaternion;
namespace Project3D
{
internal class Program
{
private static List<PrefabObject> prefabObjects = new List<PrefabObject>();
private static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
Node node;
Node camera;
using (AssetImporter importer = new AssetImporter("polygon.dae"))
{
node = importer.LoadModel();
camera = importer.GetCamera();
}
Prefab prefab = new Prefab("polygon", PrefabType.Misc_1);
PrefabObject transform = new PrefabObject(prefab, "Transform")
{
ObjectType = PrefabObjectType.Empty
};
transform.Events.ScaleKeyframes.Add(new PrefabObject.ObjectEvents.ScaleKeyframe()
{
Value = new System.Numerics.Vector2(71.1111111111f, 40f)
});
Vector3[] theme = new Vector3[]
{
new Vector3(0f, 0f, 0f),
new Vector3(0.125f, 0.125f, 0.125f),
new Vector3(0.25f, 0.25f, 0.25f),
new Vector3(0.375f, 0.375f, 0.375f),
new Vector3(0.5f, 0.5f, 0.5f),
new Vector3(0.625f, 0.625f, 0.625f),
new Vector3(0.75f, 0.75f, 0.75f),
new Vector3(0.875f, 0.875f, 0.75f),
new Vector3(1f, 1f, 1f)
};
Renderer renderer = new Renderer(node, theme, transform);
for (int i = 0; i < 140; i++)
{
float time = i / 24f;
RecursivelyUpdateAnimation(time, node);
renderer.Render(prefab, prefabObjects, time, camera);
Console.WriteLine("rendering frame " + i);
}
File.WriteAllText("polygon.lsp", PrefabBuilder.BuildPrefab(prefab));
}
private static void RecursivelyUpdateAnimation(float time, Node node)
{
if (node.PositionSequence != null)
{
node.Position = node.PositionSequence.GetValue(time);
}
if (node.ScaleSequence != null)
{
node.Scale = node.ScaleSequence.GetValue(time);
}
if (node.RotationSequence != null)
{
node.Rotation = node.RotationSequence.GetValue(time);
}
foreach (Node child in node.Children)
RecursivelyUpdateAnimation(time, child);
}
}
}