mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 18:11:01 -05:00
Add transformation matrix to labels, fixes #2501
This commit is contained in:
@@ -7,12 +7,26 @@ local equatorialRotationMatrix = {
|
||||
-0.483835 , 0.7469823, 0.4559838
|
||||
}
|
||||
|
||||
local equatorialTransformationMatrix = {
|
||||
-0.05487554, 0.4941095, -0.8676661, 0.0,
|
||||
-0.8734371 , -0.4448296, -0.1980764, 0.0,
|
||||
-0.483835 , 0.7469823, 0.4559838, 0.0,
|
||||
0.0 , 0.0 , 0.0 , 1.0
|
||||
}
|
||||
|
||||
local eclipticRotationMatrix = {
|
||||
-0.05487554, 0.4941095, -0.8676661,
|
||||
-0.9938214 , -0.1109906, -0.0003515167,
|
||||
-0.09647644, 0.8622859, 0.4971472
|
||||
}
|
||||
|
||||
local eclipticTransformationMatrix = {
|
||||
-0.05487554, 0.4941095, -0.8676661, 0.0,
|
||||
-0.9938214 , -0.1109906, -0.0003515167, 0.0,
|
||||
-0.09647644, 0.8622859, 0.4971472, 0.0,
|
||||
0.0 , 0.0 , 0.0 , 1.0
|
||||
}
|
||||
|
||||
local speck = asset.syncedResource({
|
||||
Name = "Grids Speck Files",
|
||||
Type = "HttpSynchronization",
|
||||
@@ -116,18 +130,14 @@ local eclipticLabels = {
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 14.75,
|
||||
MinMaxSize = { 1, 50 },
|
||||
Unit = "pc"
|
||||
Unit = "pc",
|
||||
TransformationMatrix = eclipticTransformationMatrix
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "pc",
|
||||
DrawLabels = true,
|
||||
TransformationMatrix = {
|
||||
-0.05487554, 0.4941095, -0.8676661, 0.0,
|
||||
-0.9938214 , -0.1109906, -0.0003515167, 0.0,
|
||||
-0.09647644, 0.8622859, 0.4971472, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0
|
||||
}
|
||||
TransformationMatrix = eclipticTransformationMatrix
|
||||
},
|
||||
GUI = {
|
||||
Name = "Ecliptic Sphere Labels",
|
||||
@@ -172,18 +182,14 @@ local equatorialLabels = {
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 14.5,
|
||||
MinMaxSize = { 2, 70 },
|
||||
Unit = "pc"
|
||||
Unit = "pc",
|
||||
TransformationMatrix = equatorialTransformationMatrix
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "pc",
|
||||
DrawLabels = true,
|
||||
TransformationMatrix = {
|
||||
-0.05487554, 0.4941095, -0.8676661, 0.0,
|
||||
-0.8734371 , -0.4448296, -0.1980764, 0.0,
|
||||
-0.483835 , 0.7469823, 0.4559838, 0.0,
|
||||
0.0 , 0.0 , 0.0 , 1.0
|
||||
}
|
||||
TransformationMatrix = equatorialTransformationMatrix
|
||||
},
|
||||
GUI = {
|
||||
Name = "Equatorial Sphere Labels",
|
||||
|
||||
@@ -83,6 +83,12 @@ namespace {
|
||||
"display rendering (for example fisheye) this should be set to false."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TransformationMatrixInfo = {
|
||||
"TransformationMatrix",
|
||||
"Transformation Matrix",
|
||||
"Transformation matrix to be applied to the labels"
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(LabelsComponent)]] Parameters {
|
||||
// [[codegen::verbatim(FileInfo.description)]]
|
||||
std::filesystem::path file;
|
||||
@@ -115,6 +121,9 @@ namespace {
|
||||
|
||||
// [[codegen::verbatim(FaceCameraInfo.description)]]
|
||||
std::optional<bool> faceCamera;
|
||||
|
||||
// [[codegen::verbatim(TransformationMatrixInfo.description)]]
|
||||
std::optional<glm::dmat4x4> transformationMatrix;
|
||||
};
|
||||
#include "labelscomponent_codegen.cpp"
|
||||
} // namespace
|
||||
@@ -184,6 +193,8 @@ LabelsComponent::LabelsComponent(const ghoul::Dictionary& dictionary)
|
||||
_faceCamera = !global::windowDelegate->isFisheyeRendering();
|
||||
}
|
||||
addProperty(_faceCamera);
|
||||
|
||||
_transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix);
|
||||
}
|
||||
|
||||
speck::Labelset& LabelsComponent::labelSet() {
|
||||
@@ -241,8 +252,11 @@ void LabelsComponent::render(const RenderData& data,
|
||||
continue;
|
||||
}
|
||||
|
||||
glm::vec3 scaledPos(e.position);
|
||||
// Transform and scale the labels
|
||||
glm::vec3 transformedPos(_transformationMatrix * glm::dvec4(e.position, 1.0));
|
||||
glm::vec3 scaledPos(transformedPos);
|
||||
scaledPos *= scale;
|
||||
|
||||
ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render(
|
||||
*_font,
|
||||
scaledPos,
|
||||
|
||||
@@ -70,6 +70,8 @@ private:
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font = nullptr;
|
||||
|
||||
glm::dmat4 _transformationMatrix = glm::dmat4(1.0);
|
||||
|
||||
// Properties
|
||||
properties::FloatProperty _opacity;
|
||||
properties::Vec3Property _color;
|
||||
|
||||
Reference in New Issue
Block a user