modified rotate
This commit is contained in:
parent
ce69c84f8a
commit
d7d1561ba8
@ -191,6 +191,10 @@ void SceneComponent::UpdateLocationAndRotation() {
|
|||||||
const osg::Vec3& s = transform_.GetScale();
|
const osg::Vec3& s = transform_.GetScale();
|
||||||
const osg::Vec3& t = transform_.GetLocation();
|
const osg::Vec3& t = transform_.GetLocation();
|
||||||
osg::Quat quat = OsgUtils::HPRToQuat(r);
|
osg::Quat quat = OsgUtils::HPRToQuat(r);
|
||||||
|
|
||||||
|
//osg::Vec3 angle;
|
||||||
|
//OsgUtils::QuatToHPR(quat, &angle);
|
||||||
|
|
||||||
osg::Matrix matrix = osg::Matrix::scale(s) * osg::Matrix::rotate(quat);
|
osg::Matrix matrix = osg::Matrix::scale(s) * osg::Matrix::rotate(quat);
|
||||||
if (!geo_.valid()) {
|
if (!geo_.valid()) {
|
||||||
matrix *= osg::Matrix::translate(t);
|
matrix *= osg::Matrix::translate(t);
|
||||||
|
|||||||
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
osg::Quat OsgUtils::HPRToQuat(const osg::Vec3& angle) {
|
osg::Quat OsgUtils::HPRToQuat(const osg::Vec3& angle) {
|
||||||
osg::Quat q(
|
osg::Quat q(
|
||||||
osg::inDegrees(angle.y()), osg::Vec3d(0.0, 1.0, 0.0),
|
osg::inDegrees(angle.x()), osg::Vec3d(0.0, 1.0, 0.0),
|
||||||
osg::inDegrees(angle.x()), osg::Vec3d(1.0, 0.0, 0.0),
|
osg::inDegrees(angle.y()), osg::Vec3d(1.0, 0.0, 0.0),
|
||||||
osg::inDegrees(angle.z()), osg::Vec3d(0.0, 0.0, 1.0));
|
osg::inDegrees(-angle.z()), osg::Vec3d(0.0, 0.0, 1.0));
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ void OsgUtils::QuatToHPR(const osg::Quat& q, osg::Vec3* angle) {
|
|||||||
double sqy = q.y() * q.y();
|
double sqy = q.y() * q.y();
|
||||||
double sqz = q.z() * q.z();
|
double sqz = q.z() * q.z();
|
||||||
heading = atan2(2.0 * q.z() * q.w() - 2.0 * q.y() * q.x(), 1.0 - 2.0 * sqz - 2.0 * sqx);
|
heading = atan2(2.0 * q.z() * q.w() - 2.0 * q.y() * q.x(), 1.0 - 2.0 * sqz - 2.0 * sqx);
|
||||||
pitch = asin(2.0 * test);
|
roll = asin(2.0 * test);
|
||||||
roll = atan2(2.0 * q.y() * q.w() - 2.0 * q.z() * q.x(), 1.0 - 2.0 * sqy - 2.0 * sqx);
|
pitch = atan2(2.0 * q.y() * q.w() - 2.0 * q.z() * q.x(), 1.0 - 2.0 * sqy - 2.0 * sqx);
|
||||||
angle->set(osg::RadiansToDegrees(pitch), osg::RadiansToDegrees(roll), osg::RadiansToDegrees(heading));
|
angle->set(osg::RadiansToDegrees(pitch), osg::RadiansToDegrees(roll), -osg::RadiansToDegrees(heading));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgUtils::Vec4ToQColor(const osg::Vec4& vec, QColor* color) {
|
void OsgUtils::Vec4ToQColor(const osg::Vec4& vec, QColor* color) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user