mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 20:39:08 -06:00
Add option to invert ModelScale
* Scale the JWST to correct size * Add non standard units as option for ModelScale * Add boolean option to invert the ModelScale of a RenderableModel * Update JWST prism to correct size and matching rotation of JWST
This commit is contained in:
@@ -43,6 +43,8 @@ local JWSTModel = {
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
GeometryFile = "C:/Users/ElmQPC/Desktop/Malin/develop/WIP/data/JWST_model/3/JWSTFBX.fbx",
|
||||
ModelScale = "Foot",
|
||||
InvertModelScale = true,
|
||||
EnableAnimation = true,
|
||||
AnimationStartTime = "2021 10 31 00:00:00",
|
||||
AnimationMode = "BounceFromStart",
|
||||
@@ -89,18 +91,22 @@ local JWSTFov = {
|
||||
Parent = JWSTModel.Identifier,
|
||||
Renderable = {
|
||||
Type = "RenderablePrism",
|
||||
StartNode = "JWSTModel",
|
||||
Segments = 6,
|
||||
Radius = 3.5,
|
||||
Radius = 3.25,
|
||||
Lines = 7,
|
||||
LineWidth = 1.5,
|
||||
LineWidth = 1.0,
|
||||
Color = {
|
||||
1.0, 1.0, 1.0
|
||||
},
|
||||
LineLength = 1000000,
|
||||
Direction = {
|
||||
1.0, 0.0, 0.0
|
||||
}
|
||||
Length = 30
|
||||
},
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = {
|
||||
0, 0, 0.523598776 -- 30 deg around Z-axis in radians
|
||||
}
|
||||
},
|
||||
},
|
||||
GUI = {
|
||||
Name = "James Webb Space Telecope Field of View",
|
||||
|
||||
@@ -157,13 +157,27 @@ namespace {
|
||||
Centimeter,
|
||||
Decimeter,
|
||||
Meter,
|
||||
Kilometer
|
||||
Kilometer,
|
||||
|
||||
// Weird units
|
||||
Thou,
|
||||
Inch,
|
||||
Foot,
|
||||
Yard,
|
||||
Chain,
|
||||
Furlong,
|
||||
Mile
|
||||
};
|
||||
|
||||
// The scale of the model. For example if the model is in centimeters
|
||||
// then ModelScale = Centimeter or ModelScale = 0.01
|
||||
std::optional<std::variant<ScaleUnit, double>> modelScale;
|
||||
|
||||
// By default the given ModelScale is used to scale the model down,
|
||||
// by setting this setting to true the model is instead scaled up with the
|
||||
// given ModelScale
|
||||
std::optional<bool> invertModelScale;
|
||||
|
||||
// Set if invisible parts (parts with no textures or materials) of the model
|
||||
// should be forced to render or not.
|
||||
std::optional<bool> forceRenderInvisible;
|
||||
@@ -292,6 +306,8 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
ghoul::io::ModelReader::NotifyInvisibleDropped(_notifyInvisibleDropped)
|
||||
);
|
||||
|
||||
_invertModelScale = p.invertModelScale.value_or(_invertModelScale);
|
||||
|
||||
if (p.modelScale.has_value()) {
|
||||
if (std::holds_alternative<Parameters::ScaleUnit>(*p.modelScale)) {
|
||||
Parameters::ScaleUnit scaleUnit =
|
||||
@@ -320,10 +336,33 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
case Parameters::ScaleUnit::Kilometer:
|
||||
distanceUnit = DistanceUnit::Kilometer;
|
||||
break;
|
||||
|
||||
// Weired units
|
||||
case Parameters::ScaleUnit::Thou:
|
||||
distanceUnit = DistanceUnit::Thou;
|
||||
break;
|
||||
case Parameters::ScaleUnit::Inch:
|
||||
distanceUnit = DistanceUnit::Inch;
|
||||
break;
|
||||
case Parameters::ScaleUnit::Foot:
|
||||
distanceUnit = DistanceUnit::Foot;
|
||||
break;
|
||||
case Parameters::ScaleUnit::Yard:
|
||||
distanceUnit = DistanceUnit::Yard;
|
||||
break;
|
||||
case Parameters::ScaleUnit::Chain:
|
||||
distanceUnit = DistanceUnit::Chain;
|
||||
break;
|
||||
case Parameters::ScaleUnit::Furlong:
|
||||
distanceUnit = DistanceUnit::Furlong;
|
||||
break;
|
||||
case Parameters::ScaleUnit::Mile:
|
||||
distanceUnit = DistanceUnit::Mile;
|
||||
break;
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
_modelScale = convertUnit(distanceUnit, DistanceUnit::Meter);
|
||||
_modelScale = toMeter(distanceUnit);
|
||||
}
|
||||
else if (std::holds_alternative<double>(*p.modelScale)) {
|
||||
_modelScale = std::get<double>(*p.modelScale);
|
||||
@@ -331,6 +370,10 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
else {
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
|
||||
if (_invertModelScale) {
|
||||
_modelScale = 1.0 / _modelScale;
|
||||
}
|
||||
}
|
||||
|
||||
if (p.animationStartTime.has_value()) {
|
||||
|
||||
@@ -81,6 +81,7 @@ private:
|
||||
|
||||
std::unique_ptr<ghoul::modelgeometry::ModelGeometry> _geometry;
|
||||
double _modelScale = 1.0;
|
||||
bool _invertModelScale = false;
|
||||
bool _forceRenderInvisible = false;
|
||||
bool _notifyInvisibleDropped = true;
|
||||
std::string _animationStart;
|
||||
|
||||
Reference in New Issue
Block a user