H3D API  2.4.1
Box.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 __BOX_H__
30 #define __BOX_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 
34 namespace H3D {
35 
71  class H3DAPI_API Box : public X3DGeometryNode {
72  public:
73 
79  class SFBound: public X3DGeometryNode::SFBound {
81  virtual void update() {
82  Vec3f b = static_cast< SFVec3f * >( routes_in[0] )->getValue();
83  BoxBound *bb = new BoxBound;
84  bb->size->setValue( b );
85  value = bb;
86  }
87  };
88 
90  Box( Inst< SFNode > _metadata = 0,
91  Inst< SFBound > _bound = 0,
92  Inst< SFVec3f > _size = 0,
93  Inst< SFBool > _solid = 0 );
94 
96  virtual void render();
97 
99  virtual int nrTriangles() {
100  return 12;
101  }
102 
103  // Traverse the scenegraph. See X3DGeometryNode::traverseSG
104  // for more info.
105  virtual void traverseSG( TraverseInfo &ti );
106 
114  H3DUniquePtr< SFVec3f > size;
115 
122  H3DUniquePtr< SFBool > solid;
123 
126  };
127 }
128 
129 #endif
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 size field of the Box node.
Definition: Box.h:79
The Box node specifies a rectangular parallelepiped box centred at (0, 0, 0) in the local coordinate ...
Definition: Box.h:71
H3DUniquePtr< SFBool > solid
The solid field determines whether the box is visible when viewed from the inside.
Definition: Box.h:122
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: Box.h:125
virtual int nrTriangles()
The number of triangles rendered by this geometry.
Definition: Box.h:99
H3DUniquePtr< SFVec3f > size
The size field specifies the extents of the box along the X-, Y-, and Z-axes respectively.
Definition: Box.h:114
The SFVec3f field contains a Vec3f.
Definition: SFVec3f.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
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