# Struggling with simple rotation in Qt3D

• I have imported a simple object from a .obj file and am attempting to rotate it about one of its own axis'. I know the x,y,z coordinates of the point I wish to rotate around from blender so I use the following code:

``````    Transform {
id: rotationTransform
matrix: {
var m = Qt.matrix4x4();
m.translate(Qt.vector3d(0.19707,0.75906,0.18050));
m.rotate(rotationTransform.userAngle, Qt.vector3d(1, 0, 0))
m.translate(Qt.vector3d(-0.19707, -0.75906,- 0.18050)); //applied first
return m;
}
}
``````

The result is completely different to what I expect however rotating about Qt.vector3d(0, 0, 1)) works fine. Furthermore m.translate only moves my object relative to where it is, I had the misunderstanding that the argument of the function was a vector centered at the origin.

All I want to do is rotate an object about its own Z axis- any help is appreciated.

• All I want to do is rotate an object about its own Z axis- any help is appreciated.

What's it's own z-axis? Is it the same as the global z-axis?
Move whatever you want to rotate to the origin (i.e. after translate it has to have (0, 0, 0) as coordinates), then rotate, then move it back to the original position.

• own z-axis? Is it the same as the global z-axis?
Move whatever you want to rotate to the origin (i.e. after translate

Thats the approach that my code above takes. The only problem is finding the coordinate of my point in qt3d after scaling it. I thought using the values from blender would work but this doesnt seem to be working. It would be great if anyone could suggest a method for finding out the x,y,z coordinate of a point in qt3d.

• No clue, but if you use the scene loader, then I think the coordinates should be in the transform of your mesh and accessible through the `translation` property.

• Based on this ([https://doc.qt.io/qt-5/qml-qt3d-render-sceneloader-members.html]) and what I tried in qml, sceneloader has no translation property.
I am currently loading .obj components into a mesh and then to find each of their x,y,z coordinates I translate them until I reach the origin (which I can visually see because creating a torusmesh for instance will have its centre on the origin ).
Needless to say, this isn't fun! There has to be an easier way to do this in qt3d itself..

• sceneloader has no translation property

The scene loader supposedly reads the whole scene and sets the components and entities correctly based on it, then your mesh should have its transform object properly set, if I understand it correctly. Again, I'm speculating here, I haven't done almost any coding with Qt3D.

I am currently loading .obj components into a mesh and then to find each of their x,y,z coordinates I translate them until I reach the origin (which I can visually see because creating a torusmesh for instance will have its centre on the origin ).

Your mesh should be centered about the origin if you do that. What I assume is that the vertex data is translated in the .obj file, so my advice is to export the mesh as centered around the origin, and after loading then move it to the proper position.