mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
LP-29 added ModelView qml files
This commit is contained in:
parent
98eb9b259e
commit
10aaafb678
9
ground/gcs/src/share/qml/ModelView.qml
Normal file
9
ground/gcs/src/share/qml/ModelView.qml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import QtQuick 2.4
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Loader {
|
||||||
|
anchors.fill: parent
|
||||||
|
focus: true
|
||||||
|
source: qmlWidget.terrainEnabled ? "model/ModelTerrainView.qml" : "model/ModelView.qml"
|
||||||
|
}
|
||||||
|
}
|
109
ground/gcs/src/share/qml/model/ModelTerrainView.qml
Normal file
109
ground/gcs/src/share/qml/model/ModelTerrainView.qml
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
import QtQuick 2.4
|
||||||
|
import osgQtQuick 1.0
|
||||||
|
import PfdQmlEnums 1.0
|
||||||
|
|
||||||
|
OSGViewport {
|
||||||
|
anchors.fill: parent
|
||||||
|
focus: true
|
||||||
|
sceneData: skyNode
|
||||||
|
camera: camera
|
||||||
|
|
||||||
|
OSGSkyNode {
|
||||||
|
id: skyNode
|
||||||
|
sceneData: sceneGroup
|
||||||
|
dateTime: getDateTime()
|
||||||
|
minimumAmbientLight: qmlWidget.minimumAmbientLight
|
||||||
|
|
||||||
|
function getDateTime() {
|
||||||
|
switch(qmlWidget.timeMode) {
|
||||||
|
case Pfd.Local:
|
||||||
|
return new Date();
|
||||||
|
case Pfd.PredefinedTime:
|
||||||
|
return qmlWidget.dateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGGroup {
|
||||||
|
id: sceneGroup
|
||||||
|
children: [ terrainNode, modelNode ]
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGFileNode {
|
||||||
|
id: terrainNode
|
||||||
|
source: qmlWidget.terrainFile
|
||||||
|
async: false
|
||||||
|
optimizeMode: OSGFileNode.OptimizeAndCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGModelNode {
|
||||||
|
id: modelNode
|
||||||
|
clampToTerrain: true
|
||||||
|
modelData: modelTransformNode
|
||||||
|
sceneData: terrainNode
|
||||||
|
|
||||||
|
attitude: uavAttitude()
|
||||||
|
position: uavPosition()
|
||||||
|
|
||||||
|
function uavAttitude() {
|
||||||
|
return Qt.vector3d(AttitudeState.Pitch, AttitudeState.Roll, -AttitudeState.Yaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
function uavPosition() {
|
||||||
|
switch(GPSPositionSensor.Status) {
|
||||||
|
case 2: // Fix2D
|
||||||
|
case 3: // Fix3D
|
||||||
|
return uavGPSPosition();
|
||||||
|
case 0: // NoGPS
|
||||||
|
case 1: // NoFix
|
||||||
|
default:
|
||||||
|
return (HomeLocation.Set == 1) ? uavHomePosition() : uavDefaultPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function uavGPSPosition() {
|
||||||
|
return Qt.vector3d(
|
||||||
|
GPSPositionSensor.Longitude / 10000000.0,
|
||||||
|
GPSPositionSensor.Latitude / 10000000.0,
|
||||||
|
GPSPositionSensor.Altitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
function uavHomePosition() {
|
||||||
|
return Qt.vector3d(
|
||||||
|
HomeLocation.Longitude / 10000000.0,
|
||||||
|
HomeLocation.Latitude / 10000000.0,
|
||||||
|
HomeLocation.Altitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
function uavDefaultPosition() {
|
||||||
|
return Qt.vector3d(qmlWidget.longitude, qmlWidget.latitude, qmlWidget.altitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGTransformNode {
|
||||||
|
id: modelTransformNode
|
||||||
|
// model dimensions are in mm, scale to meters
|
||||||
|
scale: Qt.vector3d(0.001, 0.001, 0.001)
|
||||||
|
modelData: modelFileNode
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGFileNode {
|
||||||
|
id: modelFileNode
|
||||||
|
source: qmlWidget.modelFile
|
||||||
|
async: false
|
||||||
|
optimizeMode: OSGFileNode.OptimizeAndCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGCamera {
|
||||||
|
id: camera
|
||||||
|
fieldOfView: 90
|
||||||
|
logarithmicDepthBuffer: true
|
||||||
|
manipulatorMode: OSGCamera.Track
|
||||||
|
// use model to compute camera home position
|
||||||
|
node: modelTransformNode
|
||||||
|
// model will be tracked
|
||||||
|
trackNode: modelTransformNode
|
||||||
|
}
|
||||||
|
}
|
47
ground/gcs/src/share/qml/model/ModelView.qml
Normal file
47
ground/gcs/src/share/qml/model/ModelView.qml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import QtQuick 2.4
|
||||||
|
import osgQtQuick 1.0
|
||||||
|
import PfdQmlEnums 1.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
|
||||||
|
OSGViewport {
|
||||||
|
anchors.fill: parent
|
||||||
|
focus: true
|
||||||
|
sceneData: sceneNode
|
||||||
|
camera: camera
|
||||||
|
|
||||||
|
OSGGroup {
|
||||||
|
id: sceneNode
|
||||||
|
children: [
|
||||||
|
transformNode,
|
||||||
|
backgroundNode
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGBackgroundNode {
|
||||||
|
id: backgroundNode
|
||||||
|
imageFile: qmlWidget.backgroundImageFile
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGTransformNode {
|
||||||
|
id: transformNode
|
||||||
|
modelData: fileNode
|
||||||
|
rotate: Qt.vector3d(AttitudeState.Pitch, AttitudeState.Roll, -AttitudeState.Yaw)
|
||||||
|
//scale: Qt.vector3d(0.001, 0.001, 0.001)
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGFileNode {
|
||||||
|
id: fileNode
|
||||||
|
source: qmlWidget.modelFile
|
||||||
|
async: false
|
||||||
|
optimizeMode: OSGFileNode.OptimizeAndCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
OSGCamera {
|
||||||
|
id: camera
|
||||||
|
fieldOfView: 90
|
||||||
|
node: transformNode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user