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

The IndexedFaceSet node represents a 3D shape formed by constructing faces (polygons) from vertices listed in the coord field. More...

#include <H3D/IndexedFaceSet.h>

Inheritance diagram for H3D::IndexedFaceSet:
Inheritance graph

Classes

class  AutoNormal
 Specialized field for automatically generating normals from coordinates. More...
 
class  AutoTangent
 Specialized field for automatically generating two FloatVertexAttribute nodes representing the tangent and binormal of each vertex(or face if normalPerVertex is false). More...
 

Public Types

typedef CoordBoundField SFBound
 The bound field for IndexedFaceSet is a CoordBoundField.
 
- Public Types inherited from H3D::X3DComposedGeometryNode
typedef DependentSFNode< X3DColorNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DColorNode::propertyChanged > > SFColorNode
 The SFColorNode is dependent on the propertyChanged field of the contained X3DColorNode.
 
typedef DependentSFNode< X3DCoordinateNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DCoordinateNode::propertyChanged > > SFCoordinateNode
 The SFCoordinateNode is dependent on the propertyChanged field of the contained X3DCoordinateNode.
 
typedef DependentSFNode< X3DNormalNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DNormalNode::propertyChanged > > SFNormalNode
 The SFNormalNode is dependent on the propertyChanged field of the contained X3DNormalNode.
 
typedef DependentSFNode< X3DTextureCoordinateNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DTextureCoordinateNode::propertyChanged > > SFTextureCoordinateNode
 The SFTextureCoordinteNode is dependent on the propertyChanged field of the contained X3DTextureCoordinateNode.
 
typedef DependentSFNode< FogCoordinate, FieldRef< X3DGeometricPropertyNode, Field, &FogCoordinate::propertyChanged > > SFFogCoordinate
 The SFFogCoordinate is dependent on the propertyChanged. More...
 
- 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.
 

Public Member Functions

 IndexedFaceSet (Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< DisplayList > _displayList=0, Inst< SFColorNode > _color=0, Inst< SFCoordinateNode > _coord=0, Inst< SFNormalNode > _normal=0, Inst< SFTextureCoordinateNode > _texCoord=0, Inst< SFBool > _ccw=0, Inst< SFBool > _colorPerVertex=0, Inst< SFBool > _normalPerVertex=0, Inst< SFBool > _solid=0, Inst< MFVertexAttributeNode > _attrib=0, Inst< AutoNormal > _autoNormal=0, Inst< SFBool > _convex=0, Inst< SFFloat > _creaseAngle=0, Inst< MFInt32 > _set_colorIndex=0, Inst< MFInt32 > _set_coordIndex=0, Inst< MFInt32 > _set_normalIndex=0, Inst< MFInt32 > _set_texCoordIndex=0, Inst< MFInt32 > _colorIndex=0, Inst< MFInt32 > _coordIndex=0, Inst< MFInt32 > _normalIndex=0, Inst< MFInt32 > _texCoordIndex=0, Inst< SFFogCoordinate > _fogCoord=0)
 Constructor.

 
virtual void render ()
 Renders the IndexedFaceSet using GL_POLYGONs.
 
virtual int nrTriangles ()
 An upper bound on the number of triangles.
 
virtual void traverseSG (TraverseInfo &ti)
 Traverse the scenegraph. More...
 
virtual bool supportsTangentAttributes ()
 Returns true if this geometry supports the automatic generation of tangents and binormals as FloatVertexAttribues(needed by e.g. More...
 
- Public Member Functions inherited from H3D::X3DComposedGeometryNode
virtual void startTexGen (X3DTextureCoordinateNode *tex_coord)
 Start texture coordinate generation. More...
 
virtual void stopTexGen (X3DTextureCoordinateNode *tex_coord)
 Stop texture coordinate generation.
 
virtual void renderTexCoord (int index, X3DTextureCoordinateNode *tc)
 Render the texure coordinate with the given index from the tc argument. More...
 
virtual void renderTexCoordArray (X3DTextureCoordinateNode *tc)
 Render the X3DTextureCoordinate as an array. More...
 
virtual void disableTexCoordArray (X3DTextureCoordinateNode *tc)
 Disable the arrays that were enabled in renderTexCoordArray().
 
virtual void renderTexCoordVertexBufferObject (X3DTextureCoordinateNode *tc)
 Render the X3DTextureCoordinate as a vertex buffer object. More...
 
virtual void disableTexCoordVertexBufferObject (X3DTextureCoordinateNode *tc)
 Disable the vertex buffer objects that were enabled in renderTexCoordArray().
 
virtual Matrix4f getDefaultTexGenMatrix ()
 Gets the matrix that transforms from object space to texture coordinate space in the default case when no texCoord node is specified. More...
 
 X3DComposedGeometryNode (Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< DisplayList > _displayList=0, Inst< SFColorNode > _color=0, Inst< SFCoordinateNode > _coord=0, Inst< SFNormalNode > _normal=0, Inst< SFTextureCoordinateNode > _texCoord=0, Inst< SFBool > _ccw=0, Inst< SFBool > _colorPerVertex=0, Inst< SFBool > _normalPerVertex=0, Inst< SFBool > _solid=0, Inst< MFVertexAttributeNode > _attrib=0, Inst< SFFogCoordinate > _fogCoord=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DGeometryNode
 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 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 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 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< MFInt32set_colorIndex
 Field for setting the value of the colorIndex field. More...
 
H3DUniquePtr< MFInt32set_coordIndex
 Field for setting the value of the coordIndex field. More...
 
H3DUniquePtr< MFInt32set_normalIndex
 Field for setting the value of the normalIndex field. More...
 
H3DUniquePtr< MFInt32set_texCoordIndex
 Field for setting the value of the texCoordIndex field. More...
 
H3DUniquePtr< MFInt32colorIndex
 Indices into the color field. More...
 
H3DUniquePtr< SFBoolconvex
 The convex field indicates whether all polygons in the shape are convex. More...
 
H3DUniquePtr< MFInt32coordIndex
 Indices into the coord field. More...
 
H3DUniquePtr< SFFloatcreaseAngle
 The creaseAngle field affects how default normals are generated. More...
 
H3DUniquePtr< MFInt32normalIndex
 Indices into the normal field. More...
 
H3DUniquePtr< MFInt32texCoordIndex
 Indices into the texCoord field. More...
 
H3DUniquePtr< AutoNormalautoNormal
 Auto-generated normals that are used if the normal field is NULL. More...
 
H3DUniquePtr< AutoTangentautoTangent
 Auto-generated vertex attributes for tangents and binormals. More...
 
- Public Attributes inherited from H3D::X3DComposedGeometryNode
H3DUniquePtr< SFColorNodecolor
 Contains an X3DColorNode whose colors are applied to the X3DComposedGeometryNode. More...
 
H3DUniquePtr< SFCoordinateNodecoord
 An X3DCoordinate node with the coordinates to use. More...
 
H3DUniquePtr< SFNormalNodenormal
 Contains an X3DNormalNode which normals are applied to the X3DComposedGeometryNode. More...
 
H3DUniquePtr< SFTextureCoordinateNodetexCoord
 Contains an X3DTextureCoordinateNode which texture coordinates are applied to the X3DComposedGeometryNode. More...
 
H3DUniquePtr< SFBoolccw
 The ccw field defines the ordering of the vertex coordinates of the geometry with respect to user-given or automatically generated normal vectors used in the lighting model equations. More...
 
H3DUniquePtr< SFBoolcolorPerVertex
 If TRUE the colors in the color field is applied per vertex, otherwise it is applied per face. More...
 
H3DUniquePtr< SFBoolnormalPerVertex
 If TRUE the normals in the normal field is applied per vertex, otherwise it is applied per face. More...
 
H3DUniquePtr< SFBoolsolid
 The solid field determines whether one or both sides of each polygon shall be displayed. More...
 
H3DUniquePtr< MFVertexAttributeNodeattrib
 If the attrib field is not empty it shall contain a list of X3DVertexAttributeNode instances with per-vertex attribute information for programmable shaders. More...
 
H3DUniquePtr< SFFogCoordinatefogCoord
 If the fogCoord field is not empty, it shall contain a list of per-vertex depth values for calculating fog depth. More...
 
- Public Attributes inherited from H3D::X3DGeometryNode
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::X3DComposedGeometryNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DGeometryNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Protected Attributes

bool render_tangents
 This will be set to true in traverseSG if the render function is supposed to render tangent vertex attributes.
 
- Protected Attributes inherited from H3D::X3DGeometryNode
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

- 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...
 
- Static Protected Member Functions inherited from H3D::X3DGeometryNode
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...
 

Detailed Description

The IndexedFaceSet node represents a 3D shape formed by constructing faces (polygons) from vertices listed in the coord field.

The coord field contains a Coordinate node that defines the 3D vertices referenced by the coordIndex field. IndexedFaceSet uses the indices in its coordIndex field to specify the polygonal faces by indexing into the coordinates in the Coordinate node. An index of "-1" indicates that the current face has ended and the next one begins. The last face may be (but does not have to be) followed by a "-1" index. If the greatest index in the coordIndex field is N, the Coordinate node shall contain N+1 coordinates (indexed as 0 to N). Each face of the IndexedFaceSet shall have:

Otherwise, The results are undefined.

The IndexedFaceSet node is specified in the local coordinate system and is affected by the transformations of its ancestors. Descriptions of the coord, normal, and texCoord fields are provided in the Coordinate, Normal, and TextureCoordinate nodes, respectively. Details on lighting equations and the interaction between color field, normal field, textures, materials, and geometries are provided in 11 Rendering component and 12 Shape component.

If the color field is not NULL, it shall contain a Color node whose colours are applied to the vertices or faces of the IndexedFaceSet as follows:

If the color field is NULL, the geometry shall be rendered normally using the Material and texture defined in the Appearance node.

If the normal field is not NULL, it shall contain a Normal node whose normals are applied to the vertices or faces of the IndexedFaceSet in a manner exactly equivalent to that described above for applying colours to vertices/faces (where normalPerVertex corresponds to colorPerVertex and normalIndex corresponds to colorIndex). If the normal field is NULL, the browser shall automatically generate normals, using creaseAngle to determine if and how normals are smoothed across shared vertices (see Section 11.2.3 in the X3D specification).

If the texCoord field is not NULL, it shall contain a TextureCoordinate node. The texture coordinates in that node are applied to the vertices of the IndexedFaceSet as follows:

If the texCoord field is NULL, a default texture coordinate mapping is calculated using the local coordinate system bounding box of the shape. The longest dimension of the bounding box defines the S coordinates, and the next longest defines the T coordinates. If two or all three dimensions of the bounding box are equal, ties shall be broken by choosing the X, Y, or Z dimension in that order of preference. The value of the S coordinate ranges from 0 to 1, from one end of the bounding box to the other. The T coordinate ranges between 0 and the ratio of the second greatest dimension of the bounding box to the greatest dimension and the R coordinate ranges between 0 and the ratio of the smallest dimension of the bounding box to the greatest dimension.

Examples:

Internal routes:

Member Function Documentation

◆ supportsTangentAttributes()

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

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

PhongShader. IndexedTriangleSet does support this.

Reimplemented from H3D::X3DGeometryNode.

◆ traverseSG()

void IndexedFaceSet::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::X3DGeometryNode.

References H3D::H3DDisplayListObject::displayList, H3D::TraverseInfo::getUserData(), render_tangents, H3D::X3DComposedGeometryNode::solid, H3D::X3DGeometryNode::traverseSG(), and H3D::X3DGeometryNode::useBackFaceCulling().

Member Data Documentation

◆ autoNormal

H3DUniquePtr< AutoNormal > H3D::IndexedFaceSet::autoNormal

Auto-generated normals that are used if the normal field is NULL.

Only accessable in C++.

Referenced by H3D::IndexedFaceSet::AutoTangent::generateTangentsPerVertex(), IndexedFaceSet(), and render().

◆ autoTangent

H3DUniquePtr< AutoTangent > H3D::IndexedFaceSet::autoTangent

Auto-generated vertex attributes for tangents and binormals.

Only accessable in C++.

Referenced by IndexedFaceSet(), and render().

◆ colorIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::colorIndex

Indices into the color field.

See Detailed description for details on how it is used.

Access type: inputOutput
Value range: [0,inf) or -1

Referenced by IndexedFaceSet(), and render().

◆ convex

H3DUniquePtr< SFBool > H3D::IndexedFaceSet::convex

The convex field indicates whether all polygons in the shape are convex.

A polygon is convex if it is planar, does not intersect itself, and all of the interior angles at its vertices are less than 180 degrees. Non planar and self intersecting polygons may produce undefined results even if the convex field is FALSE.

Access type: inputOutput
Default value: TRUE

Referenced by IndexedFaceSet().

◆ coordIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::coordIndex

Indices into the coord field.

See Detailed description for details on how it is used.

Access type: inputOutput
Value range: [0,inf) or -1

Referenced by IndexedFaceSet(), and render().

◆ creaseAngle

H3DUniquePtr< SFFloat > H3D::IndexedFaceSet::creaseAngle

The creaseAngle field affects how default normals are generated.

If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced.

Access type: inputOutput
Default value: 0
Valid range: [0-inf]

Referenced by IndexedFaceSet(), and render().

◆ normalIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::normalIndex

Indices into the normal field.

See Detailed description for details on how it is used.

Access type: inputOutput
Value range: [0,inf) or -1

Referenced by IndexedFaceSet(), and render().

◆ set_colorIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::set_colorIndex

Field for setting the value of the colorIndex field.

Access type: inputOnly

Referenced by IndexedFaceSet().

◆ set_coordIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::set_coordIndex

Field for setting the value of the coordIndex field.

Access type: inputOnly

Referenced by IndexedFaceSet().

◆ set_normalIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::set_normalIndex

Field for setting the value of the normalIndex field.

Access type: inputOnly

Referenced by IndexedFaceSet().

◆ set_texCoordIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::set_texCoordIndex

Field for setting the value of the texCoordIndex field.

Access type: inputOnly

Referenced by IndexedFaceSet().

◆ texCoordIndex

H3DUniquePtr< MFInt32 > H3D::IndexedFaceSet::texCoordIndex

Indices into the texCoord field.

See Detailed description for details on how it is used.

Access type: inputOutput
Value range: [0,inf) or -1

Referenced by IndexedFaceSet(), and render().


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