| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.0 as QQ2 |
| 5 |
import Qt3D.Core 2.0 |
| 6 |
import Qt3D.Render 2.0 |
| 7 |
import Qt3D.Input 2.0 |
| 8 |
import Qt3D.Logic 2.0 |
| 9 |
import Qt3D.Extras 2.0 |
| 10 |
|
| 11 |
import "planets.js" as Planets |
| 12 |
|
| 13 |
Entity { |
| 14 |
id: sceneRoot |
| 15 |
|
| 16 |
property bool ready: false |
| 17 |
|
| 18 |
property real cameraNear: 0 |
| 19 |
property real xLookAtOffset: 0 |
| 20 |
property real yLookAtOffset: 0 |
| 21 |
property real zLookAtOffset: 0 |
| 22 |
property real xCameraOffset: 0 |
| 23 |
property real yCameraOffset: 0 |
| 24 |
property real zCameraOffset: 0 |
| 25 |
|
| 26 |
property var planetData |
| 27 |
property var planets: [] |
| 28 |
|
| 29 |
property vector3d defaultUp: Qt.vector3d(0, 1, 0) |
| 30 |
property vector3d defaultCameraPosition: Qt.vector3d(Planets.solarDistance, |
| 31 |
Planets.solarDistance, |
| 32 |
Planets.solarDistance) |
| 33 |
property vector3d tiltAxis: Qt.vector3d(0, 0, 1) |
| 34 |
property vector3d rollAxis: Qt.vector3d(0, 1, 0) |
| 35 |
property real cameraDistance: 1 |
| 36 |
property vector3d oldCameraPosition |
| 37 |
property vector3d oldFocusedPlanetPosition |
| 38 |
|
| 39 |
property color ambientStrengthStarfield: "#000000" |
| 40 |
property color ambientStrengthSun: "#ffffff" |
| 41 |
property color ambientStrengthClouds: "#000000" |
| 42 |
property color ambientStrengthRing: "#111111" |
| 43 |
property color ambientStrengthPlanet: "#222222" |
| 44 |
property real shininessSpecularMap: 50.0 |
| 45 |
property real shininessClouds: 10.0 |
| 46 |
property real shininessBasic: 1.0 |
| 47 |
|
| 48 |
property real saturnRingInnerRadius |
| 49 |
property real saturnRingOuterRadius |
| 50 |
property real uranusRingInnerRadius |
| 51 |
property real uranusRingOuterRadius |
| 52 |
|
| 53 |
// Time variables |
| 54 |
property int year: 2000 |
| 55 |
property int month: 1 |
| 56 |
property int day: 1 |
| 57 |
// Time scale formula based on http://www.stjarnhimlen.se/comp/ppcomp.html |
| 58 |
property real startD: 367 * year - 7 * (year + (month + 9) / 12) / 4 + 275 * month / 9 + day - 730530 |
| 59 |
property real oldTimeD: startD |
| 60 |
property real currTimeD: startD |
| 61 |
property real deltaTimeD: 0 |
| 62 |
property real daysPerFrame |
| 63 |
property real daysPerFrameScale |
| 64 |
|
| 65 |
property real planetScale |
| 66 |
|
| 67 |
property bool focusedScaling: false |
| 68 |
property int focusedMinimumScale: 20 |
| 69 |
property real actualScale |
| 70 |
|
| 71 |
// Animate solar system with LogicComponent |
| 72 |
FrameAction { |
| 73 |
onTriggered: { |
| 74 |
frames++ |
| 75 |
animate(focusedPlanet) |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
PlanetsLight { |
| 80 |
id: light |
| 81 |
ratio: width / height |
| 82 |
} |
| 83 |
|
| 84 |
Camera { |
| 85 |
id: camera |
| 86 |
projectionType: CameraLens.PerspectiveProjection |
| 87 |
fieldOfView: 45 |
| 88 |
aspectRatio: width / height |
| 89 |
nearPlane: 2500.0 |
| 90 |
farPlane: 20000.0 |
| 91 |
position: defaultCameraPosition |
| 92 |
upVector: defaultUp |
| 93 |
viewCenter: Qt.vector3d( xLookAtOffset, yLookAtOffset, zLookAtOffset ) |
| 94 |
} |
| 95 |
|
| 96 |
FirstPersonCameraController { camera: camera } |
| 97 |
|
| 98 |
components: [ |
| 99 |
PlanetFrameGraph { |
| 100 |
id: framegraph |
| 101 |
viewCamera: camera |
| 102 |
lightCamera: light.lightCamera |
| 103 |
}, |
| 104 |
InputSettings {} |
| 105 |
] |
| 106 |
|
| 107 |
PlanetEffect { |
| 108 |
id: effectD |
| 109 |
light: light |
| 110 |
} |
| 111 |
|
| 112 |
PlanetEffect { |
| 113 |
id: effectDB |
| 114 |
light: light |
| 115 |
vertexES: "qrc:/shaders/es2/planetDB.vert" |
| 116 |
fragmentES: "qrc:/shaders/es2/planetDB.frag" |
| 117 |
vertexGL: "qrc:/shaders/gl3/planetDB.vert" |
| 118 |
fragmentGL: "qrc:/shaders/gl3/planetDB.frag" |
| 119 |
vertexRHI: "qrc:/shaders/rhi/planetDB.vert" |
| 120 |
fragmentRHI: "qrc:/shaders/rhi/planetDB.frag" |
| 121 |
} |
| 122 |
|
| 123 |
PlanetEffect { |
| 124 |
id: effectDSB |
| 125 |
light: light |
| 126 |
vertexES: "qrc:/shaders/es2/planetDB.vert" |
| 127 |
fragmentES: "qrc:/shaders/es2/planetDSB.frag" |
| 128 |
vertexGL: "qrc:/shaders/gl3/planetDB.vert" |
| 129 |
fragmentGL: "qrc:/shaders/gl3/planetDSB.frag" |
| 130 |
vertexRHI: "qrc:/shaders/rhi/planetDB.vert" |
| 131 |
fragmentRHI: "qrc:/shaders/rhi/planetDSB.frag" |
| 132 |
} |
| 133 |
|
| 134 |
PlanetEffect { |
| 135 |
id: cloudEffect |
| 136 |
light: light |
| 137 |
vertexES: "qrc:/shaders/es2/planetD.vert" |
| 138 |
fragmentES: "qrc:/shaders/es2/planetDS.frag" |
| 139 |
vertexGL: "qrc:/shaders/gl3/planetD.vert" |
| 140 |
fragmentGL: "qrc:/shaders/gl3/planetDS.frag" |
| 141 |
vertexRHI: "qrc:/shaders/rhi/planetD.vert" |
| 142 |
fragmentRHI: "qrc:/shaders/rhi/planetDS.frag" |
| 143 |
} |
| 144 |
|
| 145 |
SunEffect { |
| 146 |
id: sunEffect |
| 147 |
} |
| 148 |
|
| 149 |
ShadowEffect { |
| 150 |
id: shadowMapEffect |
| 151 |
shadowTexture: framegraph.shadowTexture |
| 152 |
light: light |
| 153 |
} |
| 154 |
|
| 155 |
//! [2] |
| 156 |
QQ2.Component.onCompleted: { |
| 157 |
planetData = Planets.loadPlanetData() |
| 158 |
// Push in the correct order |
| 159 |
planets.push(sun) |
| 160 |
planets.push(mercury) |
| 161 |
planets.push(venus) |
| 162 |
planets.push(earth) |
| 163 |
planets.push(mars) |
| 164 |
planets.push(jupiter) |
| 165 |
planets.push(saturn) |
| 166 |
planets.push(uranus) |
| 167 |
planets.push(neptune) |
| 168 |
planets.push(moon) |
| 169 |
// TODO: Once support for creating meshes from arrays is implemented take these into use |
| 170 |
//saturnRing.makeRing() |
| 171 |
//uranusRing.makeRing() |
| 172 |
saturnRingOuterRadius = planetData[Planets.SATURN].radius + Planets.saturnOuterRadius |
| 173 |
saturnRingInnerRadius = planetData[Planets.SATURN].radius + 0.006630 |
| 174 |
uranusRingOuterRadius = planetData[Planets.URANUS].radius + Planets.uranusOuterRadius |
| 175 |
uranusRingInnerRadius = planetData[Planets.URANUS].radius + 0.002 |
| 176 |
ready = true |
| 177 |
changeScale(1200) |
| 178 |
changeSpeed(0.2) |
| 179 |
setLookAtOffset(Planets.SUN) |
| 180 |
} |
| 181 |
//! [2] |
| 182 |
|
| 183 |
//! [0] |
| 184 |
QQ2.NumberAnimation { |
| 185 |
id: lookAtOffsetAnimation |
| 186 |
target: sceneRoot |
| 187 |
properties: "xLookAtOffset, yLookAtOffset, zLookAtOffset" |
| 188 |
to: 0 |
| 189 |
// easing.type: Easing.InOutQuint |
| 190 |
duration: 1250 |
| 191 |
} |
| 192 |
|
| 193 |
QQ2.NumberAnimation { |
| 194 |
id: cameraOffsetAnimation |
| 195 |
target: sceneRoot |
| 196 |
properties: "xCameraOffset, yCameraOffset, zCameraOffset" |
| 197 |
to: 0 |
| 198 |
// easing.type: Easing.InOutQuint |
| 199 |
duration: 2500 |
| 200 |
} |
| 201 |
//! [0] |
| 202 |
|
| 203 |
QQ2.Behavior on cameraNear { |
| 204 |
QQ2.PropertyAnimation { |
| 205 |
// easing.type: Easing.InOutQuint |
| 206 |
duration: 2500 |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
function changePlanetFocus(oldPlanet, focusedPlanet) { |
| 211 |
setOldPlanet(oldPlanet, focusedPlanet) |
| 212 |
setLookAtOffset(focusedPlanet) |
| 213 |
setCameraOffset(oldPlanet, focusedPlanet) |
| 214 |
lookAtOffsetAnimation.restart() |
| 215 |
cameraOffsetAnimation.restart() |
| 216 |
} |
| 217 |
|
| 218 |
function setOldPlanet(oldPlanet, focusedPlanet) { |
| 219 |
oldCameraPosition = camera.position |
| 220 |
|
| 221 |
var planet = 0 |
| 222 |
if (oldPlanet !== Planets.SOLAR_SYSTEM) |
| 223 |
planet = oldPlanet |
| 224 |
oldFocusedPlanetPosition = Qt.vector3d(planets[planet].x, |
| 225 |
planets[planet].y, |
| 226 |
planets[planet].z) |
| 227 |
checkScaling(focusedPlanet) |
| 228 |
} |
| 229 |
|
| 230 |
function setScale(value, focused) { |
| 231 |
// Save actual scale |
| 232 |
if (!focused) |
| 233 |
actualScale = value |
| 234 |
|
| 235 |
// Limit minimum scaling in focus mode to avoid jitter caused by rounding errors |
| 236 |
if (value <= focusedMinimumScale && (focusedScaling || focused)) |
| 237 |
planetScale = focusedMinimumScale |
| 238 |
else |
| 239 |
planetScale = actualScale |
| 240 |
return planetScale |
| 241 |
} |
| 242 |
|
| 243 |
function checkScaling(focusedPlanet) { |
| 244 |
if (focusedPlanet !== Planets.SOLAR_SYSTEM) { |
| 245 |
// Limit minimum scaling in focus mode to avoid jitter caused by rounding errors |
| 246 |
if (actualScale <= focusedMinimumScale) { |
| 247 |
planetScale = focusedMinimumScale |
| 248 |
changeScale(focusedMinimumSfocusedPlanetcale, true) |
| 249 |
} |
| 250 |
focusedScaling = true |
| 251 |
} else if (focusedScaling === true) { |
| 252 |
// Restore normal scaling |
| 253 |
focusedScaling = false |
| 254 |
changeScale(actualScale, false) |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
function setLookAtOffset(focusedPlanet) { |
| 259 |
var offset = oldFocusedPlanetPosition |
| 260 |
|
| 261 |
var planet = 0 |
| 262 |
if (focusedPlanet !== Planets.SOLAR_SYSTEM) |
| 263 |
planet = focusedPlanet |
| 264 |
|
| 265 |
var focusedPlanetPosition = Qt.vector3d(planets[planet].x, |
| 266 |
planets[planet].y, |
| 267 |
planets[planet].z) |
| 268 |
offset = offset.minus(focusedPlanetPosition) |
| 269 |
|
| 270 |
xLookAtOffset = offset.x |
| 271 |
yLookAtOffset = offset.y |
| 272 |
zLookAtOffset = offset.z |
| 273 |
} |
| 274 |
|
| 275 |
function setCameraOffset(oldPlanet, focusedPlanet) { |
| 276 |
var offset = oldCameraPosition |
| 277 |
|
| 278 |
var planet = 0 |
| 279 |
if (focusedPlanet !== Planets.SOLAR_SYSTEM) |
| 280 |
planet = focusedPlanet |
| 281 |
|
| 282 |
var newCameraPosition = getNewCameraPosition(focusedPlanet, Planets.getOuterRadius(planet)) |
| 283 |
|
| 284 |
if (focusedPlanet !== Planets.SUN) |
| 285 |
offset = offset.minus(newCameraPosition) |
| 286 |
|
| 287 |
if (oldPlanet === Planets.SOLAR_SYSTEM && focusedPlanet === Planets.SUN) { |
| 288 |
xCameraOffset = Math.abs(offset.x) |
| 289 |
yCameraOffset = Math.abs(offset.y) |
| 290 |
zCameraOffset = Math.abs(offset.z) |
| 291 |
} else { // from a planet to another |
| 292 |
xCameraOffset = offset.x |
| 293 |
yCameraOffset = offset.y |
| 294 |
zCameraOffset = offset.z |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
function getNewCameraPosition(focusedPlanet, radius) { |
| 299 |
var position |
| 300 |
if (focusedPlanet === Planets.SOLAR_SYSTEM) { |
| 301 |
position = defaultCameraPosition |
| 302 |
position = position.times(cameraDistance) |
| 303 |
} else if (focusedPlanet === Planets.SUN) { |
| 304 |
position = Qt.vector3d(radius * planetScale * 2, |
| 305 |
radius * planetScale * 2, |
| 306 |
radius * planetScale * 2) |
| 307 |
position = position.times(cameraDistance) |
| 308 |
} else { |
| 309 |
var vec1 = Qt.vector3d(planets[focusedPlanet].x, |
| 310 |
planets[focusedPlanet].y, |
| 311 |
planets[focusedPlanet].z) |
| 312 |
var vec2 = defaultUp |
| 313 |
vec1 = vec1.normalized() |
| 314 |
vec2 = vec2.crossProduct(vec1) |
| 315 |
vec2 = vec2.times(radius * planetScale * cameraDistance * 4) |
| 316 |
vec2 = vec2.plus(Qt.vector3d(planets[focusedPlanet].x, |
| 317 |
planets[focusedPlanet].y, |
| 318 |
planets[focusedPlanet].z)) |
| 319 |
vec1 = Qt.vector3d(0, radius * planetScale, 0) |
| 320 |
vec2 = vec2.plus(vec1) |
| 321 |
position = vec2 |
| 322 |
} |
| 323 |
return position |
| 324 |
} |
| 325 |
|
| 326 |
function advanceTime(focusedPlanet) { |
| 327 |
if (focusedPlanet === Planets.SOLAR_SYSTEM) |
| 328 |
daysPerFrame = daysPerFrameScale * 10 |
| 329 |
else |
| 330 |
daysPerFrame = daysPerFrameScale * planetData[focusedPlanet].period / 100.0 |
| 331 |
|
| 332 |
// Advance the time in days |
| 333 |
oldTimeD = currTimeD |
| 334 |
currTimeD = currTimeD + daysPerFrame |
| 335 |
deltaTimeD = currTimeD - oldTimeD |
| 336 |
} |
| 337 |
|
| 338 |
function positionPlanet(i) { |
| 339 |
var planet = planetData[i] |
| 340 |
var target = planets[i] |
| 341 |
|
| 342 |
if (i !== Planets.SUN) { |
| 343 |
// Calculate the planet orbital elements from the current time in days |
| 344 |
var N = (planet.N1 + planet.N2 * currTimeD) * Math.PI / 180 |
| 345 |
var iPlanet = (planet.i1 + planet.i2 * currTimeD) * Math.PI / 180 |
| 346 |
var w = (planet.w1 + planet.w2 * currTimeD) * Math.PI / 180 |
| 347 |
var a = planet.a1 + planet.a2 * currTimeD |
| 348 |
var e = planet.e1 + planet.e2 * currTimeD |
| 349 |
var M = (planet.M1 + planet.M2 * currTimeD) * Math.PI / 180 |
| 350 |
var E = M + e * Math.sin(M) * (1.0 + e * Math.cos(M)) |
| 351 |
|
| 352 |
var xv = a * (Math.cos(E) - e) |
| 353 |
var yv = a * (Math.sqrt(1.0 - e * e) * Math.sin(E)) |
| 354 |
var v = Math.atan2(yv, xv) |
| 355 |
|
| 356 |
// Calculate the distance (radius) |
| 357 |
// TODO: Math.hypot() is ES6 and QML JS is only ES5 currently. A patch to QtQml is |
| 358 |
// required to get Math.hypot() to work. |
| 359 |
//var r = Math.hypot(xv, yv) |
| 360 |
var r = Math.sqrt(Math.pow(xv, 2) + Math.pow(yv, 2)) |
| 361 |
|
| 362 |
// From http://www.davidcolarusso.com/astro/ |
| 363 |
// Modified to compensate for the right handed coordinate system of OpenGL |
| 364 |
var xh = r * (Math.cos(N) * Math.cos(v + w) |
| 365 |
- Math.sin(N) * Math.sin(v + w) * Math.cos(iPlanet)) |
| 366 |
var zh = -r * (Math.sin(N) * Math.cos(v + w) |
| 367 |
+ Math.cos(N) * Math.sin(v + w) * Math.cos(iPlanet)) |
| 368 |
var yh = r * (Math.sin(w + v) * Math.sin(iPlanet)) |
| 369 |
|
| 370 |
// Apply the position offset from the center of orbit to the bodies |
| 371 |
var centerOfOrbit = planet.centerOfOrbit |
| 372 |
target.x = planets[centerOfOrbit].x + xh * Planets.auScale |
| 373 |
target.y = planets[centerOfOrbit].y + yh * Planets.auScale |
| 374 |
target.z = planets[centerOfOrbit].z + zh * Planets.auScale |
| 375 |
} |
| 376 |
// Calculate the rotation (roll) of the bodies. Tilt does not change. |
| 377 |
target.roll += (deltaTimeD / planet.period) * 360 // In degrees |
| 378 |
} |
| 379 |
|
| 380 |
function changeScale(scale, focused) { |
| 381 |
if (!ready) |
| 382 |
return |
| 383 |
|
| 384 |
var scaling = setScale(scale, focused) |
| 385 |
sun.r = planetData[Planets.SUN].radius * scaling / 10 |
| 386 |
mercury.r = planetData[Planets.MERCURY].radius * scaling |
| 387 |
venus.r = planetData[Planets.VENUS].radius * scaling |
| 388 |
earth.r = planetData[Planets.EARTH].radius * scaling |
| 389 |
earthClouds.r = planetData[Planets.EARTH].radius * scaling * 1.02 |
| 390 |
moon.r = planetData[Planets.MOON].radius * scaling |
| 391 |
mars.r = planetData[Planets.MARS].radius * scaling |
| 392 |
jupiter.r = planetData[Planets.JUPITER].radius * scaling |
| 393 |
saturn.r = planetData[Planets.SATURN].radius * scaling |
| 394 |
saturnRing.outerRadius = saturnRingOuterRadius * scaling |
| 395 |
saturnRing.innerRadius = saturnRingInnerRadius * scaling |
| 396 |
uranus.r = planetData[Planets.URANUS].radius * scaling |
| 397 |
uranusRing.outerRadius = uranusRingOuterRadius * scaling |
| 398 |
uranusRing.innerRadius = uranusRingInnerRadius * scaling |
| 399 |
neptune.r = planetData[Planets.NEPTUNE].radius * scaling |
| 400 |
} |
| 401 |
|
| 402 |
function changeSpeed(speed) { |
| 403 |
daysPerFrameScale = speed |
| 404 |
} |
| 405 |
|
| 406 |
function changeCameraDistance(distance) { |
| 407 |
cameraDistance = distance |
| 408 |
} |
| 409 |
|
| 410 |
//! [3] |
| 411 |
function animate(focusedPlanet) { |
| 412 |
if (!ready) |
| 413 |
return |
| 414 |
|
| 415 |
advanceTime(focusedPlanet) |
| 416 |
for (var i = 0; i <= Planets.NUM_SELECTABLE_PLANETS; i++) |
| 417 |
positionPlanet(i) |
| 418 |
|
| 419 |
updateCamera(focusedPlanet) |
| 420 |
} |
| 421 |
//! [3] |
| 422 |
|
| 423 |
function updateCamera(focusedPlanet) { |
| 424 |
// Get the appropriate near plane position for the camera and animate it with QML animations |
| 425 |
var outerRadius = Planets.getOuterRadius(focusedPlanet) |
| 426 |
cameraNear = outerRadius |
| 427 |
camera.nearPlane = cameraNear |
| 428 |
light.near = cameraNear |
| 429 |
|
| 430 |
// Calculate position |
| 431 |
var cameraPosition = getNewCameraPosition(focusedPlanet, outerRadius) |
| 432 |
var cameraOffset = Qt.vector3d(xCameraOffset, yCameraOffset, zCameraOffset) |
| 433 |
cameraPosition = cameraPosition.plus(cameraOffset) |
| 434 |
|
| 435 |
// Calculate look-at point |
| 436 |
var lookAtPlanet = Planets.SUN |
| 437 |
if (focusedPlanet !== Planets.SOLAR_SYSTEM) |
| 438 |
lookAtPlanet = focusedPlanet |
| 439 |
var cameraLookAt = Qt.vector3d(planets[lookAtPlanet].x, |
| 440 |
planets[lookAtPlanet].y, |
| 441 |
planets[lookAtPlanet].z) |
| 442 |
var lookAtOffset = Qt.vector3d(xLookAtOffset, yLookAtOffset, zLookAtOffset) |
| 443 |
cameraLookAt = cameraLookAt.plus(lookAtOffset) |
| 444 |
|
| 445 |
// Set position and look-at |
| 446 |
camera.viewCenter = cameraLookAt |
| 447 |
camera.position = Qt.vector3d(cameraPosition.x, cameraPosition.y, cameraPosition.z) |
| 448 |
camera.upVector = defaultUp |
| 449 |
} |
| 450 |
|
| 451 |
// |
| 452 |
// STARFIELD |
| 453 |
// |
| 454 |
|
| 455 |
Entity { |
| 456 |
id: starfieldEntity |
| 457 |
|
| 458 |
Mesh { |
| 459 |
id: starfield |
| 460 |
source: "qrc:/meshes/starfield.obj" |
| 461 |
} |
| 462 |
|
| 463 |
PlanetMaterial { |
| 464 |
id: materialStarfield |
| 465 |
effect: effectD |
| 466 |
ambientLight: ambientStrengthStarfield |
| 467 |
specularColor: Qt.rgba(0.0, 0.0, 0.0, 1.0) |
| 468 |
diffuseMap: "qrc:/images/solarsystemscope/galaxy_starfield.jpg" |
| 469 |
shininess: 1000000.0 |
| 470 |
} |
| 471 |
|
| 472 |
property Transform transformStarfield: Transform { |
| 473 |
scale: 8500 |
| 474 |
translation: Qt.vector3d(0, 0, 0) |
| 475 |
} |
| 476 |
|
| 477 |
components: [ starfield, materialStarfield, transformStarfield ] |
| 478 |
} |
| 479 |
|
| 480 |
// |
| 481 |
// SUN |
| 482 |
// |
| 483 |
|
| 484 |
Entity { |
| 485 |
id: sunEntity |
| 486 |
|
| 487 |
Planet { |
| 488 |
id: sun |
| 489 |
tilt: planetData[Planets.SUN].tilt |
| 490 |
} |
| 491 |
|
| 492 |
PlanetMaterial { |
| 493 |
id: materialSun |
| 494 |
effect: sunEffect |
| 495 |
ambientLight: ambientStrengthSun |
| 496 |
diffuseMap: "qrc:/images/solarsystemscope/sunmap.jpg" |
| 497 |
} |
| 498 |
|
| 499 |
property Transform transformSun: Transform { |
| 500 |
matrix: { |
| 501 |
var m = Qt.matrix4x4() |
| 502 |
m.translate(Qt.vector3d(sun.x, sun.y, sun.z)) |
| 503 |
m.rotate(sun.tilt, tiltAxis) |
| 504 |
m.rotate(sun.roll, rollAxis) |
| 505 |
m.scale(sun.r) |
| 506 |
return m |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
components: [ sun, materialSun, transformSun ] |
| 511 |
} |
| 512 |
|
| 513 |
// |
| 514 |
// PLANETS |
| 515 |
// |
| 516 |
|
| 517 |
// MERCURY |
| 518 |
|
| 519 |
Entity { |
| 520 |
id: mercuryEntity |
| 521 |
|
| 522 |
Planet { |
| 523 |
id: mercury |
| 524 |
tilt: planetData[Planets.MERCURY].tilt |
| 525 |
} |
| 526 |
|
| 527 |
PlanetMaterial { |
| 528 |
id: materialMercury |
| 529 |
effect: effectDB |
| 530 |
ambientLight: ambientStrengthPlanet |
| 531 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 532 |
diffuseMap: "qrc:/images/solarsystemscope/mercurymap.jpg" |
| 533 |
normalMap: "qrc:/images/solarsystemscope/mercurynormal.jpg" |
| 534 |
shininess: shininessSpecularMap |
| 535 |
} |
| 536 |
|
| 537 |
property Transform transformMercury: Transform { |
| 538 |
matrix: { |
| 539 |
var m = Qt.matrix4x4() |
| 540 |
m.translate(Qt.vector3d(mercury.x, mercury.y, mercury.z)) |
| 541 |
m.rotate(mercury.tilt, tiltAxis) |
| 542 |
m.rotate(mercury.roll, rollAxis) |
| 543 |
m.scale(mercury.r) |
| 544 |
return m |
| 545 |
} |
| 546 |
} |
| 547 |
|
| 548 |
components: [ mercury, materialMercury, transformMercury ] |
| 549 |
} |
| 550 |
|
| 551 |
// VENUS |
| 552 |
|
| 553 |
Entity { |
| 554 |
id: venusEntity |
| 555 |
|
| 556 |
Planet { |
| 557 |
id: venus |
| 558 |
tilt: planetData[Planets.VENUS].tilt |
| 559 |
} |
| 560 |
|
| 561 |
PlanetMaterial { |
| 562 |
id: materialVenus |
| 563 |
effect: effectDB |
| 564 |
ambientLight: ambientStrengthPlanet |
| 565 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 566 |
diffuseMap: "qrc:/images/solarsystemscope/venusmap.jpg" |
| 567 |
normalMap: "qrc:/images/solarsystemscope/venusnormal.jpg" |
| 568 |
shininess: shininessSpecularMap |
| 569 |
} |
| 570 |
|
| 571 |
property Transform transformVenus: Transform { |
| 572 |
matrix: { |
| 573 |
var m = Qt.matrix4x4() |
| 574 |
m.translate(Qt.vector3d(venus.x, venus.y, venus.z)) |
| 575 |
m.rotate(venus.tilt, tiltAxis) |
| 576 |
m.rotate(venus.roll, rollAxis) |
| 577 |
m.scale(venus.r) |
| 578 |
return m |
| 579 |
} |
| 580 |
} |
| 581 |
|
| 582 |
components: [ venus, materialVenus, transformVenus ] |
| 583 |
} |
| 584 |
|
| 585 |
// EARTH |
| 586 |
|
| 587 |
//! [1] |
| 588 |
Entity { |
| 589 |
id: earthEntity |
| 590 |
|
| 591 |
Planet { |
| 592 |
id: earth |
| 593 |
tilt: planetData[Planets.EARTH].tilt |
| 594 |
} |
| 595 |
|
| 596 |
PlanetMaterial { |
| 597 |
id: materialEarth |
| 598 |
effect: effectDSB |
| 599 |
ambientLight: ambientStrengthPlanet |
| 600 |
diffuseMap: "qrc:/images/solarsystemscope/earthmap2k.jpg" |
| 601 |
specularMap: "qrc:/images/solarsystemscope/earthspec2k.jpg" |
| 602 |
normalMap: "qrc:/images/solarsystemscope/earthnormal2k.jpg" |
| 603 |
shininess: shininessSpecularMap |
| 604 |
} |
| 605 |
|
| 606 |
property Transform transformEarth: Transform { |
| 607 |
matrix: { |
| 608 |
var m = Qt.matrix4x4() |
| 609 |
m.translate(Qt.vector3d(earth.x, earth.y, earth.z)) |
| 610 |
m.rotate(earth.tilt, tiltAxis) |
| 611 |
m.rotate(earth.roll, rollAxis) |
| 612 |
m.scale(earth.r) |
| 613 |
return m |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
components: [ earth, materialEarth, transformEarth ] |
| 618 |
} |
| 619 |
//! [1] |
| 620 |
|
| 621 |
// EARTH CLOUDS |
| 622 |
|
| 623 |
Entity { |
| 624 |
id: earthCloudsEntity |
| 625 |
|
| 626 |
Planet { |
| 627 |
id: earthClouds |
| 628 |
tilt: planetData[Planets.EARTH].tilt |
| 629 |
} |
| 630 |
|
| 631 |
PlanetMaterial { |
| 632 |
id: materialEarthClouds |
| 633 |
effect: cloudEffect |
| 634 |
ambientLight: ambientStrengthClouds |
| 635 |
diffuseMap: "qrc:/images/solarsystemscope/earthcloudmapcolortrans.png" |
| 636 |
specularMap: "qrc:/images/solarsystemscope/earthcloudmapspec.jpg" |
| 637 |
shininess: shininessClouds |
| 638 |
opacity: 0.2 |
| 639 |
} |
| 640 |
|
| 641 |
property Transform transformEarthClouds: Transform { |
| 642 |
matrix: { |
| 643 |
var m = Qt.matrix4x4() |
| 644 |
m.translate(Qt.vector3d(earth.x, earth.y, earth.z)) |
| 645 |
m.rotate(earth.tilt, tiltAxis) |
| 646 |
m.rotate(earth.roll / 1.2, rollAxis) |
| 647 |
m.scale(earthClouds.r) |
| 648 |
return m |
| 649 |
} |
| 650 |
} |
| 651 |
|
| 652 |
components: [ earthClouds, materialEarthClouds, transformEarthClouds ] |
| 653 |
} |
| 654 |
|
| 655 |
// MOON |
| 656 |
|
| 657 |
Entity { |
| 658 |
id: moonEntity |
| 659 |
|
| 660 |
Planet { |
| 661 |
id: moon |
| 662 |
tilt: planetData[Planets.MOON].tilt |
| 663 |
} |
| 664 |
|
| 665 |
PlanetMaterial { |
| 666 |
id: materialMoon |
| 667 |
effect: effectDB |
| 668 |
ambientLight: ambientStrengthPlanet |
| 669 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 670 |
diffuseMap: "qrc:/images/solarsystemscope/moonmap2k.jpg" |
| 671 |
normalMap: "qrc:/images/solarsystemscope/moonnormal2k.jpg" |
| 672 |
shininess: shininessSpecularMap |
| 673 |
} |
| 674 |
|
| 675 |
property Transform transformMoon: Transform { |
| 676 |
matrix: { |
| 677 |
var m = Qt.matrix4x4() |
| 678 |
m.translate(Qt.vector3d(moon.x, moon.y, moon.z)) |
| 679 |
m.rotate(moon.tilt, tiltAxis) |
| 680 |
m.rotate(moon.roll, rollAxis) |
| 681 |
m.scale(moon.r) |
| 682 |
return m |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
components: [ moon, materialMoon, transformMoon ] |
| 687 |
} |
| 688 |
|
| 689 |
// MARS |
| 690 |
|
| 691 |
Entity { |
| 692 |
id: marsEntity |
| 693 |
|
| 694 |
Planet { |
| 695 |
id: mars |
| 696 |
tilt: planetData[Planets.MARS].tilt |
| 697 |
} |
| 698 |
|
| 699 |
PlanetMaterial { |
| 700 |
id: materialMars |
| 701 |
effect: effectDB |
| 702 |
ambientLight: ambientStrengthPlanet |
| 703 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 704 |
diffuseMap: "qrc:/images/solarsystemscope/marsmap2k.jpg" |
| 705 |
normalMap: "qrc:/images/solarsystemscope/marsnormal2k.jpg" |
| 706 |
shininess: shininessSpecularMap |
| 707 |
} |
| 708 |
|
| 709 |
property Transform transformMars: Transform { |
| 710 |
matrix: { |
| 711 |
var m = Qt.matrix4x4() |
| 712 |
m.translate(Qt.vector3d(mars.x, mars.y, mars.z)) |
| 713 |
m.rotate(mars.tilt, tiltAxis) |
| 714 |
m.rotate(mars.roll, rollAxis) |
| 715 |
m.scale(mars.r) |
| 716 |
return m |
| 717 |
} |
| 718 |
} |
| 719 |
|
| 720 |
components: [ mars, materialMars, transformMars ] |
| 721 |
} |
| 722 |
|
| 723 |
// JUPITER |
| 724 |
|
| 725 |
Entity { |
| 726 |
id: jupiterEntity |
| 727 |
|
| 728 |
Planet { |
| 729 |
id: jupiter |
| 730 |
tilt: planetData[Planets.JUPITER].tilt |
| 731 |
} |
| 732 |
|
| 733 |
PlanetMaterial { |
| 734 |
id: materialJupiter |
| 735 |
effect: effectD |
| 736 |
ambientLight: ambientStrengthPlanet |
| 737 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 738 |
diffuseMap: "qrc:/images/solarsystemscope/jupitermap.jpg" |
| 739 |
shininess: shininessBasic |
| 740 |
} |
| 741 |
|
| 742 |
property Transform transformJupiter: Transform { |
| 743 |
matrix: { |
| 744 |
var m = Qt.matrix4x4() |
| 745 |
m.translate(Qt.vector3d(jupiter.x, jupiter.y, jupiter.z)) |
| 746 |
m.rotate(jupiter.tilt, tiltAxis) |
| 747 |
m.rotate(jupiter.roll, rollAxis) |
| 748 |
m.scale(jupiter.r) |
| 749 |
return m |
| 750 |
} |
| 751 |
} |
| 752 |
|
| 753 |
components: [ jupiter, materialJupiter, transformJupiter ] |
| 754 |
} |
| 755 |
|
| 756 |
// SATURN |
| 757 |
|
| 758 |
Entity { |
| 759 |
id: saturnEntity |
| 760 |
|
| 761 |
Planet { |
| 762 |
id: saturn |
| 763 |
tilt: planetData[Planets.SATURN].tilt |
| 764 |
} |
| 765 |
|
| 766 |
PlanetMaterial { |
| 767 |
id: materialSaturn |
| 768 |
effect: shadowMapEffect |
| 769 |
ambientLight: ambientStrengthPlanet |
| 770 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 771 |
diffuseMap: "qrc:/images/solarsystemscope/saturnmap.jpg" |
| 772 |
shininess: shininessBasic |
| 773 |
} |
| 774 |
|
| 775 |
property Transform transformSaturn: Transform { |
| 776 |
matrix: { |
| 777 |
var m = Qt.matrix4x4() |
| 778 |
m.translate(Qt.vector3d(saturn.x, saturn.y, saturn.z)) |
| 779 |
m.rotate(saturn.tilt, tiltAxis) |
| 780 |
m.rotate(saturn.roll, rollAxis) |
| 781 |
m.scale(saturn.r) |
| 782 |
return m |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
components: [ saturn, materialSaturn, transformSaturn ] |
| 787 |
} |
| 788 |
|
| 789 |
// SATURN RING |
| 790 |
|
| 791 |
Entity { |
| 792 |
id: saturnRingEntity |
| 793 |
|
| 794 |
Ring { |
| 795 |
id: saturnRing |
| 796 |
innerRadius: saturnRingInnerRadius |
| 797 |
outerRadius: saturnRingOuterRadius |
| 798 |
} |
| 799 |
|
| 800 |
PlanetMaterial { |
| 801 |
id: materialSaturnRing |
| 802 |
effect: shadowMapEffect |
| 803 |
ambientLight: ambientStrengthRing |
| 804 |
specularColor: Qt.rgba(0.01, 0.01, 0.01, 1.0) |
| 805 |
diffuseMap: "qrc:/images/solarsystemscope/saturnringcolortrans.png" |
| 806 |
shininess: shininessBasic |
| 807 |
opacity: 0.4 |
| 808 |
} |
| 809 |
|
| 810 |
property Transform transformSaturnRing: Transform { |
| 811 |
matrix: { |
| 812 |
var m = Qt.matrix4x4() |
| 813 |
m.translate(Qt.vector3d(saturn.x, saturn.y, saturn.z)) |
| 814 |
m.rotate(saturn.tilt, tiltAxis) |
| 815 |
m.rotate(saturn.roll / 10, rollAxis) |
| 816 |
m.scale((saturnRing.innerRadius + saturnRing.outerRadius) / 1.75) |
| 817 |
return m |
| 818 |
} |
| 819 |
} |
| 820 |
|
| 821 |
components: [ saturnRing, materialSaturnRing, transformSaturnRing ] |
| 822 |
} |
| 823 |
|
| 824 |
// URANUS |
| 825 |
|
| 826 |
Entity { |
| 827 |
id: uranusEntity |
| 828 |
|
| 829 |
Planet { |
| 830 |
id: uranus |
| 831 |
tilt: planetData[Planets.URANUS].tilt |
| 832 |
} |
| 833 |
|
| 834 |
PlanetMaterial { |
| 835 |
id: materialUranus |
| 836 |
effect: shadowMapEffect |
| 837 |
ambientLight: ambientStrengthPlanet |
| 838 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 839 |
diffuseMap: "qrc:/images/solarsystemscope/uranusmap.jpg" |
| 840 |
shininess: shininessBasic |
| 841 |
} |
| 842 |
|
| 843 |
property Transform transformUranus: Transform { |
| 844 |
matrix: { |
| 845 |
var m = Qt.matrix4x4() |
| 846 |
m.translate(Qt.vector3d(uranus.x, uranus.y, uranus.z)) |
| 847 |
m.rotate(uranus.tilt, tiltAxis) |
| 848 |
m.rotate(uranus.roll, rollAxis) |
| 849 |
m.scale(uranus.r) |
| 850 |
return m |
| 851 |
} |
| 852 |
} |
| 853 |
|
| 854 |
components: [ uranus, materialUranus, transformUranus ] |
| 855 |
} |
| 856 |
|
| 857 |
// URANUS RING |
| 858 |
|
| 859 |
Entity { |
| 860 |
id: uranusRingEntity |
| 861 |
|
| 862 |
Ring { |
| 863 |
id: uranusRing |
| 864 |
innerRadius: uranusRingInnerRadius |
| 865 |
outerRadius: uranusRingOuterRadius |
| 866 |
} |
| 867 |
|
| 868 |
PlanetMaterial { |
| 869 |
id: materialUranusRing |
| 870 |
effect: shadowMapEffect |
| 871 |
ambientLight: ambientStrengthRing |
| 872 |
specularColor: Qt.rgba(0.01, 0.01, 0.01, 1.0) |
| 873 |
diffuseMap: "qrc:/images/nasa/uranusringcolortrans.png" |
| 874 |
shininess: shininessBasic |
| 875 |
opacity: 0.4 |
| 876 |
} |
| 877 |
|
| 878 |
property Transform transformUranusRing: Transform { |
| 879 |
matrix: { |
| 880 |
var m = Qt.matrix4x4() |
| 881 |
m.translate(Qt.vector3d(uranus.x, uranus.y, uranus.z)) |
| 882 |
m.rotate(uranus.tilt, tiltAxis) |
| 883 |
m.rotate(uranus.roll / 10, rollAxis) |
| 884 |
m.scale((uranusRing.innerRadius + uranusRing.outerRadius) / 1.75) |
| 885 |
return m |
| 886 |
} |
| 887 |
} |
| 888 |
|
| 889 |
components: [ uranusRing, materialUranusRing, transformUranusRing ] |
| 890 |
} |
| 891 |
|
| 892 |
// NEPTUNE |
| 893 |
|
| 894 |
Entity { |
| 895 |
id: neptuneEntity |
| 896 |
|
| 897 |
Planet { |
| 898 |
id: neptune |
| 899 |
tilt: planetData[Planets.NEPTUNE].tilt |
| 900 |
} |
| 901 |
|
| 902 |
PlanetMaterial { |
| 903 |
id: materialNeptune |
| 904 |
effect: effectD |
| 905 |
ambientLight: ambientStrengthPlanet |
| 906 |
specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) |
| 907 |
diffuseMap: "qrc:/images/solarsystemscope/neptunemap.jpg" |
| 908 |
shininess: shininessBasic |
| 909 |
} |
| 910 |
|
| 911 |
property Transform transformNeptune: Transform { |
| 912 |
matrix: { |
| 913 |
var m = Qt.matrix4x4() |
| 914 |
m.translate(Qt.vector3d(neptune.x, neptune.y, neptune.z)) |
| 915 |
m.rotate(neptune.tilt, tiltAxis) |
| 916 |
m.rotate(neptune.roll, rollAxis) |
| 917 |
m.scale(neptune.r) |
| 918 |
return m |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
components: [ neptune, materialNeptune, transformNeptune ] |
| 923 |
} |
| 924 |
} |