*** empty log message ***
[lsystem3d.git] / src / turtle.h
CommitLineData
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 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/**
526db675 36 * The model creator
15c82487 37 */
38class Turtle
39{
40public:
41 /**
42 * Constructor
526db675 43 * @param model create this model
15c82487 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
526db675 92 /**
93 * Walk forward, creating a filled surface
94 */
95 void fillWalk();
96
15c82487 97 /**
98 * Save current state to stack
99 */
100 void push();
101
102 /**
103 * Restore old state from stack
104 */
105 void pop();
106
107 /**
108 * Reset to default state
109 */
110 void reset();
111
15c82487 112 /**
113 * Set turn/pitch/roll angle
114 * @param angle the angle, in radians
115 */
116 void setAngle(double radians);
117
118 /**
119 * Get turn/pitch/roll angle
120 * @return the angle, in radians
121 */
122 double getAngle();
123
124protected:
125
526db675 126 Coordinate _position; // Current position
15c82487 127
526db675 128 Vector _heading; // Forward pointing vector
129 Vector _left; // Left pointing vector
130 Vector _up; // Up pointing vector
15c82487 131
526db675 132 double _angle; // Turn/pitch/roll angle, in radians
15c82487 133
526db675 134 stack<Coordinate> _positionStack; // Positions in stack
135 stack<Vector> _headingStack; // Heading vectors in stack
136 stack<Vector> _leftStack; // Left vectors in stack
137 stack<Vector> _upStack; // Up vectors in stack
138 stack<double> _diameterStack; // Diameters in stack
139 stack<int> _colorIndexStack; // Colors indices in stack
15c82487 140
526db675 141 Model *_model; // The created model
15c82487 142};
143
144
145
146#endif