rahulch

Untitled

Mar 11th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.38 KB | None | 0 0
  1. import Qt3D.Core 2.12
  2. import Qt3D.Render 2.12
  3. import Qt3D.Extras 2.12
  4. import Qt3D.Input 2.12
  5. import QtQuick.Scene3D 2.12
  6. import QtQuick 2.12 as QQ2
  7.  
  8. Scene3D {
  9.     id: scene3d
  10.     anchors.fill: parent
  11.     focus: true
  12.     aspects: ["input", "logic"]
  13.     height: parent.height
  14.     width: parent.width
  15.     cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
  16.     Entity {
  17.         id: sceneRoot
  18.  
  19.         Camera {
  20.             id: camera
  21.             projectionType: CameraLens.PerspectiveProjection
  22.             fieldOfView: 45
  23.             nearPlane: 0.1
  24.             farPlane: 1000.0
  25.             position: Qt.vector3d(0.0, 0.0, 40.0)
  26.             upVector: Qt.vector3d(0.0, 1.0, 0.0)
  27.             viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
  28.         }
  29.  
  30.         FirstPersonCameraController {
  31.             camera: camera
  32.         }
  33.  
  34.         components: [
  35.             RenderSettings {
  36.                 activeFrameGraph: ForwardRenderer {
  37.                     camera: camera
  38.                     clearColor: "transparent"
  39.                     Viewport {
  40.                         id: viewport
  41.                         normalizedRect: Qt.rect(0, 0, 1, 1)
  42.                     }
  43.                 }
  44.             },
  45.             InputSettings {
  46.                 id: inputSettings
  47.             }
  48.         ]
  49.  
  50.         PhongMaterial {
  51.             id: material
  52.         }
  53.  
  54.         Mesh {
  55.             id: sphereMesh
  56. //             source: "images/face3d/face_bse_mesh.obj"
  57.             source: "images/robo-obj-pose4/source/d2f0cff60afc40f5afe79156ec7db657.obj"
  58.         }
  59.  
  60.         Transform {
  61.             id: modelTransform
  62.             property real userAngle: 0.0
  63.             matrix: {
  64.                 var m = Qt.matrix4x4()
  65.                 m.rotate(userAngle, Qt.vector3d(0, 1, 0))
  66. //                 m.translate(Qt.vector3d(20, 0, 0))
  67.                 return m
  68.             }
  69.         }
  70.        
  71.         QQ2.NumberAnimation {
  72.             target: modelTransform
  73.             property: "userAngle"
  74.             duration: 10000
  75.             from: 0
  76.             to: 360
  77.            
  78.             loops: QQ2.Animation.Infinite
  79.             running: true
  80.         }
  81.        
  82.         Entity {
  83.             id: sphereEntity
  84.             components: [sphereMesh, material, modelTransform]
  85.         }
  86.    
  87.         OrbitCameraController{
  88.             id: orbitCamera
  89.             camera: camera
  90.         }
  91.     }
  92. }
Add Comment
Please, Sign In to add comment