http://huangchunquanmaker.blog.163.com/blog/static/10740848320110122504678/

Quick3D 学习文档

2011-01-12 14:50:04|  分类: QT|举报|字号 订阅

一.介绍

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

设置摄像机的位置:0,4,12 使用一张图片作为 纹理,使用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
        }
    }
}

Quick3D 学习文档相关推荐

  1. FreeMarker中文帮助手册API文档,基础入门学习文档

    FreeMarker中文帮助手册API文档,基础入门学习文档 分类: 编程技术 发布: bywei 浏览: 7 日期: 2011年5月28日 分享到: QQ空间 新浪微博 腾讯微博 人人网 什么是Fr ...

  2. ffmpeg的中文学习文档

    ffmpeg的中文学习文档 文章目录: 一.ffmpeg介绍 二.学习参考文档 1.中文 一.ffmpeg介绍 ffmpeg是视频处理工具,可选参数非常多,功能也非常的强大,可以用来开发各种视频处理工 ...

  3. Ext JS 6学习文档-第3章-基础组件

    Ext JS 6学习文档-第3章-基础组件 基础组件 在本章中,你将学习到一些 Ext JS 基础组件的使用.同时我们会结合所学创建一个小项目.这一章我们将学习以下知识点: 熟悉基本的组件 – 按钮, ...

  4. Ext JS 6学习文档-第6章-高级组件

    Ext JS 6学习文档-第6章-高级组件 高级组件 本章涵盖了高级组件,比如 tree 和 data view.它将为读者呈现一个示例项目为 图片浏览器,它使用 tree 和 data view 组 ...

  5. NodeJS-001-Nodejs学习文档整理(转-出自http://www.cnblogs.com/xucheng)

    Nodejs学习文档整理 http://www.cnblogs.com/xucheng/p/3988835.html 1.nodejs是什么: nodejs是一个是javascript能在后台运行的平 ...

  6. java学习文档_阿里技术专家带你玩转JVM,从底层源码到项目实战,都在这份文档里...

    作为 Java 的从业者,在找工作的时候,一定会被问及关于 JVM 相关的知识. JVM 知识的掌握程度,在很多面试官眼里是候选人技术深度的一个重要评判标准.而大多数人可能没有对 JVM 的实际开发和 ...

  7. [扩展阅读] EasyGUI 学习文档【超详细中文版】

    [扩展阅读] EasyGUI 学习文档[超详细中文版] 0. 安装 EasyGUI 官网:https://github.com/robertlugg/easygui python查看内置的所有模块 h ...

  8. C和C++编程和学习文档

     C和C++编程和学习文档 C和C++编程和学习文档   1 :指针变量名称以p为首字符,这是程序员通常在定义指针时的一个习惯 2 :har * p;    (int *)p 把p强制转换为int型  ...

  9. PHP学习文档——基础篇

    PHP学习文档--基础篇 PHP学习文档--基础篇 标记 短标记 脚本标记 标准标记(常用) PHP注释 行注释 块注释 PHP语句分隔符 变量 变量命名规则 预定义变量 可变变量 变量传值 常量 定 ...

最新文章

  1. [JS-JQuery]基础
  2. MIT与商汤科技成立人工智能联盟
  3. bootstrap 按钮颜色属性
  4. 定制安装操作系统(二)
  5. 【原创】mysql数据库异常:data truncate for column “*” at row *;data too long *。原因,及解决。...
  6. [react] react兄弟组件如何通信?
  7. 考研英语核心词汇辨析(黑魔方系列2007版之十一)
  8. pcie握手机制_图解PCIE原理(从软件角度)
  9. [置顶] java高级工程师-----struts的内部运行机制详解
  10. 怎样访问服务器系统盘,访问云服务器上的系统盘
  11. java 文件上传 乱码_java中文传值乱码问题的解决方法
  12. 《深入理解JVM虚拟机》读书笔记(一)
  13. make: 对“all”无需做任何事
  14. HDRP高清渲染管线-学习资料汇总
  15. git bug分支管理
  16. 香港服务器降低安全风险的 10 个最佳措施
  17. 如何用python画爱心?
  18. 关于技术部管理的一些思考
  19. 王牌战士没显示我的服务器,王牌战士号没了怎么回事 游戏档案被销号解决方法...
  20. 一道面试题(限流,幂等key)

热门文章

  1. 网络安全有哪些细分方向?零基础学Web安全需要掌握的知识(附系统路线+工具笔记)
  2. 老焦专栏 | 一个典型的知识图谱应用建设案例
  3. 机床遇到这种故障该怎么办?
  4. Java Agent 探针技术
  5. HTML元素居中(文字居中,块居中【垂直/水平居中】)
  6. Linux无所不在的10个方面
  7. chrome账号登录问题
  8. java获取当前时间和设置时间格式
  9. 数据结构(一)——线性链表的原理以及应用
  10. C语言详解 FILE文件操作