mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +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);
|
transform->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL, osg::StateAttribute::ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rotate
|
// attitude
|
||||||
osg::Quat q = osg::Quat(
|
double roll = osg::DegreesToRadians(attitude.x());
|
||||||
osg::DegreesToRadians(rotate.x()), osg::Vec3d(1, 0, 0),
|
double pitch = osg::DegreesToRadians(attitude.y());
|
||||||
osg::DegreesToRadians(rotate.y()), osg::Vec3d(0, 1, 0),
|
double yaw = osg::DegreesToRadians(attitude.z());
|
||||||
osg::DegreesToRadians(rotate.z()), osg::Vec3d(0, 0, 1));
|
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);
|
transform->setAttitude(q);
|
||||||
|
|
||||||
// translate
|
// position
|
||||||
transform->setPosition(osg::Vec3d(translate.x(), translate.y(), translate.z()));
|
transform->setPosition(osg::Vec3d(position.x(), position.y(), position.z()));
|
||||||
}
|
}
|
||||||
|
|
||||||
OSGTransformNode *const self;
|
OSGTransformNode *const self;
|
||||||
@ -147,8 +150,8 @@ public:
|
|||||||
bool dirty;
|
bool dirty;
|
||||||
|
|
||||||
QVector3D scale;
|
QVector3D scale;
|
||||||
QVector3D rotate;
|
QVector3D attitude;
|
||||||
QVector3D translate;
|
QVector3D position;
|
||||||
|
|
||||||
private slots:
|
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) {
|
if (h->attitude != arg) {
|
||||||
h->rotate = arg;
|
h->attitude = arg;
|
||||||
h->dirty = true;
|
h->dirty = true;
|
||||||
emit rotateChanged(rotate());
|
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) {
|
if (h->position != arg) {
|
||||||
h->translate = arg;
|
h->position = arg;
|
||||||
h->dirty = true;
|
h->dirty = true;
|
||||||
emit translateChanged(translate());
|
emit positionChanged(position());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace osgQtQuick
|
} // 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(osgQtQuick::OSGNode *modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
|
||||||
|
|
||||||
Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged)
|
Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged)
|
||||||
Q_PROPERTY(QVector3D rotate READ rotate WRITE setRotate NOTIFY rotateChanged)
|
Q_PROPERTY(QVector3D attitude READ attitude WRITE setAttitude NOTIFY attitudeChanged)
|
||||||
Q_PROPERTY(QVector3D translate READ translate WRITE setTranslate NOTIFY translateChanged)
|
Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSGTransformNode(QObject *parent = 0);
|
OSGTransformNode(QObject *parent = 0);
|
||||||
@ -54,18 +54,18 @@ public:
|
|||||||
QVector3D scale() const;
|
QVector3D scale() const;
|
||||||
void setScale(QVector3D arg);
|
void setScale(QVector3D arg);
|
||||||
|
|
||||||
QVector3D rotate() const;
|
QVector3D attitude() const;
|
||||||
void setRotate(QVector3D arg);
|
void setAttitude(QVector3D arg);
|
||||||
|
|
||||||
QVector3D translate() const;
|
QVector3D position() const;
|
||||||
void setTranslate(QVector3D arg);
|
void setPosition(QVector3D arg);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modelDataChanged(OSGNode *node);
|
void modelDataChanged(OSGNode *node);
|
||||||
|
|
||||||
void scaleChanged(QVector3D arg);
|
void scaleChanged(QVector3D arg);
|
||||||
void rotateChanged(QVector3D arg);
|
void attitudeChanged(QVector3D arg);
|
||||||
void translateChanged(QVector3D arg);
|
void positionChanged(QVector3D arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Hidden;
|
struct Hidden;
|
||||||
|
@ -47,8 +47,7 @@ Item {
|
|||||||
OSGTransformNode {
|
OSGTransformNode {
|
||||||
id: transformNode
|
id: transformNode
|
||||||
modelData: fileNode
|
modelData: fileNode
|
||||||
rotate: Qt.vector3d(UAV.attitudePitch(), UAV.attitudeRoll(), -UAV.attitudeYaw())
|
attitude: UAV.attitude()
|
||||||
//scale: Qt.vector3d(0.001, 0.001, 0.001)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OSGFileNode {
|
OSGFileNode {
|
||||||
|
Loading…
Reference in New Issue
Block a user