From 0228ca241bd4a3ebf3113ca1e1d39ebf32910bce Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 10 Jul 2016 09:40:30 +0200 Subject: [PATCH] Add Juno scene and scenegraphnodes Enable ability to apply a rotation matrix to the rotation vector to accomodate for model misalignments --- .gitignore | 4 + data/scene/juno.scene | 70 ++++++++++ data/scene/juno/juno/juno.mod | 153 +++++++++++++++++++++ modules/base/rendering/renderablemodel.cpp | 10 +- modules/base/rendering/renderablemodel.h | 2 + 5 files changed, 237 insertions(+), 2 deletions(-) create mode 100755 data/scene/juno.scene create mode 100644 data/scene/juno/juno/juno.mod diff --git a/.gitignore b/.gitignore index b3071d6cbe..512c197509 100644 --- a/.gitignore +++ b/.gitignore @@ -150,3 +150,7 @@ data/scene/atmosphereearth/textures/earth_clouds.jpg data/scene/atmosphereearth/textures/earth_night.jpg data/scene/atmosphereearth/textures/earth_reflectance.png data/scene/atmosphereearth/textures/marker.png +data/scene/juno/juno/textures +data/scene/juno/juno/spice +data/scene/juno/juno/Juno.mtl +data/scene/juno/juno/Juno.obj diff --git a/data/scene/juno.scene b/data/scene/juno.scene new file mode 100755 index 0000000000..54e58865da --- /dev/null +++ b/data/scene/juno.scene @@ -0,0 +1,70 @@ +function preInitialization() + --[[ + The scripts in this function are executed after the scene is loaded but before the + scene elements have been initialized, thus they should be used to set the time at + which the scene should start and other settings that might determine initialization + critical objects. + ]]-- + + -- openspace.time.setTime("2007-02-28T11:40:00.000") + + -- openspace.time.setTime("2015-07-08T15:57:45.00") + -- openspace.time.setTime("2015-07-12T07:41:00.00") + -- openspace.time.setTime("2015-07-12T15:43:00.00") + -- openspace.time.setTime("2015-07-12T22:19:20.00") + -- openspace.time.setTime("2015-07-13T20:59:00.00") + -- openspace.time.setTime("2015-07-14T02:41:55.00") + openspace.time.setTime("2016-07-12T10:05:00.00") + openspace.time.setDeltaTime(0) + + dofile(openspace.absPath('${SCRIPTS}/common.lua')) + openspace.clearKeys() + helper.setCommonKeys() + helper.setDeltaTimeKeys({ + 1, 5, 10, 20, 40, 90, 360, 720, 2880, 14400, + 28800, 57600, 115200, 230400, 460800, 921600, 1843200, 3686400, 7372800, 14745600 + }) +end + +function postInitialization() + --[[ + The scripts in this function are executed after all objects in the scene have been + created and initialized, but before the first render call. This is the place to set + graphical settings for the renderables. + ]]-- + openspace.printInfo("Setting default values") + openspace.setPropertyValue("Sun.renderable.enabled", false) + openspace.setPropertyValue("SunMarker.renderable.enabled", true) + openspace.setPropertyValue("EarthMarker.renderable.enabled", true) + + openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55) + openspace.setPropertyValue("MilkyWay.renderable.segments", 50) + + openspace.setPropertyValue('Jupiter.renderable.performShading', false); + + openspace.printInfo("Done setting default values") +end + +return { + ScenePath = ".", + CommonFolder = "common", + Camera = { + Focus = "Juno", + Position = {1, 0, 0, 5}, + }, + Modules = { + "sun", + "mercury", + "venus", + "earth", + "mars", + "jupiter", + "saturn", + "uranus", + "neptune", + "stars", + "milkyway", + "juno" + } +} + diff --git a/data/scene/juno/juno/juno.mod b/data/scene/juno/juno/juno.mod new file mode 100644 index 0000000000..50f5475b16 --- /dev/null +++ b/data/scene/juno/juno/juno.mod @@ -0,0 +1,153 @@ +return { + -- New Horizons Body module + { + Name = "Juno", + -- Parent = "PlutoBarycenter", + -- Parent = "JupiterBarycenter", + Parent = "JupiterBarycenter", + Renderable = { + Type = "RenderableModel", + Body = "JUNO", + Geometry = { + Type = "MultiModelGeometry", + GeometryFile = "Juno.obj", + Magnification = 4, + }, + Textures = { + Type = "simple", + Color = "textures/gray.png", + }, + Rotation = { + Source = "JUNO_SPACECRAFT", + Destination = "GALACTIC", + ModelTransform = { + 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, + 0.0, -1.0, 0.0 + } + }, + Shading = { + PerformShading = true, + Fadeable = false, + Ghosting = false, + }, + }, + Ephemeris = { + Type = "Spice", + Body = "JUNO", + Reference = "GALACTIC", + Observer = "JUPITER BARYCENTER", + Kernels = { + "spice/JNO_SCLKSCET.00039.tsc", + "spice/juno_jade_v00.ti", + "spice/juno_jedi_v00.ti", + "spice/juno_jiram_v01.ti", + "spice/juno_junocam_v00.ti", + "spice/juno_mag_v00.ti", + "spice/juno_mwr_v01.ti", + "spice/juno_struct_v01.ti", + "spice/juno_uvs_v00.ti", + "spice/juno_v08.tf", + "spice/juno_waves_v00.ti", + "spice/juno_mwr_v01.ti", + "spice/spk_merge_110805_171017_130515.bsp", + "spice/ck/juno_sc_prl_110930_111028_jc003c01_v01.bc", + "spice/ck/juno_sc_prl_111028_111125_jc004b00_v01.bc", + "spice/ck/juno_sc_prl_111125_111223_jc005b00_v01.bc", + "spice/ck/juno_sc_prl_111223_120127_jc006a02_v01.bc", + "spice/ck/juno_sc_prl_120127_120217_jc007a00_v01.bc", + "spice/ck/juno_sc_prl_120217_120316_jc008b00_v02.bc", + "spice/ck/juno_sc_prl_120316_120413_jc009a00_v01.bc", + "spice/ck/juno_sc_prl_120413_120511_jc010a04_v01.bc", + "spice/ck/juno_sc_prl_120511_120608_jc011a01_v02.bc", + "spice/ck/juno_sc_prl_120608_120706_jc012b01_v01.bc", + "spice/ck/juno_sc_prl_120706_120802_jc013a01_v01.bc", + "spice/ck/juno_sc_prl_120802_120824_jc014b01_v01.bc", + "spice/ck/juno_sc_prl_120824_120928_jc015m00_v01.bc", + "spice/ck/juno_sc_prl_120919_120928_jc015o00_v01.bc", + "spice/ck/juno_sc_prl_120928_121026_jc016c03_v01.bc", + "spice/ck/juno_sc_prl_121026_121123_jc017a01_v01.bc", + "spice/ck/juno_sc_prl_121123_121221_jc018b01_v01.bc", + "spice/ck/juno_sc_prl_121221_130118_jc019a01_v01.bc", + "spice/ck/juno_sc_prl_130118_130215_jc020b01_v01.bc", + "spice/ck/juno_sc_prl_130315_130412_jc022b01_v01.bc", + "spice/ck/juno_sc_prl_130412_130510_jc023b03_v01.bc", + "spice/ck/juno_sc_prl_130510_130607_jc024a01_v01.bc", + "spice/ck/juno_sc_prl_130607_130705_jc025a00_v01.bc", + "spice/ck/juno_sc_prl_130705_130802_jc026a01_v01.bc", + "spice/ck/juno_sc_prl_130726_131020_jx024a02_EFB_v03.bc", + "spice/ck/juno_sc_prl_130802_130830_jc027a02_v01.bc", + "spice/ck/juno_sc_prl_130830_130927_jc028a01_v01.bc", + "spice/ck/juno_sc_prl_130926_131025_jc029a00_v01.bc", + "spice/ck/juno_sc_prl_130927_131025_jc029c01_v01.bc", + "spice/ck/juno_sc_prl_131022_131025_jc029f00_v01.bc", + "spice/ck/juno_sc_prl_131025_131122_jc030b04_v01.bc", + "spice/ck/juno_sc_prl_131122_131220_jc031b01_v01.bc", + "spice/ck/juno_sc_prl_131220_140124_jc032a01_v01.bc", + "spice/ck/juno_sc_prl_140124_140214_jc033a01_v01.bc", + "spice/ck/juno_sc_prl_140214_140314_jc034b01_v01.bc", + "spice/ck/juno_sc_prl_140314_140411_jc035a01_v01.bc", + "spice/ck/juno_sc_prl_140411_140509_jc036b01_v01.bc", + "spice/ck/juno_sc_prl_140509_140606_jc037b02_v01.bc", + "spice/ck/juno_sc_prl_140606_140704_jc038a01_v01.bc", + "spice/ck/juno_sc_prl_140704_140801_jc039b01_v01.bc", + "spice/ck/juno_sc_prl_140801_140829_jc040a01_v01.bc", + "spice/ck/juno_sc_prl_140829_140926_jc041a01_v01.bc", + "spice/ck/juno_sc_prl_140926_141024_jc042a01_v01.bc", + "spice/ck/juno_sc_prl_141024_141121_jc043a01_v01.bc", + "spice/ck/juno_sc_prl_141105_141121_jc043m01_v01.bc", + "spice/ck/juno_sc_prl_141107_141121_jc043s01_v01.bc", + "spice/ck/juno_sc_prl_141121_141219_jc044a01_v01.bc", + "spice/ck/juno_sc_prl_141219_150123_jc045a01_v01.bc", + "spice/ck/juno_sc_prl_150123_150213_jc046a01_v01.bc", + "spice/ck/juno_sc_prl_150213_150313_jc047a01_v01.bc", + "spice/ck/juno_sc_prl_150312_150409_jc048a01_v01.bc", + "spice/ck/juno_sc_prl_150410_150508_jc049a01_v01.bc", + "spice/ck/juno_sc_prl_150508_150605_jc050a01_v01.bc", + "spice/ck/juno_sc_prl_150605_150703_jc051a01_v01.bc", + "spice/ck/juno_sc_prl_150703_150731_jc052a01_v01.bc", + "spice/ck/juno_sc_prl_150731_150828_jc053a01_v01.bc", + "spice/ck/juno_sc_prl_150805_150828_jc053m00_v01.bc", + "spice/ck/juno_sc_prl_150807_150828_jc053s00_v01.bc", + "spice/ck/juno_sc_prl_150828_150924_jc054a00_v01.bc", + "spice/ck/juno_sc_prl_150924_151023_jc055a00_v01.bc", + "spice/ck/juno_sc_prl_151023_151120_jc056a00_v01.bc", + "spice/ck/juno_sc_prl_151120_151218_jc057a00_v01.bc", + "spice/ck/juno_sc_prl_151218_160115_jc058a00_v01.bc", + "spice/ck/juno_sc_prl_160115_160212_jc059a00_v01.bc", + "spice/ck/juno_sc_prl_160212_160311_jc060a00_v01.bc", + "spice/ck/juno_sc_prl_160311_160408_jc061a00_v01.bc", + "spice/ck/juno_sc_prl_160408_160506_jc062a00_v01.bc", + "spice/ck/juno_sc_prl_160506_160603_jc063a00_v01.bc", + "spice/ck/juno_sc_prl_160603_160630_jc064a00_v01.bc", + "spice/ck/juno_sc_prl_160708_160729_jm0001rp_v02.bc", + "spice/ck/juno_sc_prl_160729_160826_jm0002rp_v01.bc", + "spice/ck/juno_sc_prl_161115_161213_jx0405rp_v01.bc" + } + }, + GuiName = "/Solar/Juno" + }, + --NewHorizonsTrail module + { + Name = "JunoTrail", + Parent = "JupiterBarycenter", + Renderable = { + Type = "RenderableTrail", + Body = "JUNO", + Frame = "GALACTIC", + Observer = "JUPITER BARYCENTER", + -- Observer = "PLUTO BARYCENTER", + RGB = {0.70,0.50,0.20}, + TropicalOrbitPeriod = 394250.0, + EarthOrbitRatio = 4.5, + DayLength = 9.9259, + TimeStamps = false, + Textures = { + Type = "simple", + Color = "textures/glare_blue.png", + -- need to add different texture + }, + }, + GuiName = "/Solar/JunoTrail" + }, + } diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index bd1137554b..dd16a4bbe4 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -53,6 +53,8 @@ namespace { const std::string keyStart = "StartTime"; const std::string keyEnd = "EndTime"; const std::string keyFading = "Shading.Fadeable"; + + const std::string keyModelTransform = "Rotation.ModelTransform"; //const std::string keyGhosting = "Shading.Ghosting"; } @@ -95,6 +97,10 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) dictionary.getValue(keySource, _source); dictionary.getValue(keyDestination, _destination); + if (dictionary.hasKeyAndValue(keyModelTransform)) + dictionary.getValue(keyModelTransform, _modelTransform); + else + _modelTransform = glm::dmat3(1.f); dictionary.getValue(keyBody, _target); openspace::SpiceManager::ref().addFrame(_target, _source); @@ -170,7 +176,7 @@ void RenderableModel::render(const RenderData& data) { _frameCount++; double lt; - glm::mat4 transform = glm::mat4(1); + glm::mat4 transform = glm::mat4(1.f); glm::mat4 tmp = glm::mat4(1); for (int i = 0; i < 3; i++){ @@ -251,7 +257,7 @@ void RenderableModel::update(const UpdateData& data) { // set spice-orientation in accordance to timestamp if (!_source.empty()) { - _stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, _time); + _stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, _time) * _modelTransform; } double lt; diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 5cd4f61abe..72eb92fd83 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -63,6 +63,8 @@ private: std::unique_ptr _texture; modelgeometry::ModelGeometry* _geometry; + + glm::dmat3 _modelTransform; float _alpha; glm::dmat3 _stateMatrix;