Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXGLTriangleMesh.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *             O p e n G L   T r i a n g l e   M e s h   O b j e c t             *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXGLTriangleMesh.h,v 1.19 2009/01/06 13:07:24 fox Exp $                  *
00022 ********************************************************************************/
00023 #ifndef FXGLTRIANGLEMESH_H
00024 #define FXGLTRIANGLEMESH_H
00025 
00026 #ifndef FXGLSHAPE_H
00027 #include "FXGLShape.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /*
00034  * Arrays Formats
00035  *
00036  * vertex: x,y,z
00037  * normal: x,y,z
00038  * Color: r,g.b,a
00039  * texture: u,v
00040  */
00041 
00042 
00043 /// OpenGL Triangle Mesh Object
00044 class FXAPI FXGLTriangleMesh : public FXGLShape {
00045   FXDECLARE(FXGLTriangleMesh)
00046 private:
00047   FXfloat   *vertexBuffer;
00048   FXfloat   *colorBuffer;
00049   FXfloat   *normalBuffer;
00050   FXfloat   *textureBuffer;
00051   FXint      vertexNumber;
00052 protected:
00053   FXGLTriangleMesh();
00054   virtual void drawshape(FXGLViewer* viewer);
00055   virtual void recomputerange();
00056   virtual void generatenormals();
00057 public:
00058 
00059   /// Construct triangle mesh with nv vertices, and optional normals, colors, and texture coordinates
00060   FXGLTriangleMesh(FXfloat x,FXfloat y,FXfloat z,FXint nv,FXfloat *v,FXfloat *n=NULL,FXfloat *c=NULL,FXfloat *t=NULL);
00061 
00062   /// Construct triangle mesh with nv vertices, and optional normals, colors, and texture coordinates, and surface material
00063   FXGLTriangleMesh(FXfloat x,FXfloat y,FXfloat z,FXint nv,FXfloat *v,FXfloat *n,FXfloat *c,FXfloat *t,const FXMaterial& mtl);
00064 
00065   /// Copy constructor
00066   FXGLTriangleMesh(const FXGLTriangleMesh& orig);
00067 
00068   /// Copy this object
00069   virtual FXGLObject* copy();
00070 
00071   /// Change number of vertices
00072   void setVertexNumber(FXint nvertices){ vertexNumber=nvertices; }
00073 
00074   /// Get number of vertices
00075   FXint getVertexNumber() const { return vertexNumber; }
00076 
00077   /// Set vertex buffer
00078   void setVertexBuffer(FXfloat *vertices);
00079 
00080   /// Get vertex buffer
00081   FXfloat* getVertexBuffer() const { return vertexBuffer; }
00082 
00083   /// Set color buffer
00084   void setColorBuffer(FXfloat *colors){ colorBuffer=colors; }
00085 
00086   /// Get color buffer
00087   FXfloat* getColorBuffer() const { return colorBuffer; }
00088 
00089   /// Set normals buffer
00090   void setNormalBuffer(FXfloat *normals){ normalBuffer=normals; }
00091 
00092   /// Get normals buffer
00093   FXfloat* getNormalBuffer() const { return normalBuffer; }
00094 
00095   /// Set texture coordinate buffer
00096   void setTextureCoordBuffer(FXfloat *textures){ textureBuffer=textures; }
00097 
00098   /// Get texture coordinate buffer
00099   FXfloat* getTextureCoordBuffer() const { return textureBuffer; }
00100 
00101   /// Save to a stream
00102   virtual void save(FXStream& store) const;
00103 
00104   /// Load from a stream
00105   virtual void load(FXStream& store);
00106 
00107   /// Destructor
00108   virtual ~FXGLTriangleMesh();
00109   };
00110 
00111 }
00112 
00113 #endif

Copyright © 1997-2009 Jeroen van der Zijp