计算旋转角度
计算旋转角度,考虑吊车朝向
void rotateRopeHAngle(int center_x, int center_y, int center_z, int armNodeNum, double rotateIndexAngle) { osg::Vec3d set_center; if (directParam == 1) { ropeMatrix = osg::Matrix::rotate(osg::DegreesToRadians(rotateIndexAngle), 0, -1, 0); set_center = osg::Vec3d((center_x + armNodeNum - 1)*(1.0), (center_y)*(1.0), (center_z)*(1.0)); } else if (directParam == 2) { ropeMatrix = osg::Matrix::rotate(osg::DegreesToRadians(rotateIndexAngle), 0, 1, 0); set_center = osg::Vec3d((center_x - armNodeNum + 1)*(1.0), (center_y)*(1.0), (center_z)*(1.0)); } else if (directParam == 3) { ropeMatrix = osg::Matrix::rotate(osg::DegreesToRadians(rotateIndexAngle), 1, 0, 0); set_center = osg::Vec3d(center_x*(1.0), (center_y + armNodeNum - 1)*(1.0), center_z*(1.0)); } else if (directParam == 4) { ropeMatrix = osg::Matrix::rotate(osg::DegreesToRadians(rotateIndexAngle), -1, 0, 0); set_center = osg::Vec3d(center_x*(1.0), (center_y - armNodeNum + 1)*(1.0), center_z*(1.0)); } //ropeMatrix = osg::Matrix::rotate(osg::DegreesToRadians(rotateIndexAngle), 1, 0, 0); osg::Matrix originPos = rotRope->getMatrix(); rotRope->setMatrix(originPos*osg::Matrix::translate(-set_center)*ropeMatrix*osg::Matrix::translate(set_center)); }
QQ 3087438119