mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
LP-29 made OSGTransform node position/attitude handling more consistent
This commit is contained in:
parent
bdb42246e8
commit
d2c8d6c657
@ -127,15 +127,18 @@ public:
|
||||
transform->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL, osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
// rotate
|
||||
osg::Quat q = osg::Quat(
|
||||
osg::DegreesToRadians(rotate.x()), osg::Vec3d(1, 0, 0),
|
||||
osg::DegreesToRadians(rotate.y()), osg::Vec3d(0, 1, 0),
|
||||
osg::DegreesToRadians(rotate.z()), osg::Vec3d(0, 0, 1));
|
||||
// attitude
|
||||
double roll = osg::DegreesToRadians(attitude.x());
|
||||
double pitch = osg::DegreesToRadians(attitude.y());
|
||||
double yaw = osg::DegreesToRadians(attitude.z());
|
||||
osg::Quat q = osg::Quat(
|
||||
roll, osg::Vec3d(0, 1, 0),
|
||||
pitch, osg::Vec3d(1, 0, 0),
|
||||
yaw, osg::Vec3d(0, 0, -1));
|
||||
transform->setAttitude(q);
|
||||
|
||||
// translate
|
||||
transform->setPosition(osg::Vec3d(translate.x(), translate.y(), translate.z()));
|
||||
// position
|
||||
transform->setPosition(osg::Vec3d(position.x(), position.y(), position.z()));
|
||||
}
|
||||
|
||||
OSGTransformNode *const self;
|
||||
@ -147,8 +150,8 @@ public:
|
||||
bool dirty;
|
||||
|
||||
QVector3D scale;
|
||||
QVector3D rotate;
|
||||
QVector3D translate;
|
||||
QVector3D attitude;
|
||||
QVector3D position;
|
||||
|
||||
private slots:
|
||||
|
||||
@ -203,31 +206,31 @@ void OSGTransformNode::setScale(QVector3D arg)
|
||||
}
|
||||
}
|
||||
|
||||
QVector3D OSGTransformNode::rotate() const
|
||||
QVector3D OSGTransformNode::attitude() const
|
||||
{
|
||||
return h->rotate;
|
||||
return h->attitude;
|
||||
}
|
||||
|
||||
void OSGTransformNode::setRotate(QVector3D arg)
|
||||
void OSGTransformNode::setAttitude(QVector3D arg)
|
||||
{
|
||||
if (h->rotate != arg) {
|
||||
h->rotate = arg;
|
||||
h->dirty = true;
|
||||
emit rotateChanged(rotate());
|
||||
if (h->attitude != arg) {
|
||||
h->attitude = arg;
|
||||
h->dirty = true;
|
||||
emit attitudeChanged(attitude());
|
||||
}
|
||||
}
|
||||
|
||||
QVector3D OSGTransformNode::translate() const
|
||||
QVector3D OSGTransformNode::position() const
|
||||
{
|
||||
return h->translate;
|
||||
return h->position;
|
||||
}
|
||||
|
||||
void OSGTransformNode::setTranslate(QVector3D arg)
|
||||
void OSGTransformNode::setPosition(QVector3D arg)
|
||||
{
|
||||
if (h->translate != arg) {
|
||||
h->translate = arg;
|
||||
h->dirty = true;
|
||||
emit translateChanged(translate());
|
||||
if (h->position != arg) {
|
||||
h->position = arg;
|
||||
h->dirty = true;
|
||||
emit positionChanged(position());
|
||||
}
|
||||
}
|
||||
} // namespace osgQtQuick
|
||||
|
@ -41,8 +41,8 @@ class OSGQTQUICK_EXPORT OSGTransformNode : public OSGNode {
|
||||
Q_PROPERTY(osgQtQuick::OSGNode *modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
|
||||
|
||||
Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged)
|
||||
Q_PROPERTY(QVector3D rotate READ rotate WRITE setRotate NOTIFY rotateChanged)
|
||||
Q_PROPERTY(QVector3D translate READ translate WRITE setTranslate NOTIFY translateChanged)
|
||||
Q_PROPERTY(QVector3D attitude READ attitude WRITE setAttitude NOTIFY attitudeChanged)
|
||||
Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
|
||||
|
||||
public:
|
||||
OSGTransformNode(QObject *parent = 0);
|
||||
@ -54,18 +54,18 @@ public:
|
||||
QVector3D scale() const;
|
||||
void setScale(QVector3D arg);
|
||||
|
||||
QVector3D rotate() const;
|
||||
void setRotate(QVector3D arg);
|
||||
QVector3D attitude() const;
|
||||
void setAttitude(QVector3D arg);
|
||||
|
||||
QVector3D translate() const;
|
||||
void setTranslate(QVector3D arg);
|
||||
QVector3D position() const;
|
||||
void setPosition(QVector3D arg);
|
||||
|
||||
signals:
|
||||
void modelDataChanged(OSGNode *node);
|
||||
|
||||
void scaleChanged(QVector3D arg);
|
||||
void rotateChanged(QVector3D arg);
|
||||
void translateChanged(QVector3D arg);
|
||||
void attitudeChanged(QVector3D arg);
|
||||
void positionChanged(QVector3D arg);
|
||||
|
||||
private:
|
||||
struct Hidden;
|
||||
|
@ -47,8 +47,7 @@ Item {
|
||||
OSGTransformNode {
|
||||
id: transformNode
|
||||
modelData: fileNode
|
||||
rotate: Qt.vector3d(UAV.attitudePitch(), UAV.attitudeRoll(), -UAV.attitudeYaw())
|
||||
//scale: Qt.vector3d(0.001, 0.001, 0.001)
|
||||
attitude: UAV.attitude()
|
||||
}
|
||||
|
||||
OSGFileNode {
|
||||
|
Loading…
Reference in New Issue
Block a user