Reputation: 271
I am trying to rotate my stl. file in the screen in x,y,z dimensions. My whole main.qml code is here:
ApplicationWindow
{
visible: true
width: 640
height: 480
title: qsTr("3D Viewer")
header: ToolBar
{
ToolButton
{
text: "Open 3D Model"
onPressed:
{
fileDialog.open()
}
}
}
FileDialog
{
id: fileDialog
onAccepted:
{
sceneLoader.source = fileDialog.fileUrl
}
}
Scene3D
{
anchors.fill: parent
aspects: ["input", "logic"]
cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
Entity
{
id: sceneRoot
Camera
{
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 90
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 100.0
position: Qt.vector3d( 0.0,-40.0, 10.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 10.0, 0.0, 0.0 )
}
OrbitCameraController
{
camera: camera
}
components: [
RenderSettings
{
activeFrameGraph: ForwardRenderer
{
clearColor: Qt.rgba(0.0,1, 1, 1)
camera: camera
}
},
InputSettings
{
}
]
Entity
{
id: satEntity
components: [
SceneLoader
{
id: sceneLoader
}
]
Transform {
id: satTransform
scale: 0.3
rotation: Qt.vector3d(0.0, 0.0, 0.0)
translation: Qt.vector3d(0.0, 0.0, 1)
rotationX: 0
rotationY: 0
rotationZ: 0
}
}
}
}
}
But its rotation doesn't change even I change the rotationX, rotationY, and rotationZ. Moreover there is no error it works but it always in the same position. It is basic but I don't know where I fail.
Upvotes: 0
Views: 237
Reputation: 271
I have solved the problem and I share it for one who may see the same problem in the future.
ApplicationWindow
{
visible: true
width: 640
height: 480
title: qsTr("3D Viewer")
header: ToolBar
{
ToolButton
{
text: "Open 3D Model"
onPressed:
{
fileDialog.open()
}
}
}
FileDialog
{
id: fileDialog
onAccepted:
{
sceneLoader.source = fileDialog.fileUrl
}
}
Scene3D
{
anchors.fill: parent
aspects: ["input", "logic"]
cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
Entity
{
id: sceneRoot
Camera
{
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 90
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 100.0
position: Qt.vector3d( 0.0,-40.0, 10.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 10.0, 0.0, 0.0 )
}
OrbitCameraController
{
camera: camera
}
components: [
RenderSettings
{
activeFrameGraph: ForwardRenderer
{
clearColor: Qt.rgba(0.0,1, 1, 1)
camera: camera
}
},
InputSettings
{
}
]
Entity
{
id: satEntity
components: [
SceneLoader
{
id: sceneLoader
},
Transform {
id: satTransform
rotationX: 0 //you can type whatever you want.
rotationY: 0 //you can type whatever you want.
rotationZ: 0 //you can type whatever you want.
}
]
}
}
}
}
Upvotes: 1