• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 319, comments - 22, trackbacks - 0, articles - 11
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Quick3D 學習文檔 (QML) 轉載

            Posted on 2011-08-04 21:14 RTY 閱讀(3722) 評論(0)  編輯 收藏 引用 所屬分類: 轉載隨筆QML

            .介紹

            quick3d是把qt3d部分以插件的形式導出,在QML中通過包含的形式來進行使用的。

            quick3d部分,使用的包含有

            import Qt3D 1.0
            import Qt3D.Shapes 1.0

            Import Qt3D 是包含主要的一些Qt3D模塊,而Qt3D.Shapes 包含的是一些立方體,球體,圓柱體等的信息,方便使用各種簡單模型。

            .具體的說明(這里沒有按照原來的意思翻譯,只根據個人理解)

            QML BillboardTransform Element 公告牌,實現一個變化使對象一直朝向攝像機。

            QML Camera Element 攝像機,定義一個視口的位置和投影3D場景

            QML Effect Element 定義一些簡單的效果,包含材質 紋理 燈光等

            QML FloatingItem Element 定義一個二維放置在3D可視化區域內的深度

            QML Item3D Element 將存儲一個3D對象,并且包含所有簡單3D操作的屬性和方法

            QML Light Element 一些燈光參數的描述

            QML LightModel Element 定義場景中燈光的模型

            QML LookAtTransform Element 提供一種變化使對象面向攝像機,具體意思需要自己理解

            QML Material Element 描述OpenGL中的材質屬性

            QML Mesh Element 對載入一些模型文件的支持,還有一些操作等

            QML Qt3d Element qt3d全局對象,為3d應用程序提供一些有用的功能

            QML Rotation3D Element 提供3d空間中的旋轉變化

            QML Scale3D Element 提供3d空間中的縮放變化

            QML ShaderProgram Element 提供著色器語言的支持,這個需要GPU的支持。

            QML StereoView Element 定義一個布局可以使用左右視角圖像,這個的作用是立體視覺效果,他分別從左右眼的方向對3D場景中的物體進行來渲染,需要硬件支持.

            QML Translation3D Element 提供3d空間中的位置變化

            QML Viewport Element 定義一個合理的3D視口


            QML Capsule Element 描述一個囊

            QML Cube Element 描述一個立方體

            QML Cylinder Element 描述一個圓柱體

            QML Line Element 描述線 可以是多條線

            QML Point Element 描述點 可以是多個點

            QML Quad Element 描述四邊形

            QML Sphere Element 描述球體

            QML Teapot Element 描述茶壺


            簡單的quick3d

            QML Viewport Element

            QML Mesh Element

            QML Item3D Element


            import Qt 4.7
            import Qt3D 1.0
            Viewport {
                width: 640; height: 480
                camera: Camera {}
                light: Light {}
                Item3D {
                    mesh: Mesh { source: "teapot.bez" }
                    effect: Effect {}
                }
            }

            QML BillboardTransform Element

            沒有成功,所以暫時不寫


            QML Camera Element

            QML Effect Element

            QML Mesh Element

            QML Item3D Element


            設置攝像機的位置:0412 使用一張圖片作為 紋理,使用Mesh 載入obj模型


            import Qt 4.7
            import Qt3D 1.0
            Viewport {
                id: viewport;
                width: 640; height: 480
                // 設置攝像機及指向的位置
                camera: Camera {
                    eye: Qt.vector3d(0, 4, 12);
                }
                // 添加一棵樹
                Item3D{
                   id: tree
                   mesh: Mesh { source: "tree.obj" }
                   effect: Effect { blending: true; texture: "tree.png"}
                   position: Qt.vector3d(0, 0, 0)
                }
            }

            QML FloatingItem Element

            3D場景上使用2D元素

            import Qt 4.7
            import Qt3D 1.0
            Viewport {
                id: viewport;
                width: 640; height: 480
                // 設置攝像機及指向的位置
                camera: Camera {
                    eye: Qt.vector3d(0, 4, 12);
                }
                // 添加一個2D的東西
                FloatingItem {
                     anchors.fill: parent
                     depth: -10
                    Rectangle {
                        x:100; y: 100; width: 100; height: 30;
                        color: "#8f00ff00";
                        Text {anchors.fill: parent; text:"OK"; color: "blue"}
                    }
                 }
                // 設置地面
                Item3D {
                    id: ground
                    mesh: Mesh { source:"ground.obj"} // 載入一個obj模型
                    effect: Effect{
                        color: "#604000";
                        useLighting: false;
                    }
                }
                // 添加一棵樹
                Item3D{
                   id: tree
                   mesh: Mesh { source: "tree.obj" }
                   effect: Effect { blending: true; texture: "tree.png"}
                   position: Qt.vector3d(0, 0, 0)
                }
            }


            QML Light Element

            可以比對下打開燈光和不打開燈光效果的差別

            import Qt 4.7
            import Qt3D 1.0
            Viewport {
                width: 640; height: 480
                camera: Camera {
                    eye: Qt.vector3d(0, 4, 12);
                }
                light:  Light {
                    position: Qt.vector3d(0, 4, 12);
                    direction: Qt.vector3d(0, 0, 0);
                }
                Item3D {
                    mesh: Mesh { source: "teapot.bez" }
                    effect: Effect {}
                }
            }

            QML Qt3d Element

            里面包含了一些有用的類型

            Qt3d::matrix4x4 ( real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44 )

            Qt3d::quaternion ( real scalar, real x, real y, real z )

            Qt3d::vector2d ( real x, real y )

            Qt3d::vector4d ( real x, real y, real z, real w )


            QML Rotation3D Element

            QML Scale3D Element

            QML Translation3D Element

            直接對一棵樹進行縮放 移動 旋轉操作

            import Qt 4.7
            import Qt3D 1.0
            Viewport {
                width: 640; height: 480
                camera: Camera {
                    eye: Qt.vector3d(0, 4, 12);
                }
                // 添加地面
                Item3D {
                     id: ground
                     mesh: Mesh { source: "ground.obj" }
                     effect: Effect {
                         color: "#604000"
                         useLighting: false
                     }
                 }
                Item3D {
                    id: mainItem
                    // 1棵樹旋轉
                    Item3D{
                       id: tree1
                       mesh: Mesh { source: "tree.obj" }
                       effect: Effect {
                              blending: true
                              texture: "tree.png"
                        }
                       position: Qt.vector3d(0, 0, 0)
                       transform:[
                           Rotation3D {id: tree1Rot; axis: Qt.vector3d(0, 1, 0);},
                           Translation3D {id: tree1Tran; translate: Qt.vector3d(3, 0, 0)},
                           Scale3D {id: tree1Scale;scale: 0.5 }
                       ]
                    }
                }
                ParallelAnimation{
                    running: true;
                    NumberAnimation { loops: Animation.Infinite; target: tree1Rot; 
                                        property: "angle"; from: 0; to : 360.0; duration: 3000;}
                    NumberAnimation { loops: Animation.Infinite; target: tree1Tran; 
                                        property: "progress"; from: 0; to : 1; duration: 3000;}
                    NumberAnimation { loops: Animation.Infinite; target: tree1Scale; 
                                        property: "scale"; from: 0; to : 1; duration: 3000;}
                }
            }

            QML LookAtTransform Element

            未知


            QML LightModel Element

            QML Material Element

            這里是對茶壺表面的材質進行了光照的設置

            import Qt 4.7
            import Qt3D 1.0
            Viewport {
                width: 640; height: 480
                camera: Camera {
                    eye: Qt.vector3d(0, 4, 12);
                }
                // 燈光
                light: Light {
                    ambientColor: "black"; // 環境光
                    constantAttenuation: 1;
                    diffuseColor: "white"; // 慢發射
                    specularColor: "white"; //鏡面光
                }
                // 設置場景的環境光
                lightModel: LightModel {
                    ambientSceneColor: Qt.rgba(0.2, 0.2, 0.2, 1.0);
                }
                // 物體
                Item3D{
                       id: teapot
                       mesh: Mesh { source: "teapot.bez" }
                       effect: Effect {
                              blending: true
                              material: Material {
                                  id: teapotMate
                                  ambientColor: "#cf00f010";
                                  specularColor: "#cf030010";
                                  diffuseColor: "#cf200310";
                             }
                      }
                }
                ParallelAnimation{
                    running: true;
                    ColorAnimation { loops: Animation.Infinite; target: teapotMate;
                        property: "ambientColor"; from: "#cf00f010"; to : "#a33ca326"; duration: 3000;}
                    ColorAnimation { loops: Animation.Infinite; target: teapotMate;
                        property: "specularColor"; from: "#cf030010"; to : "#3091f300"; duration: 3000;}
                    ColorAnimation { loops: Animation.Infinite; target: teapotMate;
                        property: "diffuseColor"; from: "#cf200310"; to : "#59649350"; duration: 3000;}
                }
            }

            QML ShaderProgram Element

            對于這塊我不是很了解具體的例子可以查看

            declarative/teapot-shader.qml

            QML StereoView Element

            import Qt 4.7
            import Qt3D 1.0
            StereoView{
                 width: 640; height: 480
                 //layout: StereoView.LeftRight
                 FloatingItem {
                     anchors.fill: parent
                     depth: -10
                     Image {
                         anchors.fill: parent
                         source: "tree.png"
                     }
                 }
                 Viewport {
                     anchors.fill: parent
                     navigation: false
                     camera: Camera {
                         eye: Qt.vector3d(0, 0, 10)
                         eyeSeparation: 0.08
                     }
                 // 添加地面
                 Item3D {
                      id: ground
                      position: Qt.vector3d(-1.0, -1.0, -5.0)
                      mesh: Mesh { source: "ground.obj" }
                      effect: Effect {
                          color: "#604000"
                          useLighting: false
                      }
                  }
                 }
            }


            QML Capsule Element 描述一個囊

            QML Cube Element 描述一個立方體

            QML Cylinder Element 描述一個圓柱體

            QML Line Element 描述線 可以是多條線

            QML Point Element 描述點 可以是多個點

            QML Quad Element 描述四邊形

            QML Sphere Element 描述球體

            QML Teapot Element 描述茶壺

            import Qt 4.7
            import Qt3D 1.0
            import Qt3D.Shapes 1.0
            Viewport {
                width: 640; height: 480
                camera: Camera {
                    eye: Qt.vector3d(0, 4, 12);
                }
                // 燈光
                light: Light {
                    ambientColor: "black"; // 環境光
                    constantAttenuation: 1;
                    diffuseColor: "white"; // 慢發射
                    specularColor: "white"; //鏡面光
                }
                // 設置場景的環境光
                lightModel: LightModel {
                    ambientSceneColor: Qt.rgba(0.2, 0.2, 0.2, 1.0);
                }
                // 囊狀
                Capsule {
                    radius: 0.5
                    length: 3.0
                    scale: 0.5
                    position: Qt.vector3d(-2, 1, 0);
                    effect: Effect {
                        color: "#aaca00"
                    }
                }
                // 立方體
                Cube {
                    scale: 0.5
                    position: Qt.vector3d(-1, 1, 0);
                    effect: Effect {
                        color: "#aaca00"
                        texture: "qtlogo.png"
                    }
                }
                // 圓柱體
                Cylinder {
                     radius: 0.5
                     length: 3.0
                     scale: 0.5
                     position: Qt.vector3d(0, 1, 0);
                     effect: Effect {
                         color: "#aaca00"
                     }
                 }
                // 
                Line {
                    vertices: [
                       0, 0, 0,
                       0, 0, 1,
                       0, 1, 1
                    ]
                    position: Qt.vector3d(-2.0, 0, 0);
                    effect: Effect {
                        color: "#aaca00"
                    }
                }
                // 
                Point {
                    vertices: [
                       0, 0, 0,
                       1, 1, 1,
                       -1, -1, -1
                            ]
                    pointSize: 0.5;
                    position: Qt.vector3d(1, -1, 0);
                    effect: Effect {
                        color: "white"
                    }
                }
                // 四邊形
                Quad {
                    scale: 0.5
                    position: Qt.vector3d(0, 0, 0);
                    effect: Effect {
                        color: "#aaca00"
                        texture: "qtlogo.png"
                    }
                }
                // 球體
                Sphere {
                    radius: 0.5
                    position: Qt.vector3d(-2, -1, 0);
                    effect: Effect {
                        color: "#aaca00"
                    }
                }
                // 茶壺
                Teapot {
                    scale: 0.5
                    position: Qt.vector3d(-1, -1, 0);
                    effect: Effect {
                        color: "#aaca00"
                        texture: "qtlogo.png"
                        decal: true
                    }
                }
            }

            精品久久久久久成人AV| 亚洲va久久久噜噜噜久久男同| 亚洲&#228;v永久无码精品天堂久久 | 久久九九久精品国产免费直播| 久久久青草青青国产亚洲免观| 岛国搬运www久久| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区| 久久久久一级精品亚洲国产成人综合AV区| 日日狠狠久久偷偷色综合96蜜桃| 嫩草影院久久国产精品| 国产ww久久久久久久久久| 国产精品狼人久久久久影院| 97久久天天综合色天天综合色hd | 日本久久久久亚洲中字幕| 亚洲午夜久久久影院| 久久精品国产亚洲av麻豆小说| 久久精品国产亚洲精品2020| 热99RE久久精品这里都是精品免费 | 99久久这里只精品国产免费| 久久天天躁狠狠躁夜夜不卡 | 久久综合香蕉国产蜜臀AV| AV色综合久久天堂AV色综合在| 欧美777精品久久久久网| 亚洲国产精品一区二区三区久久| 亚洲精品无码久久久久| 色综合久久精品中文字幕首页| 日韩久久无码免费毛片软件| 久久99热这里只有精品66| 久久亚洲精品视频| www.久久精品| 久久国产精品77777| 久久午夜免费视频| 亚洲精品第一综合99久久| 亚洲乱亚洲乱淫久久| 亚洲综合伊人久久综合| 国产精品久久久99| 99久久99久久精品国产片| 青草国产精品久久久久久| 久久妇女高潮几次MBA| 久久久久亚洲AV无码去区首| 婷婷久久香蕉五月综合加勒比|