changed targetname
[lsystem3d.git] / src / turtle.h
... / ...
CommitLineData
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
31using namespace std;
32
33
34
35/**
36 * The model renderer
37 */
38class Turtle
39{
40public:
41 /**
42 * Constructor
43 * @param model render this model
44 */
45 Turtle(Model *model);
46
47 /**
48 * Destructor
49 */
50 ~Turtle();
51
52 /**
53 * Turn left
54 */
55 void turnLeft();
56
57 /**
58 * Turn right
59 */
60 void turnRight();
61
62 /**
63 * Pitch down
64 */
65 void pitchDown();
66
67 /**
68 * Pitch up
69 */
70 void pitchUp();
71
72 /**
73 * Roll left
74 */
75 void rollLeft();
76
77 /**
78 * Roll right
79 */
80 void rollRight();
81
82 /**
83 * Turn around
84 */
85 void turnAround();
86
87 /**
88 * Walk forward
89 */
90 void walk();
91
92 /**
93 * Save current state to stack
94 */
95 void push();
96
97 /**
98 * Restore old state from stack
99 */
100 void pop();
101
102 /**
103 * Reset to default state
104 */
105 void reset();
106
107 /**
108 * Decrement diameter of segment
109 */
110 void decrementDiameter();
111
112 /**
113 * Begin creation of a filled surface
114 */
115 void fenceInBegin();
116
117 /**
118 * End creation of a filled surface
119 */
120 void fenceInEnd();
121
122 /**
123 * Set turn/pitch/roll angle
124 * @param angle the angle, in radians
125 */
126 void setAngle(double radians);
127
128 /**
129 * Get turn/pitch/roll angle
130 * @return the angle, in radians
131 */
132 double getAngle();
133
134protected:
135
136 Coordinate _position; // current position
137
138 Vector _heading; // forward pointing vector
139 Vector _left; // left pointing vector
140 Vector _up; // up pointing vector
141
142 double _angle; // turn/pitch/roll angle
143 double _diameter; // diameter of segment
144 bool _fenceMode; // create filled surface?
145
146 stack<Coordinate> _positionStack; // positions in stack
147 stack<Vector> _headingStack; // heading vectors in stack
148 stack<Vector> _leftStack; // left vectors in stack
149 stack<Vector> _upStack; // up vectors in stack
150 stack<double> _diameterStack; // diameters in stack
151
152 Model *_model; // the rendered model
153};
154
155
156
157#endif