H3D API  2.4.1
Polyline2D.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 __POLYLINE2D_H__
30 #define __POLYLINE2D_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 #include <H3D/MFVec2f.h>
34 
35 namespace H3D {
36 
52  class H3DAPI_API Polyline2D :
53  public X3DGeometryNode {
54  public:
55 
60  class H3DAPI_API DisplayList: public X3DGeometryNode::DisplayList {
61  public:
63  virtual void callList( bool build_list = true );
64  };
65 
71  class SFBound: public TypedField< X3DGeometryNode::SFBound,
72  MFVec2f > {
74  virtual void update() {
75  const vector< Vec2f > &points =
76  static_cast< MFVec2f * >( routes_in[0] )->getValue();
77  BoxBound *_bound = new BoxBound();
78  _bound->fitAround2DPoints( points.begin(), points.end() );
79  value = _bound;
80  }
81  };
82 
84  Polyline2D( Inst< SFNode > _metadata = 0,
85  Inst< SFBound > _bound = 0,
86  Inst< DisplayList > _displayList = 0,
87  Inst< MFBool > _isTouched = 0,
88  Inst< MFVec3f > _force = 0,
89  Inst< MFVec3f > _contactPoint = 0,
90  Inst< MFVec3f > _contactNormal = 0,
91  Inst< MFVec2f > _lineSegments = 0 );
92 
93  ~Polyline2D();
94 
96  virtual void render();
97 
99  virtual int nrLines() {
100  return lineSegments->size();
101  }
102 
108  H3DUniquePtr< MFVec2f > lineSegments;
109 
112  protected:
115  H3DUniquePtr< Field > vboFieldsUpToDate;
116  // The index for the vertex buffer object
117  GLuint *vbo_id;
118  };
119 }
120 
121 #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
Display list is extended in order to set color to emissive color from material outside of display lis...
Definition: Polyline2D.h:60
SFBound is specialized update itself from the lineSegments field of the Polyline2D node.
Definition: Polyline2D.h:72
The Polyline2D node specifies a series of contiguous line segments in the local 2D coordinate system ...
Definition: Polyline2D.h:53
H3DUniquePtr< Field > vboFieldsUpToDate
Internal field used to know if vertex buffer object can be created.
Definition: Polyline2D.h:115
virtual int nrLines()
The number of lines rendered by this geometry.
Definition: Polyline2D.h:99
H3DUniquePtr< MFVec2f > lineSegments
The lineSegments field specifies the vertices to be connected.
Definition: Polyline2D.h:108
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: Polyline2D.h:111
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
Display list is extended in order to set front sidedness of triangles outside the display list.
Definition: X3DGeometryNode.h:76
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