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: |
41 | /** |
42 | * Constructor |
43 | */ |
44 | Model(); |
45 | |
46 | /** |
47 | * Destructor |
48 | */ |
49 | ~Model(); |
50 | |
51 | /** |
526db675 |
52 | * Create a segment |
15c82487 |
53 | * @param x1 x start point |
54 | * @param y1 y start point |
55 | * @param z1 z start point |
56 | * @param x2 x end point |
57 | * @param y2 y end point |
58 | * @param z2 z end point |
59 | */ |
526db675 |
60 | void segment(double x1, double y1, double z1, double x2, double y2, double z2); |
61 | |
62 | /** |
63 | * Specify a vertex |
64 | * @param x x-coordinate |
65 | * @param y y-coordinate |
66 | * @param z z-coordinate |
67 | */ |
68 | void vertex(double x, double y, double z); |
69 | |
70 | /** |
71 | * Specify a normal |
72 | * @param x x-coordinate |
73 | * @param y y-coordinate |
74 | * @param z z-coordinate |
75 | */ |
76 | void normal(double x, double y, double z); |
15c82487 |
77 | |
78 | /** |
526db675 |
79 | * Render to screen |
15c82487 |
80 | */ |
81 | void draw(); |
82 | |
83 | /** |
84 | * Clear the model |
85 | */ |
86 | void clear(); |
87 | |
88 | /** |
526db675 |
89 | * Begin a modelling session |
15c82487 |
90 | */ |
91 | void begin(); |
92 | |
93 | /** |
526db675 |
94 | * End a modelling session |
15c82487 |
95 | */ |
96 | void end(); |
97 | |
98 | /** |
526db675 |
99 | * Begin creation of a filled polygon |
15c82487 |
100 | */ |
101 | void fillBegin(); |
102 | |
103 | /** |
526db675 |
104 | * End creation of a filled polygon |
15c82487 |
105 | */ |
106 | void fillEnd(); |
107 | |
108 | /** |
526db675 |
109 | * Increment current index to color table |
110 | */ |
111 | void nextColor(); |
112 | |
113 | /** |
114 | * Decrement current index to color table |
115 | */ |
116 | void prevColor(); |
117 | |
118 | /** |
119 | * Decrement diameter of segment |
120 | */ |
121 | void decrementDiameter(); |
122 | |
123 | /** |
124 | * Set current color index |
125 | * @param index the color index |
126 | */ |
127 | void setColorIndex(int index); |
128 | |
129 | /** |
130 | * Set current diameter of segment |
131 | * @param diameter the diameter |
15c82487 |
132 | */ |
526db675 |
133 | void setDiameter(double diameter); |
134 | |
135 | /** |
136 | * Set diameter factor |
137 | * @param diameter the diameter factor |
138 | */ |
139 | void setDiameterFactor(double diameterFactor); |
140 | |
141 | /** |
142 | * Get current color index |
143 | * @return color index |
144 | */ |
145 | int getColorIndex(); |
146 | |
147 | /** |
148 | * Get current diameter of segment |
149 | * @return diameter of segment |
150 | */ |
151 | double getDiameter(); |
15c82487 |
152 | |
153 | protected: |
154 | |
526db675 |
155 | GLuint _displayList; // All drawing operations |
156 | |
157 | vector<Color> _colorTable; // Color table |
158 | int _colorIndex; // Current index to color table |
159 | double _diameter; // Current diameter of segment |
160 | double _diameterFactor; // Diameter factor // TODO: "Diameter factor"? |
15c82487 |
161 | }; |
162 | |
163 | |
164 | |
165 | #endif |