/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.0 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Logic 2.0
import Qt3D.Extras 2.0
import "planets.js" as Planets
Entity {
id: sceneRoot
property boolready: false
property realcameraNear: 0
property realxLookAtOffset: 0
property realyLookAtOffset: 0
property realzLookAtOffset: 0
property realxCameraOffset: 0
property realyCameraOffset: 0
property realzCameraOffset: 0
property varplanetData
property varplanets: []
property vector3ddefaultUp: Qt.vector3d(0, 1, 0)
property vector3ddefaultCameraPosition: Qt.vector3d(Planets.solarDistance,
Planets.solarDistance,
Planets.solarDistance)
property vector3dtiltAxis: Qt.vector3d(0, 0, 1)
property vector3drollAxis: Qt.vector3d(0, 1, 0)
property realcameraDistance: 1
property vector3doldCameraPosition
property vector3doldFocusedPlanetPosition
property colorambientStrengthStarfield: "#000000"
property colorambientStrengthSun: "#ffffff"
property colorambientStrengthClouds: "#000000"
property colorambientStrengthRing: "#111111"
property colorambientStrengthPlanet: "#222222"
property realshininessSpecularMap: 50.0
property realshininessClouds: 10.0
property realshininessBasic: 1.0
property realsaturnRingInnerRadius
property realsaturnRingOuterRadius
property realuranusRingInnerRadius
property realuranusRingOuterRadius// Time variables
property intyear: 2000
property intmonth: 1
property intday: 1// Time scale formula based on http://www.stjarnhimlen.se/comp/ppcomp.html
property realstartD: 367*year-7* (year+ (month+9) /12) /4+275*month/9+day-730530
property realoldTimeD: startD
property realcurrTimeD: startD
property realdeltaTimeD: 0
property realdaysPerFrame
property realdaysPerFrameScale
property realplanetScale
property boolfocusedScaling: false
property intfocusedMinimumScale: 20
property realactualScale// Animate solar system with LogicComponentFrameAction {
onTriggered: {
frames++
animate(focusedPlanet)
}
}
PlanetsLight {
id: lightratio: width/height
}
Camera {
id: cameraprojectionType: CameraLens.PerspectiveProjectionfieldOfView: 45aspectRatio: width/heightnearPlane: 2500000.0farPlane: 20000000.0position: defaultCameraPositionupVector: defaultUpviewCenter: Qt.vector3d( xLookAtOffset, yLookAtOffset, zLookAtOffset )
}
FirstPersonCameraController { camera: camera }
components: [
PlanetFrameGraph {
id: framegraphviewCamera: cameralightCamera: light.lightCamera
},
InputSettings {}
]
PlanetEffect {
id: effectDlight: light
}
PlanetEffect {
id: effectDBlight: lightvertexES: "qrc:/shaders/es2/planetDB.vert"fragmentES: "qrc:/shaders/es2/planetDB.frag"vertexGL: "qrc:/shaders/gl3/planetDB.vert"fragmentGL: "qrc:/shaders/gl3/planetDB.frag"
}
PlanetEffect {
id: effectDSBlight: lightvertexES: "qrc:/shaders/es2/planetDB.vert"fragmentES: "qrc:/shaders/es2/planetDSB.frag"vertexGL: "qrc:/shaders/gl3/planetDB.vert"fragmentGL: "qrc:/shaders/gl3/planetDSB.frag"
}
PlanetEffect {
id: cloudEffectlight: lightvertexES: "qrc:/shaders/es2/planetD.vert"fragmentES: "qrc:/shaders/es2/planetDS.frag"vertexGL: "qrc:/shaders/gl3/planetD.vert"fragmentGL: "qrc:/shaders/gl3/planetDS.frag"
}
SunEffect {
id: sunEffect
}
ShadowEffect {
id: shadowMapEffectshadowTexture: framegraph.shadowTexturelight: light
}
QQ2.Component.onCompleted: {
planetData=Planets.loadPlanetData()
// Push in the correct orderplanets.push(sun)
planets.push(mercury)
planets.push(venus)
planets.push(earth)
planets.push(mars)
planets.push(jupiter)
planets.push(saturn)
planets.push(uranus)
planets.push(neptune)
planets.push(moon)
// TODO: Once support for creating meshes from arrays is implemented take these into use//saturnRing.makeRing()//uranusRing.makeRing()saturnRingOuterRadius=planetData[Planets.SATURN].radius+Planets.saturnOuterRadiussaturnRingInnerRadius=planetData[Planets.SATURN].radius+6.630uranusRingOuterRadius=planetData[Planets.URANUS].radius+Planets.uranusOuterRadiusuranusRingInnerRadius=planetData[Planets.URANUS].radius+2ready=truechangeScale(1200)
changeSpeed(0.2)
setLookAtOffset(Planets.SUN)
}
QQ2.NumberAnimation {
id: lookAtOffsetAnimationtarget: sceneRootproperties: "xLookAtOffset, yLookAtOffset, zLookAtOffset"to: 0easing.type: Easing.InOutQuintduration: 1250
}
QQ2.NumberAnimation {
id: cameraOffsetAnimationtarget: sceneRootproperties: "xCameraOffset, yCameraOffset, zCameraOffset"to: 0easing.type: Easing.InOutQuintduration: 2500
}
QQ2.Behavior on cameraNear {
QQ2.PropertyAnimation {
easing.type: Easing.InOutQuintduration: 2500
}
}
functionchangePlanetFocus(oldPlanet, focusedPlanet) {
setOldPlanet(oldPlanet, focusedPlanet)
setLookAtOffset(focusedPlanet)
setCameraOffset(oldPlanet, focusedPlanet)
lookAtOffsetAnimation.restart()
cameraOffsetAnimation.restart()
}
functionsetOldPlanet(oldPlanet, focusedPlanet) {
oldCameraPosition=camera.position
var planet = 0if (oldPlanet!==Planets.SOLAR_SYSTEM)
planet=oldPlanetoldFocusedPlanetPosition=Qt.vector3d(planets[planet].x,
planets[planet].y,
planets[planet].z)
checkScaling(focusedPlanet)
}
functionsetScale(value, focused) {
// Save actual scaleif (!focused)
actualScale=value// Limit minimum scaling in focus mode to avoid jitter caused by rounding errorsif (value<=focusedMinimumScale&& (focusedScaling||focused))
planetScale=focusedMinimumScaleelseplanetScale=actualScalereturnplanetScale
}
functioncheckScaling(focusedPlanet) {
if (focusedPlanet!==Planets.SOLAR_SYSTEM) {
// Limit minimum scaling in focus mode to avoid jitter caused by rounding errorsif (actualScale<=focusedMinimumScale) {
planetScale=focusedMinimumScalechangeScale(focusedMinimumScale, true)
}
focusedScaling=true
} elseif (focusedScaling===true) {
// Restore normal scalingfocusedScaling=falsechangeScale(actualScale, false)
}
}
functionsetLookAtOffset(focusedPlanet) {
var offset = oldFocusedPlanetPosition
var planet = 0if (focusedPlanet!==Planets.SOLAR_SYSTEM)
planet=focusedPlanet
var focusedPlanetPosition = Qt.vector3d(planets[planet].x,
planets[planet].y,
planets[planet].z)
offset=offset.minus(focusedPlanetPosition)
xLookAtOffset=offset.xyLookAtOffset=offset.yzLookAtOffset=offset.z
}
functionsetCameraOffset(oldPlanet, focusedPlanet) {
var offset = oldCameraPosition
var planet = 0if (focusedPlanet!==Planets.SOLAR_SYSTEM)
planet=focusedPlanet
var newCameraPosition = getNewCameraPosition(focusedPlanet, Planets.getOuterRadius(planet))
if (focusedPlanet!==Planets.SUN)
offset=offset.minus(newCameraPosition)
if (oldPlanet===Planets.SOLAR_SYSTEM&&focusedPlanet===Planets.SUN) {
xCameraOffset=Math.abs(offset.x)
yCameraOffset=Math.abs(offset.y)
zCameraOffset=Math.abs(offset.z)
} else { // from a planet to anotherxCameraOffset=offset.xyCameraOffset=offset.yzCameraOffset=offset.z
}
}
functiongetNewCameraPosition(focusedPlanet, radius) {
var position
if (focusedPlanet===Planets.SOLAR_SYSTEM) {
position=defaultCameraPositionposition=position.times(cameraDistance)
} elseif (focusedPlanet===Planets.SUN) {
position=Qt.vector3d(radius*planetScale*2,
radius*planetScale*2,
radius*planetScale*2)
position=position.times(cameraDistance)
} else {
var vec1 = Qt.vector3d(planets[focusedPlanet].x,
planets[focusedPlanet].y,
planets[focusedPlanet].z)
var vec2 = defaultUpvec1=vec1.normalized()
vec2=vec2.crossProduct(vec1)
vec2=vec2.times(radius*planetScale*cameraDistance*4)
vec2=vec2.plus(Qt.vector3d(planets[focusedPlanet].x,
planets[focusedPlanet].y,
planets[focusedPlanet].z))
vec1=Qt.vector3d(0, radius*planetScale, 0)
vec2=vec2.plus(vec1)
position=vec2
}
returnposition
}
functionadvanceTime(focusedPlanet) {
if (focusedPlanet===Planets.SOLAR_SYSTEM)
daysPerFrame=daysPerFrameScale*10elsedaysPerFrame=daysPerFrameScale*planetData[focusedPlanet].period/100.0// Advance the time in daysoldTimeD=currTimeDcurrTimeD=currTimeD+daysPerFramedeltaTimeD=currTimeD-oldTimeD
}
functionpositionPlanet(i) {
var planet = planetData[i]
var target = planets[i]
if (i!==Planets.SUN) {
// Calculate the planet orbital elements from the current time in days
var N = (planet.N1+planet.N2*currTimeD) *Math.PI/180
var iPlanet = (planet.i1+planet.i2*currTimeD) *Math.PI/180
var w = (planet.w1+planet.w2*currTimeD) *Math.PI/180
var a = planet.a1+planet.a2*currTimeD
var e = planet.e1+planet.e2*currTimeD
var M = (planet.M1+planet.M2*currTimeD) *Math.PI/180
var E = M+e*Math.sin(M) * (1.0+e*Math.cos(M))
var xv = a* (Math.cos(E) -e)
var yv = a* (Math.sqrt(1.0-e*e) *Math.sin(E))
var v = Math.atan2(yv, xv)
// Calculate the distance (radius)// TODO: Math.hypot() is ES6 and QML JS is only ES5 currently. A patch to QtQml is// required to get Math.hypot() to work.//var r = Math.hypot(xv, yv)
var r = Math.sqrt(Math.pow(xv, 2) +Math.pow(yv, 2))
// From http://www.davidcolarusso.com/astro/// Modified to compensate for the right handed coordinate system of OpenGL
var xh = r* (Math.cos(N) *Math.cos(v+w)
-Math.sin(N) *Math.sin(v+w) *Math.cos(iPlanet))
var zh = -r* (Math.sin(N) *Math.cos(v+w)
+Math.cos(N) *Math.sin(v+w) *Math.cos(iPlanet))
var yh = r* (Math.sin(w+v) *Math.sin(iPlanet))
// Apply the position offset from the center of orbit to the bodies
var centerOfOrbit = planet.centerOfOrbittarget.x=planets[centerOfOrbit].x+xh*Planets.auScaletarget.y=planets[centerOfOrbit].y+yh*Planets.auScaletarget.z=planets[centerOfOrbit].z+zh*Planets.auScale
}
// Calculate the rotation (roll) of the bodies. Tilt does not change.target.roll+= (deltaTimeD/planet.period) *360// In degrees
}
functionchangeScale(scale, focused) {
if (!ready)
return
var scaling = setScale(scale, focused)
sun.r=planetData[Planets.SUN].radius*scaling/100mercury.r=planetData[Planets.MERCURY].radius*scalingvenus.r=planetData[Planets.VENUS].radius*scalingearth.r=planetData[Planets.EARTH].radius*scalingearthClouds.r=planetData[Planets.EARTH].radius*scaling*1.02moon.r=planetData[Planets.MOON].radius*scalingmars.r=planetData[Planets.MARS].radius*scalingjupiter.r=planetData[Planets.JUPITER].radius*scalingsaturn.r=planetData[Planets.SATURN].radius*scalingsaturnRing.outerRadius=saturnRingOuterRadius*scalingsaturnRing.innerRadius=saturnRingInnerRadius*scalinguranus.r=planetData[Planets.URANUS].radius*scalinguranusRing.outerRadius=uranusRingOuterRadius*scalinguranusRing.innerRadius=uranusRingInnerRadius*scalingneptune.r=planetData[Planets.NEPTUNE].radius*scaling
}
functionchangeSpeed(speed) {
daysPerFrameScale=speed
}
functionchangeCameraDistance(distance) {
cameraDistance=distance
}
functionanimate(focusedPlanet) {
if (!ready)
returnadvanceTime(focusedPlanet)
for (var i = 0; i<=Planets.NUM_SELECTABLE_PLANETS; i++)
positionPlanet(i)
updateCamera(focusedPlanet)
}
functionupdateCamera(focusedPlanet) {
// Get the appropriate near plane position for the camera and animate it with QML animations
var outerRadius = Planets.getOuterRadius(focusedPlanet)
cameraNear=outerRadiuscamera.nearPlane=cameraNearlight.near=cameraNear// Calculate position
var cameraPosition = getNewCameraPosition(focusedPlanet, outerRadius)
var cameraOffset = Qt.vector3d(xCameraOffset, yCameraOffset, zCameraOffset)
cameraPosition=cameraPosition.plus(cameraOffset)
// Calculate look-at point
var lookAtPlanet = Planets.SUNif (focusedPlanet!==Planets.SOLAR_SYSTEM)
lookAtPlanet=focusedPlanet
var cameraLookAt = Qt.vector3d(planets[lookAtPlanet].x,
planets[lookAtPlanet].y,
planets[lookAtPlanet].z)
var lookAtOffset = Qt.vector3d(xLookAtOffset, yLookAtOffset, zLookAtOffset)
cameraLookAt=cameraLookAt.plus(lookAtOffset)
// Set position and look-atcamera.viewCenter=cameraLookAtcamera.position=Qt.vector3d(cameraPosition.x, cameraPosition.y, cameraPosition.z)
camera.upVector=defaultUp
}
//
// STARFIELD
//
Entity {
id: starfieldEntityMesh {
id: starfieldsource: "qrc:/meshes/starfield.obj"
}
PlanetMaterial {
id: materialStarfieldeffect: effectDambientLight: ambientStrengthStarfieldspecularColor: Qt.rgba(0.0, 0.0, 0.0, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/galaxy_starfield.jpg"shininess: 1000000.0
}
property TransformtransformStarfield: Transform {
scale: 8500000translation: Qt.vector3d(0, 0, 0)
}
components: [ starfield, materialStarfield, transformStarfield ]
}
//
// SUN
//
Entity {
id: sunEntityPlanet {
id: suntilt: planetData[Planets.SUN].tilt
}
PlanetMaterial {
id: materialSuneffect: sunEffectambientLight: ambientStrengthSundiffuseMap: "qrc:/images/solarsystemscope/sunmap.jpg"
}
property TransformtransformSun: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(sun.x, sun.y, sun.z))
m.rotate(sun.tilt, tiltAxis)
m.rotate(sun.roll, rollAxis)
m.scale(sun.r)
returnm
}
}
components: [ sun, materialSun, transformSun ]
}
//
// PLANETS
//
// MERCURYEntity {
id: mercuryEntityPlanet {
id: mercurytilt: planetData[Planets.MERCURY].tilt
}
PlanetMaterial {
id: materialMercuryeffect: effectDBambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/mercurymap.jpg"normalMap: "qrc:/images/solarsystemscope/mercurynormal.jpg"shininess: shininessSpecularMap
}
property TransformtransformMercury: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(mercury.x, mercury.y, mercury.z))
m.rotate(mercury.tilt, tiltAxis)
m.rotate(mercury.roll, rollAxis)
m.scale(mercury.r)
returnm
}
}
components: [ mercury, materialMercury, transformMercury ]
}
// VENUSEntity {
id: venusEntityPlanet {
id: venustilt: planetData[Planets.VENUS].tilt
}
PlanetMaterial {
id: materialVenuseffect: effectDBambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/venusmap.jpg"normalMap: "qrc:/images/solarsystemscope/venusnormal.jpg"shininess: shininessSpecularMap
}
property TransformtransformVenus: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(venus.x, venus.y, venus.z))
m.rotate(venus.tilt, tiltAxis)
m.rotate(venus.roll, rollAxis)
m.scale(venus.r)
returnm
}
}
components: [ venus, materialVenus, transformVenus ]
}
// EARTHEntity {
id: earthEntityPlanet {
id: earthtilt: planetData[Planets.EARTH].tilt
}
PlanetMaterial {
id: materialEartheffect: effectDSBambientLight: ambientStrengthPlanetdiffuseMap: "qrc:/images/solarsystemscope/earthmap2k.jpg"specularMap: "qrc:/images/solarsystemscope/earthspec2k.jpg"normalMap: "qrc:/images/solarsystemscope/earthnormal2k.jpg"shininess: shininessSpecularMap
}
property TransformtransformEarth: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(earth.x, earth.y, earth.z))
m.rotate(earth.tilt, tiltAxis)
m.rotate(earth.roll, rollAxis)
m.scale(earth.r)
returnm
}
}
components: [ earth, materialEarth, transformEarth ]
}
// EARTH CLOUDSEntity {
id: earthCloudsEntityPlanet {
id: earthCloudstilt: planetData[Planets.EARTH].tilt
}
PlanetMaterial {
id: materialEarthCloudseffect: cloudEffectambientLight: ambientStrengthCloudsdiffuseMap: "qrc:/images/solarsystemscope/earthcloudmapcolortrans.png"specularMap: "qrc:/images/solarsystemscope/earthcloudmapspec.jpg"shininess: shininessCloudsopacity: 0.2
}
property TransformtransformEarthClouds: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(earth.x, earth.y, earth.z))
m.rotate(earth.tilt, tiltAxis)
m.rotate(earth.roll/1.2, rollAxis)
m.scale(earthClouds.r)
returnm
}
}
components: [ earthClouds, materialEarthClouds, transformEarthClouds ]
}
// MOONEntity {
id: moonEntityPlanet {
id: moontilt: planetData[Planets.MOON].tilt
}
PlanetMaterial {
id: materialMooneffect: effectDBambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/moonmap2k.jpg"normalMap: "qrc:/images/solarsystemscope/moonnormal2k.jpg"shininess: shininessSpecularMap
}
property TransformtransformMoon: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(moon.x, moon.y, moon.z))
m.rotate(moon.tilt, tiltAxis)
m.rotate(moon.roll, rollAxis)
m.scale(moon.r)
returnm
}
}
components: [ moon, materialMoon, transformMoon ]
}
// MARSEntity {
id: marsEntityPlanet {
id: marstilt: planetData[Planets.MARS].tilt
}
PlanetMaterial {
id: materialMarseffect: effectDBambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/marsmap2k.jpg"normalMap: "qrc:/images/solarsystemscope/marsnormal2k.jpg"shininess: shininessSpecularMap
}
property TransformtransformMars: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(mars.x, mars.y, mars.z))
m.rotate(mars.tilt, tiltAxis)
m.rotate(mars.roll, rollAxis)
m.scale(mars.r)
returnm
}
}
components: [ mars, materialMars, transformMars ]
}
// JUPITEREntity {
id: jupiterEntityPlanet {
id: jupitertilt: planetData[Planets.JUPITER].tilt
}
PlanetMaterial {
id: materialJupitereffect: effectDambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/jupitermap.jpg"shininess: shininessBasic
}
property TransformtransformJupiter: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(jupiter.x, jupiter.y, jupiter.z))
m.rotate(jupiter.tilt, tiltAxis)
m.rotate(jupiter.roll, rollAxis)
m.scale(jupiter.r)
returnm
}
}
components: [ jupiter, materialJupiter, transformJupiter ]
}
// SATURNEntity {
id: saturnEntityPlanet {
id: saturntilt: planetData[Planets.SATURN].tilt
}
PlanetMaterial {
id: materialSaturneffect: shadowMapEffectambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/saturnmap.jpg"shininess: shininessBasic
}
property TransformtransformSaturn: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(saturn.x, saturn.y, saturn.z))
m.rotate(saturn.tilt, tiltAxis)
m.rotate(saturn.roll, rollAxis)
m.scale(saturn.r)
returnm
}
}
components: [ saturn, materialSaturn, transformSaturn ]
}
// SATURN RINGEntity {
id: saturnRingEntityRing {
id: saturnRinginnerRadius: saturnRingInnerRadiusouterRadius: saturnRingOuterRadius
}
PlanetMaterial {
id: materialSaturnRingeffect: shadowMapEffectambientLight: ambientStrengthRingspecularColor: Qt.rgba(0.01, 0.01, 0.01, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/saturnringcolortrans.png"shininess: shininessBasicopacity: 0.4
}
property TransformtransformSaturnRing: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(saturn.x, saturn.y, saturn.z))
m.rotate(saturn.tilt, tiltAxis)
m.rotate(saturn.roll/10, rollAxis)
m.scale((saturnRing.innerRadius+saturnRing.outerRadius) /1.75)
returnm
}
}
components: [ saturnRing, materialSaturnRing, transformSaturnRing ]
}
// URANUSEntity {
id: uranusEntityPlanet {
id: uranustilt: planetData[Planets.URANUS].tilt
}
PlanetMaterial {
id: materialUranuseffect: shadowMapEffectambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/uranusmap.jpg"shininess: shininessBasic
}
property TransformtransformUranus: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(uranus.x, uranus.y, uranus.z))
m.rotate(uranus.tilt, tiltAxis)
m.rotate(uranus.roll, rollAxis)
m.scale(uranus.r)
returnm
}
}
components: [ uranus, materialUranus, transformUranus ]
}
// URANUS RINGEntity {
id: uranusRingEntityRing {
id: uranusRinginnerRadius: uranusRingInnerRadiusouterRadius: uranusRingOuterRadius
}
PlanetMaterial {
id: materialUranusRingeffect: shadowMapEffectambientLight: ambientStrengthRingspecularColor: Qt.rgba(0.01, 0.01, 0.01, 1.0)
diffuseMap: "qrc:/images/nasa/uranusringcolortrans.png"shininess: shininessBasicopacity: 0.4
}
property TransformtransformUranusRing: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(uranus.x, uranus.y, uranus.z))
m.rotate(uranus.tilt, tiltAxis)
m.rotate(uranus.roll/10, rollAxis)
m.scale((uranusRing.innerRadius+uranusRing.outerRadius) /1.75)
returnm
}
}
components: [ uranusRing, materialUranusRing, transformUranusRing ]
}
// NEPTUNEEntity {
id: neptuneEntityPlanet {
id: neptunetilt: planetData[Planets.NEPTUNE].tilt
}
PlanetMaterial {
id: materialNeptuneeffect: effectDambientLight: ambientStrengthPlanetspecularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
diffuseMap: "qrc:/images/solarsystemscope/neptunemap.jpg"shininess: shininessBasic
}
property TransformtransformNeptune: Transform {
matrix: {
var m = Qt.matrix4x4()
m.translate(Qt.vector3d(neptune.x, neptune.y, neptune.z))
m.rotate(neptune.tilt, tiltAxis)
m.rotate(neptune.roll, rollAxis)
m.scale(neptune.r)
returnm
}
}
components: [ neptune, materialNeptune, transformNeptune ]
}
}