Units in light years and interaction sphere

Co-Authored-By: Emil Wallberg <49481622+EmilWallberg@users.noreply.github.com>
This commit is contained in:
Wilhelm Björkström
2025-03-12 16:46:32 +01:00
parent e0e40d0625
commit 495d8559fa
3 changed files with 16 additions and 4 deletions

View File

@@ -1,10 +1,21 @@
local lightyear = 9.4607304725808E15
local parsec = 3.0856776E16
local Node = {
Identifier = "Blackhole_Example",
InteractionSphere = 1 * parsec,
BoundingSphere = 1 * parsec,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 10, 20, 30 }
}
},
Renderable = {
Type = "RenderableBlackHole",
},
GUI = {
Name = "Schwarzchild Blackhole - Example",
Name = "Schwarzchild Blackhole",
Path = "/Blackholes"
}
}

View File

@@ -10,7 +10,7 @@
"position": {
"x": 0,
"y": 0,
"z": 30
"z": 80.4607304725808E15
},
"type": "setNavigationState",
"up": {

View File

@@ -65,9 +65,10 @@ namespace openspace {
bool RenderableBlackHole::isReady() const {
return _program != nullptr;
}
void RenderableBlackHole::update(const UpdateData&) {
float distanceToAnchor = (float)glm::distance(_viewport.getCameraPos(), global::navigationHandler->anchorNode()->position());
glm::vec3 cameraPosition = global::navigationHandler->camera()->positionVec3();
glm::vec3 anchorNodePosition = global::navigationHandler->anchorNode()->position();
float distanceToAnchor = (float)glm::distance(cameraPosition, anchorNodePosition) / distanceconstants::LightYear;
if (abs(_rCamera - distanceToAnchor) > 0.01) {
_rCamera = distanceToAnchor;