[Interest] why do I don't see my 3d mesh ?

jagernicolas at legtux.org jagernicolas at legtux.org
Mon Jun 25 16:32:09 CEST 2018


 

still stuck with this issue. 

On 2018-06-23 16:40, jagernicolas at legtux.org wrote: 

> Hi, 
> 
> I failed to load a 3d object with the following code: 
> 
> **- main.cpp**
> 
> #include <QGuiApplication>
> #include <QQmlApplicationEngine>
> 
> int main(int argc, char *argv[])
> {
> QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
> 
> QGuiApplication app(argc, argv);
> 
> QQmlApplicationEngine engine;
> engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
> if (engine.rootObjects().isEmpty())
> return -1;
> 
> return app.exec();
> }
> 
> **- main.qml**
> 
> import QtQuick.Window 2.2
> import QtQuick.Controls 2.2
> import QtQuick.Dialogs 1.2
> 
> 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
> 
> import QtQuick.Layouts 1.3
> 
> ApplicationWindow
> {
> visible: true
> width: 640
> height: 480
> title: qsTr("3D Viewer")
> 
> header: ToolBar
> {
> RowLayout
> {
> anchors.fill: parent
> ToolButton
> {
> id: exitBtn
> text: "Exit"
> onPressed:
> {
> Qt.quit()
> }
> }
> ToolButton
> {
> id: loadModelBtn
> text: "Load Model"
> onPressed:
> {
> fileDialog.open()
> }
> }
> }
> }
> 
> FileDialog
> {
> id: fileDialog
> onAccepted:
> {
> mesh.source = fileDialog.fileUrl
> }
> }
> 
> Scene3D
> {
> anchors.fill: parent
> 
> aspects: ["input", "logic"]
> cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
> 
> Entity
> {
> id: sceneRoot
> 
> Camera
> {
> id: camera
> projectionType: CameraLens.PerspectiveProjection
> fieldOfView: 30
> aspectRatio: 16/9
> nearPlane : 0.1
> farPlane : 1000.0
> position: Qt.vector3d( 20.0, 0.0, 0.0 )
> upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
> viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
> }
> 
> OrbitCameraController
> {
> camera: camera
> }
> 
> components: [
> RenderSettings
> {
> activeFrameGraph: ForwardRenderer
> {
> clearColor: Qt.rgba(0, 0.5, 1, 1)
> camera: camera
> }
> },
> InputSettings
> {
> }
> ]
> 
> Entity {
> components: [
> Mesh {
> id: mesh
> },
> Material {
> id: material
> parameters: [
> Parameter { name: "color"; value: "green" }
> ]
> }
> ]
> }
> 
> }
> }
> }
> 
> I paste the whole code but hen I changed the word `Mesh` for `SceneLoader` I can load my obj file without problem. I guess there is something I miss in the case of the `mesh`. 
> 
> nb : I can upload the whole project if required. 
> 
> regards, 
> 
> // Nicolas Jäger 
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest [1]

 

Links:
------
[1] http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180625/bc61b124/attachment.html>


More information about the Interest mailing list