H3D API  2.4.1
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
H3D::Anchor Class Reference

The Anchor grouping node retrieves the content of a URL when the user activates (e.g., clicks) some geometry contained within the Anchor node's children. More...

#include <H3D/Anchor.h>

Inheritance diagram for H3D::Anchor:
Inheritance graph

Classes

class  GeometrySelected
 Takes care of changing the scene when an object in the Anchor is selected (by clicking on it with the mouse). More...
 

Public Member Functions

 Anchor (Inst< AddChildren > _addChildren=0, Inst< RemoveChildren > _removeChildren=0, Inst< MFChild > _children=0, Inst< SFString > _description=0, Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< MFString > _parameter=0, Inst< MFString > _url=0, Inst< SFVec3f > _bboxCenter=0, Inst< SFVec3f > _bboxSize=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DGroupingNode
 X3DGroupingNode (Inst< AddChildren > _addChildren=0, Inst< RemoveChildren > _removeChildren=0, Inst< MFChild > _children=0, Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< SFVec3f > _bboxCenter=0, Inst< SFVec3f > _bboxSize=0)
 Constructor.
 
virtual ~X3DGroupingNode ()
 Destructor.
 
virtual void initialize ()
 Sets up the bound field using the bboxCenter and bboxSize fields. More...
 
virtual void render ()
 Render the children.
 
virtual void traverseSG (TraverseInfo &ti)
 Traverse the scenegraph. traverseSG() is called in all children nodes.
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and a Node. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on Node to p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the Node. More...
 
- Public Member Functions inherited from H3D::X3DChildNode
 X3DChildNode (Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DNode
 X3DNode (Inst< SFNode > _metadata=0)
 Constructor.
 
X3DMetadataObjectgetMetadataByName (const string &_name)
 Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More...
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL)
 Returns a new instance of this node type with the same state as this one. More...
 
virtual ~Node ()
 Destructor.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More...
 
void setProtoInstanceParent (X3DPrototypeInstance *p)
 Set the X3DPrototypeInstance this node is the the root node if applicaple.
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual FieldgetField (const string &_name) const
 return a pointer to the field specified by name within this instance
 
int addDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
int removeDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
- Public Member Functions inherited from H3D::H3DBoundedObject
 H3DBoundedObject (Inst< SFBound > _bound=0)
 Constructor.
 
- Public Member Functions inherited from H3D::H3DDisplayListObject
 H3DDisplayListObject (Inst< DisplayList > _displayList=0)
 Constructor.
 

Static Public Member Functions

static void replaceScene (AutoRef< Node > new_world, const X3DViewpointNode *new_vp, const Anchor *the_anchor)
 Replaces the world in the scene with a new one. More...
 
static void replaceSceneRoot (Scene *the_scene)
 Replaces the world in the scene with a new one. More...
 
static bool isAnchorInScene (const X3DGroupingNode *group_node, const Anchor *anchor_to_find)
 Checks which Scenes the given anchor is part of. More...
 
- Static Public Member Functions inherited from H3D::Node
static unsigned int nrNodesAlive ()
 Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
 
static int nrNodesCreated ()
 Returns the number of nodes created in total since the start of the program.
 

Public Attributes

H3DUniquePtr< SFStringdescription
 The description field in the Anchor node specifies a textual description of the Anchor node. More...
 
H3DUniquePtr< MFStringparameter
 The parameter field may be used to supply any additional information to be interpreted by the browser. More...
 
H3DUniquePtr< MFStringurl
 Contains path to file (or name of Viewpoint) used when clicking on a geometry in the children field. More...
 
- Public Attributes inherited from H3D::X3DGroupingNode
bool use_union_bound
 if true a route will be set up between the bound field of the nodes in children and the bound field of the grouping node. More...
 
H3DUniquePtr< AddChildrenaddChildren
 The addChildren event appends nodes to the children field of a grouping node. More...
 
H3DUniquePtr< RemoveChildrenremoveChildren
 The removeChildren event removes nodes from the children field of the grouping node . More...
 
H3DUniquePtr< MFChildchildren
 The nodes that are grouped together by this node. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about the node. More...
 
- Public Attributes inherited from H3D::X3DBoundedObject
H3DUniquePtr< SFVec3fbboxCenter
 Specifies a the center of an axis-aligned bounding box enclosing the node. More...
 
H3DUniquePtr< SFVec3fbboxSize
 Specifies a the size of an axis-aligned bounding box enclosing the node. More...
 
- Public Attributes inherited from H3D::H3DBoundedObject
H3DUniquePtr< SFBoundbound
 The field containing the bound object. More...
 
- Public Attributes inherited from H3D::H3DDisplayListObject
H3DUniquePtr< DisplayListdisplayList
 The DisplayList instance handling the OpenGL caching of this object.
 

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DGroupingNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Additional Inherited Members

- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 
- Protected Attributes inherited from H3D::X3DGroupingNode
bool children_multi_pass_transparency
 Will be set in traverseSG to indicate if any of the children enables multi-pass transparency. More...
 
vector< H3DRenderStateObject * > render_states
 A vector of all the H3DRenderStatesObject within this X3DGroupingNode.
 
vector< ClipPlane * > clip_planes
 A vector of only ClipPlane children of this X3DGroupingNode.
 

Detailed Description

The Anchor grouping node retrieves the content of a URL when the user activates (e.g., clicks) some geometry contained within the Anchor node's children.

If the URL points to a valid X3D file, that world replaces the world of which the Anchor node is a part (except when the parameter field, described below, alters this behaviour). If non-X3D data is retrieved, the browser shall determine how to handle that data; typically, it will be passed to an appropriate non-X3D browser.

Exactly how a user activates geometry contained by the Anchor node depends on the pointing device and is determined by the X3D browser. Typically, clicking with the pointing device will result in the new scene replacing the current scene. An Anchor node with an empty url does nothing when its children are chosen. For a description of how multiple Anchors and pointing-device sensors are resolved on activation see the Pointing Device Sensor Component in the X3D specification.

The description field in the Anchor node specifies a textual description of the Anchor node. This may be used by browser-specific user interfaces that wish to present users with more detailed information about the Anchor.

The parameter field may be used to supply any additional information to be interpreted by the browser. Each string shall consist of "keyword=value" pairs. For example, some browsers allow the specification of a "target" for a link to display a link in another part of an HTML document. The parameter field is then:

Anchor {
parameter [ "target=name_of_frame" ];
...
}
An Anchor node may be used to bind the initial Viewpoint node in a world by specifying a URL ending with "#ViewpointName" where "ViewpointName" is the DEF name of a viewpoint defined in the X3D file.

EXAMPLE
Anchor {
url "http://www.school.edu/X3D/someScene.wrl#OverView";
children Shape { geometry Box {} };
}
specifies an anchor that loads the X3D file "someScene.wrl" and binds the initial user view to the Viewpoint node named "OverView" when the Anchor node's geometry (Box) is activated. If the named Viewpoint node is not found in the X3D file, the X3D file is loaded using the default Viewpoint node binding stack rules.

If the url field is specified in the form "#ViewpointName" (i.e., no file name), the Viewpoint node with the given name ("ViewpointName") in the Anchor's run-time name scope(s) shall be bound (set_bind TRUE). The results are undefined if there are multiple Viewpoints with the same name in the Anchor's run-time name scope(s). The results are undefined if the Anchor node is not part of any run-time name scope or is part of more than one run-time name scope. ( RUN-TIME scope not implemented, if the name exist the first created X3DViewpoint with the correct name will be used )

For example:

Anchor {
url "#Doorway";
children Shape { geometry Sphere {} };
}
binds the viewer to the viewpoint defined by the "Doorway" viewpoint in the current world when the sphere is activated. In this case, if the Viewpoint is not found, no action occurs on activation. NOTE: This node is not fully tested and may crash now and then when used.

Examples:

Member Function Documentation

◆ isAnchorInScene()

bool Anchor::isAnchorInScene ( const X3DGroupingNode group_node,
const Anchor anchor_to_find 
)
static

Checks which Scenes the given anchor is part of.

Parameters
group_nodeThe X3DGroupingNode to traverse in order to find the anchor.
anchor_to_findThe anchor that is tested for inclusion in the scene defined by the group_node.
Returns
true if the anchor is found in the group_node, false otherwise.

References H3D::X3DGroupingNode::children, and H3DUtil::AutoRefVector< class >::size().

Referenced by replaceScene(), and replaceSceneRoot().

◆ replaceScene()

void Anchor::replaceScene ( AutoRef< Node new_world,
const X3DViewpointNode new_vp,
const Anchor the_anchor 
)
static

Replaces the world in the scene with a new one.

Parameters
new_worldThe top node of the new world.
new_vpThe viewpoint to use after changing the world.
the_anchorThe Anchor node causing the call to this function.

References H3D::X3DGroupingNode::children, H3D::H3DNavigation::enableDevice(), H3DUtil::AutoRef< class >::get(), H3D::X3DViewpointNode::getAllViewpoints(), isAnchorInScene(), H3D::Scene::scenes, and H3D::X3DBindableNode::set_bind.

◆ replaceSceneRoot()

void Anchor::replaceSceneRoot ( Scene the_scene)
static

Replaces the world in the scene with a new one.

Uses the static protected parameters new_scene_root, old_anchor, new_world_vp set internally by the Anchor. Used in order to replace the sceneRoot from Scene::idle instead of the routing network since calling it from the routing network might cause corruption in heap.

References H3D::X3DGroupingNode::children, H3D::X3D::createX3DFromURL(), H3D::H3DNavigation::enableDevice(), H3DUtil::ResourceResolver::getBaseURL(), H3D::X3D::DEFNodes::getNode(), isAnchorInScene(), H3D::Scene::sceneRoot, and H3DUtil::ResourceResolver::setBaseURL().

Referenced by H3D::Scene::idle().

Member Data Documentation

◆ description

H3DUniquePtr< SFString > H3D::Anchor::description

The description field in the Anchor node specifies a textual description of the Anchor node.

Access type: inputOutput

◆ parameter

H3DUniquePtr< MFString > H3D::Anchor::parameter

The parameter field may be used to supply any additional information to be interpreted by the browser.

Each string shall consist of "keyword=value" pairs.

Access type: inputOutput

◆ url

H3DUniquePtr< MFString > H3D::Anchor::url

Contains path to file (or name of Viewpoint) used when clicking on a geometry in the children field.

Access type: inputOutput

Referenced by H3D::Anchor::GeometrySelected::update().


The documentation for this class was generated from the following files: