Loading...
Searching...
No Matches
Ogre::TangentSpaceCalc Class Reference
Core » Math

Class for calculating a tangent space basis. More...

`#include <OgreTangentSpaceCalc.h>`

## Classes

struct | IndexRemap
| Information about a remapped index. More...
struct | Result
| The result of having built a tangent space basis. More...

## Public Types

typedef std::list< IndexRemap > | IndexRemapList
| List of indexes that were remapped (split vertices).
typedef std::pair< size_t, size_t > | VertexSplit
typedef std::list< VertexSplit > | VertexSplits

## Public Member Functions

| TangentSpaceCalc ()
void | addIndexData (IndexData *i_in, RenderOperation::OperationType opType=RenderOperation::OT_TRIANGLE_LIST)
| Add a set of index data that references the vertex data.
Result | build (unsigned short sourceTexCoordSet=0)
| Build a tangent space basis from the provided data.
Result | build (VertexElementSemantic targetSemantic, unsigned short sourceTexCoordSet=0, unsigned short index=0)
void | clear ()
| Reset the calculation object.
bool | getSplitMirrored () const
| Gets whether or not to split vertices when a mirrored tangent space transition is detected.
bool | getSplitRotated () const
| Sets whether or not to split vertices when tangent space rotates more than 90 degrees around a vertex.
bool | getStoreParityInW () const
| Gets whether to store tangent space parity in the W of a 4-component tangent or not.
void | setSplitMirrored (bool split)
| Sets whether or not to split vertices when a mirrored tangent space transition is detected (matrix parity differs).
void | setSplitRotated (bool split)
| Sets whether or not to split vertices when tangent space rotates more than 90 degrees around a vertex.
void | setStoreParityInW (bool enabled)
| Sets whether to store tangent space parity in the W of a 4-component tangent or not.
void | setVertexData (VertexData *v_in)
| Set the incoming vertex data (which will be modified).

## Detailed Description

Class for calculating a tangent space basis.

## Member Typedef Documentation

## VertexSplit

typedef std::pair<size_t, size_t> Ogre::TangentSpaceCalc::VertexSplit

## IndexRemapList

typedef std::list<IndexRemap> Ogre::TangentSpaceCalc::IndexRemapList

List of indexes that were remapped (split vertices).

## VertexSplits

typedef std::list<VertexSplit> Ogre::TangentSpaceCalc::VertexSplits

## Constructor & Destructor Documentation

## TangentSpaceCalc()

Ogre::TangentSpaceCalc::TangentSpaceCalc | ( |  | ) |

## Member Function Documentation

## clear()

void Ogre::TangentSpaceCalc::clear | ( |  | ) |

Reset the calculation object.

## setVertexData()

void Ogre::TangentSpaceCalc::setVertexData | ( | VertexData * | v_in | ) |

Set the incoming vertex data (which will be modified).

## addIndexData()

void Ogre::TangentSpaceCalc::addIndexData | ( | IndexData * | i_in,
|  | RenderOperation::OperationType | opType = RenderOperation::OT_TRIANGLE_LIST )

Add a set of index data that references the vertex data.

This might be modified if there are vertex splits.

References Ogre::RenderOperation::OT_TRIANGLE_LIST.

## setStoreParityInW()

void Ogre::TangentSpaceCalc::setStoreParityInW | ( | bool | enabled | ) |

inline

Sets whether to store tangent space parity in the W of a 4-component tangent or not.

The default element format to use is VET_FLOAT3 which is enough to accurately deal with tangents that do not involve any texture coordinate mirroring. If you wish to allow UV mirroring in your model, you must enable 4-component tangents using this method, and the 'w' coordinate will be populated with the parity of the triangle (+1 or -1), which will allow you to generate the bitangent properly.

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.

## getStoreParityInW()

bool Ogre::TangentSpaceCalc::getStoreParityInW | ( |  | ) | const

inline

Gets whether to store tangent space parity in the W of a 4-component tangent or not.

## setSplitMirrored()

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).

This defaults to 'off' because it's the safest option; tangents will be interpolated in all cases even if they don't agree around a vertex, so artefacts will be smoothed out. When you're using art assets of unknown quality this can avoid extra seams on the visible surface. However, if your artists are good, they will be hiding texture seams in folds of the model and thus you can turn this option on, which will prevent the results of those seams from getting smoothed into other areas, which is exactly what you want.

Note
  This option is automatically disabled if you provide any strip or fan based geometry.

## getSplitMirrored()

bool Ogre::TangentSpaceCalc::getSplitMirrored | ( |  | ) | const

inline

Gets whether or not to split vertices when a mirrored tangent space transition is detected.

## setSplitRotated()

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.

This defaults to 'off' because it's the safest option; tangents will be interpolated in all cases even if they don't agree around a vertex, so artefacts will be smoothed out. When you're using art assets of unknown quality this can avoid extra seams on the visible surface. However, if your artists are good, they will be hiding texture inconsistencies in folds of the model and thus you can turn this option on, which will prevent the results of those seams from getting smoothed into other areas, which is exactly what you want.

Note
  This option is automatically disabled if you provide any strip or fan based geometry.

## getSplitRotated()

bool Ogre::TangentSpaceCalc::getSplitRotated | ( |  | ) | const

inline

Sets whether or not to split vertices when tangent space rotates more than 90 degrees around a vertex.

## build() [1/2]

Result Ogre::TangentSpaceCalc::build | ( | unsigned short | sourceTexCoordSet = 0 | ) |

Build a tangent space basis from the provided data.

Only indexed triangle lists are allowed. Strips and fans cannot be supported because it may be necessary to split the geometry up to respect deviances in the tangent space basis better.

Parameters

  sourceTexCoordSet | The texture coordinate index which should be used as the source of 2D texture coordinates, with which to calculate the tangents.

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.

Referenced by build().

## build() [2/2]

Result Ogre::TangentSpaceCalc::build | ( | VertexElementSemantic | targetSemantic,
|  | unsigned short | sourceTexCoordSet = 0,
|  | unsigned short | index = 0 )

inline

References build(), OgreAssert, and Ogre::VES_TANGENT.

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

- OgreTangentSpaceCalc.h