查看单个帖子
旧 2008-07-24, 01:02 AM   #1
huangyhg
超级版主
 
huangyhg的头像
 
注册日期: 04-03
帖子: 18592
精华: 36
现金: 249466 标准币
资产: 1080358888 标准币
huangyhg 向着好的方向发展
默认 Matrix 矩阵变换

1OpenGL matrix
void CCadTransform::GetGLMatrix (double matrix[16]) const
{
/* OpenGL matrix is a 4x4 matrix in column-major order. Translate component is
in last column. m_rotate is a 3x3 matrix in column-major order. */
//
rotation matrix (3x3)
matrix[0] = m_rotate[E_MAJOR_AXIS][X_AXIS] * m_scale[X_AXIS];
matrix[1] = m_rotate[E_MAJOR_AXIS][Y_AXIS] * m_scale[X_AXIS];
matrix[2] = m_rotate[E_MAJOR_AXIS][Z_AXIS] * m_scale[X_AXIS];
matrix[3] = 0.0;
matrix[4] = m_rotate[E_MINOR_AXIS][X_AXIS] * m_scale[Y_AXIS];
matrix[5] = m_rotate[E_MINOR_AXIS][Y_AXIS] * m_scale[Y_AXIS];
matrix[6] = m_rotate[E_MINOR_AXIS][Z_AXIS] * m_scale[Y_AXIS];
matrix[7] = 0.0;
matrix[8] = m_rotate[E_ALIGN_AXIS][X_AXIS] * m_scale[Z_AXIS];
matrix[9] = m_rotate[E_ALIGN_AXIS][Y_AXIS] * m_scale[Z_AXIS];
matrix[10] = m_rotate[E_ALIGN_AXIS][Z_AXIS] * m_scale[Z_AXIS];
matrix[11] = 0.0;
// translate component
matrix[12] = m_translate[X_AXIS];
matrix[13] = m_translate[Y_AXIS];
matrix[14] = m_translate[Z_AXIS];
matrix[15] = 1.0;
} // CCadTransform::GetGLMatrix()
huangyhg离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)