-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain_panel.cpp
106 lines (89 loc) · 2.12 KB
/
main_panel.cpp
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
#include "main_panel.h"
#include "imgui.h"
#include "graphics_color.h"
#include <string>
#include <vector>
#include <map>
void MAIN_PANEL::init( void )
{
m_plant.reset();
m_plant.m_axiom = "F";
m_plant.m_rules[ 'F' ] = "F[+F]F[-F]F";
m_plant.m_rotation_degree = 25.7f;
m_plant.create( m_iteration );
}
void MAIN_PANEL::create_ui( void )
{
ImGui::Begin( "Hello Tree" );
if ( ImGui::SliderInt( "Itereation", &m_iteration, 0, 7 ) )
{
m_plant.create( m_iteration );
}
if ( ImGui::SliderFloat( "growth rate", &m_growth_rate, 0.0f, 0.1f ) )
{
m_plant.m_growth_rate = m_growth_rate;
m_plant.create( m_iteration );
}
if ( ImGui::Button( "Plant1" ) )
{
m_plant.reset();
m_plant.m_axiom = "F";
m_plant.m_rules[ 'F' ] = "F[+F]F[-F]F";
m_plant.m_rotation_degree = 25.7f;
m_plant.create( m_iteration );
}
if ( ImGui::Button( "Plant2" ) )
{
m_plant.reset();
m_plant.m_axiom = "F";
m_plant.m_rules[ 'F' ] = "F[+F]F[-F][F]";
m_plant.m_rotation_degree = 20.f;
m_plant.create( m_iteration );
}
if ( ImGui::Button( "Plant3" ) )
{
m_plant.reset();
m_plant.m_axiom = "F";
m_plant.m_rules[ 'F' ] = "FF-[-F+F+F]+[+F-F-F]";
m_plant.m_rotation_degree = 22.5f;
m_plant.create( m_iteration );
}
if ( ImGui::Button( "Plant4" ) )
{
m_plant.reset();
m_plant.m_axiom = "X";
m_plant.m_rules[ 'X' ] = "F[+X]F[-X]+X";
m_plant.m_rules[ 'F' ] = "FF";
m_plant.m_rotation_degree = 20.0f;
m_plant.create( m_iteration );
}
if ( ImGui::Button( "Plant5" ) )
{
m_plant.reset();
m_plant.m_axiom = "X";
m_plant.m_rules[ 'X' ] = "F[+X][-X]FX";
m_plant.m_rules[ 'F' ] = "FF";
m_plant.m_rotation_degree = 25.7f;
m_plant.create( m_iteration );
}
if ( ImGui::Button( "Plant6" ) )
{
m_plant.reset();
m_plant.m_axiom = "X";
m_plant.m_rules[ 'X' ] = "F-[[X]+X]+F[+FX]-X";
m_plant.m_rules[ 'F' ] = "FF";
m_plant.m_rotation_degree = 22.5f;
m_plant.create( m_iteration );
}
ImGui::End();
}
void MAIN_PANEL::draw( void )
{
create_ui();
GRAPHICS_UTILITY::push_translation_matrix( MATH_VECTOR_2D( 0.0f, -6.0f ) );
m_plant.draw();
GRAPHICS_UTILITY::pop__matrix();
}
void MAIN_PANEL::update( void )
{
}