Go to the documentation of this file.
16 #ifndef SURGSIM_GRAPHICS_TANGENTSPACEGENERATOR_H
17 #define SURGSIM_GRAPHICS_TANGENTSPACEGENERATOR_H
19 #include <osg/NodeVisitor>
21 #include <osg/Geometry>
51 void set(
const osg::Vec3Array* vertexArray,
52 const osg::Vec3Array* normalArray,
53 const osg::Vec2Array* textureCoordArray,
54 osg::Vec4Array* tangentArray,
55 osg::Vec4Array* bitangentArray);
68 void operator()(
unsigned int vertexIndex1,
unsigned int vertexIndex2,
unsigned int vertexIndex3);
116 void apply(osg::Geode& geode)
override;
126 int textureCoordUnit,
127 int tangentAttribIndex,
128 int bitangentAttribIndex,
const osg::Vec2Array * m_textureCoordArray
Array containing texture coordinates.
Definition: TangentSpaceGenerator.h:78
int m_textureCoordUnit
Texture unit of texture coordinates to use for calculating the tangent space.
Definition: TangentSpaceGenerator.h:133
bool m_createOrthonormalBasis
Whether or not to create a fully orthonormal basis; otherwise, each tangent is separately orthonormal...
Definition: TangentSpaceGenerator.h:88
const osg::Vec3Array * m_normalArray
Array containing normals.
Definition: TangentSpaceGenerator.h:75
const osg::Vec3Array * m_vertexArray
Array containing vertex positions.
Definition: TangentSpaceGenerator.h:72
Node visitor which calculates the tangent space basis vectors from the texture coordinates of any geo...
Definition: TangentSpaceGenerator.h:94
GenerateTangentSpaceTriangleIndexFunctor()
Constructor.
Definition: TangentSpaceGenerator.cpp:67
TangentSpaceGenerator(int textureCoordUnit, int tangentAttribIndex, int bitangentAttribIndex)
Constructor.
Definition: TangentSpaceGenerator.cpp:182
void orthogonalize()
Orthogonalize and normalize the calculated tangent space basis vectors.
Definition: TangentSpaceGenerator.cpp:116
void operator()(unsigned int vertexIndex1, unsigned int vertexIndex2, unsigned int vertexIndex3)
Calculates the triangle tangent space basis vectors and adds it to each adjacent vertex's tangent.
Definition: TangentSpaceGenerator.cpp:140
osg::Vec4Array * m_bitangentArray
Array storing calculated bitangents.
Definition: TangentSpaceGenerator.h:84
Definition: CompoundShapeToGraphics.cpp:30
void setBasisOrthonormality(bool orthonormal)
Sets whether the three tangent space basis vectors are made to be orthonormal; otherwise,...
Definition: TangentSpaceGenerator.cpp:77
static void generateTangentSpace(osg::Geometry *geometry, int textureCoordUnit, int tangentAttribIndex, int bitangentAttribIndex, bool orthonormal)
Generates tangent space basis vectors for the geometry.
Definition: TangentSpaceGenerator.cpp:217
int m_bitangentAttribIndex
Index of the vertex attribute array to store the calculated bitangents.
Definition: TangentSpaceGenerator.h:139
bool m_createOrthonormalBasis
Whether or not to create a fully orthonormal basis; otherwise, each tangent is separately orthonormal...
Definition: TangentSpaceGenerator.h:143
osg::Vec4Array * m_tangentArray
Array storing calculated tangents.
Definition: TangentSpaceGenerator.h:81
void setBasisOrthonormality(bool orthonormal)
Sets whether the three tangent space basis vectors are made to be orthonormal; otherwise,...
Definition: TangentSpaceGenerator.cpp:195
void reset()
Resets all calculated tangent space basis vectors to 0.
Definition: TangentSpaceGenerator.cpp:129
bool getBasisOrthonormality()
Gets whether the three tangent space basis vectors are made to be orthonormal; otherwise,...
Definition: TangentSpaceGenerator.cpp:199
void set(const osg::Vec3Array *vertexArray, const osg::Vec3Array *normalArray, const osg::Vec2Array *textureCoordArray, osg::Vec4Array *tangentArray, osg::Vec4Array *bitangentArray)
Sets the arrays required to generate tangent space basis vectors.
Definition: TangentSpaceGenerator.cpp:86
virtual ~TangentSpaceGenerator()
Destructor.
Definition: TangentSpaceGenerator.cpp:191
Triangle index functor which calculates the tangent space basis vectors for the vertices of a geometr...
Definition: TangentSpaceGenerator.h:31
int m_tangentAttribIndex
Index of the vertex attribute array to store the calculated tangents.
Definition: TangentSpaceGenerator.h:136
bool getBasisOrthonormality()
Definition: TangentSpaceGenerator.cpp:81
void apply(osg::Geode &geode) override
Generates tangent space vectors for all geometry in the geode.
Definition: TangentSpaceGenerator.cpp:204