diff options
author | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-27 09:09:57 +0200 |
---|---|---|
committer | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-27 09:09:57 +0200 |
commit | 8a17cd03497a4037067f9c1714d69a8975090189 (patch) | |
tree | 19cc0fa832028f83da27e842b8dffc263b028117 /nGJ2019/Assets/Scripts/SwarmSystem.cs | |
parent | 8db39efb58e68f57404ec204f9dbe15e6157f1b0 (diff) |
optimize dragon transformations
Diffstat (limited to 'nGJ2019/Assets/Scripts/SwarmSystem.cs')
-rw-r--r-- | nGJ2019/Assets/Scripts/SwarmSystem.cs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/nGJ2019/Assets/Scripts/SwarmSystem.cs b/nGJ2019/Assets/Scripts/SwarmSystem.cs index 9f19dd0..9658a92 100644 --- a/nGJ2019/Assets/Scripts/SwarmSystem.cs +++ b/nGJ2019/Assets/Scripts/SwarmSystem.cs @@ -26,6 +26,7 @@ public class SwarmSystem : MonoBehaviour private List<List<int>> triGraph; public float Noise {get; set;} + public float Collapse {get; set;} private Mesh getCurrentMesh() { @@ -365,11 +366,15 @@ public class SwarmSystem : MonoBehaviour Vector3 boneCenter = findBoneCenter(u, out boneDirec); - anchors[u].position = boneCenter + (Quaternion.AngleAxis(1f, boneDirec) * (anchors[u].position - boneCenter)); + anchors[u].position = boneCenter + (Quaternion.AngleAxis(3f, boneDirec) * (anchors[u].position - boneCenter)); anchors[u].position = meshIntersection(u, vertices, triangles, boneCenter); unit.position = anchors[u].position + Noise*noiseDirecs[u]; + + Vector3 collapsedPos = Vector3.Project(unit.position - transform.position, Vector3.right) + transform.position; + + unit.position = (1-Collapse)*unit.position + Collapse*collapsedPos; } } |