Minor cleanup.
[lsystem3d.git] / src / model.h
index d7ebf26c2b20f63de244e9242824e9de7124e53d..138b8018fe3350c99ba846369344902b57417d44 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (C) 2006 Erik Dahlberg
 // 
-// This file is part of LSystem3d.
+// 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
 #ifndef MODEL_H
 #define MODEL_H
 
+#include <vector>
+
 #include <GL/gl.h>
 
+#include "color.h"
+
+using namespace std;
+
 
 
 /**
- * The generated l-system model
- * TODO: inheritance, i.e. Model<-OpenGLModel/WireModel/...?
+ * The L-system model
  */
 class Model
 {
 public:
+    
     /**
      * Constructor
      */
@@ -43,9 +49,19 @@ public:
      */
     ~Model();
     
+    
+    /**
+     * Clear the model
+     */
+    void clear();
+    
+    /**
+     * Render to screen
+     */
+    void draw();
+    
     /**
-     * Connect two points
-     * @param diameter diameter of segment
+     * Create a segment
      * @param x1 x start point
      * @param y1 y start point
      * @param z1 z start point
@@ -53,49 +69,105 @@ public:
      * @param y2 y end point
      * @param z2 z end point
      */
-    void segment(double diameter, double x1, double y1, double z1, double x2, double y2, double z2);
+    void segment(double x1, double y1, double z1, double x2, double y2, double z2);
     
     /**
-     * Draw model to screen
+     * Specify a vertex
+     * @param x x-coordinate
+     * @param y y-coordinate
+     * @param z z-coordinate
      */
-    void draw();
+    void vertex(double x, double y, double z);
     
     /**
-     * Clear the model
+     * Specify a normal
+     * @param x x-coordinate
+     * @param y y-coordinate
+     * @param z z-coordinate
      */
-    void clear();
+    void normal(double x, double y, double z);
     
     /**
-     * Start recording of drawing operations
+     * Begin a modelling session
      */
     void begin();
     
     /**
-     * Stop recording of drawing operations
+     * End a modelling session
      */
     void end();
     
     /**
-     * Begin creation of a filled surface
+     * Begin creation of a filled polygon
      */
     void fillBegin();
     
     /**
-     * End creation of a filled surface
+     * End creation of a filled polygon
      */
     void fillEnd();
     
     /**
-     * Create one vertex in the filled surface
-     * @param x x-coordinate
-     * @param y y-coordinate
-     * @param z z-coordinate
+     * Increment current index to color table
      */
-    void point(double x, double y, double z);
+    void nextColor();
+    
+    /**
+     * Decrement current index to color table
+     */
+    void prevColor();
+    
+    /**
+     * Decrement segment diameter
+     */
+    void decrementDiameter();
+    
+    
+    /**
+     * Set current color index
+     * @param index the color index
+     */
+    void setColorIndex(int index);
+    
+    /**
+     * Set current segment diameter
+     * @param diameter the diameter
+     */
+    void setDiameter(double diameter);
+    
+    /**
+     * Set segment diameter factor
+     * @param diameter the diameter factor
+     */
+    void setDiameterFactor(double diameterFactor);
+    
+    
+    /**
+     * Get current color index
+     * @return color index
+     */
+    int getColorIndex();
+    
+    /**
+     * Get current segment diameter
+     * @return the diameter
+     */
+    double getDiameter();
+    
+    /**
+     * Get segment diameter factor
+     * @return the diameter factor
+     */
+    double getDiameterFactor();
     
 protected:
     
-    GLuint _displayList;    // all drawing operations
+    GLuint _displayList;    // All drawing operations
+    
+    vector<Color> _colorTable;  // Color table
+    int _colorIndex;            // Current index to color table
+    double _diameter;           // Current segment diameter
+    double _diameterFactor;     // Diameter factor // TODO: "Diameter factor"?
 };