PySide2学习总结(十四)3D场景中的带网格平面

本文介绍了如何使用PySide2和QML创建一个带有网格的3D场景。通过在`main.qml`中设置`ApplicationWindow`和`Scene3D`组件,然后在`Viewer3D.qml`定义场景根实体,最后在`Grid3D.qml`中绘制网格,最终实现了类似建模软件中带网格参考的3D平面效果。
摘要由CSDN通过智能技术生成

在建模软件中,往往会有一个作为参考的带网格的平面,现在我们利用PySide2+qml来实现这个效果。

创建窗口

main.qml中利用ApplicationWindow 新建了一个窗口用于显示,Scene3D组件用于创建一个三维场景

import QtQuick 2.7
import QtQuick.Controls 2.3
import QtQuick.Scene3D 2.0


ApplicationWindow {
   
    id: rootWindow
    title: "Grid3D Test"
    width: 800
    height: 600
    visible: true

    Scene3D {
   
        id: scene3d
        anchors.fill: parent
        anchors.margins: 10
        focus: true
        aspects: ['input', 'logic']
        cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
        hoverEnabled: true

        Viewer3D {
   }
    }
}

创建场景根实体

Viewer3D.qml

import QtQuick 2.7
import Qt3D.Core 2.1
import Qt3D.Render 2.1
import Qt3D.Extras 2.1
import Qt3D.Input 2.1


Entity {
   
    id: rootEntity

    Camera {
   
        id: mainCamera
        projectionType: CameraLens.PerspectiveProjection
        fieldOfView: 45
        nearPlane: 0.01
        farPlane: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值