H3D API
2.4.1
|
The Collision node is a grouping node that specifies the collision detection properties for its children (and their descendants), specifies surrogate objects that replace its children during collision detection, and sends events signalling that a collision has occurred between the avatar and the Collision node's geometry or surrogate. More...
#include <H3D/Collision.h>
Public Member Functions | |
Collision (Inst< AddChildren > _addChildren=0, Inst< RemoveChildren > _removeChildren=0, Inst< SFBool > _enabled=0, Inst< MFChild > _children=0, Inst< SFNode > _metadata=0, Inst< SFTime > _collideTime=0, Inst< SFBool > _isActive=0, Inst< SFBound > _bound=0, Inst< SFVec3f > _bboxCenter=0, Inst< SFVec3f > _bboxSize=0, Inst< SFChild > _proxy=0) | |
Constructor. | |
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... | |
![]() | |
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. | |
![]() | |
X3DChildNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (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. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
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 Field * | getField (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... | |
![]() | |
H3DBoundedObject (Inst< SFBound > _bound=0) | |
Constructor. | |
![]() | |
H3DDisplayListObject (Inst< DisplayList > _displayList=0) | |
Constructor. | |
Public Attributes | |
H3DUniquePtr< SFTime > | collideTime |
The collideTime field generates an event specifying the time when the avatar (see NavigationInfo) makes contact with the collidable children or proxy of the Collision node. More... | |
H3DUniquePtr< SFChild > | proxy |
The collision proxy, defined in the proxy field, is any legal children node as described in 10.2.1 Grouping and children node types that is used as a substitute for the Collision node's children during collision detection. More... | |
H3DUniquePtr< SFBool > | enabled |
The enabled field enables and disables collision detection as well as terrain following (not implemented in H3DAPI) when the navigation type requires it. More... | |
H3DUniquePtr< SFBool > | isActive |
The value of the isActive field indicates the current state of the Collision node. More... | |
![]() | |
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< AddChildren > | addChildren |
The addChildren event appends nodes to the children field of a grouping node. More... | |
H3DUniquePtr< RemoveChildren > | removeChildren |
The removeChildren event removes nodes from the children field of the grouping node . More... | |
H3DUniquePtr< MFChild > | children |
The nodes that are grouped together by this node. More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< SFVec3f > | bboxCenter |
Specifies a the center of an axis-aligned bounding box enclosing the node. More... | |
H3DUniquePtr< SFVec3f > | bboxSize |
Specifies a the size of an axis-aligned bounding box enclosing the node. More... | |
![]() | |
H3DUniquePtr< SFBound > | bound |
The field containing the bound object. More... | |
![]() | |
H3DUniquePtr< DisplayList > | displayList |
The DisplayList instance handling the OpenGL caching of this object. | |
Additional Inherited Members | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
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. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
![]() | |
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. | |
The Collision node is a grouping node that specifies the collision detection properties for its children (and their descendants), specifies surrogate objects that replace its children during collision detection, and sends events signalling that a collision has occurred between the avatar and the Collision node's geometry or surrogate.
By default, all geometric nodes in the scene are collidable with the viewer except IndexedLineSet and PointSet. Browsers shall detect geometric collisions between the avatar (see NavigationInfo) and the scene's geometry and prevent the avatar from 'entering' the geometry. See 23.2.4 Collision detection and terrain following for general information on collision detection.
If there are no Collision nodes specified in a X3D file, browsers shall detect collisions between the avatar and all objects during navigation.
The Collision node's enabled field enables and disables collision detection as well as terrain following when the navigation type requires it. If enabled is set to FALSE, the children and all descendants of the Collision node shall not be checked for collision or terrain, even though they are drawn. This includes any descendent Collision nodes that have enabled set to TRUE (i.e., setting enabled to FALSE turns collision off for every child node below it).
The value of the isActive field indicates the current state of the Collision node. An isActive TRUE event is generated when a collision occurs. An isActive FALSE event is generated when a collision no longer occurs.
Collision nodes with the enabled field set to TRUE detect the nearest collision with their descendent geometry (or proxies). When the nearest collision is detected, the collided Collision node sends the time of the collision through its collideTime field. If a Collision node contains a child, descendant, or proxy (see below) that is a Collision node, and both Collision nodes detect that a collision has occurred, both send a collideTime event at the same time. A collideTime event shall be generated if the avatar is colliding with collidable geometry when the Collision node is read from a X3D file or inserted into the transformation hierarchy.
The bboxCenter and bboxSize fields specify a bounding box that encloses the Collision node's children. This is a hint that may be used for optimization purposes. The results are undefined if the specified bounding box is smaller than the actual bounding box of the children at any time. A default bboxSize value, (-1, -1, -1), implies that the bounding box is not specified and if needed shall be calculated by the browser. More details on the bboxCenter and bboxSize fields can be found in 10.2.2 Bounding boxes..
The collision proxy, defined in the proxy field, is any legal children node as described in 10.2.1 Grouping and children node types that is used as a substitute for the Collision node's children during collision detection. The proxy is used strictly for collision detection; it is not drawn.
If the value of the enabled field is TRUE and the proxy field is non-NULL, the proxy field defines the scene on which collision detection is performed. If the proxy value is NULL, collision detection is performed against the children of the Collision node. If proxy is specified, any descendent children of the Collision node are ignored during collision detection. If children is empty, enabled is TRUE, and proxy is specified, collision detection is performed against the proxy but nothing is displayed. In this manner, invisible collision objects may be supported.
The collideTime field generates an event specifying the time when the avatar (see 23.3.4 NavigationInfo) makes contact with the collidable children or proxy of the Collision node. An ideal implementation computes the exact time of collision. Implementations may approximate the ideal by sampling the positions of collidable objects and the user. The NavigationInfo node contains additional information for parameters that control the avatar size. Examples:
|
virtual |
Find closest point on Node to p.
Calls closestPoint for all children if the node is enabled.
p | The point to find the closest point to. |
result | A struct containing various results of closest points such as which geometries the closest points where detected on. |
Reimplemented from H3D::X3DGroupingNode.
References H3D::Node::closestPoint(), H3D::X3DGroupingNode::closestPoint(), enabled, H3D::Node::NodeIntersectResult::override_no_collision, and proxy.
|
virtual |
Detect intersection between a line segment and a Node.
Calls lineIntersect for all children if the Node is enabled.
from | The start of the line segment. |
to | The end of the line segment. |
result | Contains info about the closest intersection for every object that intersects the line. |
Reimplemented from H3D::X3DGroupingNode.
References enabled, H3D::Node::lineIntersect(), H3D::X3DGroupingNode::lineIntersect(), H3D::Node::NodeIntersectResult::override_no_collision, and proxy.
|
virtual |
Detect collision between a moving sphere and the Node.
Calls movingSphereIntersect for all children if the node is enabled.
radius | The radius of the sphere |
from | The start position of the sphere |
to | The end position of the sphere. |
result | A struct containing various results of intersections such as which geometries intersected the moving sphere. |
Reimplemented from H3D::X3DGroupingNode.
References collideTime, enabled, H3D::X3D::Convert::getValue(), isActive, H3D::Node::movingSphereIntersect(), H3D::X3DGroupingNode::movingSphereIntersect(), H3D::Node::NodeIntersectResult::override_no_collision, proxy, and H3D::Scene::time.
H3DUniquePtr< SFTime > H3D::Collision::collideTime |
The collideTime field generates an event specifying the time when the avatar (see NavigationInfo) makes contact with the collidable children or proxy of the Collision node.
Access type: outputOnly
Referenced by movingSphereIntersect().
H3DUniquePtr< SFBool > H3D::Collision::enabled |
The enabled field enables and disables collision detection as well as terrain following (not implemented in H3DAPI) when the navigation type requires it.
If enabled is set to FALSE, the children and all descendants of the Collision node shall not be checked for collision or terrain, even though they are drawn. This includes any descendent Collision nodes that have enabled set to TRUE (i.e., setting enabled to FALSE turns collision off for every child node below it).
Access type: inpuOutput
Default value: true
Referenced by closestPoint(), Collision(), lineIntersect(), and movingSphereIntersect().
H3DUniquePtr< SFBool > H3D::Collision::isActive |
The value of the isActive field indicates the current state of the Collision node.
An isActive TRUE event is generated when a collision occurs. An isActive FALSE event is generated when a collision no longer occurs.
Access type: inpuOutput
Default value: false
Referenced by Collision(), and movingSphereIntersect().
H3DUniquePtr< SFChild > H3D::Collision::proxy |
The collision proxy, defined in the proxy field, is any legal children node as described in 10.2.1 Grouping and children node types that is used as a substitute for the Collision node's children during collision detection.
The proxy is used strictly for collision detection; it is not drawn.
Access type: inpuOutput
Default value: NULL
Referenced by closestPoint(), lineIntersect(), and movingSphereIntersect().