H3D API
2.4.1
|
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>
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 | |
![]() | |
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... | |
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.
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().
|
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.
_coord | Node with the coordinates. |
tex_coord | Node with the texture coordinates. |
coord_index | The indices in coord for the vertices. |
tex_coord_index | The indices in tex_coord for the texture coordinates. |
normalize_values | If true the resulting tangents and binormals will be normalized. |
tangent | Variable in which generated tangents are set. |
binormal | Variable in which generated binormals are set. |
References H3D::X3DVertexAttributeNode::name, H3D::FloatVertexAttribute::numComponents, and H3D::FloatVertexAttribute::value.
|
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.
_coord | Node with the coordinates. |
tex_coord | Node with the texture coordinates. |
coord_index | The indices in coord for the vertices. |
tex_coord_index | The indices in tex_coord for the texture coordinates. |
tangent | Variable in which generated tangents are set. |
binormal | Variable in which generated binormals are set. |
References H3DUtil::AutoRef< class >::get(), H3D::X3DVertexAttributeNode::name, H3D::X3DCoordinateNode::nrAvailableCoords(), H3D::FloatVertexAttribute::numComponents, and H3D::FloatVertexAttribute::value.
|
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.
_coord | Node with the coordinates. |
tex_coord | Node with the texture coordinates. |
coord_index | The indices in coord for the vertices. |
tex_coord_index | The indices in tex_coord for the texture coordinates. |
crease_angle | If 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. |
_ccw | Defines 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. |
tangent | Variable in which generated tangents are set. |
binormal | Variable 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.
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().