qt - 使用 Qt3D 加载 .FBX 文件
问题描述
我对 QT 很陌生。我正在按照示例将 .FBX 文件加载到对话框中。
ToolButton
单击以将 .FBX 文件加载到Scene3D
:
main.qml
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Scene3D 2.0
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Extras 2.0
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: 30
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 1000.0
position: Qt.vector3d( 10.0, 0.0, 0.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
}
OrbitCameraController
{
camera: camera
}
components: [
RenderSettings
{
activeFrameGraph: ForwardRenderer
{
clearColor: Qt.rgba(0, 0.5, 1, 1)
camera: camera
}
},
InputSettings
{
}
]
Entity
{
id: monkeyEntity
components: [
SceneLoader
{
id: sceneLoader
}
]
}
}
}
}
但是,对话框甚至没有打开并终止并出现以下错误:
terminate called after throwing an instance of 'std::bad_alloc'
不太确定它来自哪里,因为我无法调试到.qml
文件中。
解决方案
推荐阅读
- swift - Java 服务器的 Swift RSA 加密公钥失败
- server - 访问在 Hyper-V 中运行的虚拟服务器
- reactjs - 路由更改时反应路由器的位置状态变为未定义
- typescript - Typescript 包到一个 .js 文件
- kubernetes - 如何将 k8s yaml 转换为 helm chart
- python - 同一棵树 | leetcode错误复杂度分析解决方案
- laravel-5 - 在 ubuntu 16 上运行作曲家时出现 Permission denied 错误
- javascript - 引导模态不关闭角度js
- json - JSON 数据未显示在 Ionic HTML 文件中
- lua - Tarantool 预读限制已达到警告