Solved QT 3D
-
Hi ,
I am new to qt3d.i have a requirement like i need to load external 3d models(*.obj or *.stl) to a surface3d with xyz axis.thanks in advance for any help
Jafar
-
Hi @Jafar-VM. Months ago I develop this single example trying to do it, and It works.
https://gitlab.com/homerooria/3d-model-rotation
I hope this helps you. If you have any doubt, don't hesitate to ask.
Good luck
-
Hi ,
Thanks for ur help.
can we draw xyz axis along with that scene3d?
-
@Jafar-VM Yes, you can. In fact, the final version of the prototype I send you has an XYZ axis in the corner of the scene. But, unfortunately, it belongs to a commercial app.
Now that you know is possible, do you want to think over it and try by yourself? Or you want that I upload the code?
Clues:
- Do a 3dmodel of an arrow.
- Load it into your app and make three Entities.
- Modify the rotation axis to fulfill your requirements.
If you have any doubts, don't hesitate to ask!!!!!
Good luck
-
@oria66 it would be great if you could share the code.
thanks in advance
-
@Jafar-VM. Here there are the Entities. Enjoy!!!!
Entity{ id: axisManipulationEntity Transform { id: carTransform3 property real userAngle: 0.0 matrix: { var m = Qt.matrix4x4(); m.rotate(userAngle, Qt.vector3d(0, 0, 1)); return m; } } components: [ , , carTransform3] Entity { id: arrowZEntity Mesh{ id:axisZ source: "res/arrow.obj" } PhongMaterial{ id: zMaterial ambient: Qt.rgba(0.0, 0.0, 1.0, 1.0) diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0) specular: Qt.rgba(0.5, 0.5, 0.5, 1.0) shininess: 150.0 } Transform { id: arrowZTransform property real userAngle: 0.0 property real x: 0 property real y: 0 property real z: 0 rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), 0) matrix: { var m = Qt.matrix4x4(); m.rotate(userAngle, Qt.vector3d(0, 1, 0)) m.translate(Qt.vector3d(x, y, z)) return m; } } components: [ axisZ, zMaterial, arrowZTransform] } Entity { id: arrowXEntity Mesh{ id:axisX source: "res/arrow.obj" } PhongMaterial{ id: xMaterial ambient: Qt.rgba(1.0, 0.0, 0.0, 1.0) diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0) specular: Qt.rgba(0.5, 0.5, 0.5, 1.0) shininess: 150.0 } Transform { id: arrowXTransform property real userAngle: 0.0 property real x: 0 property real y: 0 property real z: 0 rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), 90) matrix: { var m = Qt.matrix4x4(); m.rotate(userAngle + 90, Qt.vector3d(0, 1, 0)) m.translate(Qt.vector3d(x, y, z)) return m; } } components: [ axisX, xMaterial, arrowXTransform] } Entity { id: arrowYEntity Mesh{ id:axisY source: "res/arrow.obj" } PhongMaterial{ id: yMaterial ambient: Qt.rgba(0.0, 1.0, 0.0, 1.0) diffuse: Qt.rgba(0.5, 0.5, 0.5, 1.0) specular: Qt.rgba(0.5, 0.5, 0.5, 1.0) shininess: 150.0 } Transform { id: arrowYTransform property real userAngle: 0.0 property real x: 0 property real y: 0 property real z: 0 matrix: { var m = Qt.matrix4x4(); m.rotate(-90, Qt.vector3d(1, 0, 0)) m.translate(Qt.vector3d(x, y, z)) return m; } } components: [ axisY, yMaterial, arrowYTransform] } }
Good luck
-