Camera Rotation around a mesh



  • 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 ]
        }
    
    }
    
    

  • Moderators

    @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  
        }
    }
    


  • @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


  • Moderators

    @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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.