forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeNode.cs
More file actions
122 lines (122 loc) · 2.82 KB
/
Copy pathTreeNode.cs
File metadata and controls
122 lines (122 loc) · 2.82 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using UnityEngine;
namespace TreeEditor
{
[Serializable]
public class TreeNode
{
public TreeSpline spline;
public int seed;
public float animSeed;
public bool visible;
public int triStart;
public int triEnd;
public int vertStart;
public int vertEnd;
public float capRange;
public float breakOffset;
public float size;
public float scale;
public float offset;
public float baseAngle;
public float angle;
public float pitch;
public Quaternion rotation;
public Matrix4x4 matrix;
public int parentID;
public int groupID;
[NonSerialized]
internal TreeNode parent;
[NonSerialized]
internal TreeGroup group;
[SerializeField]
private int _uniqueID = -1;
public int uniqueID
{
get
{
return this._uniqueID;
}
set
{
if (this._uniqueID == -1)
{
this._uniqueID = value;
}
}
}
public TreeNode()
{
this.spline = null;
this.parentID = 0;
this.groupID = 0;
this.parent = null;
this.group = null;
this.seed = 1234;
this.breakOffset = 1f;
this.visible = true;
this.animSeed = 0f;
this.scale = 1f;
this.rotation = Quaternion.identity;
this.matrix = Matrix4x4.identity;
}
public float GetScale()
{
float num = 1f;
if (this.parent != null)
{
num = this.parent.GetScale();
}
return this.scale * num;
}
public float GetSurfaceAngleAtTime(float time)
{
if (this.spline == null)
{
return 0f;
}
Vector3 positionAtTime = this.spline.GetPositionAtTime(time);
float radiusAtTime = this.group.GetRadiusAtTime(this, time, false);
float num;
if (time < 0.5f)
{
float magnitude = (this.spline.GetPositionAtTime(time + 0.01f) - positionAtTime).magnitude;
float y = this.group.GetRadiusAtTime(this, time + 0.01f, false) - radiusAtTime;
num = Mathf.Atan2(y, magnitude);
}
else
{
float magnitude2 = (positionAtTime - this.spline.GetPositionAtTime(time - 0.01f)).magnitude;
float y2 = radiusAtTime - this.group.GetRadiusAtTime(this, time - 0.01f, false);
num = Mathf.Atan2(y2, magnitude2);
}
return num * 57.29578f;
}
public float GetRadiusAtTime(float time)
{
return this.group.GetRadiusAtTime(this, time, false);
}
public void GetPropertiesAtTime(float time, out Vector3 pos, out Quaternion rot, out float rad)
{
if (this.spline == null)
{
pos = Vector3.zero;
rot = Quaternion.identity;
}
else
{
pos = this.spline.GetPositionAtTime(time);
rot = this.spline.GetRotationAtTime(time);
}
rad = this.group.GetRadiusAtTime(this, time, false);
}
public Matrix4x4 GetLocalMatrixAtTime(float time)
{
Vector3 zero = Vector3.zero;
Quaternion identity = Quaternion.identity;
float num = 0f;
this.GetPropertiesAtTime(time, out zero, out identity, out num);
return Matrix4x4.TRS(zero, identity, Vector3.one);
}
}
}