H3D API  2.4.1
Cone.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 __CONE_H__
30 #define __CONE_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 #include <H3D/SFFloat.h>
34 
35 namespace H3D {
36 
75  class H3DAPI_API Cone : public X3DGeometryNode {
76  public:
77 
84  class SFBound: public X3DGeometryNode::SFBound {
86  virtual void update() {
87  H3DFloat h = static_cast< SFFloat * >( routes_in[0] )->getValue();
88  H3DFloat br = static_cast< SFFloat * >( routes_in[1] )->getValue();
89  BoxBound *bb = new BoxBound;
90  H3DFloat d = 2 * br;
91  bb->size->setValue( Vec3f( d, h, d ) );
92  value = bb;
93  }
94  };
95 
97  Cone( Inst< SFNode > _metadata = 0,
98  Inst< SFBound > _bound = 0,
99  Inst< SFBool > _bottom = 0,
100  Inst< SFFloat > _bottomRadius = 0,
101  Inst< SFFloat > _height = 0,
102  Inst< SFBool > _side = 0,
103  Inst< SFBool > _solid = 0 );
104 
106  virtual void render();
107 
109  virtual int nrTriangles() {
110  return 560;
111  }
112 
114  virtual void traverseSG( TraverseInfo &ti );
115 
121  H3DUniquePtr< SFBool > bottom;
122 
127  H3DUniquePtr< SFFloat > bottomRadius;
128 
134  H3DUniquePtr< SFFloat > height;
135 
140  H3DUniquePtr< SFBool > side;
141 
147  H3DUniquePtr< SFBool > solid;
148 
151  };
152 }
153 
154 #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 Cone node.
Definition: Cone.h:84
The Cone node specifies a cone which is centred in the local coordinate system and whose central axis...
Definition: Cone.h:75
H3DUniquePtr< SFFloat > bottomRadius
The bottomRadius field specifies the radius of the cone's base.
Definition: Cone.h:127
H3DUniquePtr< SFBool > bottom
The side field specifies whether the bottom cap of the cone is rendered.
Definition: Cone.h:121
H3DUniquePtr< SFBool > solid
The solid field determines whether the box is visible when viewed from the inside.
Definition: Cone.h:147
H3DUniquePtr< SFFloat > height
The height field specifies the height of the cone from the centre of the base to the apex.
Definition: Cone.h:134
virtual int nrTriangles()
The number of triangles rendered by this geometry.
Definition: Cone.h:109
H3DUniquePtr< SFBool > side
The side field specifies whether the sides of the cone are rendered.
Definition: Cone.h:140
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: Cone.h:150
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