-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
107 lines (79 loc) · 3.23 KB
/
Program.cs
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
using Raylib_cs;
using static Raylib_cs.Raylib;
using static Raylib_cs.ConfigFlags;
using static Raylib_cs.CameraProjection;
using Simulator;
using Univers;
using Renderer;
namespace ClothSimulator;
class Program{
static void Main(string[] args){
const int ScreenWidth = 1920;
const int ScreenHeight = 1080;
Vector3 WORLD_UP = new Vector3(0,1,0);
/*
Raylib initialisation
*/
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
InitWindow(ScreenWidth, ScreenHeight, "Gravity");
Camera3D camera = new Camera3D();
camera.position = new Vector3(250f, 50f, 0f); // Camera position
camera.target = new Vector3(0.0f, 0.0f, 0.0f); // Camera looking at point
camera.up = WORLD_UP;
camera.fovy = 90.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE;
SetCameraMode(camera, CameraMode.CAMERA_THIRD_PERSON);
SetTargetFPS(120);
//useless initialisation -> go check Load function
UniversCreator.CreateUnivers3(WORLD_UP);
RaylibRenderer renderer = new RaylibRenderer(camera,UniversCreator.colors);
UniverSimulation univer_simulation = new UniverSimulation(UniversCreator.univers,UniversCreator.entities,UniversCreator.clothList);
Menu menu = new Menu(camera);
menu.Add("2 Rings with cloth and planet collision");
menu.Add("Cloth on a sphere");
menu.Add("Soft sphere on a sphere");
/*
Main loop
*/
int selected = -1;
bool loaded = false;
while (!WindowShouldClose()) {
selected = menu.Run();
if(selected != -1){
if(loaded == false){
loaded = true;
Load(selected,WORLD_UP,camera,ref renderer,ref univer_simulation);
}
if(IsKeyPressed(KeyboardKey.KEY_BACKSPACE)){
menu.reRun();
loaded = false;
selected = -1;
//univer_simulation.Clear();
}
univer_simulation.Run();
renderer.Run(univer_simulation);
}
}
}
public static void Load(int selected,Vector3 WORLD_UP,Camera3D camera, ref RaylibRenderer renderer,ref UniverSimulation univer_simulation){
switch(selected){
case 0:
UniversCreator.CreateUnivers1(WORLD_UP);
break;
case 1:
UniversCreator.CreateUnivers2(WORLD_UP);
break;
case 2:
UniversCreator.CreateUnivers4(WORLD_UP);
break;
case 3:
UniversCreator.CreateMiniUniver(WORLD_UP);
break;
}
SetCameraMode(camera,CameraMode.CAMERA_THIRD_PERSON);
renderer = new RaylibRenderer(camera,UniversCreator.colors);
univer_simulation = new UniverSimulation(UniversCreator.univers,UniversCreator.entities,UniversCreator.clothList);
}
}