实例介绍
【实例简介】
qml用3D的方式展示太阳系
【实例截图】
【文件目录】
planets-qml
├── AppleTVInput.qml
├── FpsDisplay.qml
├── InfoSheet.qml
├── Planet.qml
├── PlanetButton.qml
├── PlanetEffect.qml
├── PlanetFrameGraph.qml
├── PlanetMaterial.qml
├── PlanetsLight.qml
├── PlanetsMain.qml
├── Ring.qml
├── ShadowEffect.qml
├── SolarSystem.qml
├── StyledSlider.qml
├── SunEffect.qml
├── android
│ ├── AndroidManifest.xml
│ └── res
│ ├── drawable-hdpi
│ │ └── icon.png
│ ├── drawable-ldpi
│ │ └── icon.png
│ └── drawable-mdpi
│ └── icon.png
├── doc
│ ├── images
│ │ └── planets-qml-example.jpg
│ └── src
│ └── planets-qml.qdoc
├── images
│ ├── earth.png
│ ├── jupiter.png
│ ├── mars.png
│ ├── mercury.png
│ ├── nasa
│ │ ├── license.txt
│ │ ├── qt_attribution.json
│ │ └── uranusringcolortrans.png
│ ├── neptune.png
│ ├── saturn.png
│ ├── solarsystemscope
│ │ ├── earthcloudmapcolortrans.png
│ │ ├── earthcloudmapspec.jpg
│ │ ├── earthmap2k.jpg
│ │ ├── earthnormal2k.jpg
│ │ ├── earthspec2k.jpg
│ │ ├── galaxy_starfield.jpg
│ │ ├── jupitermap.jpg
│ │ ├── license.txt
│ │ ├── marsmap2k.jpg
│ │ ├── marsnormal2k.jpg
│ │ ├── mercurymap.jpg
│ │ ├── mercurynormal.jpg
│ │ ├── moonmap2k.jpg
│ │ ├── moonnormal2k.jpg
│ │ ├── neptunemap.jpg
│ │ ├── qt_attribution.json
│ │ ├── saturnmap.jpg
│ │ ├── saturnringcolortrans.png
│ │ ├── sunmap.jpg
│ │ ├── uranusmap.jpg
│ │ ├── venusmap.jpg
│ │ └── venusnormal.jpg
│ ├── sun.png
│ ├── uranus.png
│ └── venus.png
├── main.cpp
├── meshes
│ ├── ring.obj
│ └── starfield.obj
├── networkcontroller.cpp
├── networkcontroller.h
├── planets-qml-images.qrc
├── planets-qml.pro
├── planets-qml.qrc
├── planets-watchos
│ ├── PlanetsClient
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── icon120.png
│ │ │ └── icon180.png
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ ├── PlanetsClient WatchKit App
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ └── home_icon.png
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ └── Interface.storyboard
│ │ └── Info.plist
│ ├── PlanetsClient WatchKit Extension
│ │ ├── Assets.xcassets
│ │ │ └── Complication.complicationset
│ │ │ ├── Circular.imageset
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── Extra Large.imageset
│ │ │ │ └── Contents.json
│ │ │ ├── Modular.imageset
│ │ │ │ └── Contents.json
│ │ │ └── Utilitarian.imageset
│ │ │ └── Contents.json
│ │ ├── ExtensionDelegate.h
│ │ ├── ExtensionDelegate.m
│ │ ├── Info.plist
│ │ ├── InterfaceController.h
│ │ └── InterfaceController.m
│ └── PlanetsClient.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── planets.js
└── shaders
├── es2
│ ├── planetD.frag
│ ├── planetD.vert
│ ├── planetDB.frag
│ ├── planetDB.vert
│ ├── planetDS.frag
│ ├── planetDSB.frag
│ ├── sun.frag
│ └── sun.vert
└── gl3
├── planetD.frag
├── planetD.vert
├── planetDB.frag
├── planetDB.vert
├── planetDS.frag
├── planetDSB.frag
├── planetDShadow.frag
├── planetDShadow.vert
├── shadowmap.frag
├── shadowmap.vert
├── sun.frag
└── sun.vert
33 directories, 112 files
【核心代码】
import QtQuick 2.0
Item {
id: fpsDisplayControl
property bool hidden: true
property real fps: 0.0
onHiddenChanged: {
if (fpsDisplayControl.hidden)
fpsDisplay.color = "transparent";
else
fpsDisplay.color = "#000000FF";
}
onFpsChanged: {
fpsDisplay.updateFps();
}
Rectangle {
anchors.fill: parent
id: fpsDisplay
color: "transparent"
property real maxFps: 60.0
property color maxFpsColor: "#00FF00"
property color minFpsColor: "#FF0000"
function updateFps() {
var scale = (fps > maxFps)?1.0:(fps/maxFps);
var r = (1 - scale) * minFpsColor.r scale * maxFpsColor.r;
var g = (1 - scale) * minFpsColor.g scale * maxFpsColor.g;
var b = (1 - scale) * minFpsColor.b scale * maxFpsColor.b;
var a = (1 - scale) * minFpsColor.a scale * maxFpsColor.a;
fpsCauge.height = scale * fpsDisplay.height;
fpsCauge.color = Qt.rgba(r,g,b,a);
}
Rectangle {
id: fpsCauge
width: parent.width
anchors.bottom: parent.bottom
visible: !fpsDisplayControl.hidden
}
Text {
id: fpsText
text: "" (fps | 0)
font.family: "Helvetica"
font.pixelSize: 16
font.weight: Font.Light
color: "white"
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
visible: !fpsDisplayControl.hidden
}
}
MouseArea {
anchors.fill: parent
onClicked: {
fpsDisplayControl.hidden = !fpsDisplayControl.hidden;
}
}
}
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论