Merge branch 'new_osg' of http://192.168.1.2:13521/PM/DYTSrouce into new_osg

This commit is contained in:
brige 2025-11-13 22:14:03 +08:00
commit 2a05254ffb
2 changed files with 10 additions and 6 deletions

View File

@ -191,6 +191,10 @@ void SceneComponent::UpdateLocationAndRotation() {
const osg::Vec3& s = transform_.GetScale();
const osg::Vec3& t = transform_.GetLocation();
osg::Quat quat = OsgUtils::HPRToQuat(r);
//osg::Vec3 angle;
//OsgUtils::QuatToHPR(quat, &angle);
osg::Matrix matrix = osg::Matrix::scale(s) * osg::Matrix::rotate(quat);
if (!geo_.valid()) {
matrix *= osg::Matrix::translate(t);

View File

@ -7,9 +7,9 @@
osg::Quat OsgUtils::HPRToQuat(const osg::Vec3& angle) {
osg::Quat q(
osg::inDegrees(angle.y()), osg::Vec3d(0.0, 1.0, 0.0),
osg::inDegrees(angle.x()), osg::Vec3d(1.0, 0.0, 0.0),
osg::inDegrees(angle.z()), osg::Vec3d(0.0, 0.0, 1.0));
osg::inDegrees(angle.x()), osg::Vec3d(0.0, 1.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));
return q;
}
@ -34,9 +34,9 @@ void OsgUtils::QuatToHPR(const osg::Quat& q, osg::Vec3* angle) {
double sqy = q.y() * q.y();
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);
pitch = 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);
angle->set(osg::RadiansToDegrees(pitch), osg::RadiansToDegrees(roll), osg::RadiansToDegrees(heading));
roll = asin(2.0 * test);
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));
}
void OsgUtils::Vec4ToQColor(const osg::Vec4& vec, QColor* color) {