3DMAX的IGame接口对导出顶点的切向量写的不够清晰。

IGameMesh接口(3DXI V 2.2)关于切向量相关说明:

Binormal and Tangents can be initialized and accessed separately from other mesh data, To initialize entire mesh data (including Binormals and Tangents) IGameObject::InitializeData() should be called.

 

MAX中关于切向量的存储位置如果放在下面Face中是最好了。

class FaceEx: public MaxHeapOperators
{
public:

 //! Index into the vertex array
 DWORD vert[3];
 //! Index into the standard mapping channel
 DWORD texCoord[3];
 //! Index into the normal array
 DWORD norm[3];
 //! Index into the vertex color array
 DWORD color[3];
 //! Index into the vertex illumination array
 DWORD illum[3];
 //! Index into the vertex alpha array
 DWORD alpha[3];
 //! The smoothing group
 DWORD smGrp;
 //! The material ID of the face
 int matID;
 //! Additional flags
 DWORD flags;
 //! Index of corresponding face in the original mesh
 int meshFaceIndex;
 //! Index into edge visibility array. 
 /*! 1 for visible, 0 if the edge is invisible.*/
 DWORD edgeVis[3]; 

};

可惜我们看上面没有关于切向量的的数据。如果使用FaceEx::norm作为切向量的索引得到的结果是不正确的。仔细读下IGameMesh类,发现里面有个

virtual int GetFaceVertexTangentBinormal (int faceIndex, int corner, int mapChannel = 1)=0;

这个接口函数可以用来获取Tangent和Binormal的索引,Tangent和Binormal的索引是同一个值。有了这个索引值就可以通过

Point3 GetTangent(int index, int mapChannel = 1) ;

Point3 GetBinormal(int index, int mapChannel = 1);

获取Tangent和Binormal的具体数值。

导出一个经典的茶壶模型,查看TBN数据,白色代表N,红色代表T,绿色代表B。

 

从表面上看数据基本正确。但是我计算一下TBN之间的夹角,发现TBN并非完全垂直,因此这个TBN数据也许需要进行一定的较正。以后再说吧。

 

posted on 2011-02-07 20:06  操作系统  阅读(2078)  评论(0编辑  收藏  举报