Minor cleanup.
[lsystem3d.git] / src / model.h
1 // Copyright (C) 2006 Erik Dahlberg
2 //
3 // This file is part of LSystem3D.
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
25 #include <vector>
26
27 #include <GL/gl.h>
28
29 #include "color.h"
30
31 using namespace std;
32
33
34
35 /**
36 * The L-system model
37 */
38 class Model
39 {
40 public:
41
42 /**
43 * Constructor
44 */
45 Model();
46
47 /**
48 * Destructor
49 */
50 ~Model();
51
52
53 /**
54 * Clear the model
55 */
56 void clear();
57
58 /**
59 * Render to screen
60 */
61 void draw();
62
63 /**
64 * Create a segment
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 */
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);
89
90 /**
91 * Begin a modelling session
92 */
93 void begin();
94
95 /**
96 * End a modelling session
97 */
98 void end();
99
100 /**
101 * Begin creation of a filled polygon
102 */
103 void fillBegin();
104
105 /**
106 * End creation of a filled polygon
107 */
108 void fillEnd();
109
110 /**
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 /**
121 * Decrement segment diameter
122 */
123 void decrementDiameter();
124
125
126 /**
127 * Set current color index
128 * @param index the color index
129 */
130 void setColorIndex(int index);
131
132 /**
133 * Set current segment diameter
134 * @param diameter the diameter
135 */
136 void setDiameter(double diameter);
137
138 /**
139 * Set segment diameter factor
140 * @param diameter the diameter factor
141 */
142 void setDiameterFactor(double diameterFactor);
143
144
145 /**
146 * Get current color index
147 * @return color index
148 */
149 int getColorIndex();
150
151 /**
152 * Get current segment diameter
153 * @return the diameter
154 */
155 double getDiameter();
156
157 /**
158 * Get segment diameter factor
159 * @return the diameter factor
160 */
161 double getDiameterFactor();
162
163 protected:
164
165 GLuint _displayList; // All drawing operations
166
167 vector<Color> _colorTable; // Color table
168 int _colorIndex; // Current index to color table
169 double _diameter; // Current segment diameter
170 double _diameterFactor; // Diameter factor // TODO: "Diameter factor"?
171 };
172
173
174
175 #endif