Class for calculating a tangent space basis.
More...
#include <OgreTangentSpaceCalc.h>
|
void | addFaceTangentSpaceToVertices (size_t indexSet, size_t faceIndex, size_t *localVertInd, const Vector3 &faceTsU, const Vector3 &faceTsV, const Vector3 &faceNorm, Result &result) |
|
Real | calculateAngleWeight (size_t v0, size_t v1, size_t v2) |
|
void | calculateFaceTangentSpace (const size_t *vertInd, Vector3 &tsU, Vector3 &tsV, Vector3 &tsN) |
| Calculate face tangent space, U and V are weighted by UV area, N is normalised. More...
|
|
int | calculateParity (const Vector3 &u, const Vector3 &v, const Vector3 &n) |
|
void | extendBuffers (VertexSplits &splits) |
|
void | insertTangents (Result &res, VertexElementSemantic targetSemantic, unsigned short sourceTexCoordSet, unsigned short index) |
|
void | normaliseVertices () |
|
void | populateVertexArray (unsigned short sourceTexCoordSet) |
|
void | processFaces (Result &result) |
|
void | remapIndexes (Result &res) |
|
template<typename T > |
void | remapIndexes (T *ibuf, size_t indexSet, Result &res) |
|
Class for calculating a tangent space basis.
Definition at line 49 of file OgreTangentSpaceCalc.h.
Ogre::TangentSpaceCalc::TangentSpaceCalc |
( |
| ) |
|
virtual Ogre::TangentSpaceCalc::~TangentSpaceCalc |
( |
| ) |
|
|
virtual |
void Ogre::TangentSpaceCalc::addFaceTangentSpaceToVertices |
( |
size_t |
indexSet, |
|
|
size_t |
faceIndex, |
|
|
size_t * |
localVertInd, |
|
|
const Vector3 & |
faceTsU, |
|
|
const Vector3 & |
faceTsV, |
|
|
const Vector3 & |
faceNorm, |
|
|
Result & |
result |
|
) |
| |
|
protected |
Add a set of index data that references the vertex data.
This might be modified if there are vertex splits.
Build a tangent space basis from the provided data.
- Parameters
-
targetSemantic | The semantic to store the tangents in. Defaults to the explicit tangent binding, but note that this is only usable on more modern hardware (Shader Model 2), so if you need portability with older cards you should change this to a texture coordinate binding instead. |
sourceTexCoordSet | The texture coordinate index which should be used as the source of 2D texture coordinates, with which to calculate the tangents. |
index | The element index, ie the texture coordinate set which should be used to store the 3D coordinates representing a tangent vector per vertex, if targetSemantic is VES_TEXTURE_COORDINATES. If this already exists, it will be overwritten. |
- Returns
- A structure containing the results of the tangent space build. Vertex data will always be modified but it's also possible that the index data could be adjusted. This happens when mirroring is used on a mesh, which causes the tangent space to be inverted on opposite sides of an edge. This is discontinuous, therefore the vertices have to be split along this edge, resulting in new vertices.
Real Ogre::TangentSpaceCalc::calculateAngleWeight |
( |
size_t |
v0, |
|
|
size_t |
v1, |
|
|
size_t |
v2 |
|
) |
| |
|
protected |
void Ogre::TangentSpaceCalc::calculateFaceTangentSpace |
( |
const size_t * |
vertInd, |
|
|
Vector3 & |
tsU, |
|
|
Vector3 & |
tsV, |
|
|
Vector3 & |
tsN |
|
) |
| |
|
protected |
Calculate face tangent space, U and V are weighted by UV area, N is normalised.
void Ogre::TangentSpaceCalc::clear |
( |
| ) |
|
Reset the calculation object.
void Ogre::TangentSpaceCalc::extendBuffers |
( |
VertexSplits & |
splits | ) |
|
|
protected |
bool Ogre::TangentSpaceCalc::getSplitMirrored |
( |
| ) |
const |
|
inline |
Gets whether or not to split vertices when a mirrored tangent space transition is detected.
Definition at line 136 of file OgreTangentSpaceCalc.h.
bool Ogre::TangentSpaceCalc::getSplitRotated |
( |
| ) |
const |
|
inline |
Sets whether or not to split vertices when tangent space rotates more than 90 degrees around a vertex.
Definition at line 156 of file OgreTangentSpaceCalc.h.
bool Ogre::TangentSpaceCalc::getStoreParityInW |
( |
| ) |
const |
|
inline |
Gets whether to store tangent space parity in the W of a 4-component tangent or not.
Definition at line 115 of file OgreTangentSpaceCalc.h.
void Ogre::TangentSpaceCalc::insertTangents |
( |
Result & |
res, |
|
|
VertexElementSemantic |
targetSemantic, |
|
|
unsigned short |
sourceTexCoordSet, |
|
|
unsigned short |
index |
|
) |
| |
|
protected |
void Ogre::TangentSpaceCalc::normaliseVertices |
( |
| ) |
|
|
protected |
void Ogre::TangentSpaceCalc::populateVertexArray |
( |
unsigned short |
sourceTexCoordSet | ) |
|
|
protected |
void Ogre::TangentSpaceCalc::processFaces |
( |
Result & |
result | ) |
|
|
protected |
void Ogre::TangentSpaceCalc::remapIndexes |
( |
Result & |
res | ) |
|
|
protected |
template<typename T >
void Ogre::TangentSpaceCalc::remapIndexes |
( |
T * |
ibuf, |
|
|
size_t |
indexSet, |
|
|
Result & |
res |
|
) |
| |
|
inlineprotected |
void Ogre::TangentSpaceCalc::setSplitMirrored |
( |
bool |
split | ) |
|
|
inline |
Sets whether or not to split vertices when a mirrored tangent space transition is detected (matrix parity differs).
- Note
- This option is automatically disabled if you provide any strip or fan based geometry.
Definition at line 131 of file OgreTangentSpaceCalc.h.
void Ogre::TangentSpaceCalc::setSplitRotated |
( |
bool |
split | ) |
|
|
inline |
Sets whether or not to split vertices when tangent space rotates more than 90 degrees around a vertex.
- Note
- This option is automatically disabled if you provide any strip or fan based geometry.
Definition at line 152 of file OgreTangentSpaceCalc.h.
void Ogre::TangentSpaceCalc::setStoreParityInW |
( |
bool |
enabled | ) |
|
|
inline |
Sets whether to store tangent space parity in the W of a 4-component tangent or not.
- Parameters
-
enabled | true to enable 4-component tangents (default false). If you enable this, you will probably also want to enable mirror splitting (see setSplitMirrored), and your shader must understand how to deal with the parity. |
Definition at line 112 of file OgreTangentSpaceCalc.h.
void Ogre::TangentSpaceCalc::setVertexData |
( |
VertexData * |
v_in | ) |
|
Set the incoming vertex data (which will be modified)
bool Ogre::TangentSpaceCalc::mSplitMirrored |
|
protected |
bool Ogre::TangentSpaceCalc::mSplitRotated |
|
protected |
bool Ogre::TangentSpaceCalc::mStoreParityInW |
|
protected |
The documentation for this class was generated from the following file: