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

FXGLTriangleMesh.h

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,2005 by Jeroen van der Zijp. 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: FXGLTriangleMesh.h,v 1.14 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXGLTRIANGLEMESH_H 00025 #define FXGLTRIANGLEMESH_H 00026 00027 #ifndef FXGLSHAPE_H 00028 #include "FXGLShape.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /* 00035 * Arrays Formats 00036 * 00037 * vertex: x,y,z 00038 * normal: x,y,z 00039 * Color: r,g.b,a 00040 * texture: u,v 00041 */ 00042 00043 00044 /// OpenGL Triangle Mesh Object 00045 class FXAPI FXGLTriangleMesh : public FXGLShape { 00046 FXDECLARE(FXGLTriangleMesh) 00047 private: 00048 FXfloat *vertexBuffer; 00049 FXfloat *colorBuffer; 00050 FXfloat *normalBuffer; 00051 FXfloat *textureBuffer; 00052 FXint vertexNumber; 00053 protected: 00054 FXGLTriangleMesh(); 00055 virtual void drawshape(FXGLViewer* viewer); 00056 virtual void recomputerange(); 00057 virtual void generatenormals(); 00058 public: 00059 00060 /// Construct triangle mesh with nv vertices, and optional normals, colors, and texture coordinates 00061 FXGLTriangleMesh(FXfloat x,FXfloat y,FXfloat z,FXint nv,FXfloat *v,FXfloat *n=NULL,FXfloat *c=NULL,FXfloat *t=NULL); 00062 00063 /// Construct triangle mesh with nv vertices, and optional normals, colors, and texture coordinates, and surface material 00064 FXGLTriangleMesh(FXfloat x,FXfloat y,FXfloat z,FXint nv,FXfloat *v,FXfloat *n,FXfloat *c,FXfloat *t,const FXMaterial& mtl); 00065 00066 /// Copy constructor 00067 FXGLTriangleMesh(const FXGLTriangleMesh& orig); 00068 00069 /// Copy this object 00070 virtual FXGLObject* copy(); 00071 00072 /// Change number of vertices 00073 void setVertexNumber(FXint nvertices){ vertexNumber=nvertices; } 00074 00075 /// Get number of vertices 00076 FXint getVertexNumber() const { return vertexNumber; } 00077 00078 /// Set vertex buffer 00079 void setVertexBuffer(FXfloat *vertices); 00080 00081 /// Get vertex buffer 00082 FXfloat* getVertexBuffer() const { return vertexBuffer; } 00083 00084 /// Set color buffer 00085 void setColorBuffer(FXfloat *colors){ colorBuffer=colors; } 00086 00087 /// Get color buffer 00088 FXfloat* getColorBuffer() const { return colorBuffer; } 00089 00090 /// Set normals buffer 00091 void setNormalBuffer(FXfloat *normals){ normalBuffer=normals; } 00092 00093 /// Get normals buffer 00094 FXfloat* getNormalBuffer() const { return normalBuffer; } 00095 00096 /// Set texture coordinate buffer 00097 void setTextureCoordBuffer(FXfloat *textures){ textureBuffer=textures; } 00098 00099 /// Get texture coordinate buffer 00100 FXfloat* getTextureCoordBuffer() const { return textureBuffer; } 00101 00102 /// Save to a stream 00103 virtual void save(FXStream& store) const; 00104 00105 /// Load from a stream 00106 virtual void load(FXStream& store); 00107 00108 /// Destructor 00109 virtual ~FXGLTriangleMesh(); 00110 }; 00111 00112 } 00113 00114 #endif

Copyright © 1997-2005 Jeroen van der Zijp