I am working on a simple 3D application where I am rotating the 3D object based on the Quaternion values that I read from the MPU6050 sensor.
I used the below code from simple-qml example as reference:
Entity {
id: sceneRoot
property real x: 0.5
property real y: -0.5
property real z: 0.5
property real w: 0.5
onWChanged: console.log("3W: "+w)
onXChanged: console.log("3X: "+x)
onYChanged: console.log("3Y: "+y)
onZChanged: console.log("3Z: "+z)
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 90
nearPlane : 0.1
farPlane : 100
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 { }
]
PhongMaterial {
id: material
}
Mesh
{
id: arrowMesh
source: "/3dObj/resources/3dObj/arrow.obj"
}
Transform
{
id: arrowTransform
//Default/Reset position
//Arrow head facing towards the screen
//x:90,y:90,z:0
property int eXAngle: 90
property int eYAngle: 90
property int eZAngle: 0
rotation:
{
//MPU6050 gives values in quaternion
Qt.quaternion(sceneRoot.w,sceneRoot.x,sceneRoot.y,sceneRoot.z)
}
scale: 0.05
}
Entity {
id: sphereEntity
components: [ arrowMesh, material, arrowTransform ]
}
}
The problem I am facing is that rotation happens around the head of the arrow (3D object) instead the centre of the arrow and also the object for certain quaternion values zooms.
What are the things I need to change so that I can rotate the object alone around its center without any zoom effects?
Also, I tried the three projectionTypes as well.
I need the 3D to behave like the one in the youtube link below: Arduino MPU6050 example