X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lsystem3d%2Fsrc%2Fturtle.h;fp=lsystem3d%2Fsrc%2Fturtle.h;h=d56c09a371acd848cd19990bcb3ae8204d3f5ef6;hb=e5247a3b88c449937af08f46afc271afda2954a2;hp=0000000000000000000000000000000000000000;hpb=c48a55e9e62ed7a9d46e3c6a53faae4bc05856e5;p=lsystem3d.git diff --git a/lsystem3d/src/turtle.h b/lsystem3d/src/turtle.h new file mode 100644 index 0000000..d56c09a --- /dev/null +++ b/lsystem3d/src/turtle.h @@ -0,0 +1,157 @@ +// Copyright (C) 2006 Erik Dahlberg +// +// This file is part of LSystem3d. +// +// LSystem3D is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// LSystem3D is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with LSystem3D; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + + + +#ifndef TURTLE_H +#define TURTLE_H + +#include + +#include "coordinate.h" +#include "model.h" +#include "vector.h" + +using namespace std; + + + +/** + * The model renderer + */ +class Turtle +{ +public: + /** + * Constructor + * @param model render this model + */ + Turtle(Model *model); + + /** + * Destructor + */ + ~Turtle(); + + /** + * Turn left + */ + void turnLeft(); + + /** + * Turn right + */ + void turnRight(); + + /** + * Pitch down + */ + void pitchDown(); + + /** + * Pitch up + */ + void pitchUp(); + + /** + * Roll left + */ + void rollLeft(); + + /** + * Roll right + */ + void rollRight(); + + /** + * Turn around + */ + void turnAround(); + + /** + * Walk forward + */ + void walk(); + + /** + * Save current state to stack + */ + void push(); + + /** + * Restore old state from stack + */ + void pop(); + + /** + * Reset to default state + */ + void reset(); + + /** + * Decrement diameter of segment + */ + void decrementDiameter(); + + /** + * Begin creation of a filled surface + */ + void fenceInBegin(); + + /** + * End creation of a filled surface + */ + void fenceInEnd(); + + /** + * Set turn/pitch/roll angle + * @param angle the angle, in radians + */ + void setAngle(double radians); + + /** + * Get turn/pitch/roll angle + * @return the angle, in radians + */ + double getAngle(); + +protected: + + Coordinate _position; // current position + + Vector _heading; // forward pointing vector + Vector _left; // left pointing vector + Vector _up; // up pointing vector + + double _angle; // turn/pitch/roll angle + double _diameter; // diameter of segment + bool _fenceMode; // create filled surface? + + stack _positionStack; // positions in stack + stack _headingStack; // heading vectors in stack + stack _leftStack; // left vectors in stack + stack _upStack; // up vectors in stack + stack _diameterStack; // diameters in stack + + Model *_model; // the rendered model +}; + + + +#endif