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. Camera Rotation around a mesh
Forum Updated to NodeBB v4.3 + New Features

Camera Rotation around a mesh

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 2.3k Views 3 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.
  • Naveen_DN Offline
    Naveen_DN Offline
    Naveen_D
    wrote on last edited by
    #1

    Hi all,
    I am using 3D in qml and trying a simple example of torusmesh. What i am doing is, i have an entity within which i have camera, material, transform and torus mesh, what i want to do is, to fix the camera and move the mesh and all x,y,z direction (i want to rotate the mesh in 360deg) i am trying with the following code but that is not happening. can anyone guide me through this ?
    Thank you
    here is the code :

    import QtQuick 2.2
    import Qt3D.Core 2.0
    import Qt3D.Render 2.0
    import Qt3D.Input 2.0
    import Qt3D.Extras 2.0
    
    Entity {
        id: sceneRoot
    
        Camera {
            id: camera
            projectionType: CameraLens.PerspectiveProjection
            fieldOfView: 45
            aspectRatio: 16/9
            nearPlane : 0.1
            farPlane : 1000.0
            position: Qt.vector3d( 0, 0.0, 20.0 )
            upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
            viewCenter: torusTransform.translation
        }
    
    //    OrbitCameraController {camera: camera}
        FirstPersonCameraController { camera: camera}
    
        components: [
            RenderSettings {
                activeFrameGraph: ForwardRenderer {
                    clearColor: Qt.rgba(0, 0.5, 1, 1)
                    camera: camera
                }
            },
            // Event Source will be set by the Qt3DQuickWindow
            InputSettings { }
        ]
    
        PhongMaterial {
            id: material
        }
    
        TorusMesh {
            id: torusMesh
            radius: 5
            minorRadius: 1
            rings: 100
            slices: 20        
        }
    
        Transform {
            id: torusTransform
            scale3D: Qt.vector3d(1.5, 1, 0.5)
            rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
            translation: Qt.vector3d(0,0,0)
        }
    
        Entity {
            id: torusEntity
    
            components: [ torusMesh, material, torusTransform ]
        }
    
    }
    
    

    Naveen_D

    1 Reply Last reply
    1
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      @Naveen_D said in Camera Rotation around a mesh:

      (i want to rotate the mesh in 360deg)

      Transform {
          id: transf
          NumberAnimation on rotationY { 
              to: 360
              duration: 1000
              running: true  
          }
      }
      
      Naveen_DN 1 Reply Last reply
      2
      • ? A Former User

        @Naveen_D said in Camera Rotation around a mesh:

        (i want to rotate the mesh in 360deg)

        Transform {
            id: transf
            NumberAnimation on rotationY { 
                to: 360
                duration: 1000
                running: true  
            }
        }
        
        Naveen_DN Offline
        Naveen_DN Offline
        Naveen_D
        wrote on last edited by Naveen_D
        #3

        @Wieland Thank you for the reply,

        I got the output, but another thing is i want to rotate it using the mouse cursor, is it possible ?
        I want to rotate the car like this,

        Dodge Viper

        Thank you

        Naveen_D

        ? 1 Reply Last reply
        3
        • Naveen_DN Naveen_D

          @Wieland Thank you for the reply,

          I got the output, but another thing is i want to rotate it using the mouse cursor, is it possible ?
          I want to rotate the car like this,

          Dodge Viper

          Thank you

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @Naveen_D I don't know how to do this. There is very little documentation for Qt3D. You need to study the sources: http://code.qt.io/cgit/qt/qt3d.git/tree/src

          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