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. Animation, 3D development
Forum Updated to NodeBB v4.3 + New Features

Animation, 3D development

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
30 Posts 4 Posters 10.8k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #20

    Hi! Sorry, that it already just too complex / incomplete for me to test and help with. Can you boil it down to a simpler question or a minimal runnable example that I - or anyone else who reads this - can use to reproduce the issue?

    Naveen_DN 2 Replies Last reply
    0
    • ? A Former User

      Hi! Sorry, that it already just too complex / incomplete for me to test and help with. Can you boil it down to a simpler question or a minimal runnable example that I - or anyone else who reads this - can use to reproduce the issue?

      Naveen_DN Offline
      Naveen_DN Offline
      Naveen_D
      wrote on last edited by
      #21

      @Wieland ya sure.. i will reproduce it and post the example code..
      Can you please guide in the following issue also
      Thank you.
      https://forum.qt.io/topic/84633/camera-rotation-around-a-mesh

      Naveen_D

      1 Reply Last reply
      0
      • ? A Former User

        Hi! Sorry, that it already just too complex / incomplete for me to test and help with. Can you boil it down to a simpler question or a minimal runnable example that I - or anyone else who reads this - can use to reproduce the issue?

        Naveen_DN Offline
        Naveen_DN Offline
        Naveen_D
        wrote on last edited by
        #22

        @Wieland Hi,
        I have few doubts regarding rotating an object in 3D,
        For ex, i have a car model, which i have sliced in blender, to get door as a separate object and whole car as a separate object, i have exported both as .obj files and i have assembled them in the code.
        Now what is happening, when i try to rotate the door which is separate object using number animation, it is rotating with respect to car's origin not w.r.t to door's so, i want to rotate it based on it's own axis or origin. not w.r.t car's origin.
        I have tried the following code but didn't get the excepted result.

            // Car front door //
            Mesh {
                id: carDoorMesh
                source: "qrc:/Meshes/CarFrontDoor_modified.obj"
            }
        
            PhongMaterial{
                id: carDoorMaterial
            }
        
            Transform {
                id: carDoorTransform
                property real userAngle: 0.0
        
                matrix: {
                    var m= Qt.matrix4x4();
                    m.translate(Qt.vector3d(0.501096,1.5006,1.78036))
                    m.rotate(userAngle, Qt.vector3d(0,1,0))
                    m.translate(Qt.vector3d(-0.501096,-1.5006,-1.75036))
                    return m
                }
                 NumberAnimation on rotationY {
                            to: -45
                            duration: 1000
                            running: true
                        }
        }
        

        i got the respective values from blender.
        Any guidance is appreciated
        Thank you.

        Naveen_D

        ? 1 Reply Last reply
        0
        • Naveen_DN Naveen_D

          @Wieland Hi,
          I have few doubts regarding rotating an object in 3D,
          For ex, i have a car model, which i have sliced in blender, to get door as a separate object and whole car as a separate object, i have exported both as .obj files and i have assembled them in the code.
          Now what is happening, when i try to rotate the door which is separate object using number animation, it is rotating with respect to car's origin not w.r.t to door's so, i want to rotate it based on it's own axis or origin. not w.r.t car's origin.
          I have tried the following code but didn't get the excepted result.

              // Car front door //
              Mesh {
                  id: carDoorMesh
                  source: "qrc:/Meshes/CarFrontDoor_modified.obj"
              }
          
              PhongMaterial{
                  id: carDoorMaterial
              }
          
              Transform {
                  id: carDoorTransform
                  property real userAngle: 0.0
          
                  matrix: {
                      var m= Qt.matrix4x4();
                      m.translate(Qt.vector3d(0.501096,1.5006,1.78036))
                      m.rotate(userAngle, Qt.vector3d(0,1,0))
                      m.translate(Qt.vector3d(-0.501096,-1.5006,-1.75036))
                      return m
                  }
                   NumberAnimation on rotationY {
                              to: -45
                              duration: 1000
                              running: true
                          }
          }
          

          i got the respective values from blender.
          Any guidance is appreciated
          Thank you.

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

          @Naveen_D No offense, but this has nothing to do with Qt really but only with your lack of a basic understanding of how transformation matrices work. Seriously, get a book on linear algebra or you'll never get this to work.

          Naveen_DN 1 Reply Last reply
          1
          • ? A Former User

            @Naveen_D No offense, but this has nothing to do with Qt really but only with your lack of a basic understanding of how transformation matrices work. Seriously, get a book on linear algebra or you'll never get this to work.

            Naveen_DN Offline
            Naveen_DN Offline
            Naveen_D
            wrote on last edited by
            #24

            @Wieland Hi,
            If i want to give color animation for a particular part of the 3d object, here for eg, car tire or door etc how can i do that? i want to show color animation for car tire, from existing color to red and back to same color and once started, it should be running continuously.
            I tried with the following code within transform, but didn't get the result

            Transform{
                                id: frontRightDoorWheelTireTransform
                                property real userAngle: 0.0
                                property real userDistance: 0.0
                                matrix: {
                                    var m= Qt.matrix4x4();
                                    m.translate(0.57005,-0.462196,-2.27110)
                                    m.rotate(userAngle,Qt.vector3d(1,0,0))
                                    m.translate(-0.57005,0.462196,2.27110)
                                    return m;
                                }
                                translation: Qt.vector3d(userDistance,0,0)
            
                                ColorAnimation {
                                    id: frontRightDoorWheelTireAnimation
                                    from: "#171512"
                                    to: "red"
                                    duration: 2000
                                    running: true
                                }
            
                            }
            

            Thank you,
            Naveen

            Naveen_D

            1 Reply Last reply
            0
            • Naveen_DN Offline
              Naveen_DN Offline
              Naveen_D
              wrote on last edited by
              #25

              Any updates on the above query.. ?
              Thank you.

              Naveen_D

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

                What makes you think that you could apply a color animation to a spatial transformation? That doesn't make any sense.

                Naveen_DN 2 Replies Last reply
                1
                • ? A Former User

                  What makes you think that you could apply a color animation to a spatial transformation? That doesn't make any sense.

                  Naveen_DN Offline
                  Naveen_DN Offline
                  Naveen_D
                  wrote on last edited by Naveen_D
                  #27

                  @Wieland Ok thank you...

                  1. one more thing, i have a scene 3D function in which i am rendering my car entity, but i am not able to rotate it, when it runs the object is still at one place i am not able to move it. can you please guide me through this
                    here is the code
                  import QtQuick 2.5
                  import Qt3D.Core 2.0
                  import Qt3D.Render 2.0
                  import Qt3D.Input 2.0
                  import Qt3D.Extras 2.0
                  import QtQuick.Scene3D 2.0
                  import QtQuick.Window 2.2
                  import QtQuick.Controls 1.4
                  import QtQuick.Layouts 1.1
                  
                  ApplicationWindow {
                      id: appWindow
                      visible: true
                      width: Screen.width
                      height: Screen.height
                  
                      Rectangle {
                          width: parent.width
                          height: parent.height
                          color: "Transparent"
                  
                          // 3D scene
                          Scene3D {
                              id: scene3d
                              anchors.fill: parent
                              aspects: "input"
                  
                              Entity {
                                  id: root
                  
                                  components: [
                                      RenderSettings {
                                          activeFrameGraph: ForwardRenderer {
                                              clearColor: "#0D8EA2"
                                              camera: camera
                                          }
                                      },
                                      InputSettings { }
                                  ]
                  
                                  Camera {
                                      id: camera
                                      property real topPosition: 3.0
                                      property real topPos: 0.5
                                      projectionType: CameraLens.PerspectiveProjection
                                      fieldOfView: 25
                                      nearPlane : 0.1
                                      farPlane : 1000.0
                                      position: Qt.vector3d( 15.0, topPosition, 20.5)
                                      upVector: Qt.vector3d(0.0,1.0,0.0)
                                      viewCenter: carBodySlicedTransform.translation
                                  }
                  
                                  OrbitCameraController {camera: camera}
                                  // car Base
                                  Mesh{
                                      id: baseMesh
                                      source: "qrc:/Meshes/CarBase.obj"
                                  }
                                  PhongAlphaMaterial{
                                      id: baseMaterial
                                      diffuse: "#7bc0ce"
                                      alpha: 1.0
                                  }
                                  Transform{
                                      id: baseTransform
                                      translation: Qt.vector3d(0.0,-1.0,0.0)
                                  }
                  
                                  // car Body sliced
                                  Mesh {
                                      id: carBodySlicedMesh
                                      source: "qrc:/Meshes/CarBodySliced.obj"
                                  }
                  
                                  PhongAlphaMaterial {
                                      id: carBodySlicedMaterial
                                      shininess: 500.0
                                      specular: "#62788d"
                                      diffuse: "#62788d"
                                      alpha: 1.0
                                  }
                  
                                  Transform {
                                      id: carBodySlicedTransform
                                      property real userAngle: 0.0
                                      property real userDistance: 0.0
                                      property real xAngleValue: 0.0
                                      property real yAngleValue: 0.0
                                      property real zAngleValue: 0.0
                                      matrix: {
                                          var m = Qt.matrix4x4();
                                          m.rotate(userAngle, Qt.vector3d(xAngleValue, yAngleValue, zAngleValue));
                                          m.translate(Qt.vector3d(userDistance, 0, 0));
                                          return m;
                                      }
                                      translation: Qt.vector3d(0.0,0.0,0.0)
                                      NumberAnimation on rotationY {
                                          id: carAnimation
                                          to: 360
                                          duration: 5000
                                          running: false
                                      }
                                  }
                  
                                  // main car body entity
                                  Entity {
                                      id: carMainEntity
                                      components: [ carBodySlicedMesh, carBodySlicedMaterial, carBodySlicedTransform ]
                                      // car base entity
                                      Entity{
                                          id: carBaseEntity
                                          components: [baseMesh, baseMaterial, baseTransform]
                                      }
                                  }
                              }
                          }
                      }
                  
                  1. Also i want to know how to apply animation to zoom the car based certain condition for eg: if i want to show the engine part of the car then i want to zoom the car towards that particular part in show it using animation.
                    Thank you

                  Naveen_D

                  1 Reply Last reply
                  0
                  • Naveen_DN Offline
                    Naveen_DN Offline
                    Naveen_D
                    wrote on last edited by
                    #28

                    Hi, can anyone guide me.. regarding above question
                    Thank you

                    Naveen_D

                    1 Reply Last reply
                    0
                    • ? A Former User

                      What makes you think that you could apply a color animation to a spatial transformation? That doesn't make any sense.

                      Naveen_DN Offline
                      Naveen_DN Offline
                      Naveen_D
                      wrote on last edited by
                      #29

                      @Wieland Hi, how can i place the camera within the car, so that i can give the inside view of the car in 3D development environment.
                      Thank you

                      Naveen_D

                      1 Reply Last reply
                      0
                      • ? A Former User

                        Here's an almost minimal example in QML:

                        GearEntity.qml

                        import Qt3D.Core 2.0
                        import Qt3D.Render 2.0
                        import Qt3D.Input 2.0
                        import Qt3D.Extras 2.0
                        
                        Entity {
                            id: gearEntity
                        
                            Mesh {
                                id: gearMesh
                                source: "qrc:///assets/gear.obj"
                            }
                        
                            Transform {
                                id: gearTransform
                                scale3D: Qt.vector3d(45, 45, 45)
                                rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
                            }
                        
                            PhongMaterial {
                                id: gearMaterial
                            }
                        
                            Entity {
                                id: torusEntity
                                components: [ gearMesh, gearTransform, gearMaterial ]
                            }
                        
                        }
                        

                        RootEntity.qml

                        import Qt3D.Core 2.0
                        import Qt3D.Render 2.0
                        import Qt3D.Input 2.0
                        import Qt3D.Extras 2.0
                        
                        Entity {
                            id: rootEntity
                        
                            Camera {
                                id: camera
                                projectionType: CameraLens.PerspectiveProjection
                                fieldOfView: 45
                                nearPlane : 0.1
                                farPlane : 1000.0
                                position: Qt.vector3d( 0.0, 0.0, 40.0 )
                                upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
                                viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
                            }
                        
                            FirstPersonCameraController { camera: camera }
                        
                            components: [
                                RenderSettings {
                                    activeFrameGraph: ForwardRenderer {
                                        camera: camera
                                        clearColor: "transparent"
                                    }
                                },
                                InputSettings {}
                            ]
                        
                            GearEntity {}
                        }
                        

                        main.qml

                        import QtQuick 2.7
                        import QtQuick.Window 2.3
                        import QtQuick.Controls 2.0
                        import QtQuick.Layouts 1.3
                        import QtQuick.Scene3D 2.0
                        import Qt3D.Core 2.0
                        import Qt3D.Render 2.0
                        import Qt3D.Extras 2.0
                        
                        ApplicationWindow {
                            visible: true
                            visibility: Window.Maximized
                        
                            Rectangle {
                                anchors.fill: parent
                                gradient: Gradient {
                                    GradientStop { position: 0.0; color: "blue" }
                                    GradientStop { position: 1.0; color: "grey" }
                                }
                            }
                        
                            Scene3D {
                                id: scene3d
                                anchors.fill: parent
                                focus: true
                                aspects: ["input", "logic"]
                                cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
                                RootEntity {}
                            }
                        
                            Button {
                                text: "Exit"
                                onClicked: Qt.quit()
                            }
                        }
                        
                        S Offline
                        S Offline
                        Saeed Magdy
                        wrote on last edited by
                        #30

                        hi is there any good tutorial for this ? thanks

                        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