-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwave_simulation.py
61 lines (42 loc) · 1.3 KB
/
wave_simulation.py
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
import dataclasses
from ursina import Ursina, destroy, Vec3, camera, window
import parameters
from parameters_panel import MainGui
from t_sim import Simulation
app = Ursina(title="Wave Simulation")
window.fps_counter.enabled = False
window.cog_button.enabled = False
gui: MainGui = None
sim: Simulation = None
def simulate():
global sim
if sim is not None:
print("Warning: simulation is already running. Not starting again")
return
# Shallow copy. PLI.Image appears to be immutable
parameters.Instance = dataclasses.replace(parameters.SoftInstance)
print("Simulation Parameters:")
parameters.Instance.printToConsole()
sim = Simulation()
#sim = t_sim_threading.Simulation() #DOES NOT WORK
sim.begin()
# After simulation has stopped, call gui.stet_stopped()
def stop_simulation():
global sim
if sim is None:
print("WARNING: Tried to stop the simulation when it was not running")
return
sim.disable()
sim.visible = False
destroy(sim)
sim.disable()
sim.visible = False
sim = None
if __name__ == "__main__":
parameters.initParams()
gui = MainGui(simulate, stop_simulation)
cam = camera
cam.position = Vec3(7, 7, -7)
cam.look_at(Vec3(0, 0, 0), 'forward')
cam.rotation_z = 0
app.run()