H3D API  2.4.1
Inline.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 __INLINE_H__
30 #define __INLINE_H__
31 
32 #include <H3D/X3DChildNode.h>
33 #include <H3D/X3DUrlObject.h>
34 #include <H3D/X3DBoundedObject.h>
36 #include <H3D/Group.h>
37 #include <H3D/DEFNodes.h>
38 
39 namespace H3D {
40 
116  class H3DAPI_API Inline :
117  public X3DChildNode,
118  public X3DBoundedObject,
119  public X3DUrlObject,
120  public H3DDisplayListObject {
121  public:
122 
129  class H3DAPI_API LoadedScene:
130  public TypedField< DependentMFNode< Group,
131  FieldRef< H3DDisplayListObject,
132  H3DDisplayListObject::DisplayList,
133  &H3DDisplayListObject::displayList >,
134  true >,
135  Types< SFBool, MFString > > {
136  public:
141  clear( ownerId() );
142  }
143 
144  protected:
145  typedef TypedField< DependentMFNode< Group,
149  true >,
150  Types< SFBool, MFString > > LoadedSceneBase;
152  virtual void update();
153 
155  virtual void onAdd( Node *n );
156 
158  virtual void onRemove( Node *n );
159 
160  };
161 
171  class H3DAPI_API SFBound:
172  public TypedField< X3DBoundedObject::SFBound,
173  void,
174  AnyNumber< X3DBoundedObject::SFBound > > {
177  virtual void update();
178  };
179 
181  Inline( Inst< SFNode > _metadata = 0,
182  Inst< DisplayList > _displayList = 0,
183  Inst< MFString > _url = 0,
184  Inst< SFBound > _bound = 0,
185  Inst< SFVec3f > _bboxCenter = 0,
186  Inst< SFVec3f > _bboxSize = 0,
187  Inst< SFBool > _load = 0,
188  Inst< LoadedScene > _loadedScene = 0,
189  Inst< SFString > _importMode = 0,
190  Inst< SFBool > _traverseOn = 0 );
191 
192  virtual ~Inline() {
193  exported_nodes.clear();
194  DEF_nodes.clear();
195  }
196 
202  virtual void initialize() {
203  const Vec3f &size = bboxSize->getValue();
204  if( size.x == -1 && size.y == -1 && size.z == -1 ) {
205  NodeVector children_nodes = loadedScene->getValue();
206  use_union_bound = true;
207  // set the values againg in order to run onNodeAdd again
208  // with use_union_bound set to true to set the routes.
209  loadedScene->setValue( children_nodes, id );
210  } else {
211  use_union_bound = false;
212  BoxBound *bb = new BoxBound();
213  bb->center->setValue( bboxCenter->getValue() );
214  bb->size->setValue( bboxSize->getValue() );
215  bound->setValue( bb );
216  }
218  }
219 
221  virtual void render();
222 
224  virtual void traverseSG( TraverseInfo &ti );
225 
232  virtual bool lineIntersect( const Vec3f &from,
233  const Vec3f &to,
234  LineIntersectResult &result );
235 
241  virtual void closestPoint( const Vec3f &p,
242  NodeIntersectResult &result );
243 
252  virtual bool movingSphereIntersect( H3DFloat radius,
253  const Vec3f &from,
254  const Vec3f &to,
255  NodeIntersectResult &result );
256 
264  H3DUniquePtr< SFBool > load;
265 
270  H3DUniquePtr< LoadedScene > loadedScene;
271 
286  H3DUniquePtr< SFString > importMode;
287 
295  H3DUniquePtr< SFBool > traverseOn;
296 
297  // if true a route will be set up between the bound field of the
298  // loadedScene field and the bound field of the inline node.
299  bool use_union_bound;
300 
303 
307 
311  };
312 }
313 
314 #endif
Contains the DEFNodes class.
Header file for Group, X3D scene-graph node.
Header file for H3DDisplayListObject.
Header file for X3DBoundedObject.
Header file for X3DChildNode, X3D scene-graph node.
Header file for X3DUrlObject, 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
DependentMFNode are modified TypedMFNode fields where the field dirty status is dependent on fields i...
Definition: DependentNodeFields.h:336
Class used for specifying a field member of a node in a DependentSFNode or DependentMFNode specificat...
Definition: DependentNodeFields.h:48
A Group node contains children nodes without introducing a new transformation.
Definition: Group.h:53
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
The LoadedScene class updates itself from the load and url field and sets itself to the first url tha...
Definition: Inline.h:135
~LoadedScene()
Destructor.
Definition: Inline.h:140
SFBound is specialized to update from the SFBound fields routed to it.
Definition: Inline.h:174
The Inline node embeds an X3D scene stored at a location on the World Wide Web into the current scene...
Definition: Inline.h:120
H3DUniquePtr< SFString > importMode
The autoImport mode defines the way that the Inline node exports its nodes and how they are imported ...
Definition: Inline.h:286
H3DUniquePtr< LoadedScene > loadedScene
The scene that is currently loaded by the inline node.
Definition: Inline.h:270
H3DUniquePtr< SFBool > traverseOn
If set to false the children nodes of the Inline node will not be traversed at all,...
Definition: Inline.h:295
H3DUniquePtr< SFBool > load
If the load field is set to TRUE (the default field value), the X3D file specified by the url field i...
Definition: Inline.h:264
X3D::DEFNodes exported_nodes
A DEFNodes structure from the name of nodes exported with the EXPORT statement in the url of the Inli...
Definition: Inline.h:306
X3D::DEFNodes DEF_nodes
A DEFNodes structure from the name of nodes named with the DEF statement in the url of the Inline nod...
Definition: Inline.h:310
virtual void initialize()
Sets up the bound field using the bboxCenter and bboxSize fields.
Definition: Inline.h:202
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: Inline.h:302
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
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 abstract interface is inherited by all nodes that contain data located on the World Wide Web,...
Definition: X3DUrlObject.h:51
Provides a mapping between defined DEF names in X3D and the nodes they refer to.
Definition: DEFNodes.h:92
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
The Types template can be used in the RequiredArgTypes or OptionalArgTypes arguments of a TypedField ...
Definition: TypedFieldTypesTmpl.h:60