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

FXGLTriangleMesh.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * O p e n G L T r i a n g l e M e s h O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXGLTriangleMesh.h,v 1.15 2006/01/22 17:58:04 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXGLTRIANGLEMESH_H
25 #define FXGLTRIANGLEMESH_H
26 
27 #ifndef FXGLSHAPE_H
28 #include "FXGLShape.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /*
35  * Arrays Formats
36  *
37  * vertex: x,y,z
38  * normal: x,y,z
39  * Color: r,g.b,a
40  * texture: u,v
41  */
42 
43 
44 /// OpenGL Triangle Mesh Object
47 private:
48  FXfloat *vertexBuffer;
49  FXfloat *colorBuffer;
50  FXfloat *normalBuffer;
51  FXfloat *textureBuffer;
52  FXint vertexNumber;
53 protected:
55  virtual void drawshape(FXGLViewer* viewer);
56  virtual void recomputerange();
57  virtual void generatenormals();
58 public:
59 
60  /// Construct triangle mesh with nv vertices, and optional normals, colors, and texture coordinates
62 
63  /// Construct triangle mesh with nv vertices, and optional normals, colors, and texture coordinates, and surface material
65 
66  /// Copy constructor
68 
69  /// Copy this object
70  virtual FXGLObject* copy();
71 
72  /// Change number of vertices
73  void setVertexNumber(FXint nvertices){ vertexNumber=nvertices; }
74 
75  /// Get number of vertices
76  FXint getVertexNumber() const { return vertexNumber; }
77 
78  /// Set vertex buffer
79  void setVertexBuffer(FXfloat *vertices);
80 
81  /// Get vertex buffer
82  FXfloat* getVertexBuffer() const { return vertexBuffer; }
83 
84  /// Set color buffer
85  void setColorBuffer(FXfloat *colors){ colorBuffer=colors; }
86 
87  /// Get color buffer
88  FXfloat* getColorBuffer() const { return colorBuffer; }
89 
90  /// Set normals buffer
91  void setNormalBuffer(FXfloat *normals){ normalBuffer=normals; }
92 
93  /// Get normals buffer
94  FXfloat* getNormalBuffer() const { return normalBuffer; }
95 
96  /// Set texture coordinate buffer
97  void setTextureCoordBuffer(FXfloat *textures){ textureBuffer=textures; }
98 
99  /// Get texture coordinate buffer
100  FXfloat* getTextureCoordBuffer() const { return textureBuffer; }
101 
102  /// Save to a stream
103  virtual void save(FXStream& store) const;
104 
105  /// Load from a stream
106  virtual void load(FXStream& store);
107 
108  /// Destructor
109  virtual ~FXGLTriangleMesh();
110  };
111 
112 }
113 
114 #endif
Definition: FXGLViewer.h:79
Basic OpenGL object.
Definition: FXGLObject.h:39
OpenGL Triangle Mesh Object.
Definition: FXGLTriangleMesh.h:45
OpenGL viewer widget.
Definition: FXGLViewer.h:100
#define FXAPI
Definition: fxdefs.h:122
#define NULL
Definition: fxdefs.h:41
int FXint
Definition: fxdefs.h:397
OpenGL Shape Object.
Definition: FXGLShape.h:64
float FXfloat
Definition: fxdefs.h:398
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92

Copyright © 1997-2005 Jeroen van der Zijp