15c82487 |
1 | // Copyright (C) 2006 Erik Dahlberg |
2 | // |
1a372e99 |
3 | // This file is part of LSystem3D. |
15c82487 |
4 | // |
5 | // LSystem3D is free software; you can redistribute it and/or |
6 | // modify it under the terms of the GNU General Public License |
7 | // as published by the Free Software Foundation; either version 2 |
8 | // of the License, or (at your option) any later version. |
9 | // |
10 | // LSystem3D is distributed in the hope that it will be useful, |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | // GNU General Public License for more details. |
14 | // |
15 | // You should have received a copy of the GNU General Public License |
16 | // along with LSystem3D; if not, write to the Free Software |
17 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 | |
19 | |
20 | |
21 | |
22 | #ifndef MODEL_H |
23 | #define MODEL_H |
24 | |
526db675 |
25 | #include <vector> |
26 | |
15c82487 |
27 | #include <GL/gl.h> |
28 | |
526db675 |
29 | #include "color.h" |
30 | |
31 | using namespace std; |
32 | |
15c82487 |
33 | |
34 | |
35 | /** |
526db675 |
36 | * The L-system model |
15c82487 |
37 | */ |
38 | class Model |
39 | { |
40 | public: |
68a7b857 |
41 | |
15c82487 |
42 | /** |
43 | * Constructor |
44 | */ |
45 | Model(); |
46 | |
47 | /** |
48 | * Destructor |
49 | */ |
50 | ~Model(); |
51 | |
68a7b857 |
52 | |
53 | /** |
54 | * Clear the model |
55 | */ |
56 | void clear(); |
57 | |
58 | /** |
59 | * Render to screen |
60 | */ |
61 | void draw(); |
62 | |
15c82487 |
63 | /** |
526db675 |
64 | * Create a segment |
15c82487 |
65 | * @param x1 x start point |
66 | * @param y1 y start point |
67 | * @param z1 z start point |
68 | * @param x2 x end point |
69 | * @param y2 y end point |
70 | * @param z2 z end point |
71 | */ |
526db675 |
72 | void segment(double x1, double y1, double z1, double x2, double y2, double z2); |
73 | |
74 | /** |
75 | * Specify a vertex |
76 | * @param x x-coordinate |
77 | * @param y y-coordinate |
78 | * @param z z-coordinate |
79 | */ |
80 | void vertex(double x, double y, double z); |
81 | |
82 | /** |
83 | * Specify a normal |
84 | * @param x x-coordinate |
85 | * @param y y-coordinate |
86 | * @param z z-coordinate |
87 | */ |
88 | void normal(double x, double y, double z); |
15c82487 |
89 | |
15c82487 |
90 | /** |
526db675 |
91 | * Begin a modelling session |
15c82487 |
92 | */ |
93 | void begin(); |
94 | |
95 | /** |
526db675 |
96 | * End a modelling session |
15c82487 |
97 | */ |
98 | void end(); |
99 | |
100 | /** |
526db675 |
101 | * Begin creation of a filled polygon |
15c82487 |
102 | */ |
103 | void fillBegin(); |
104 | |
105 | /** |
526db675 |
106 | * End creation of a filled polygon |
15c82487 |
107 | */ |
108 | void fillEnd(); |
109 | |
110 | /** |
526db675 |
111 | * Increment current index to color table |
112 | */ |
113 | void nextColor(); |
114 | |
115 | /** |
116 | * Decrement current index to color table |
117 | */ |
118 | void prevColor(); |
119 | |
120 | /** |
68a7b857 |
121 | * Decrement segment diameter |
526db675 |
122 | */ |
123 | void decrementDiameter(); |
124 | |
68a7b857 |
125 | |
526db675 |
126 | /** |
127 | * Set current color index |
128 | * @param index the color index |
129 | */ |
130 | void setColorIndex(int index); |
131 | |
132 | /** |
68a7b857 |
133 | * Set current segment diameter |
526db675 |
134 | * @param diameter the diameter |
15c82487 |
135 | */ |
526db675 |
136 | void setDiameter(double diameter); |
137 | |
138 | /** |
68a7b857 |
139 | * Set segment diameter factor |
526db675 |
140 | * @param diameter the diameter factor |
141 | */ |
142 | void setDiameterFactor(double diameterFactor); |
143 | |
68a7b857 |
144 | |
526db675 |
145 | /** |
146 | * Get current color index |
147 | * @return color index |
148 | */ |
149 | int getColorIndex(); |
150 | |
151 | /** |
68a7b857 |
152 | * Get current segment diameter |
153 | * @return the diameter |
526db675 |
154 | */ |
155 | double getDiameter(); |
15c82487 |
156 | |
68a7b857 |
157 | /** |
158 | * Get segment diameter factor |
159 | * @return the diameter factor |
160 | */ |
161 | double getDiameterFactor(); |
162 | |
15c82487 |
163 | protected: |
164 | |
526db675 |
165 | GLuint _displayList; // All drawing operations |
166 | |
167 | vector<Color> _colorTable; // Color table |
168 | int _colorIndex; // Current index to color table |
68a7b857 |
169 | double _diameter; // Current segment diameter |
526db675 |
170 | double _diameterFactor; // Diameter factor // TODO: "Diameter factor"? |
15c82487 |
171 | }; |
172 | |
173 | |
174 | |
175 | #endif |