Created
April 25, 2017 12:44
-
-
Save theoriginalgri/88be555d85fcac9e7e65b0c449c4a46d to your computer and use it in GitHub Desktop.
Qt3D with QtMultimedia Camera
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.7 | |
import QtQuick.Controls 2.0 | |
import QtQuick.Layouts 1.0 | |
import QtMultimedia 5.5 as MM | |
import QtQuick.Scene3D 2.0 | |
import Qt3D.Core 2.0 | |
import Qt3D.Render 2.0 | |
import Qt3D.Input 2.0 | |
import Qt3D.Extras 2.0 | |
ApplicationWindow { | |
visible: true | |
width: 640 | |
height: 480 | |
title: qsTr("Hello World") | |
Rectangle { | |
anchors.fill: parent | |
MM.VideoOutput { | |
anchors.fill: parent | |
autoOrientation: true | |
source: MM.Camera { | |
} | |
} | |
// TODO: Move position bindings from the component to the Loader. | |
// Check all uses of 'parent' inside the root element of the component. | |
// Rename all outer uses of the id "camera" to "loader_Scene3D.item.camera". | |
Component { | |
id: component_Scene3D | |
Scene3D { | |
property alias camera: inner_camera | |
//anchors.centerIn: parent | |
width: 300 | |
height: 300 | |
Entity { | |
Camera { | |
id: inner_camera | |
projectionType: CameraLens.PerspectiveProjection | |
fieldOfView: 45 | |
aspectRatio: 16/9 | |
nearPlane : 0.1 | |
farPlane : 5000.0 | |
position: Qt.vector3d( 0.0, 0.0, 5.0 ) | |
upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) | |
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) | |
} | |
components: [ | |
RenderSettings { | |
activeFrameGraph: ForwardRenderer { | |
clearColor: Qt.rgba(0, 0.5, 1, 1) | |
camera: camera | |
} | |
}, | |
// Event Source will be set by the Qt3DQuickWindow | |
InputSettings { | |
} | |
] | |
} | |
} | |
} | |
Loader { | |
id: loader_Scene3D | |
anchors.centerIn: parent | |
// sourceComponent: component_Scene3D | |
} | |
Button { | |
anchors.centerIn: parent | |
text: "Load Scene3D" | |
onClicked: loader_Scene3D.sourceComponent = component_Scene3D | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment