mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-28 16:09:46 -06:00
Use spice ephemeris for renderable globe. Still not considering rotation in rendering.
This commit is contained in:
@@ -1,10 +1,33 @@
|
||||
return {
|
||||
-- DebugGlobe module
|
||||
-- Earth barycenter module
|
||||
{
|
||||
Name = "EarthBarycenter",
|
||||
Parent = "Root",
|
||||
Static = true,
|
||||
--[[
|
||||
Ephemeris = {
|
||||
Type = "Kepler",
|
||||
Inclination = 0.00041,
|
||||
AscendingNode = 349.2,
|
||||
Perihelion = 102.8517,
|
||||
SemiMajorAxis = 1.00002,
|
||||
DailyMotion = 0.9855796,
|
||||
Eccentricity = 0.0166967,
|
||||
MeanLongitude = 328.40353
|
||||
}
|
||||
--]]
|
||||
Ephemeris = {
|
||||
Type = "Static"
|
||||
}
|
||||
},
|
||||
-- RenderableGlobe module
|
||||
{
|
||||
Name = "DebugGlobe",
|
||||
Parent = "Root",
|
||||
Renderable = {
|
||||
Type = "RenderableGlobe",
|
||||
Frame = "IAU_EARTH",
|
||||
Body = "EARTH",
|
||||
Radii = {6378137.0, 6378137.0, 6356752.314245}, -- Earth's radii
|
||||
SegmentsPerPatch = 64,
|
||||
Textures = {
|
||||
@@ -54,6 +77,35 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
--[[
|
||||
Ephemeris = {
|
||||
Type = "Spice",
|
||||
Body = "EARTH",
|
||||
Reference = "ECLIPJ2000",
|
||||
Observer = "SUN",
|
||||
Kernels = {
|
||||
"${OPENSPACE_DATA}/spice/de430_1850-2150.bsp"
|
||||
}
|
||||
},
|
||||
--]]
|
||||
GuiName = "/Solar/Planets/DebugGlobe"
|
||||
},
|
||||
--[[
|
||||
-- EarthTrail module
|
||||
{
|
||||
Name = "EarthTrail",
|
||||
Parent = "EarthBarycenter",
|
||||
Renderable = {
|
||||
Type = "RenderableTrail",
|
||||
Body = "EARTH",
|
||||
Frame = "GALACTIC",
|
||||
Observer = "SUN",
|
||||
RGB = { 0.5, 0.8, 1.0},
|
||||
TropicalOrbitPeriod = 365.242,
|
||||
EarthOrbitRatio = 1,
|
||||
DayLength = 24
|
||||
},
|
||||
GuiName = "/Solar/EarthTrail"
|
||||
},
|
||||
--]]
|
||||
}
|
||||
|
||||
@@ -127,6 +127,16 @@ namespace openspace {
|
||||
|
||||
}
|
||||
|
||||
void ChunkedLodGlobe::setStateMatrix(const glm::dmat3& stateMatrix)
|
||||
{
|
||||
_stateMatrix = stateMatrix;
|
||||
}
|
||||
|
||||
const glm::dmat3& ChunkedLodGlobe::stateMatrix()
|
||||
{
|
||||
return _stateMatrix;
|
||||
}
|
||||
|
||||
const Ellipsoid& ChunkedLodGlobe::ellipsoid() const
|
||||
{
|
||||
return _ellipsoid;
|
||||
|
||||
@@ -69,10 +69,13 @@ namespace openspace {
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
void setStateMatrix(const glm::dmat3& stateMatrix);
|
||||
|
||||
double minDistToCamera;
|
||||
|
||||
//Scalar globeRadius;
|
||||
const Ellipsoid& ellipsoid() const;
|
||||
const glm::dmat3& stateMatrix();
|
||||
|
||||
const int minSplitDepth;
|
||||
const int maxSplitDepth;
|
||||
@@ -118,6 +121,7 @@ namespace openspace {
|
||||
static const ChunkIndex RIGHT_HEMISPHERE_INDEX;
|
||||
|
||||
const Ellipsoid& _ellipsoid;
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
Camera* _savedCamera;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace {
|
||||
const std::string _loggerCat = "RenderableGlobe";
|
||||
|
||||
// Keys for the dictionary
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyRadii = "Radii";
|
||||
const std::string keySegmentsPerPatch = "SegmentsPerPatch";
|
||||
const std::string keyTextures = "Textures";
|
||||
@@ -82,6 +83,8 @@ namespace openspace {
|
||||
doHorizonCulling.setValue(true);
|
||||
renderSmallChunksFirst.setValue(true);
|
||||
|
||||
dictionary.getValue(keyFrame, _frame);
|
||||
|
||||
// Read the radii in to its own dictionary
|
||||
Vec3 radii;
|
||||
dictionary.getValue(keyRadii, radii);
|
||||
@@ -161,6 +164,12 @@ namespace openspace {
|
||||
}
|
||||
|
||||
void RenderableGlobe::update(const UpdateData& data) {
|
||||
// set spice-orientation in accordance to timestamp
|
||||
//_chunkedLodGlobe->setStateMatrix(
|
||||
// SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time));
|
||||
// We currently do not consider rotation anywhere in the rendering.
|
||||
// @TODO Consider rotation everywhere in the rendering (culling, splitting, camera, etc)
|
||||
_chunkedLodGlobe->setStateMatrix(glm::dmat3(1.0));
|
||||
_time = data.time;
|
||||
_distanceSwitch.update(data);
|
||||
|
||||
@@ -191,5 +200,9 @@ namespace openspace {
|
||||
return _ellipsoid.geodeticSurfaceProjection(position);
|
||||
}
|
||||
|
||||
std::shared_ptr<ChunkedLodGlobe> RenderableGlobe::chunkedLodGlobe() {
|
||||
return _chunkedLodGlobe;
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
glm::dvec3 geodeticSurfaceProjection(glm::dvec3 position);
|
||||
std::shared_ptr<ChunkedLodGlobe> chunkedLodGlobe();
|
||||
|
||||
properties::BoolProperty doFrustumCulling;
|
||||
properties::BoolProperty doHorizonCulling;
|
||||
@@ -79,6 +80,7 @@ public:
|
||||
properties::BoolProperty blendColorMap;
|
||||
|
||||
private:
|
||||
std::string _frame;
|
||||
|
||||
void addToggleLayerProperties(
|
||||
std::vector<TileProviderManager::TileProviderWithName>&,
|
||||
@@ -92,7 +94,6 @@ private:
|
||||
//std::vector<std::string> _heightMapKeys;
|
||||
//std::vector<std::string> _colorTextureKeys;
|
||||
|
||||
|
||||
std::shared_ptr<TileProviderManager> _tileProviderManager;
|
||||
std::shared_ptr<ChunkedLodGlobe> _chunkedLodGlobe;
|
||||
|
||||
|
||||
@@ -345,10 +345,11 @@ namespace openspace {
|
||||
auto patchSize = chunk.surfacePatch().size();
|
||||
|
||||
// TODO : Model transform should be fetched as a matrix directly.
|
||||
mat4 modelTransform = translate(mat4(1), data.position.vec3());
|
||||
mat4 viewTransform = data.camera.combinedViewMatrix();
|
||||
dmat4 modelTransform = dmat4(chunk.owner()->stateMatrix()); // Rotation
|
||||
modelTransform = translate(dmat4(1), data.position.dvec3()) * modelTransform; // Translation
|
||||
dmat4 viewTransform = data.camera.combinedViewMatrix();
|
||||
mat4 modelViewProjectionTransform = data.camera.projectionMatrix()
|
||||
* viewTransform * modelTransform;
|
||||
* mat4(viewTransform * modelTransform);
|
||||
|
||||
// Upload the uniform variables
|
||||
programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform);
|
||||
|
||||
Reference in New Issue
Block a user