2017-05 http://blog.qt.io/blog/2017/05/24/qt3d/ Qt3D future 5.9 Use Qt Quick or QPainter to render into a texture Embed Qt Quick into Qt3D, including input handling Level of Detail support for meshes Text support - 2D and 3D Additional materials such as PBR materials others Generating and filling buffers out of QAbstractItemModels Billboards - camera facing entities Particle systems VR support new aspects: 碰撞檢測 動畫:關鍵幀動畫;骨骼動畫;Morph target animation; Removes animation workload from main thread 物理:剛體/柔體物理模擬 AI: 三維位置音效:如喇叭,越近越響 工具 設計時工具:場景設計器 Qt 3D Studio 編譯時工具:資產狀態監控 More 貼圖控制 可yizhi算法(OpenGL) 各類3d模型的加載 2d ui嵌入到 3d裏面用Scene2D Scene2D { id: qmlTexture output: RenderTargetOutput { attachmentPoint: RenderTargetOutput.Color0 texture: Texture2D { id: offscreenTexture } } entities: [ cube ] Item { id: customQtQuickStuff } } 紋理加載器 TextureLoader { source: "qrc:/assets/textures/pbr-default/pbr-default-metallic.png" minificationFilter: Texture.LinearMipMapLinear magnificationFilter: Texture.Linear wrapMode { x: WrapMode.ClampToEdge y: WrapMode.ClampToEdge } generateMipMaps: true } 新增材質 粗糙金屬材質 MetalRoughMaterial 粗糙金屬紋理材質 TexturedMetalRoughMaterial { baseColor: TextureLoader { format: Texture.SRGB8_Alpha8 source: "qrc:/assets/powerup/basecolor.png" } metalness: TextureLoader { source: "qrc:/assets/powerup/metalness.png" } roughness: TextureLoader { source: "qrc:/assets/powerup/roughness.png" } normal: TextureLoader { source: "qrc:/assets/powerup/normal.png" } ambientOcclusion: TextureLoader { source: "qrc:/assets/powerup/ambientocclusion.png" } } 新增環境光 EnvironmentLight { id: envLight irradiance: TextureLoader { source: "qrc:/assets/envmaps/wobbly-bridge/wobbly_bridge_4k" + _envmapFormat + "_cube_irradiance.dds" minificationFilter: Texture.LinearMipMapLinear magnificationFilter: Texture.Linear wrapMode { x: WrapMode.ClampToEdge y: WrapMode.ClampToEdge } generateMipMaps: false } specular: TextureLoader { source: "qrc:/assets/envmaps/wobbly-bridge/wobbly_bridge_4k" + _envmapFormat + "_cube_specular.dds" minificationFilter: Texture.LinearMipMapLinear magnificationFilter: Texture.Linear wrapMode { x: WrapMode.ClampToEdge y: WrapMode.ClampToEdge } generateMipMaps: false } } 天空盒實體 SkyboxEntity { baseName: "qrc:/assets/envmaps/wobbly-bridge/wobbly_bridge_4k" + _envmapFormat + "_cube_radiance" extension: ".dds" gammaCorrect: true } 相機增長曝光度屬性 Camera { id: mainCamera position: Qt.vector3d(-10, 0, 0) viewCenter: Qt.vector3d(0, 0, 0) exposure: 1.4 // 曝光度 } 加載預設的動畫 import Qt3D.Animation 2.9 ClipAnimator { id: animator loops: 3 clip: AnimationClipLoader { source: "qrc:/jumpinganimation.json" } channelMapper: ChannelMapper { mappings: [ ChannelMapping { channelName: "Location"; target: cubeTransform; property: "translation" }, ChannelMapping { channelName: "Rotation"; target: cubeTransform; property: "rotation" }, ChannelMapping { channelName: "Scale"; target: cubeTransform; property: "scale3D" } ] } } 對象選擇器 ObjectPicker { onClicked: animator.running = true;} 根據遠近來動態調整場景(volumeOverride) LevelOfDetail Entity { components: [ CylinderMesh { radius: 1 length: 3 rings: 2 slices: sliceValues[lod.currentIndex] property var sliceValues: [20, 10, 6, 4] }, Transform { rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45) }, PhongMaterial { diffuse: "lightgreen" }, LevelOfDetail { id: lod camera: camera thresholds: [1000, 600, 300, 180] thresholdType: LevelOfDetail.ProjectedScreenPixelSizeThreshold volumeOverride: lod.createBoundingSphere(Qt.vector3d(0, 0, 0), 2.0) } ] } LevelOfDetailSwitch Entity { components: [ LevelOfDetailSwitch { camera: camera thresholds: [20, 35, 50] thresholdType: LevelOfDetail.DistanceToCameraThreshold } ] HighDetailEntity { enabled: false } MediumDetailEntity { enabled: false } LowDetailEntity { enabled: false } } LevelOfDetailLoader LevelOfDetailLoader { id: lodLoader camera: camera thresholds: [20, 35, 50] thresholdType: LevelOfDetail.DistanceToCameraThreshold volumeOverride: lodLoader.createBoundingSphere(Qt.vector3d(0, 0, 0), -1) sources: ["qrc:/HighDetailEntity.qml", "qrc:/MediumDetailEntity.qml", "qrc:/LowDetailEntity.qml"] } 渲染文本 Text2DEntity Text2DEntity { id: text text: "Hello World" width: 20 height: 10 } ExtrudedTextMesh auto *text = new Qt3DCore::QEntity(root); auto *textTransform = new Qt3DCore::QTransform(); auto *textMesh = new Qt3DExtras::QExtrudedTextMesh(); textMesh->setDepth(.45f); QFont font(family, 32, -1, false); textMesh->setFont(font); textMesh->setText(QString(family)); auto *textMaterial = new Qt3DExtras::QPhongMaterial(root); textMaterial->setDiffuse(QColor(111, 150, 255)); text->addComponent(textTransform); text->addComponent(textMesh); text->addComponent(textMaterial);