H3D API  2.4.1
Cylinder.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 __CYLINDER_H__
30 #define __CYLINDER_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 #include <H3D/SFFloat.h>
34 
35 namespace H3D {
36 
78  class H3DAPI_API Cylinder : public X3DGeometryNode {
79  public:
80 
87  class SFBound: public X3DGeometryNode::SFBound {
89  virtual void update() {
90  H3DFloat h = static_cast< SFFloat * >( routes_in[0] )->getValue();
91  H3DFloat r = static_cast< SFFloat * >( routes_in[1] )->getValue();
92  BoxBound *bb = new BoxBound;
93  H3DFloat d = 2 * r;
94  bb->size->setValue( Vec3f( d, h, d ) );
95  value = bb;
96  }
97  };
98 
100  Cylinder( Inst< SFNode > _metadata = 0,
101  Inst< SFBound > _bound = 0,
102  Inst< SFBool > _bottom = 0,
103  Inst< SFFloat> _height = 0,
104  Inst< SFFloat> _radius = 0,
105  Inst< SFBool > _side = 0,
106  Inst< SFBool > _solid = 0,
107  Inst< SFBool > _top = 0 );
108 
110  ~Cylinder();
111 
113  virtual void render();
114 
116  virtual void traverseSG( TraverseInfo &ti );
117 
119  virtual int nrTriangles() {
120  return 720;
121  }
128  H3DUniquePtr< SFBool > bottom;
129 
137  H3DUniquePtr< SFFloat > height;
138 
146  H3DUniquePtr< SFFloat > radius;
147 
154  H3DUniquePtr< SFBool > side;
155 
164  H3DUniquePtr< SFBool > solid;
165 
172  H3DUniquePtr< SFBool > top;
173 
174  static H3DNodeDatabase database;
175  protected:
178  H3DUniquePtr< Field > vboFieldsUpToDate;
179  // The index for the vertex buffer object
180  GLuint *vbo_id;
181  };
182 }
183 
184 #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 Cylinder node.
Definition: Cylinder.h:87
The Cylinder node specifies a capped cylinder centred at (0,0,0) in the local coordinate system and w...
Definition: Cylinder.h:78
H3DUniquePtr< SFBool > solid
The solid field determines whether the cylinder is visible when viewed from the inside.
Definition: Cylinder.h:164
H3DUniquePtr< SFBool > top
Specifies if the top of the cylinder should be rendered or not.
Definition: Cylinder.h:172
H3DUniquePtr< Field > vboFieldsUpToDate
Internal field used to know if vertex buffer object can be created.
Definition: Cylinder.h:178
virtual int nrTriangles()
The number of triangles rendered by this geometry.
Definition: Cylinder.h:119
H3DUniquePtr< SFBool > side
Specifies if the sides of the Cylinder should be rendered or not.
Definition: Cylinder.h:154
H3DUniquePtr< SFBool > bottom
Specifies if the bottom of the Cylinder should be rendered or not.
Definition: Cylinder.h:128
H3DUniquePtr< SFFloat > radius
The radius of the Cylinder.
Definition: Cylinder.h:146
H3DUniquePtr< SFFloat > height
The height of the Cylinder in meters.
Definition: Cylinder.h:137
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