在qml中加载3D模型,并进行简单的操作

import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Extras 2.0
import QtQuick 2.0
import QtQuick.Scene3D 2.0

Item {

    width: 800
    height: 600

    Scene3D{
        anchors.fill: parent

        Entity {
            id: sceneRoot

            Camera {
                id: camera
                projectionType: CameraLens.PerspectiveProjection
                fieldOfView: 450
                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 )
            }

            FirstPersonCameraController { camera: camera }

            components: [
                RenderSettings{
                    activeFrameGraph: ForwardRenderer{
                        clearColor: Qt.rgba(0,0.5,1,1);
                        camera: camera
                    }
                },
                InputSettings{}
            ]



            Mesh {
                   id: mesh
                   source: "qrc:/new/prefix1/glTF/untitled.obj"
               }

            Transform{
                id:torTransform
                scale3D:Qt.vector3d(1.5,1,0.5)
                rotation:fromAxisAndAngle(Qt.vector3d(0,1,0),1)
                property real hAngle:0.0

                NumberAnimation on hAngle{
                    from:0
                    to:360.0
                    duration: 10000
                    loops: Animation.Infinite
                }
                matrix:{
                    var m=Qt.matrix4x4();
                    m.rotate(hAngle,Qt.vector3d(0,1,0));
                    m.translate(Qt.vector3d(0,0,0));
                    return m;

                }

            }

               PhongAlphaMaterial {
                   id: material
                   ambient: "gray"
                   alpha: 1.0
               }

               Entity {
                   id: entity
                   components: [mesh, material,torTransform]
               }

        }

    }
}

 

转载于:https://my.oschina.net/urlove/blog/1828571

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值