Make hover circle work again and remove unneccessary conversion function

This commit is contained in:
sylvass
2022-01-26 05:41:46 -05:00
parent f8936db40c
commit 5128056272
6 changed files with 36 additions and 21 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ local circle = {
FaceCamera = false,
UseRadiusAzimuthElevation = false,
RadiusAzimuthElevation = {1.0, 0.0, 0.0}, -- use for dome
Scale= 0.015,
Scale= 0.025,
Enabled = false,
TexturePath = "${ASSETS}/circle.png",
CartesianPosition = { 0, 0, -2.1 },
@@ -69,6 +69,7 @@ public:
virtual void update();
virtual bool isReady() const;
bool isEnabled() const;
bool isUsingRaeCoords() const;
void setEnabled(bool isEnabled);
float depth();
@@ -80,8 +81,9 @@ public:
glm::vec2 lowerLeftCornerScreenSpace();
bool intersection(glm::vec2 coord);
void translate(glm::vec2 translation, glm::vec2 position);
void setPosition(const glm::vec3& position);
void setCartesianPosition(const glm::vec3& position);
void setRaeFromCartesianPosition(const glm::vec3& position);
glm::vec3 raePosition() const;
// End of addition by skybrowser team
static documentation::Documentation Documentation();
+1 -2
View File
@@ -28,8 +28,7 @@ namespace openspace {
glm::dvec3 galacticToEquatorial(const glm::dvec3& coords);
glm::dvec3 equatorialToGalactic(const glm::dvec3& coords);
// Conversion to screen space from J2000 equatorial / galactic / pixels
glm::dvec3 equatorialToScreenSpace3d(const glm::dvec3& coords);
// Conversion to screen space from local camera / pixels
glm::dvec3 localCameraToScreenSpace3d(const glm::dvec3& coords);
glm::vec2 pixelToScreenSpace2d(const glm::vec2& mouseCoordinate);
+12 -5
View File
@@ -532,11 +532,18 @@ void SkyBrowserModule::moveHoverCircle(int i)
// Make circle visible
_hoverCircle->setEnabled(true);
// Calculate coords for the circle and translate
glm::vec3 coordsScreen = skybrowser::equatorialToScreenSpace3d(
image.equatorialCartesian
);
_hoverCircle->setPosition(coordsScreen);
// Set the exact target position
glm::dvec3 localCamera = skybrowser::equatorialToLocalCamera(image.equatorialCartesian);
if (_hoverCircle->isUsingRaeCoords()) {
glm::vec3 position = _hoverCircle->raePosition().x * glm::vec3(localCamera);
_hoverCircle->setRaeFromCartesianPosition(position);
}
else {
_hoverCircle->setCartesianPosition(
skybrowser::localCameraToScreenSpace3d(localCamera)
);
}
}
}
+3 -10
View File
@@ -99,14 +99,6 @@ namespace openspace::skybrowser {
return glm::normalize(viewDirectionLocal);
}
glm::dvec3 equatorialToScreenSpace3d(const glm::dvec3& coords) {
// Transform equatorial J2000 to galactic coord with infinite radius
glm::dvec3 galactic = equatorialToGalactic(coords);
glm::dvec3 localCameraSpace = galacticToLocalCamera(coords);
// Transform galactic coord to screen space
return localCameraToScreenSpace3d(localCameraSpace);
}
double cameraRoll() {
openspace::Camera* camera = global::navigationHandler->camera();
glm::dvec3 upWorld = camera->lookUpVectorWorldSpace();
@@ -141,9 +133,10 @@ namespace openspace::skybrowser {
return windowRatio.x / windowRatio.y;
}
bool isCoordinateInView(const glm::dvec3& equatorial) {
bool isCoordinateInView(const glm::dvec3& equatorial) {
// Check if image coordinate is within current FOV
glm::dvec3 coordsScreen = equatorialToScreenSpace3d(equatorial);
glm::dvec3 localCamera = equatorialToLocalCamera(equatorial);
glm::dvec3 coordsScreen = localCameraToScreenSpace3d(localCamera);
double r = static_cast<float>(windowRatio());
bool isCoordInView = abs(coordsScreen.x) < r && abs(coordsScreen.y) < 1.f &&
+15 -1
View File
@@ -460,6 +460,10 @@ void ScreenSpaceRenderable::update() {}
bool ScreenSpaceRenderable::isEnabled() const {
return _enabled;
}
bool ScreenSpaceRenderable::isUsingRaeCoords() const
{
return _useRadiusAzimuthElevation;
}
void ScreenSpaceRenderable::setEnabled(bool isEnabled)
{
_enabled = isEnabled;
@@ -550,11 +554,21 @@ void ScreenSpaceRenderable::translate(glm::vec2 translation, glm::vec2 position)
_cartesianPosition = translationMatrix * origin;
}
void ScreenSpaceRenderable::setPosition(const glm::vec3& position)
void ScreenSpaceRenderable::setCartesianPosition(const glm::vec3& position)
{
_cartesianPosition = position;
}
void ScreenSpaceRenderable::setRaeFromCartesianPosition(const glm::vec3& position)
{
_raePosition = cartesianToRae(position);
}
glm::vec3 ScreenSpaceRenderable::raePosition() const
{
return _raePosition;
}
glm::mat4 ScreenSpaceRenderable::globalRotationMatrix() {
// We do not want the screen space planes to be affected by
// 1) The global rotation of the view applied in the render engine