mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-05 02:20:11 -05:00
Use new label class for the new grids
This commit is contained in:
@@ -110,14 +110,17 @@ local eclipticLabels = {
|
||||
Renderable = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "eclip.label",
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 14.75,
|
||||
MinMaxSize = { 1, 50 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
LabelFile = speck .. "eclip.label",
|
||||
Unit = "pc",
|
||||
DrawLabels = true,
|
||||
TextColor = { 0.5, 0.5, 0.5 },
|
||||
TextSize = 14.75,
|
||||
TextMinMaxSize = { 1, 50 },
|
||||
TransformationMatrix = {
|
||||
-0.05487554, 0.4941095, -0.8676661, 0.0,
|
||||
-0.9938214 , -0.1109906, -0.0003515167, 0.0,
|
||||
@@ -163,14 +166,17 @@ local equatorialLabels = {
|
||||
Renderable = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "radec.label",
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 14.5,
|
||||
MinMaxSize = { 2, 70 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
LabelFile = speck .. "radec.label",
|
||||
Unit = "pc",
|
||||
DrawLabels = true,
|
||||
TextColor = { 0.5, 0.5, 0.5 },
|
||||
TextSize = 14.5,
|
||||
TextMinMaxSize = { 2, 70 },
|
||||
TransformationMatrix = {
|
||||
-0.05487554, 0.4941095, -0.8676661, 0.0,
|
||||
-0.8734371 , -0.4448296, -0.1980764, 0.0,
|
||||
@@ -212,14 +218,17 @@ local galacticLabels = {
|
||||
Renderable = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "galac.label",
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 15.8,
|
||||
MinMaxSize = { 1, 100 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
LabelFile = speck .. "galac.label",
|
||||
Unit = "pc",
|
||||
DrawLabels = true,
|
||||
TextColor = { 0.5, 0.5, 0.5 },
|
||||
TextSize = 15.8,
|
||||
TextMinMaxSize = { 1, 100 }
|
||||
DrawLabels = true
|
||||
},
|
||||
GUI = {
|
||||
Name = "Galactic Sphere Labels",
|
||||
@@ -239,6 +248,13 @@ local plane1ld = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "1ld.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 10.3,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "Km"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
LineWidth = 2.0,
|
||||
@@ -263,6 +279,13 @@ local plane1lm = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "1lm.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 11.8,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
LineWidth = 2.0,
|
||||
@@ -287,6 +310,13 @@ local plane1ly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "1ly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 13.0,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
LineWidth = 2.0,
|
||||
@@ -311,6 +341,13 @@ local plane10ly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "10ly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 14.17,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
LineWidth = 2.0,
|
||||
@@ -335,6 +372,13 @@ local plane100ly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "100ly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 15.0,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
LineWidth = 2.0,
|
||||
@@ -359,6 +403,13 @@ local plane1kly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "1kly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 16.0,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
LineWidth = 2.0,
|
||||
@@ -383,6 +434,13 @@ local plane10kly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "10kly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 17.25,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "pc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
LineWidth = 2.0,
|
||||
@@ -400,6 +458,13 @@ local plane100kly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "100kly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 18.6,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "Mpc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
HighlightColor = { 0.3, 0.7, 0.8 },
|
||||
@@ -419,6 +484,13 @@ local plane1Mly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "1Mly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 19.6,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "Mpc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
HighlightColor = { 0.3, 0.7, 0.8 },
|
||||
@@ -438,6 +510,13 @@ local plane10Mly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "10Mly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 20.6,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "Mpc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
HighlightColor = { 0.3, 0.7, 0.8 },
|
||||
@@ -457,6 +536,13 @@ local plane100Mly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "100Mly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 21.6,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "Mpc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
HighlightColor = { 0.3, 0.7, 0.8 },
|
||||
@@ -476,6 +562,13 @@ local plane20Gly = {
|
||||
Renderable = {
|
||||
Type = "RenderableGrid",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
File = speck .. "20Gly.label",
|
||||
Color = { 0.0, 0.2, 0.5 },
|
||||
Size = 23.6,
|
||||
MinMaxSize = { 0, 30 },
|
||||
Unit = "Mpc"
|
||||
},
|
||||
Opacity = 0.4,
|
||||
Color = { 0.1, 0.5, 0.6 },
|
||||
HighlightColor = { 0.3, 0.7, 0.8 },
|
||||
|
||||
@@ -252,16 +252,33 @@ void RenderableGrid::deinitializeGL() {
|
||||
void RenderableGrid::render(const RenderData& data, RendererTasks&){
|
||||
_gridProgram->activate();
|
||||
|
||||
glm::dmat4 modelTransform =
|
||||
const glm::dmat4 modelMatrix =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
|
||||
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
|
||||
glm::scale(glm::dmat4(1.0), data.modelTransform.scale);
|
||||
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
|
||||
|
||||
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelMatrix;
|
||||
const glm::dmat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
|
||||
glm::dmat4 modelViewProjectionMatrix =
|
||||
glm::dmat4(projectionMatrix) * modelViewTransform;
|
||||
const glm::dmat4 modelViewProjectionMatrix = projectionMatrix * modelViewTransform;
|
||||
|
||||
const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
const glm::vec3 up = glm::cross(right, viewDirection);
|
||||
|
||||
const glm::dmat4 worldToModelTransform = glm::inverse(modelMatrix);
|
||||
glm::vec3 orthoRight = glm::normalize(
|
||||
glm::vec3(worldToModelTransform * glm::vec4(right, 0.0))
|
||||
);
|
||||
|
||||
if (orthoRight == glm::vec3(0.0)) {
|
||||
glm::vec3 otherVector(lookup.y, lookup.x, lookup.z);
|
||||
right = glm::cross(viewDirection, otherVector);
|
||||
orthoRight = glm::normalize(
|
||||
glm::vec3(worldToModelTransform * glm::vec4(right, 0.0))
|
||||
);
|
||||
}
|
||||
|
||||
_gridProgram->setUniform("modelViewTransform", modelViewTransform);
|
||||
_gridProgram->setUniform("MVPTransform", modelViewProjectionMatrix);
|
||||
@@ -303,22 +320,10 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
glm::dvec3 cameraViewDirectionWorld = -data.camera.viewDirectionWorldSpace();
|
||||
glm::dvec3 cameraUpDirectionWorld = data.camera.lookUpVectorWorldSpace();
|
||||
glm::dvec3 orthoRight = glm::normalize(
|
||||
glm::cross(cameraUpDirectionWorld, cameraViewDirectionWorld)
|
||||
const glm::vec3 orthoUp = glm::normalize(
|
||||
glm::vec3(worldToModelTransform * glm::dvec4(up, 0.0))
|
||||
);
|
||||
if (orthoRight == glm::dvec3(0.0)) {
|
||||
glm::dvec3 otherVector(
|
||||
cameraUpDirectionWorld.y,
|
||||
cameraUpDirectionWorld.x,
|
||||
cameraUpDirectionWorld.z
|
||||
);
|
||||
orthoRight = glm::normalize(glm::cross(otherVector, cameraViewDirectionWorld));
|
||||
}
|
||||
glm::dvec3 orthoUp = glm::normalize(glm::cross(cameraViewDirectionWorld, orthoRight));
|
||||
|
||||
_labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp);
|
||||
_labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,8 +194,8 @@ bool LabelsComponent::isReady() const {
|
||||
}
|
||||
|
||||
void LabelsComponent::render(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp,
|
||||
float fadeInVariable)
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp,
|
||||
float fadeInVariable)
|
||||
{
|
||||
float scale = static_cast<float>(toMeter(_unit));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user