H3D API  2.4.1
PlanarReflector.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 __PLANARREFLECTOR_H__
30 #define __PLANARREFLECTOR_H__
31 
32 #include <H3D/X3DGroupingNode.h>
33 #include <H3D/X3DBoundedObject.h>
34 #include <H3D/X3DGeometryNode.h>
35 #include <H3D/X3DViewpointNode.h>
39 #include <H3D/SFColor.h>
40 
41 namespace H3D {
58  class H3DAPI_API PlanarReflector :
59  public X3DChildNode,
60  public X3DBoundedObject,
61  public H3DDisplayListObject,
63  public:
72  public DependentSFNode< X3DGeometryNode,
73  FieldRef< H3DDisplayListObject,
74  H3DDisplayListObject::DisplayList,
75  &H3DDisplayListObject::displayList >, true > {
80  public:
81 
84 
88  value = NULL;
89  }
90 
97  virtual void onAdd( Node *n ) {
98  PlanarReflector *pr = static_cast< PlanarReflector * >( getOwner() );
99  BaseField::onAdd( n );
100  if( n && pr->use_geometry_bound ) {
101  X3DGeometryNode *g = static_cast< X3DGeometryNode * >( n );
102  g->bound->route( pr->bound );
103  }
104  }
105 
112  virtual void onRemove( Node *n ) {
113  PlanarReflector *pr = static_cast< PlanarReflector * >( getOwner() );
114  BaseField::onRemove( n );
115  if( n && pr->use_geometry_bound ) {
116  X3DGeometryNode *g = static_cast< X3DGeometryNode * >( n );
117  g->bound->unroute( pr->bound );
118  }
119  }
120 
121  };
122 
124  PlanarReflector( Inst< SFNode > _metadata = 0,
125  Inst< SFBound > _bound = 0,
126  Inst< SFVec3f > _bboxCenter = 0,
127  Inst< SFVec3f > _bboxSize = 0,
128  Inst< DisplayList > _displayList = 0,
129  Inst< SFGeometryNode > _geometry = 0,
130  Inst< SFFloat > _reflectivity = 0,
131  Inst< SFColor > _color = 0
132  );
133 
138  virtual void initialize() {
139  const Vec3f &size = bboxSize->getValue();
140  if( size.x == -1 && size.y == -1 && size.z == -1 ) {
141  use_geometry_bound = true;
142  X3DGeometryNode *g =
143  static_cast< X3DGeometryNode * >( geometry->getValue() );
144  if( g ) {
145  g->bound->route( this->bound );
146  }
147  } else {
148  BoxBound *bb = new BoxBound();
149  bb->center->setValue( bboxCenter->getValue() );
150  bb->size->setValue( bboxSize->getValue() );
151  bound->setValue( bb );
152  }
154  }
155 
157  virtual void renderPostViewpoint ( X3DChildNode *n,
158  X3DViewpointNode *vp );
159 
161  virtual void traverseSG( TraverseInfo &ti );
162 
170  virtual bool lineIntersect(
171  const Vec3f &from,
172  const Vec3f &to,
173  LineIntersectResult &result );
174 
180  virtual void closestPoint( const Vec3f &p,
181  NodeIntersectResult &result );
182 
191  virtual bool movingSphereIntersect( H3DFloat radius,
192  const Vec3f &from,
193  const Vec3f &to,
194  NodeIntersectResult &result );
195 
201  H3DUniquePtr< SFGeometryNode > geometry;
202 
211  H3DUniquePtr< SFFloat > reflectivity;
212 
219  H3DUniquePtr< SFColor > color;
220 
221  // if true a route will be set up between the bound field of the
222  // geometry node in this field and the bound field of the shape.
223  bool use_geometry_bound;
224 
227 
228  Matrix4f local_to_global;
229  };
230 }
231 
232 #endif
Contains the DependentSFNode and DependentMFNode template classes.
Header file for H3DDisplayListObject.
Header file for H3DMultiPassRenderObject.
Contains the SFColor field class.
Header file for X3DBoundedObject.
Header file for X3DGeometryNode, X3D scene-graph node.
Header file for X3DGroupingNode, X3D scene-graph node.
Header file for X3DViewpointNode, X3D scene-graph node.
virtual void initialize()
The BoxBound is a Bound class that specifies the bound using an axis-aligned bounding box.
Definition: Bound.h:144
H3DUniquePtr< SFVec3f > center
The center point of the bounding box.
Definition: Bound.h:285
H3DUniquePtr< SFVec3f > size
The size of the bounding box.
Definition: Bound.h:287
DependentSFNode are modified TypedSFNode fields where the field dirty status is dependent on fields i...
Definition: DependentNodeFields.h:294
Class used for specifying a field member of a node in a DependentSFNode or DependentMFNode specificat...
Definition: DependentNodeFields.h:48
H3DUniquePtr< SFBound > bound
The field containing the bound object.
Definition: H3DBoundedObject.h:59
We use the Field's lazy evaluation mechanisms to manage the GL display lists for rendering,...
Definition: H3DDisplayListObject.h:60
This abstract interface class is the base class for all node types that wants to create an OpenGL dis...
Definition: H3DDisplayListObject.h:54
H3DUniquePtr< DisplayList > displayList
The DisplayList instance handling the OpenGL caching of this object.
Definition: H3DDisplayListObject.h:256
This abstract interface is inherited by all nodes that needs to render the scene an extra time(or mor...
Definition: H3DMultiPassRenderObject.h:41
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
SFGeometryNode is dependent on the displayList field of its encapsulated X3DGeometryNode node,...
Definition: PlanarReflector.h:75
virtual void onAdd(Node *n)
This function will be called when the value of RefCountField changes.
Definition: PlanarReflector.h:97
SFGeometryNode()
Constructor.
Definition: PlanarReflector.h:83
virtual void onRemove(Node *n)
This function will be called when the value of RefCountField changes.
Definition: PlanarReflector.h:112
~SFGeometryNode()
Destructor.
Definition: PlanarReflector.h:87
The PlanarReflector defines a geometry which will act as a mirror in the scene.
Definition: PlanarReflector.h:62
H3DUniquePtr< SFColor > color
The color of the mirror.
Definition: PlanarReflector.h:219
H3DUniquePtr< SFFloat > reflectivity
The reflectivity of the mirror.
Definition: PlanarReflector.h:211
H3DUniquePtr< SFGeometryNode > geometry
Contains the X3DGeometryNode to be rendered.
Definition: PlanarReflector.h:201
virtual void initialize()
Sets up the bound field using the bboxCenter and bboxSize fields.
Definition: PlanarReflector.h:138
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: PlanarReflector.h:226
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
This X3D abstract interface type is basis for all X3D node types that have bounds specified as part o...
Definition: X3DBoundedObject.h:46
This abstract node type indicates that the concrete nodes which are instantiated based on it may be u...
Definition: X3DChildNode.h:42
This is the base node type for all geometry in X3D.
Definition: X3DGeometryNode.h:61
The X3DViewpointNode node defines a specific location in the local coordinate system from which the u...
Definition: X3DViewpointNode.h:239
float H3DFloat
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