This class is a callback for computing bump basis vectors on a given set of triangle/quad faces.
The callback could be used as an input parameter of the method ComputeMikkTangents to compute the tangent and binormal(bitangent). The Plug-ins need to implement GetNumberOfFaces, GetNumberVerticesOfFace, GetVertex, GetNormal and GetTexture methods to input all required data to be computed, and SetTangent method to output the computation results. Usage: The following code demostrates how to compute the MikkT tangents for a given triangle face.
{
public:
virtual int GetNumberOfFaces() const override
{
return 1;
}
virtual int GetNumberVerticesOfFace(const int faceIdx) const override
{
return 3;
}
virtual void GetVertex(
Point3& position,
const int faceIdx,
const int vertIdx)
override
{
if (vertIdx ==0) {
position = { 0.0f, 0.0f, 0.0f };
}
else if (vertIdx==1) {
position = { 0.0f, 1.0f, 0.0f };
}
else if (vertIdx==2) {
position = { 1.0f, 0.0f, 0.0f };
}
}
virtual void GetNormal(
Point3& normal,
const int faceIdx,
const int vertIdx)
override
{
if (vertIdx == 0) {
normal = { 0.0f, 0.0f, 1.0f };
}
else if (vertIdx == 1) {
normal = { 0.0f, 0.0f, 1.0f };
}
else if (vertIdx == 2) {
normal = { 0.0f, 0.0f, 1.0f };
}
}
virtual void GetTexture(
Point2& texture,
const int faceIdx,
const int vertIdx)
override
{
if (vertIdx == 0) {
texture = { 0.0f, 0.0f };
}
else if (vertIdx == 1) {
texture = { 0.0f, 1.0f };
}
else if (vertIdx == 2) {
texture = { 1.0f, 0.0f };
}
}
virtual void SetTangent(
const Point3& tangent,
const Point3& binormal,
const float handedness, const int faceIdx, const int vertIdx) override
{
outputTangents.Append(1, &tan);
outputBinormals.Append(1, &binml);
float hand = handedness;
outputHandednesses.Append(1, &hand);
}
return outputTangents;
}
return outputBinormals;
}
return outputHandednesses;
}
private:
};
TangentsComputationCallback cb;
Tab<float> handednesses = cb.GetHandednessesResult();
This class is a callback for computing bump basis vectors on a given set of triangle/quad faces.
Definition: gutil.h:242
Generic container class.
Definition: tab.h:180
void ComputeMikkTangents(ITangentsComputationCallback *tangentsComputationCallback)
Computes the bump basis vector in MikkT way for the U texture channel (called the tangent),...