Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How do I set the center of rotation of a Qt3D scene to the center of the active .obj file in the scene?
Forum Updated to NodeBB v4.3 + New Features

How do I set the center of rotation of a Qt3D scene to the center of the active .obj file in the scene?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 188 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Danny141
    wrote on last edited by
    #1

    import QtQuick.Scene3D 2.13
    import Qt3D.Core 2.13
    import Qt3D.Render 2.13
    import Qt3D.Input 2.13
    import Qt3D.Logic 2.13
    import Qt3D.Extras 2.13

    import QtQuick.Controls 2.5
    import QtQuick.Dialogs 1.3
    import QtQuick 2.5 as QQ2

    ApplicationWindow
    {
    visible: true
    width: 1050
    height: 780
    title: qsTr("3D Viewer")
    flags: Qt | Qt.Window | Qt.FramelessWindowHint

    header: ToolBar
    {
        ToolButton
        {
            text: "Open 3D Model"
            onPressed:
            {
                fileDialog.open()
            }
        }
    }
    
    
    
    Scene3D
    {
        anchors.fill: parent
    
        aspects: ["input", "logic"]
        cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
    
        Entity {
            id: sceneRoot
    
    
            Camera {
                id: maincamera
                projectionType: CameraLens.PerspectiveProjection
                fieldOfView: 60
                aspectRatio:16.0 / 9.0
                nearPlane : 0.1
                farPlane : 1000.0
                position: Qt.vector3d( 0.0, 0.0, 30.0 )
                upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
                viewCenter: Qt.vector3d( 0, 0, 0 )
    
            }
    
    
    
           FirstPersonCameraController {
                          camera: maincamera
                      }
    
    
    
           ObjectPicker{
              id: spherePicker
              onPressed:{
                 console.log(maincamera.viewVector)
              }
           }
    
            components:[
                RenderSettings {
                    activeFrameGraph: ForwardRenderer {
                    camera: maincamera
                    clearColor:"#333333"
                    }
                },
    
                InputSettings { }
            ]
    
            PhongMaterial {
               id: material
               diffuse:"#CECECE"
            }
    
            TorusMesh {
                id: torusMesh
                radius:15
                minorRadius:6
                slices:16
                rings:32
                //source: "Monkey.obj"
    
             }
            Transform {
                    id: torusTransform
    
                    translation: Qt.vector3d(0, 0, 0)
                }
    
            Entity {
                id: torusEntity
                components: [ torusMesh, material, spherePicker,torusTransform]
            }
    
    
            Entity {
                id:pointLightEntity1
                PointLight{
                    id:pointLight1
                }
    
                Transform{
                    id:lightTransform1
                    translation:Qt.vector3d(0.0, 0.0, 30)
                }
    
                components:[pointLight1,lightTransform1]
            }
    
            Entity {
                id:pointLightEntity2
                PointLight{
                    id:pointLight2
                }
    
                Transform{
                    id:lightTransform2
                    translation:Qt.vector3d(0.0, 0.0, 30)
                }
    
                components:[pointLight2,lightTransform2]
            }
    
    
    
        }
    
    }
    

    }

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved