Minor cleanup.
[lsystem3d.git] / src / turtle.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 TURTLE_H
23 #define TURTLE_H
24
25 #include <stack>
26
27 #include "coordinate.h"
28 #include "model.h"
29 #include "vector.h"
30
31 using namespace std;
32
33
34
35 /**
36 * The model creator
37 */
38 class Turtle
39 {
40 public:
41
42 /**
43 * Constructor
44 * @param model create this model
45 */
46 Turtle(Model *model);
47
48 /**
49 * Destructor
50 */
51 ~Turtle();
52
53
54 /**
55 * Reset to default state
56 */
57 void reset();
58
59 /**
60 * Turn left
61 */
62 void turnLeft();
63
64 /**
65 * Turn right
66 */
67 void turnRight();
68
69 /**
70 * Pitch down
71 */
72 void pitchDown();
73
74 /**
75 * Pitch up
76 */
77 void pitchUp();
78
79 /**
80 * Roll left
81 */
82 void rollLeft();
83
84 /**
85 * Roll right
86 */
87 void rollRight();
88
89 /**
90 * Turn around
91 */
92 void turnAround();
93
94 /**
95 * Walk forward
96 */
97 void walk();
98
99 /**
100 * Walk forward, creating a filled surface
101 */
102 void fillWalk();
103
104 /**
105 * Save current state to stack
106 */
107 void push();
108
109 /**
110 * Restore old state from stack
111 */
112 void pop();
113
114
115 /**
116 * Set turn/pitch/roll angle
117 * @param angle the angle, in radians
118 */
119 void setAngle(double radians);
120
121
122 /**
123 * Get turn/pitch/roll angle
124 * @return the angle, in radians
125 */
126 double getAngle();
127
128 protected:
129
130 Coordinate _position; // Current position
131
132 Vector _heading; // Forward pointing vector
133 Vector _left; // Left pointing vector
134 Vector _up; // Up pointing vector
135
136 double _angle; // Turn/pitch/roll angle, in radians
137
138 stack<Coordinate> _positionStack; // Positions in stack
139 stack<Vector> _headingStack; // Heading vectors in stack
140 stack<Vector> _leftStack; // Left vectors in stack
141 stack<Vector> _upStack; // Up vectors in stack
142 stack<double> _diameterStack; // Diameters in stack
143 stack<int> _colorIndexStack; // Colors indices in stack
144
145 Model *_model; // The created model
146 };
147
148
149
150 #endif