H3D API  2.4.1
Capsule.h
Go to the documentation of this file.
1 // Copyright 2010-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 __CAPSULE_H__
30 #define __CAPSULE_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 #include <H3D/SFFloat.h>
34 
35 namespace H3D {
63  class H3DAPI_API Capsule : public X3DGeometryNode {
64  public:
65 
72  class H3DAPI_API SFBound: public X3DGeometryNode::SFBound {
74  virtual void update() {
75  H3DFloat h = static_cast< SFFloat * >( routes_in[0] )->getValue();
76  H3DFloat r = static_cast< SFFloat * >( routes_in[1] )->getValue();
77  BoxBound *bb = new BoxBound;
78  H3DFloat d = 2 * r;
79  bb->size->setValue( Vec3f( d, h+d, d ) );
80  value = bb;
81  }
82  };
83 
85  Capsule( Inst< SFNode > _metadata = 0,
86  Inst< SFBound > _bound = 0,
87  Inst< SFBool > _bottom = 0,
88  Inst< SFFloat > _height = 0,
89  Inst< SFFloat > _radius = 0,
90  Inst< SFBool > _side = 0,
91  Inst< SFBool > _solid = 0,
92  Inst< SFBool > _top = 0 );
93 
95  ~Capsule();
96 
98  virtual void render();
99 
101  virtual void traverseSG( TraverseInfo &ti );
102 
104  virtual int nrTriangles();
105 
112  H3DUniquePtr< SFBool > bottom;
113 
121  H3DUniquePtr< SFFloat > height;
122 
130  H3DUniquePtr< SFFloat > radius;
131 
138  H3DUniquePtr< SFBool > side;
139 
148  H3DUniquePtr< SFBool > solid;
149 
156  H3DUniquePtr< SFBool > top;
157 
160 
161  protected:
164  H3DUniquePtr< Field > vboFieldsUpToDate;
165  // The index for the vertex buffer object
166  GLuint *vbo_id;
167 
168  // the number of parts around the cylinder and along the equator of the end-cap half-spheres
169  static const unsigned int theta_parts = 10;
170  // the number of parts along the height of the half-spheres
171  static const unsigned int phi_parts = 5;
172  };
173 }
174 
175 #endif
Contains the SFFloat 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
H3DUniquePtr< SFVec3f > size
The size of the bounding box.
Definition: Bound.h:287
SFBound is specialized update itself from the radius and heigh field of the Capsule node.
Definition: Capsule.h:72
The Capsule node specifies a cylinder, with half-sphere as end caps, centred at (0,...
Definition: Capsule.h:63
H3DUniquePtr< Field > vboFieldsUpToDate
Internal field used to know if vertex buffer object can be created.
Definition: Capsule.h:164
H3DUniquePtr< SFBool > bottom
Specifies if the bottom of the Capsule should be rendered or not.
Definition: Capsule.h:112
H3DUniquePtr< SFBool > side
Specifies if the sides of the Capsule should be rendered or not.
Definition: Capsule.h:138
static H3DNodeDatabase database
The H3DNodeDatabase instance for this node.
Definition: Capsule.h:159
H3DUniquePtr< SFBool > top
Specifies if the top of the Capsule should be rendered or not.
Definition: Capsule.h:156
H3DUniquePtr< SFFloat > radius
The radius of the Capsule.
Definition: Capsule.h:130
H3DUniquePtr< SFBool > solid
The solid field determines whether the Capsule is visible when viewed from the inside.
Definition: Capsule.h:148
H3DUniquePtr< SFFloat > height
The height of the Capsule in meters.
Definition: Capsule.h:121
The SFFloat field contains one single-precision floating point number.
Definition: SFFloat.h:41
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
This is the base node type for all geometry in X3D.
Definition: X3DGeometryNode.h:61
float H3DFloat
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