Skip to content

Commit 7cc3014

Browse files
Merge pull request #1 from sandalconsumer/advanced-visualization
Separate Visualization Module
2 parents b722497 + 23da586 commit 7cc3014

File tree

7 files changed

+65
-123
lines changed

7 files changed

+65
-123
lines changed

.idea/.idea.unity-harmonics/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.unity-harmonics/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.unity-harmonics/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Physics/Body.cs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,32 @@
22
using System.Collections.Generic;
33

44
[System.Serializable]
5-
public class Spring // in this simulation, springs are considered to all be acting on one body, and class "Body" is a singleton although not explicitly being defined as that.
5+
public class Spring
66
{
77
public Vector3 rootPosition = new Vector3(0,0,0);
88
public float springConstant = 100;
99

1010
[HideInInspector]public Vector3 restorativeForce = Vector3.zero;
11-
[HideInInspector]public Vector3 stretch; //how far the mass is from the root position
11+
[HideInInspector]public Vector3 stretch;
1212
public Vector3 restPosition = new Vector3(3, 0, 0);
1313
}
1414

1515
public class Body : MonoBehaviour
1616
{
17+
public SimulationDataCompiler dataCompiler;
18+
1719
Vector3 position;
1820
Vector3 acceleration;
1921
Vector3 velocity;
2022

21-
float mass = 100;
23+
public float mass = 100;
2224

2325
Vector3 leadForce;
2426

2527
public List<Spring> connectedSprings = new List<Spring>();
2628

2729
private float timestep;
2830

29-
public float plotScale = 1f;
30-
public Vector3 plotOrigin = new Vector3(0, 0, -10);
31-
32-
private List<float> timeStamps = new List<float>();
33-
private List<Vector3> positions = new List<Vector3>();
34-
private List<float> stretches = new List<float>();
35-
3631
void Start()
3732
{
3833
position = transform.position;
@@ -64,16 +59,10 @@ void FixedUpdate()
6459

6560
VerletFinalstep(timestep);
6661

67-
timeStamps.Add(Time.fixedTime);
68-
positions.Add(position);
69-
stretches.Add(connectedSprings[0].stretch.magnitude);
62+
dataCompiler.simulationEndData.timeStamps.Add(Time.fixedTime);
63+
dataCompiler.simulationEndData.positions.Add(position);
64+
dataCompiler.simulationEndData.stretches.Add(connectedSprings[0].stretch.magnitude);
7065

71-
for (int i = 1; i < timeStamps.Count; i++)
72-
{
73-
Vector3 p1 = plotOrigin + new Vector3(timeStamps[i-1] * plotScale, stretches[i-1] * plotScale, 0);
74-
Vector3 p2 = plotOrigin + new Vector3(timeStamps[i] * plotScale, stretches[i] * plotScale, 0);
75-
Debug.DrawLine(p1, p2, Color.cyan);
76-
}
7766
}
7867

7968
void UpdateSpringDisplacement(List<Spring> springs)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using UnityEngine;
2+
using System.Collections.Generic;
3+
4+
public class SimulationEndData
5+
{
6+
public List<float> timeStamps = new List<float>();
7+
public List<Vector3> positions = new List<Vector3>();
8+
public List<float> stretches = new List<float>();
9+
}
10+
11+
public class SimulationDataCompiler : MonoBehaviour // to be used as a singleton
12+
{
13+
public SimulationEndData simulationEndData = new SimulationEndData();
14+
15+
public float plotScale = 1f;
16+
public Vector3 plotOrigin = new Vector3(10, 0, 0);
17+
18+
void Update()
19+
{
20+
for (int i = 1; i < simulationEndData.timeStamps.Count; i++)
21+
{
22+
Vector3 p1 = plotOrigin + new Vector3(simulationEndData.timeStamps[i-1] * plotScale, simulationEndData.stretches[i-1] * plotScale, 0);
23+
Vector3 p2 = plotOrigin + new Vector3(simulationEndData.timeStamps[i] * plotScale, simulationEndData.stretches[i] * plotScale, 0);
24+
Debug.DrawLine(p1, p2, Color.cyan);
25+
}
26+
}
27+
}

Assets/Scripts/Utilities/SimulationDataCompiler.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,5 @@
11
%YAML 1.1
22
%TAG !u! tag:unity3d.com,2011:
3-
--- !u!114 &-7893295128165547882
4-
MonoBehaviour:
5-
m_ObjectHideFlags: 3
6-
m_CorrespondingSourceObject: {fileID: 0}
7-
m_PrefabInstance: {fileID: 0}
8-
m_PrefabAsset: {fileID: 0}
9-
m_GameObject: {fileID: 0}
10-
m_Enabled: 1
11-
m_EditorHideFlags: 0
12-
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
13-
m_Name: Bloom
14-
m_EditorClassIdentifier:
15-
active: 1
16-
skipIterations:
17-
m_OverrideState: 1
18-
m_Value: 0
19-
threshold:
20-
m_OverrideState: 1
21-
m_Value: 1
22-
intensity:
23-
m_OverrideState: 1
24-
m_Value: 0.25
25-
scatter:
26-
m_OverrideState: 1
27-
m_Value: 0.5
28-
clamp:
29-
m_OverrideState: 0
30-
m_Value: 65472
31-
tint:
32-
m_OverrideState: 0
33-
m_Value: {r: 1, g: 1, b: 1, a: 1}
34-
highQualityFiltering:
35-
m_OverrideState: 1
36-
m_Value: 1
37-
downscale:
38-
m_OverrideState: 0
39-
m_Value: 0
40-
maxIterations:
41-
m_OverrideState: 0
42-
m_Value: 6
43-
dirtTexture:
44-
m_OverrideState: 0
45-
m_Value: {fileID: 0}
46-
dimension: 1
47-
dirtIntensity:
48-
m_OverrideState: 0
49-
m_Value: 0
50-
--- !u!114 &-3357603926938260329
51-
MonoBehaviour:
52-
m_ObjectHideFlags: 3
53-
m_CorrespondingSourceObject: {fileID: 0}
54-
m_PrefabInstance: {fileID: 0}
55-
m_PrefabAsset: {fileID: 0}
56-
m_GameObject: {fileID: 0}
57-
m_Enabled: 1
58-
m_EditorHideFlags: 0
59-
m_Script: {fileID: 11500000, guid: 899c54efeace73346a0a16faa3afe726, type: 3}
60-
m_Name: Vignette
61-
m_EditorClassIdentifier:
62-
active: 1
63-
color:
64-
m_OverrideState: 0
65-
m_Value: {r: 0, g: 0, b: 0, a: 1}
66-
center:
67-
m_OverrideState: 0
68-
m_Value: {x: 0.5, y: 0.5}
69-
intensity:
70-
m_OverrideState: 1
71-
m_Value: 0.2
72-
smoothness:
73-
m_OverrideState: 0
74-
m_Value: 0.2
75-
rounded:
76-
m_OverrideState: 0
77-
m_Value: 0
783
--- !u!114 &11400000
794
MonoBehaviour:
805
m_ObjectHideFlags: 0
@@ -89,9 +14,6 @@ MonoBehaviour:
8914
m_EditorClassIdentifier:
9015
components:
9116
- {fileID: 849379129802519247}
92-
- {fileID: -7893295128165547882}
93-
- {fileID: 7391319092446245454}
94-
- {fileID: -3357603926938260329}
9517
--- !u!114 &849379129802519247
9618
MonoBehaviour:
9719
m_ObjectHideFlags: 3
@@ -107,7 +29,7 @@ MonoBehaviour:
10729
active: 1
10830
mode:
10931
m_OverrideState: 1
110-
m_Value: 1
32+
m_Value: 2
11133
neutralHDRRangeReductionMode:
11234
m_OverrideState: 0
11335
m_Value: 2
@@ -132,28 +54,3 @@ MonoBehaviour:
13254
maxNits:
13355
m_OverrideState: 1
13456
m_Value: 647
135-
--- !u!114 &7391319092446245454
136-
MonoBehaviour:
137-
m_ObjectHideFlags: 3
138-
m_CorrespondingSourceObject: {fileID: 0}
139-
m_PrefabInstance: {fileID: 0}
140-
m_PrefabAsset: {fileID: 0}
141-
m_GameObject: {fileID: 0}
142-
m_Enabled: 1
143-
m_EditorHideFlags: 0
144-
m_Script: {fileID: 11500000, guid: ccf1aba9553839d41ae37dd52e9ebcce, type: 3}
145-
m_Name: MotionBlur
146-
m_EditorClassIdentifier:
147-
active: 0
148-
mode:
149-
m_OverrideState: 0
150-
m_Value: 0
151-
quality:
152-
m_OverrideState: 1
153-
m_Value: 2
154-
intensity:
155-
m_OverrideState: 1
156-
m_Value: 0.6
157-
clamp:
158-
m_OverrideState: 0
159-
m_Value: 0.05

0 commit comments

Comments
 (0)