H3D API  2.4.1
Public Member Functions | List of all members
H3D::IndexedFaceSet::AutoTangent Class Reference

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

#include <H3D/IndexedFaceSet.h>

Inheritance diagram for H3D::IndexedFaceSet::AutoTangent:
Inheritance graph

Public Member Functions

virtual void generateTangentsPerVertex (X3DCoordinateNode *_coord, X3DTextureCoordinateNode *tex_coord, const vector< int > &coord_index, const vector< int > &tex_coord_index, FloatVertexAttribute *tangent, FloatVertexAttribute *binormal)
 Set the vales in the tangent and binormal arguments to the tangent and binormal for each vertex. More...
 
virtual void generateTangentsPerVertex (X3DCoordinateNode *_coord, X3DTextureCoordinateNode *tex_coord, const vector< int > &coord_index, const vector< int > &tex_coord_index, H3DFloat crease_angle, bool _ccw, FloatVertexAttribute *tangent, FloatVertexAttribute *binormal)
 Set the values in the tangent and binormal arguments to the tangent and binormal for each vertex. More...
 
virtual void generateTangentsPerFace (X3DCoordinateNode *_coord, X3DTextureCoordinateNode *tex_coord, const vector< int > &coord_index, const vector< int > &tex_coord_index, bool normalize_values, FloatVertexAttribute *tangent, FloatVertexAttribute *binormal)
 Set the valees in the tangent and binormal arguments to the tangent and binormal for each face. More...
 
Vec3f getTexCoord (X3DCoordinateNode *_coord, X3DTextureCoordinateNode *tex_coord, int index)
 Returns the texture coordinate for a given index. More...
 
void calculateTangent (const Vec3f &a, const Vec3f &b, const Vec3f &c, const Vec3f &ta, const Vec3f &tb, const Vec3f &tc, Vec3f &tangent, Vec3f &binormal)
 Calculate the tangent and binormal for a triangle. More...
 

Additional Inherited Members

- Protected Member Functions inherited from H3D::TypedField< MFVertexAttributeNode, Types< SFBool, SFCoordinateNode, MFInt32, SFTextureCoordinateNode, MFInt32, SFFloat, SFBool > >
void checkFieldType (Field *f, int index)
 Function for checking that a field is of a correct type given type specification according to the TypedField template arguments. More...
 
void checkTemplateArguments ()
 Function for checking that a field given TypedField type specification is valid. More...
 

Detailed Description

Specialized field for automatically generating two FloatVertexAttribute nodes representing the tangent and binormal of each vertex(or face if normalPerVertex is false).

These can then be used in shader nodes such as PhongShader.

routes_in[0] is the normalPerVertex field. routes_in[1] is the coord field. routes_in[2] is the coordIndex field. routes_in[3] is the texCoord field. routes_in[4] is the texCoordIndex field. routes_in[5] is the creaseAngle field. routes_in[6] is the ccw field.

Member Function Documentation

◆ calculateTangent()

void IndexedFaceSet::AutoTangent::calculateTangent ( const Vec3f &  a,
const Vec3f &  b,
const Vec3f &  c,
const Vec3f &  ta,
const Vec3f &  tb,
const Vec3f &  tc,
Vec3f &  tangent,
Vec3f &  binormal 
)

Calculate the tangent and binormal for a triangle.

a,b and c are the coordinates of the triangle vertices. ta, tb and tc are the texture coordinates of the triangle vertices. tangent and binormal are output parameters that are set by the function.

References Vec2f().

◆ generateTangentsPerFace()

void IndexedFaceSet::AutoTangent::generateTangentsPerFace ( X3DCoordinateNode _coord,
X3DTextureCoordinateNode tex_coord,
const vector< int > &  coord_index,
const vector< int > &  tex_coord_index,
bool  normalize_values,
FloatVertexAttribute tangent,
FloatVertexAttribute binormal 
)
virtual

Set the valees in the tangent and binormal arguments to the tangent and binormal for each face.

The result will be one tangent per face.

Parameters
_coordNode with the coordinates.
tex_coordNode with the texture coordinates.
coord_indexThe indices in coord for the vertices.
tex_coord_indexThe indices in tex_coord for the texture coordinates.
normalize_valuesIf true the resulting tangents and binormals will be normalized.
tangentVariable in which generated tangents are set.
binormalVariable in which generated binormals are set.

References H3D::X3DVertexAttributeNode::name, H3D::FloatVertexAttribute::numComponents, and H3D::FloatVertexAttribute::value.

◆ generateTangentsPerVertex() [1/2]

void IndexedFaceSet::AutoTangent::generateTangentsPerVertex ( X3DCoordinateNode _coord,
X3DTextureCoordinateNode tex_coord,
const vector< int > &  coord_index,
const vector< int > &  tex_coord_index,
FloatVertexAttribute tangent,
FloatVertexAttribute binormal 
)
virtual

Set the vales in the tangent and binormal arguments to the tangent and binormal for each vertex.

The result will be one tangent per coordinate in coord.

Parameters
_coordNode with the coordinates.
tex_coordNode with the texture coordinates.
coord_indexThe indices in coord for the vertices.
tex_coord_indexThe indices in tex_coord for the texture coordinates.
tangentVariable in which generated tangents are set.
binormalVariable in which generated binormals are set.

References H3DUtil::AutoRef< class >::get(), H3D::X3DVertexAttributeNode::name, H3D::X3DCoordinateNode::nrAvailableCoords(), H3D::FloatVertexAttribute::numComponents, and H3D::FloatVertexAttribute::value.

◆ generateTangentsPerVertex() [2/2]

void IndexedFaceSet::AutoTangent::generateTangentsPerVertex ( X3DCoordinateNode _coord,
X3DTextureCoordinateNode tex_coord,
const vector< int > &  coord_index,
const vector< int > &  tex_coord_index,
H3DFloat  crease_angle,
bool  _ccw,
FloatVertexAttribute tangent,
FloatVertexAttribute binormal 
)
virtual

Set the values in the tangent and binormal arguments to the tangent and binormal for each vertex.

The result will be one tangent per value in coord_index.

Parameters
_coordNode with the coordinates.
tex_coordNode with the texture coordinates.
coord_indexThe indices in coord for the vertices.
tex_coord_indexThe indices in tex_coord for the texture coordinates.
crease_angleIf the angle between the geometric normals of two adjacent faces is less than the crease angle, tangents are calculated so that the faces are shaded smoothly across the edge; otherwise, tangents are calculated so that a lighting discontinuity across the edge is produced.
_ccwDefines the ordering of the vertex coordinates of the geometry with respect to generated normal vectors used in the lighting model equations. If ccw is TRUE, the normals shall follow the right hand rule; the orientation of each normal with respect to the vertices (taken in order) shall be such that the vertices appear to be oriented in a counterclockwise order when the vertices are viewed (in the local coordinate system of the Shape) from the opposite direction as the normal.
tangentVariable in which generated tangents are set.
binormalVariable in which generated binormals are set.

References H3D::IndexedFaceSet::autoNormal, H3DUtil::AutoRef< class >::get(), H3DCos(), H3D::X3DVertexAttributeNode::name, H3D::X3DCoordinateNode::nrAvailableCoords(), H3D::FloatVertexAttribute::numComponents, H3DUtil::AutoRef< class >::reset(), and H3D::FloatVertexAttribute::value.

◆ getTexCoord()

Vec3f IndexedFaceSet::AutoTangent::getTexCoord ( X3DCoordinateNode _coord,
X3DTextureCoordinateNode tex_coord,
int  index 
)

Returns the texture coordinate for a given index.

If no texture coordinate node is specified it will use the default texture coordinate generation for an IndexedTriangleSet.

References H3D::X3DComposedGeometryNode::getDefaultTexGenMatrix(), H3D::X3DTextureCoordinateNode::getTexCoord(), H3D::X3DTextureCoordinateNode::supportsGetTexCoord(), and Vec4f().


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