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

This is the base node type for all geometry in X3D. More...

#include <H3D/X3DGeometryNode.h>

Inheritance diagram for H3D::X3DGeometryNode:
Inheritance graph

Classes

class  BugWorkaroundDisplayList
 This is just a dummy class to get around a bug in Visual C++ 7.1 If the X3DGeometry::DisplayList inherits directly from H3DDisplayListObject::Display list the application will crash if trying to call H3DDisplayListObject::DisplayList::callList By using an intermediate class the bug dissappears. More...
 
class  DisplayList
 Display list is extended in order to set front sidedness of triangles outside the display list. More...
 
class  SFBoundTree
 The SFBoundTree constructs a BinaryBoundTree that can be used for collision detection as well as fast collection of haptic primitives (triangles, points, lines). More...
 

Public Member Functions

 X3DGeometryNode (Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< DisplayList > _displayList=0, Inst< MFBool > _isTouched=0, Inst< MFVec3f > _force=0, Inst< MFVec3f > _contactPoint=0, Inst< MFVec3f > _contactNormal=0, Inst< MFVec3f > _contactTexCoord=0, Inst< SFBoundTree > _boundTree=0, Inst< SFVec3f > _centerOfMass=0)
 Constructor.
 
virtual void traverseSG (TraverseInfo &ti)
 Traverse the scenegraph. More...
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and this geometry. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on this geometry to point p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the geometry. More...
 
virtual void glRender ()
 Function overridden from HAPIGLShape. More...
 
virtual H3DShadowObjectNodegetShadowObject ()
 Get the H3DShadowObjectNode used to create a shadow volume for this geometry. More...
 
void useCulling (bool enabled)
 This function should be used by the render() function to disable or enable face culling. More...
 
bool usingCulling ()
 Returns if face culling is in use or not.
 
void allowCulling (bool allow)
 Control if face culling is allowed or not. More...
 
void useBackFaceCulling (bool enabled)
 Enabling/disabling back face culling. More...
 
bool allowingCulling ()
 Returns true if back face culling is allowed, false otherwise.
 
void setCullFace (GLenum face)
 Set which side of a polygon to cull. More...
 
GLenum getCullFace ()
 Get which face will be culled if culling is enabled.
 
template<class OptionNodeType >
void getOptionNode (OptionNodeType *&option)
 Get the first option node of the type of the pointer given as argument from the renderOptions fieeld The option argument will contain the node afterwards, or NULL if no option of that type exists.
 
int getHapticShapeId (unsigned int index)
 Get a shape id to be used for rendering of this geometry with HLAPI for the given haptics device. More...
 
virtual ~X3DGeometryNode ()
 Destructor.
 
HAPI::HAPIHapticShape * getOpenGLHapticShape (unsigned int hd_index, H3DSurfaceNode *_surface, const Matrix4f &_transform, int _nr_vertices=-1)
 Returns a either a HLFeedbackShape or a HLDepthBufferShape with the X3DGeometryNode. More...
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual bool supportsTangentAttributes ()
 Returns true if this geometry supports the automatic generation of tangents and binormals as FloatVertexAttribues(needed by e.g. More...
 
virtual void getBound (HAPI::Vec3 &center, HAPI::Vec3 &size)
 Overriden from HAPIGLShape to use the bound field in he X3DGeometryNode. More...
 
virtual void initialize ()
 Changes behaviour of X3DGeometryNode to be a thread safe RefCountedClass.
 
- 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 void render ()
 the render() function is used for the depth-first rendering traversal of the scene-graph. 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.
 

Public Attributes

H3DUniquePtr< MFBoolisTouched
 Tells if a HapticsDevice has been in contact with the geometry in the last scenegraph loop. More...
 
H3DUniquePtr< MFVec3fforce
 The last force delivered by this geometry to the haptics device. More...
 
H3DUniquePtr< MFVec3fcontactPoint
 The last contact points of the HapticDevices on the geometry. More...
 
H3DUniquePtr< MFVec3fcontactTexCoord
 The texture coordinate of last the contact points of the HapticDevices on the geometry. More...
 
H3DUniquePtr< MFVec3fcontactNormal
 The normal at the last contact points of the HapticDevices on the geometry. More...
 
H3DUniquePtr< SFVec3fcenterOfMass
 The field contains center of mass for the object, based on its bounding box. More...
 
H3DUniquePtr< SFBoundTreeboundTree
 Contains a tree of the HAPI::GeometryPrimitives that build up the X3DGeometryNode. More...
 
H3DUniquePtr< MFOptionsNodeoptions
 Contains nodes with options for haptics and graphics rendering. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about 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::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Static Protected Member Functions

static void cleanUpFunction (void *userdata)
 Function sent to HAPIHapticsShape created to allow for deletion of X3DGeometryNode at the correct time. 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

AutoRef< Nodeshadow_volume
 The shadow volume used for this geometry when shadows enabled. More...
 
vector< pair< int, pair< Matrix4f, H3DTime > > > haptic_shape_ids
 identifiers for the shapes geometry.
 

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.
 
- 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.
 
- 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...
 

Detailed Description

This is the base node type for all geometry in X3D.


Member Function Documentation

◆ allowCulling()

void H3D::X3DGeometryNode::allowCulling ( bool  allow)
inline

Control if face culling is allowed or not.

Used when rendering HLFeedbackBuffer or HLDepthBuffer shapes in order not to have back face culling on when rendering shapes with OpenHaptics.

◆ cleanUpFunction()

static void H3D::X3DGeometryNode::cleanUpFunction ( void *  userdata)
inlinestaticprotected

Function sent to HAPIHapticsShape created to allow for deletion of X3DGeometryNode at the correct time.

The X3DGeometryNode is not automatically reference counted when sent to HAPIHapticShape.

Referenced by H3D::Sphere::traverseSG().

◆ closestPoint()

virtual void H3D::X3DGeometryNode::closestPoint ( const Vec3f &  p,
NodeIntersectResult result 
)
virtual

Find closest point on this geometry to point p.

Parameters
pThe point to find the closest point to.
resultA struct containing various results of closest points such as which geometries the closest points where detected on.

Reimplemented from H3D::Node.

Reimplemented in H3D::Sphere, H3D::HumanHand, and H3D::GeometryGroup.

Referenced by H3D::PlanarReflector::closestPoint(), H3D::X3DShapeNode::closestPoint(), and H3D::MagneticGeometryEffect::traverseSG().

◆ defaultXMLContainerField()

virtual string H3D::X3DGeometryNode::defaultXMLContainerField ( )
inlinevirtual

Returns the default xml containerField attribute value.

For this node it is "geometry".

Reimplemented from H3D::Node.

◆ getBound()

virtual void H3D::X3DGeometryNode::getBound ( HAPI::Vec3 &  center,
HAPI::Vec3 &  size 
)
inlinevirtual

Overriden from HAPIGLShape to use the bound field in he X3DGeometryNode.

An axis aligned bounding box containing all the primitives rendered by the glRender function. If no such bounding box is available, size should be set to Vec3( -1, -1, -1 )

References H3D::BoxBound::center, and H3D::BoxBound::size.

◆ getHapticShapeId()

int H3D::X3DGeometryNode::getHapticShapeId ( unsigned int  index)

Get a shape id to be used for rendering of this geometry with HLAPI for the given haptics device.

In the future it will have more uses. Since the geometry can appear in several places in the scene graph it can contain several shape ids (one for each place). Which one to get is determined by the index argument.

Referenced by H3D::TraverseInfo::addHapticShape(), and H3D::TraverseInfo::addHapticShapeToAll().

◆ getOpenGLHapticShape()

HAPI::HAPIHapticShape* H3D::X3DGeometryNode::getOpenGLHapticShape ( unsigned int  hd_index,
H3DSurfaceNode _surface,
const Matrix4f &  _transform,
int  _nr_vertices = -1 
)

Returns a either a HLFeedbackShape or a HLDepthBufferShape with the X3DGeometryNode.

Which type depents on possible OpenHapticsOptions nodes in the options field and the default settings in OpenHapticsSettings bindable node.

◆ getShadowObject()

virtual H3DShadowObjectNode* H3D::X3DGeometryNode::getShadowObject ( )
virtual

Get the H3DShadowObjectNode used to create a shadow volume for this geometry.


Reimplemented in H3D::Sphere.

Referenced by H3D::X3DShapeNode::traverseSG().

◆ glRender()

virtual void H3D::X3DGeometryNode::glRender ( )
inlinevirtual

Function overridden from HAPIGLShape.

Just call the displayList->callList per default

Reimplemented in H3D::IndexedTriangleSet, and H3D::GeometryGroup.

◆ lineIntersect()

virtual bool H3D::X3DGeometryNode::lineIntersect ( const Vec3f &  from,
const Vec3f &  to,
LineIntersectResult result 
)
virtual

Detect intersection between a line segment and this geometry.

Parameters
fromThe start of the line segment.
toThe end of the line segment.
resultContains info about the closest intersection for every object that intersects the line.
Returns
true if intersected, false otherwise.

Reimplemented from H3D::Node.

Reimplemented in H3D::Text, H3D::Sphere, H3D::HumanHand, and H3D::GeometryGroup.

Referenced by H3D::PlanarReflector::lineIntersect(), and H3D::X3DShapeNode::lineIntersect().

◆ movingSphereIntersect()

virtual bool H3D::X3DGeometryNode::movingSphereIntersect ( H3DFloat  radius,
const Vec3f &  from,
const Vec3f &  to,
NodeIntersectResult result 
)
virtual

Detect collision between a moving sphere and the geometry.

Parameters
radiusThe radius of the sphere
fromThe start position of the sphere
toThe end position of the sphere.
resultA struct containing various results of intersections such as which geometries intersected the moving sphere.
Returns
true if intersected, false otherwise.

Reimplemented from H3D::Node.

Reimplemented in H3D::Sphere, H3D::PointSet, H3D::IndexedLineSet, H3D::HumanHand, and H3D::GeometryGroup.

Referenced by H3D::PlanarReflector::movingSphereIntersect(), and H3D::X3DShapeNode::movingSphereIntersect().

◆ setCullFace()

void H3D::X3DGeometryNode::setCullFace ( GLenum  face)
inline

Set which side of a polygon to cull.

Valid values are GL_FRONT or GL_BACK

Referenced by H3D::ParticleSystem::render(), and H3D::X3DShapeNode::render().

◆ supportsTangentAttributes()

virtual bool H3D::X3DGeometryNode::supportsTangentAttributes ( )
inlinevirtual

Returns true if this geometry supports the automatic generation of tangents and binormals as FloatVertexAttribues(needed by e.g.

PhongShader.

Reimplemented in H3D::IndexedTriangleSet, H3D::IndexedFaceSet, and H3D::GeometryGroup.

◆ traverseSG()

virtual void H3D::X3DGeometryNode::traverseSG ( TraverseInfo ti)
virtual

Traverse the scenegraph.

A HAPIHapticShape is added for haptic rendering if haptics is enabled.

Parameters
tiThe TraverseInfo object containing information about the traversal.

Reimplemented from H3D::Node.

Reimplemented in H3D::X3DNurbsSurfaceGeometryNode, H3D::TriangleStripSet, H3D::TriangleSet2D, H3D::TriangleSet, H3D::TriangleFanSet, H3D::Text, H3D::TexGenGeometry, H3D::SuperShape, H3D::Sphere, H3D::Rectangle2D, H3D::LineSet, H3D::IndexedTriangleStripSet, H3D::IndexedTriangleSet, H3D::IndexedTriangleFanSet, H3D::IndexedFaceSet, H3D::HumanHand, H3D::GeometryGroup, H3D::Extrusion, H3D::ElevationGrid, H3D::Disk2D, H3D::Cylinder, H3D::Cone, H3D::Capsule, H3D::Box, and H3D::ArcClose2D.

Referenced by H3D::ArcClose2D::traverseSG(), H3D::Box::traverseSG(), H3D::Capsule::traverseSG(), H3D::Cone::traverseSG(), H3D::Cylinder::traverseSG(), H3D::Disk2D::traverseSG(), H3D::ElevationGrid::traverseSG(), H3D::Extrusion::traverseSG(), H3D::HumanHand::traverseSG(), H3D::IndexedFaceSet::traverseSG(), H3D::IndexedTriangleFanSet::traverseSG(), H3D::IndexedTriangleSet::traverseSG(), H3D::IndexedTriangleStripSet::traverseSG(), H3D::LineSet::traverseSG(), H3D::Rectangle2D::traverseSG(), H3D::SuperShape::traverseSG(), H3D::TexGenGeometry::traverseSG(), H3D::Text::traverseSG(), H3D::TriangleFanSet::traverseSG(), H3D::TriangleSet::traverseSG(), H3D::TriangleSet2D::traverseSG(), H3D::TriangleStripSet::traverseSG(), H3D::X3DNurbsSurfaceGeometryNode::traverseSG(), and H3D::X3DShapeNode::traverseSG().

◆ useBackFaceCulling()

void H3D::X3DGeometryNode::useBackFaceCulling ( bool  enabled)
inline

◆ useCulling()

void H3D::X3DGeometryNode::useCulling ( bool  enabled)
inline

This function should be used by the render() function to disable or enable face culling.

DO NOT USE glEnable/glDisable to do this, since it will cause problems with OpenHaptics.

Referenced by H3D::ParticleSystem::render(), and H3D::X3DShapeNode::render().

Member Data Documentation

◆ boundTree

H3DUniquePtr< SFBoundTree > H3D::X3DGeometryNode::boundTree

◆ centerOfMass

H3DUniquePtr< SFVec3f > H3D::X3DGeometryNode::centerOfMass

The field contains center of mass for the object, based on its bounding box.

The point is given in local coordinates of the X3DGeometryNode.

Access type: inputOutput

◆ contactNormal

H3DUniquePtr< MFVec3f > H3D::X3DGeometryNode::contactNormal

The normal at the last contact points of the HapticDevices on the geometry.

The field contains a normal for each of the points in contactPoint. The value will be an empty vector before the first contact. The contact normal is given in local coordinates of the X3DGeometryNode.

Access type: outputOnly

Referenced by H3D::DeformableShape::traverseSG(), H3D::GeometryGroup::IsTouched::update(), and H3D::H3DHapticsDevice::updateDeviceValues().

◆ contactPoint

H3DUniquePtr< MFVec3f > H3D::X3DGeometryNode::contactPoint

The last contact points of the HapticDevices on the geometry.

The field contains a contact point for each HapticsDevice with the index as specified in the DeviceInfo node. The value will be an empty vector before the first contact. The contact point is given in local coordinates of the X3DGeometryNode.

Access type: outputOnly

Referenced by H3D::DeformableShape::traverseSG(), H3D::GeometryGroup::IsTouched::update(), and H3D::H3DHapticsDevice::updateDeviceValues().

◆ contactTexCoord

H3DUniquePtr< MFVec3f > H3D::X3DGeometryNode::contactTexCoord

The texture coordinate of last the contact points of the HapticDevices on the geometry.

The field contains a contact point for each HapticsDevice with the index as specified in the DeviceInfo node. The value will be an empty vector before the first contact. NOTE: Will not return correct texture coordinate when using OpenHapticsRenderer.

Access type: outputOnly

Referenced by H3D::GeometryGroup::IsTouched::update(), and H3D::H3DHapticsDevice::updateDeviceValues().

◆ force

H3DUniquePtr< MFVec3f > H3D::X3DGeometryNode::force

The last force delivered by this geometry to the haptics device.

The field contains a force vector for each HapticsDevice with the index as specified in the DeviceInfo node. The value will be an empty vector before the first contact.

Referenced by H3D::DeformableShape::traverseSG(), H3D::GeometryGroup::IsTouched::update(), and H3D::H3DHapticsDevice::updateDeviceValues().

◆ isTouched

H3DUniquePtr< MFBool > H3D::X3DGeometryNode::isTouched

Tells if a HapticsDevice has been in contact with the geometry in the last scenegraph loop.

The field contains a boolean for each HapticsDevice with the index as specified in the DeviceInfo node. You can get the contact point from the contactPoint field. The value will be an empty vector before the first contact.

Access type: outputOnly

Referenced by H3D::DeformableShape::traverseSG(), and H3D::H3DHapticsDevice::updateDeviceValues().

◆ options

H3DUniquePtr< MFOptionsNode > H3D::X3DGeometryNode::options

Contains nodes with options for haptics and graphics rendering.

Access type: inputOutput

◆ shadow_volume

AutoRef< Node > H3D::X3DGeometryNode::shadow_volume
protected

The shadow volume used for this geometry when shadows enabled.

Note
If you decide to use this variable in subclasses getShadowObject Make sure that you do take care of the circular reference somehow. See source code for how it is done in X3DGeometryNode.

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