main.cpp 966 Bytes
Newer Older
Yuwei Xiao's avatar
Yuwei Xiao committed
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
#include "EarthSim.h"
#include "Gui.h"

/*
 * GUI for the earth simulation.
 */
class EarthGui : public Gui {
   public:
    // simulation parameters
    float m_dt = 1e-2;
    float m_radius = 10.0;

    EarthSim *p_EarthSim = NULL;

    EarthGui() {
        // create a new Earth simulation, set it in the GUI, and start the GUI
        p_EarthSim = new EarthSim();
        setSimulation(p_EarthSim);

        start();
    }

    virtual void updateSimulationParameters() override {
        // change all parameters of the simulation to the values that are set in the GUI
        p_EarthSim->setTimestep(m_dt);
        p_EarthSim->setRadius(m_radius);
    }


    virtual void drawSimulationParameterMenu() override {
        ImGui::InputFloat("Radius", &m_radius, 0, 0);
        ImGui::InputFloat("dt", &m_dt, 0, 0);
    }
};

int main(int argc, char *argv[]) {
    // create a new instance of the GUI for the Earth simulation
    new EarthGui();

    return 0;
}