FXGLVertices.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                 O p e n G L   V e r t i c e s   O b j e c t                   *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2006 by Niall Douglas.   All Rights Reserved.                   *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXGLVertices.h                                                           *
00023 ********************************************************************************/
00024 #ifndef FX_DISABLEGL
00025 
00026 #if FX_GRAPHINGMODULE
00027 
00028 #ifndef FXGLVERTICES_H
00029 #define FXGLVERTICES_H
00030 
00031 #ifndef FXGLSHAPE_H
00032 #include "FXGLShape.h"
00033 #endif
00034 
00035 namespace FX {
00036 
00037 
00038 // Vertices drawing options
00039 enum {
00040   VERTICES_POINTS          = 0x00000100,     // Draw each point
00041   VERTICES_LINES           = 0x00000200,     // Draw as set of connected lines
00042   VERTICES_LOOPLINES       = 0x00000400,     // Connect start to end
00043   VERTICES_LINEITEMS       = 0x00000800,     // Draw as set of separate lines
00044   VERTICES_NODEPTHTEST     = 0x00001000      // Disable the depth test during rendition
00045   };
00046 
00047 
00053 class FXGRAPHINGMODULEAPI FXGLVertices : public FXGLShape {
00054   FXDECLARE(FXGLVertices)
00055 public:
00056   typedef void (*ColorGeneratorFunc)(FXGLColor &color, FXGLVertices *obj, FXGLViewer *viewer, FXuint vertex, void *&data);
00057 
00058 protected:
00059   FXuchar modified;
00060   FXuint displayLists;
00061   FXuint vertexNumber;
00062   FXVec3f *vertices;
00063   FXfloat pointSize, lineSize;
00064   FXGLColor color;
00065   ColorGeneratorFunc colorGenerator;
00066   void *colorGeneratorData;
00067 protected:
00068   FXGLVertices();
00069 private:
00070   friend class FXGLCircle;
00071   inline void renderPoints(FXGLViewer *viewer, bool isHit, bool complex);
00072   inline void renderLines(FXGLViewer *viewer, bool isHit, bool complex);
00073   inline void render(FXGLViewer *viewer, bool isHit, bool complex);
00074   virtual void drawshape(FXGLViewer*);
00075 public:
00077   FXGLVertices(FXfloat x,FXfloat y,FXfloat z,FXuint opts=VERTICES_POINTS, FXVec3f *vertices=NULL, FXuint no=0, FXfloat pointSize=4.0f, FXfloat lineSize=1.0f);
00078 
00080   FXGLVertices(const FXGLVertices& orig);
00081 
00082   ~FXGLVertices();
00083 
00085   void setModified(bool v=true) { modified=3*v; }
00086 
00088   FXuint getNumberOfVertices() const { return vertexNumber; }
00089 
00091   void setNumberOfVertices(FXuint vertices);
00092 
00094   FXVec3f *getVertices() const { return vertices; }
00095 
00097   void setVertices(FXVec3f *verts, FXuint no);
00098 
00100   FXfloat getPointSize() const { return pointSize; }
00101 
00103   void setPointSize(FXfloat ps);
00104 
00106   FXfloat getLineSize() const { return lineSize; }
00107 
00109   void setLineSize(FXfloat ps);
00110 
00112   const FXGLColor &getColor() const { return color; }
00113 
00115   void setColor(const FXGLColor &col);
00116 
00118   void setColorGenerator(ColorGeneratorFunc func, void *data=0);
00119 
00121   virtual void bounds(FXRangef& box);
00122 
00124   virtual void draw(FXGLViewer* viewer);
00125 
00127   virtual void hit(FXGLViewer* viewer);
00128 
00130   virtual FXGLObject* copy();
00131 
00133   virtual void save(FXStream& store) const;
00134 
00136   virtual void load(FXStream& store);
00137 
00138 public:
00140   static void RainbowGenerator(FXGLColor &color, FXGLVertices *obj, FXGLViewer *viewer, FXuint vertex, void *&data);
00141 
00143   static void BrighterGenerator(FXGLColor &color, FXGLVertices *obj, FXGLViewer *viewer, FXuint vertex, void *&data);
00144 
00146   static void DarkerGenerator(FXGLColor &color, FXGLVertices *obj, FXGLViewer *viewer, FXuint vertex, void *&data);
00147 
00148   };
00149 
00150 
00156 class FXGRAPHINGMODULEAPI FXGLCircle : public FXGLShape {
00157     float radius;
00158     FXMat4f transformation;
00159 protected:
00160     virtual void drawshape(FXGLViewer*);
00161 public:
00162     FXGLCircle() { }
00164     FXGLCircle(float x, float y, float z, float r, FXuint options=0);
00166     const FXMat4f &getTransformation() const { return transformation; }
00168     void setTransformation(const FXMat4f &t) { transformation=t; }
00169 
00170     virtual void bounds(FXRangef& box);
00171     virtual void draw(FXGLViewer* viewer);
00172     virtual FXGLObject* copy();
00173     virtual void save(FXStream& store) const;
00174     virtual void load(FXStream& store);
00175 };
00176 
00177 }
00178 
00179 #endif
00180 #endif
00181 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:22 2009 for TnFOX by doxygen v1.4.7