![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
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,2002 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.9 2002/01/18 22:42:53 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXGLTRIANGLEMESH_H 00025 #define FXGLTRIANGLEMESH_H 00026 00027 #ifndef FXGLSHAPE_H 00028 #include "FXGLShape.h" 00029 #endif 00030 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 #endif