trimesh2沿x、y、z轴旋转

//zdd:  沿x,y,z旋转angle 度
//例如,rot_angle(90.0,1.0, 0.0, 0.0)为沿x轴旋转90度
void rot_angle(float angle, float x, float y, float z)
{

	Vec<3, double> x_axis(x, y, z);
	
	double ang = M_PI / 180.0f * angle;
	
/*
	//为了将模型显示在视口中心,所以移动了一个xff矩阵
	xform xff = xform::trans(0, 0, -3.5f / fov * themesh->bsphere.r) *
		     xform::trans(-themesh->bsphere.center);

	xform i_xff =xform::trans(themesh->bsphere.center) * xform::trans(0, 0, 3.5f / fov * themesh->bsphere.r);

	xf = xff * xform::trans(themesh->bsphere.center) *xform::rot(ang, x_axis) * xform::trans(-themesh->bsphere.center) * i_xff * xf;
*/
	//以上三行原理清晰,化简如下:
	xf = xform::trans(0, 0, -3.5f / fov * themesh->bsphere.r) * xform::rot(ang, x_axis) * xform::trans(0, 0, 3.5f / fov * themesh->bsphere.r) * xf;

}


你可能感兴趣的:(trimesh2沿x、y、z轴旋转)