|
|
发表于 2005-9-28 22:21:00
|
显示全部楼层
Re:请问3ds max插件纹理坐标的问题
void get_v_n3_t2(Mesh& mesh, long faceIndex, long pointIndex, _v_n3_t2* pV, Matrix3& m3){
long vindex = mesh.faces[faceIndex].getVert(pointIndex);
Point3 v = mesh.verts[vindex];
float tmpz = v.y; v.y = v.z; v.z = tmpz;
Point3 n;
getNormal(mesh, faceIndex, pointIndex, &n, m3);
/////得到纹理点,注意有可能没有纹理坐标,要先检查
long texNum = mesh.numTVerts;
Point3 t(0,0,0);
if(texNum>0){
long tindex = mesh.tvFace[faceIndex].getTVert(pointIndex);
t = mesh.tVerts[tindex];
Matrix3 m;
m.IdentityMatrix();
m.Scale(Point3(1,-1,1));
m.Translate(Point3(0,1,0));
t = m*t;
}
BYTE * pBuf = (BYTE*)pV;
memcpy(pBuf, &v, sizeof(Point3));
memcpy(pBuf + sizeof(Point3), &n, sizeof(Point3));
memcpy(pBuf + sizeof(Point3)*2, &t, sizeof(float)*2);
} |
|