CAL3d右手坐标系转左手坐标系(2009-04-27 00:10)
同事看了cal3d导出件,配上一键导出的脚本,确实不错,cal3d除了渲染模块有待改进外,其他部分都写得相当到位。但人物角色老拿“左手剑”不是那么回事儿,特贴出他给出的最简易而有效的解决办法。
#include 'StdAfx.h'
#include 'max2ogl.h'
Matrix3 ConvertMax2Ogl(const Matrix3& _mat)
{
//return _mat;
//T = R x _mat x R-1
Matrix3 tm,tmogl,tmoglInv;
tmogl.IdentityMatrix();
//tmogl.RotateX(PI*0.5f);
//原来opengl的
// tmogl.SetRow(0,Point3(1,0,0));
//这个省略
tmogl.SetRow(1,Point3(0,0,1));
tmogl.SetRow(2,Point3(0,1,0));
tmoglInv=tmogl;
tmoglInv.Invert();
tm=tmogl*_mat*tmoglInv;
return tm;
}
Point3 ConvertMax2Ogl(const Point3& _p)
{
//return _p;
// return Point3(_p[0],_p[2],-_p[1]); &
ok!