Class MikkTSpaceImpl

java.lang.Object
com.jme3.util.mikktspace.MikkTSpaceImpl
All Implemented Interfaces:
MikkTSpaceContext

public class MikkTSpaceImpl extends Object implements MikkTSpaceContext
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    getNormal(float[] normOut, int face, int vert)
     
    int
    Returns the number of faces (triangles/quads) on the mesh to be processed.
    int
    Returns the number of vertices on face number iFace iFace is a number in the range {0, 1, ..., getNumFaces()-1}
    void
    getPosition(float[] posOut, int face, int vert)
    returns the position/normal/texcoord of the referenced face of vertex number iVert.
    void
    getTexCoord(float[] texOut, int face, int vert)
     
    void
    setTSpace(float[] tangent, float[] biTangent, float magS, float magT, boolean isOrientationPreserving, int face, int vert)
    This function is used to return tangent space results to the application.
    void
    setTSpaceBasic(float[] tangent, float sign, int face, int vert)
    The callback setTSpaceBasic() is sufficient for basic normal mapping.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MikkTSpaceImpl

      public MikkTSpaceImpl(Mesh mesh)
  • Method Details

    • getNumFaces

      public int getNumFaces()
      Description copied from interface: MikkTSpaceContext
      Returns the number of faces (triangles/quads) on the mesh to be processed.
      Specified by:
      getNumFaces in interface MikkTSpaceContext
      Returns:
      the count (≥0)
    • getNumVerticesOfFace

      public int getNumVerticesOfFace(int face)
      Description copied from interface: MikkTSpaceContext
      Returns the number of vertices on face number iFace iFace is a number in the range {0, 1, ..., getNumFaces()-1}
      Specified by:
      getNumVerticesOfFace in interface MikkTSpaceContext
      Parameters:
      face - which face (≥0, <numFaces)
      Returns:
      the count (≥0)
    • getPosition

      public void getPosition(float[] posOut, int face, int vert)
      Description copied from interface: MikkTSpaceContext
      returns the position/normal/texcoord of the referenced face of vertex number iVert. iVert is in the range {0,1,2} for triangles and {0,1,2,3} for quads.
      Specified by:
      getPosition in interface MikkTSpaceContext
      Parameters:
      posOut - storage for the results (modified)
      face - which face (≥0, <numFaces)
      vert - which vertex in the face (≥0, <numVertices)
    • getNormal

      public void getNormal(float[] normOut, int face, int vert)
      Specified by:
      getNormal in interface MikkTSpaceContext
    • getTexCoord

      public void getTexCoord(float[] texOut, int face, int vert)
      Specified by:
      getTexCoord in interface MikkTSpaceContext
    • setTSpaceBasic

      public void setTSpaceBasic(float[] tangent, float sign, int face, int vert)
      Description copied from interface: MikkTSpaceContext
      The callback setTSpaceBasic() is sufficient for basic normal mapping. This function is used to return the tangent and sign to the application. tangent is a unit length vector. For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level. bitangent = fSign * cross(vN, tangent); Note that the results are returned unindexed. It is possible to generate a new index list But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCORRECT results. DO NOT! use an already existing index list.
      Specified by:
      setTSpaceBasic in interface MikkTSpaceContext
      Parameters:
      tangent - the desired tangent vector (unaffected)
      sign - the desired sign
      face - which face (≥0, <numFaces)
      vert - which vertex in the face (≥0, <numVertices)
    • setTSpace

      public void setTSpace(float[] tangent, float[] biTangent, float magS, float magT, boolean isOrientationPreserving, int face, int vert)
      Description copied from interface: MikkTSpaceContext
      This function is used to return tangent space results to the application. tangent and biTangent are unit length vectors and fMagS and fMagT are their true magnitudes which can be used for relief mapping effects. biTangent is the "real" bitangent and thus may not be perpendicular to tangent. However, both are perpendicular to the vertex normal. For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level.
       fSign = bIsOrientationPreserving ? 1.0f : (-1.0f);
       bitangent = fSign * cross(vN, tangent);
       
      Note that the results are returned unindexed. It is possible to generate a new index list. But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCORRECT results. DO NOT! use an already existing index list.
      Specified by:
      setTSpace in interface MikkTSpaceContext
      Parameters:
      tangent - the desired tangent vector (unaffected)
      biTangent - the desired bitangent vector (unaffected)
      magS - true magnitude of S
      magT - true magnitude of T
      isOrientationPreserving - true→preserves, false→doesn't preserve
      face - which face (≥0, <numFaces)
      vert - which vertex in the face (≥0, <numVertices)