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 rotate an object around specified axis?
Forum Updated to NodeBB v4.3 + New Features

How do I rotate an object around specified axis?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
10 Posts 3 Posters 1.7k Views 2 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.
  • R Offline
    R Offline
    Ronak5
    wrote on 19 Sept 2018, 05:08 last edited by
    #1

    Hi there,
    I want to rotate an object around one axis and show it's 360 view..like 3d view.
    Please help how can it be achieved. Thanks.

    K 1 Reply Last reply 19 Sept 2018, 07:21
    0
    • R Ronak5
      19 Sept 2018, 05:08

      Hi there,
      I want to rotate an object around one axis and show it's 360 view..like 3d view.
      Please help how can it be achieved. Thanks.

      K Offline
      K Offline
      koahnig
      wrote on 19 Sept 2018, 07:21 last edited by
      #2

      @Ronak5

      You need to give details on what you have already as starting point.

      Vote the answer(s) that helped you to solve your issue(s)

      R 1 Reply Last reply 19 Sept 2018, 07:27
      0
      • K koahnig
        19 Sept 2018, 07:21

        @Ronak5

        You need to give details on what you have already as starting point.

        R Offline
        R Offline
        Ronak5
        wrote on 19 Sept 2018, 07:27 last edited by
        #3

        @koahnig
        thanks for reply..so like I've a static car object/image which I want to rotate around it's centre continuously and show it's complete view.

        K J 2 Replies Last reply 19 Sept 2018, 07:36
        0
        • R Ronak5
          19 Sept 2018, 07:27

          @koahnig
          thanks for reply..so like I've a static car object/image which I want to rotate around it's centre continuously and show it's complete view.

          K Offline
          K Offline
          koahnig
          wrote on 19 Sept 2018, 07:36 last edited by
          #4

          @Ronak5

          What are the Qt classes you are using?

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • R Ronak5
            19 Sept 2018, 07:27

            @koahnig
            thanks for reply..so like I've a static car object/image which I want to rotate around it's centre continuously and show it's complete view.

            J Offline
            J Offline
            J.Hilk
            Moderators
            wrote on 19 Sept 2018, 07:36 last edited by
            #5

            @Ronak5
            thats still not enough information. Is it a 2d canvas, an image, a 3d model etc.

            I would suggest posting the qml code you use to display the non rotationg car.


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            R 1 Reply Last reply 19 Sept 2018, 07:41
            2
            • J J.Hilk
              19 Sept 2018, 07:36

              @Ronak5
              thats still not enough information. Is it a 2d canvas, an image, a 3d model etc.

              I would suggest posting the qml code you use to display the non rotationg car.

              R Offline
              R Offline
              Ronak5
              wrote on 19 Sept 2018, 07:41 last edited by Ronak5
              #6

              @J.Hilk

              Ok sure.. so it's just a whole image of a car with few image parts of the car like doors on it(as of now doors only). But yea it's just a image source.

              Image {
                  id: car1
                  x: 500
                  y: 160
                  width: 293
                  height: 330
                  source: "car-1.png"
                  opacity:1
              
                  Image {
                      id: door1
                      x: -28
                      y: 17
                      width: 338
                      height: 365
                      visible: be.door1
                      source: "door-1.png"
                  }
              
                  Image {
                      id: door3
                      x: -16
                      y: 17
                      width: 338
                      height: 365
                      visible: be.door3
                      source: "door-3.png"
                  }
              
              
                  Image {
                      id: door2
                      x: -22
                      y: -63
                      width: 338
                      height: 365
                      visible:be.door2
                      source: "door-2.png"
                  }
              
                  Image {
                      id: door4
                      x: -22
                      y: -63
                      width: 338
                      height: 365
                      visible: be.door4
                      source: "door-4.png"
                  }
              }
              
              J 1 Reply Last reply 19 Sept 2018, 07:46
              0
              • R Ronak5
                19 Sept 2018, 07:41

                @J.Hilk

                Ok sure.. so it's just a whole image of a car with few image parts of the car like doors on it(as of now doors only). But yea it's just a image source.

                Image {
                    id: car1
                    x: 500
                    y: 160
                    width: 293
                    height: 330
                    source: "car-1.png"
                    opacity:1
                
                    Image {
                        id: door1
                        x: -28
                        y: 17
                        width: 338
                        height: 365
                        visible: be.door1
                        source: "door-1.png"
                    }
                
                    Image {
                        id: door3
                        x: -16
                        y: 17
                        width: 338
                        height: 365
                        visible: be.door3
                        source: "door-3.png"
                    }
                
                
                    Image {
                        id: door2
                        x: -22
                        y: -63
                        width: 338
                        height: 365
                        visible:be.door2
                        source: "door-2.png"
                    }
                
                    Image {
                        id: door4
                        x: -22
                        y: -63
                        width: 338
                        height: 365
                        visible: be.door4
                        source: "door-4.png"
                    }
                }
                
                J Offline
                J Offline
                J.Hilk
                Moderators
                wrote on 19 Sept 2018, 07:46 last edited by
                #7

                @Ronak5
                ok,
                all QtQuick items have a "rotation" property/function, you can see details here:
                http://doc.qt.io/qt-5/qml-qtquick-rotation.html

                should work for images as well,

                but you won't be able to make a true 3d rotaion with 2d images

                for that you would need to go into qt3d,

                theres a "demo" by KDAB, here's a yt-link for that. Not sure if the source code is public available.
                https://www.youtube.com/watch?v=zCBESbHSR1k


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                R 1 Reply Last reply 19 Sept 2018, 07:53
                1
                • J J.Hilk
                  19 Sept 2018, 07:46

                  @Ronak5
                  ok,
                  all QtQuick items have a "rotation" property/function, you can see details here:
                  http://doc.qt.io/qt-5/qml-qtquick-rotation.html

                  should work for images as well,

                  but you won't be able to make a true 3d rotaion with 2d images

                  for that you would need to go into qt3d,

                  theres a "demo" by KDAB, here's a yt-link for that. Not sure if the source code is public available.
                  https://www.youtube.com/watch?v=zCBESbHSR1k

                  R Offline
                  R Offline
                  Ronak5
                  wrote on 19 Sept 2018, 07:53 last edited by
                  #8

                  @J.Hilk
                  hey thanks a lot for the hints. So I had gone through the "rotation" property.
                  But with the explanation there, looks for each rotation tag it needs same image source everytime and output i get is multiple different rotated images.
                  What i was looking for specifically is infinitely rotating the image only.

                  And I've been going through 3d examples also, but got nothing concrete as of now. I'll go through the link posted above.
                  Please update if you could provide any more inputs here.
                  Appreciate your help. Thanks again.!

                  J 1 Reply Last reply 19 Sept 2018, 08:01
                  0
                  • R Ronak5
                    19 Sept 2018, 07:53

                    @J.Hilk
                    hey thanks a lot for the hints. So I had gone through the "rotation" property.
                    But with the explanation there, looks for each rotation tag it needs same image source everytime and output i get is multiple different rotated images.
                    What i was looking for specifically is infinitely rotating the image only.

                    And I've been going through 3d examples also, but got nothing concrete as of now. I'll go through the link posted above.
                    Please update if you could provide any more inputs here.
                    Appreciate your help. Thanks again.!

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 19 Sept 2018, 08:01 last edited by
                    #9

                    @Ronak5
                    here's a very basic example (working) its with a rectangle, but its the same for an image

                    import QtQuick 2.9
                    import QtQuick.Window 2.2
                    
                    Window {
                        id:root
                        visible: true
                        width: 640
                        height: 480
                        title: qsTr("Hello World")
                    
                        Rectangle{
                            id: redRect
                    
                            anchors.centerIn: parent
                    
                            color: "red"
                    
                            height: Math.min(root.height, root.width) /3
                            width:  height
                    
                        }
                    
                        Timer{
                            id:rotateTimer
                    
                            interval: 20
                            repeat: true
                            running: true
                    
                            onTriggered: redRect.rotation = redRect.rotation + 1
                        }
                    }
                    
                    

                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    R 1 Reply Last reply 19 Sept 2018, 08:38
                    1
                    • J J.Hilk
                      19 Sept 2018, 08:01

                      @Ronak5
                      here's a very basic example (working) its with a rectangle, but its the same for an image

                      import QtQuick 2.9
                      import QtQuick.Window 2.2
                      
                      Window {
                          id:root
                          visible: true
                          width: 640
                          height: 480
                          title: qsTr("Hello World")
                      
                          Rectangle{
                              id: redRect
                      
                              anchors.centerIn: parent
                      
                              color: "red"
                      
                              height: Math.min(root.height, root.width) /3
                              width:  height
                      
                          }
                      
                          Timer{
                              id:rotateTimer
                      
                              interval: 20
                              repeat: true
                              running: true
                      
                              onTriggered: redRect.rotation = redRect.rotation + 1
                          }
                      }
                      
                      
                      R Offline
                      R Offline
                      Ronak5
                      wrote on 19 Sept 2018, 08:38 last edited by
                      #10

                      @J.Hilk

                      Oh, so you've used a timer here and just applied rotate on image. Wow! I never knew there's something like this could be done. This shall help atleast for 2d-rotation I believe. Thanks a lot man! This is something new I've learned today!

                      1 Reply Last reply
                      0

                      1/10

                      19 Sept 2018, 05:08

                      • Login

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