| 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 OPENGLWINDOW_H |
| 23 | #define OPENGLWINDOW_H |
| 24 | |
| 25 | #include <string> |
| 26 | #include <vector> |
| 27 | |
| 28 | #include <glui.h> |
| 29 | |
| 30 | #include "lindenmayersystem.h" |
| 31 | #include "lsystemparameters.h" |
| 32 | #include "model.h" |
| 33 | |
| 34 | using namespace std; |
| 35 | |
| 36 | |
| 37 | |
| 38 | /** |
| 39 | * OpenGL drawing context |
| 40 | */ |
| 41 | class OpenGLWindow |
| 42 | { |
| 43 | public: |
| 44 | /** |
| 45 | * Constructor |
| 46 | */ |
| 47 | OpenGLWindow(); |
| 48 | |
| 49 | /** |
| 50 | * Destructor |
| 51 | */ |
| 52 | ~OpenGLWindow(); |
| 53 | |
| 54 | /** |
| 55 | * Start generation of l-system data |
| 56 | */ |
| 57 | void generate(); |
| 58 | |
| 59 | /** |
| 60 | * Move camera left |
| 61 | */ |
| 62 | void left(); |
| 63 | |
| 64 | /** |
| 65 | * Move camera right |
| 66 | */ |
| 67 | void right(); |
| 68 | |
| 69 | /** |
| 70 | * Move camera up |
| 71 | */ |
| 72 | void up(); |
| 73 | |
| 74 | /** |
| 75 | * Move camera down |
| 76 | */ |
| 77 | void down(); |
| 78 | |
| 79 | /** |
| 80 | * Move camera forth |
| 81 | */ |
| 82 | void forth(); |
| 83 | |
| 84 | /** |
| 85 | * Move camera back |
| 86 | */ |
| 87 | void back(); |
| 88 | |
| 89 | /** |
| 90 | * Zoom in |
| 91 | */ |
| 92 | void zoomIn(); |
| 93 | |
| 94 | /** |
| 95 | * Zoom out |
| 96 | */ |
| 97 | void zoomOut(); |
| 98 | |
| 99 | /** |
| 100 | * Rotate around y-axis |
| 101 | */ |
| 102 | void rotateY(); |
| 103 | |
| 104 | /** |
| 105 | * Draw l-system model to screen |
| 106 | */ |
| 107 | void draw(); |
| 108 | |
| 109 | /** |
| 110 | * Reset to default view |
| 111 | */ |
| 112 | void defaultView(); |
| 113 | |
| 114 | /** |
| 115 | * Check if live mode is activated |
| 116 | * @return true, if activated |
| 117 | */ |
| 118 | bool liveActivated(); |
| 119 | |
| 120 | protected: |
| 121 | |
| 122 | // Model view |
| 123 | double _xModel, // model coordinate (starting point) |
| 124 | _yModel, |
| 125 | _zModel; |
| 126 | double _scaleModel; // model scale factor |
| 127 | double _yRotationModel; // model rotation |
| 128 | |
| 129 | // L-system |
| 130 | LindenmayerSystem *_lsystem; // l-system generator |
| 131 | Model *_model; // the generated l-system model |
| 132 | LSystemParameters _lsystemParameters; // saves/loads l-system parameters from file |
| 133 | string lsystemParametersPath; // where to find the l-system rules |
| 134 | |
| 135 | // Rendering window |
| 136 | int _window; // the rendering window |
| 137 | bool _busyGenerating; // currently generating? |
| 138 | |
| 139 | // GUI window |
| 140 | GLUI *_glui; // the GUI window |
| 141 | GLUI_EditText *_axiomEditText; // axiom textbox |
| 142 | vector<GLUI_EditText *> _ruleEditTexts; // rule textboxes |
| 143 | GLUI_Spinner *_angleSpinner; // angle spinner |
| 144 | GLUI_Spinner *_iterationsSpinner; // iteration spinner |
| 145 | GLUI_Checkbox *_liveCheckbox; // live checkbox |
| 146 | int _liveUpdates; // status of live checkbox |
| 147 | }; |
| 148 | |
| 149 | |
| 150 | |
| 151 | #endif |