How do I rotate an object around specified axis?
-
wrote on 19 Sept 2018, 05:08 last edited by
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. -
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. -
@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. -
@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.@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.
-
@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.
wrote on 19 Sept 2018, 07:41 last edited by Ronak5Ok 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" } }
-
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" } }
@Ronak5
ok,
all QtQuick items have a "rotation" property/function, you can see details here:
http://doc.qt.io/qt-5/qml-qtquick-rotation.htmlshould 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 -
@Ronak5
ok,
all QtQuick items have a "rotation" property/function, you can see details here:
http://doc.qt.io/qt-5/qml-qtquick-rotation.htmlshould 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=zCBESbHSR1kwrote on 19 Sept 2018, 07:53 last edited by@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.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.!@Ronak5
here's a very basic example (working) its with a rectangle, but its the same for an imageimport 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 } }
-
@Ronak5
here's a very basic example (working) its with a rectangle, but its the same for an imageimport 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 } }
wrote on 19 Sept 2018, 08:38 last edited byOh, 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/10