H3D API  2.4.1
TriangleSet2D.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __TRIANGLESET2D_H__
30 #define __TRIANGLESET2D_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 #include <H3D/MFVec2f.h>
34 
35 namespace H3D {
36 
57 
58  class H3DAPI_API TriangleSet2D :
59  public X3DGeometryNode {
60  public:
61 
67  class SFBound: public TypedField< X3DGeometryNode::SFBound,
68  MFVec2f > {
70  virtual void update() {
71  const vector< Vec2f > &points =
72  static_cast< MFVec2f * >( routes_in[0] )->getValue();
73  BoxBound *_bound = new BoxBound();
74  _bound->fitAround2DPoints( points.begin(), points.end() );
75  value = _bound;
76  }
77  };
78 
80  TriangleSet2D( Inst< SFNode > _metadata = 0,
81  Inst< SFBound > _bound = 0,
82  Inst< DisplayList > _displayList = 0,
83  Inst< MFBool > _isTouched = 0,
84  Inst< MFVec3f > _force = 0,
85  Inst< MFVec3f > _contactPoint = 0,
86  Inst< MFVec3f > _contactNormal = 0,
87  Inst< MFVec2f > _vertices = 0,
88  Inst< SFBool > _solid = 0 );
89 
90  ~TriangleSet2D();
91 
93  virtual void render();
94 
95  // Traverse the scenegraph. See X3DGeometryNode::traverseSG
96  // for more info.
97  virtual void traverseSG( TraverseInfo &ti );
98 
100  virtual int nrTriangles() {
101  return vertices->size() / 3;
102  }
103 
111  H3DUniquePtr< MFVec2f > vertices;
112 
120  H3DUniquePtr< SFBool > solid;
121 
124  protected:
127  H3DUniquePtr< Field > vboFieldsUpToDate;
128  // The index for the vertex buffer object
129  GLuint *vbo_id;
130  };
131 }
132 
133 #endif
Contains the MFVec2f field class.
Header file for X3DGeometryNode, X3D scene-graph node.
The BoxBound is a Bound class that specifies the bound using an axis-aligned bounding box.
Definition: Bound.h:144
The MFVec2f field contains a vector of Vec2f.
Definition: MFVec2f.h:41
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
SFBound is specialized update itself from the vertices field of the TriangleSet2D node.
Definition: TriangleSet2D.h:68
The TriangleSet2D node specifies a set of triangles in the local 2D coordinate system.
Definition: TriangleSet2D.h:59
H3DUniquePtr< MFVec2f > vertices
The vertices field specifies the triangles to be displayed.
Definition: TriangleSet2D.h:111
H3DUniquePtr< Field > vboFieldsUpToDate
Internal field used to know if vertex buffer object can be created.
Definition: TriangleSet2D.h:127
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: TriangleSet2D.h:123
H3DUniquePtr< SFBool > solid
The solid field specifies if both sides of the closed arc should be rendered.
Definition: TriangleSet2D.h:120
virtual int nrTriangles()
The number of triangles renderered in this geometry.
Definition: TriangleSet2D.h:100
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
This is the base node type for all geometry in X3D.
Definition: X3DGeometryNode.h:61
Type getValue(const char *s, const char *&rest)
Function that reads characters from a char * and converts them to a given type.
Definition: X3DFieldConversion.h:134
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194