void SceneNode::Rotate( char axis, double angle ) { if( IsJoint() ) { JointNode* joint = dynamic_cast<JointNode*>(this); switch( axis ) { case 'x': joint->SetCurX( joint->GetJointX().cur + angle ); break; case 'y': joint->SetCurY( joint->GetJointY().cur + angle ); break; default: break; } } angle = angle * M_PI / 180.0; Matrix4x4 rotMatrix; switch( axis ) { case 'x': rotMatrix[1][1] = cos( angle ); rotMatrix[1][2] = -sin( angle ); rotMatrix[2][1] = sin( angle ); rotMatrix[2][2] = cos( angle ); break; case 'y': rotMatrix[0][0] = cos( angle ); rotMatrix[0][2] = sin( angle ); rotMatrix[2][0] = -sin( angle ); rotMatrix[2][2] = cos( angle ); break; case 'z': rotMatrix[0][0] = cos( angle ); rotMatrix[0][1] = -sin( angle ); rotMatrix[1][0] = sin( angle ); rotMatrix[1][1] = cos( angle ); break; default: break; } SetTransform( mTrans * rotMatrix ); }