mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-07 12:00:05 -05:00
More documentation work
This commit is contained in:
@@ -65,6 +65,44 @@ namespace {
|
||||
const char* keyShadowSource = "Source";
|
||||
const char* keyShadowCaster = "Caster";
|
||||
const char* keyBody = "Body";
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo ColorTextureInfo = {
|
||||
"PlanetTexture",
|
||||
"Color Base Texture",
|
||||
"The path to the base color texture that is used on the planet prior to any "
|
||||
"image projection."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo HeightTextureInfo = {
|
||||
"HeightMap",
|
||||
"Heightmap Texture",
|
||||
"The path to the height map texture that is used for the planet. If no height "
|
||||
"map is specified the planet does not use a height field."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo NightTextureInfo = {
|
||||
"NightTexture",
|
||||
"Night Texture",
|
||||
"The path to the night texture that is used for the part of the planet that is "
|
||||
"facing away from the Sun. If no night texture is loaded, the night side of the "
|
||||
"planet is rendered dark."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo HeightExaggerationInfo = {
|
||||
"HeightExaggeration",
|
||||
"Height Exaggeration",
|
||||
"This value determines the level of height exaggeration that is applied to a "
|
||||
"potential height field. A value of '0' inhibits the height field, whereas a "
|
||||
"value of '1' uses the measured height field."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo PerformShadingInfo = {
|
||||
"PerformShading",
|
||||
"Perform Shading",
|
||||
"If this value is enabled, the model will be shaded based on the relative "
|
||||
"location to the Sun. If this value is disabled, shading is disabled and the "
|
||||
"entire model is rendered brightly."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -89,19 +127,19 @@ documentation::Documentation RenderablePlanet::Documentation() {
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
KeyColorTexture,
|
||||
KeyColorTexture, // @TODO Use ColorTextureInfo.identifier instead
|
||||
new StringVerifier,
|
||||
"Specifies the color texture that is used for this RenderablePlanet.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
KeyHeightTexture,
|
||||
KeyHeightTexture, // @TODO Use HeightTextureInfo.identifier instead
|
||||
new StringVerifier,
|
||||
"Specifies the height texture that is used for this RenderablePlanet.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
KeyNightTexture,
|
||||
KeyNightTexture, // @TODO Use NightTextureInfo.identifier instead
|
||||
new StringVerifier,
|
||||
"Specifies the texture that is used for the night side of this "
|
||||
"RenderablePlanet.",
|
||||
@@ -114,6 +152,18 @@ documentation::Documentation RenderablePlanet::Documentation() {
|
||||
"this value is 'false', any existing night texture will not be used. "
|
||||
"This value defaults to 'true'.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
HeightExaggerationInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
HeightExaggerationInfo.description,
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
PerformShadingInfo.identifier,
|
||||
new BoolVerifier,
|
||||
PerformShadingInfo.description,
|
||||
Optional::Yes
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -121,15 +171,15 @@ documentation::Documentation RenderablePlanet::Documentation() {
|
||||
|
||||
RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath({ "ColorTexture", "Color Texture", "" }) // @TODO Missing documentation
|
||||
, _nightTexturePath({ "NightTexture", "Night Texture", "" }) // @TODO Missing documentation
|
||||
, _heightMapTexturePath({ "HeightMap", "Heightmap Texture", "" }) // @TODO Missing documentation
|
||||
, _colorTexturePath(ColorTextureInfo)
|
||||
, _nightTexturePath(NightTextureInfo)
|
||||
, _heightMapTexturePath(HeightTextureInfo)
|
||||
, _programObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _nightTexture(nullptr)
|
||||
, _heightExaggeration({ "HeightExaggeration", "Height Exaggeration", "" }, 1.f, 0.f, 10.f) // @TODO Missing documentation
|
||||
, _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 10.f)
|
||||
, _geometry(nullptr)
|
||||
, _performShading({ "PerformShading", "Perform Shading", "" }, true) // @TODO Missing documentation
|
||||
, _performShading(PerformShadingInfo, true)
|
||||
, _alpha(1.f)
|
||||
, _planetRadius(0.f)
|
||||
, _hasNightTexture(false)
|
||||
@@ -201,7 +251,16 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_heightMapTexturePath);
|
||||
_heightMapTexturePath.onChange(loadTextureCallback);
|
||||
|
||||
if (dictionary.hasKey(HeightExaggerationInfo.identifier)) {
|
||||
_heightExaggeration = static_cast<float>(
|
||||
dictionary.value<double>(HeightExaggerationInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_heightExaggeration);
|
||||
|
||||
if (dictionary.hasKey(HeightExaggerationInfo.identifier)) {
|
||||
_performShading = dictionary.value<bool>(HeightExaggerationInfo.identifier);
|
||||
}
|
||||
addProperty(_performShading);
|
||||
|
||||
// Shadow data:
|
||||
|
||||
@@ -38,9 +38,42 @@
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
namespace {
|
||||
const char* KeyTexture = "Texture";
|
||||
const char* KeySize = "Size";
|
||||
const char* KeyOffset = "Offset";
|
||||
static const openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
"This value is the path to a texture on disk that contains a one-dimensional "
|
||||
"texture which is used for these rings."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo SizeInfo = {
|
||||
"Size",
|
||||
"Size",
|
||||
"This value specifies the radius of the rings in meter."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo OffsetInfo = {
|
||||
"Offset",
|
||||
"Offset",
|
||||
"This value is used to limit the width of the rings.Each of the two values is a "
|
||||
"value between 0 and 1, where 0 is the center of the ring and 1 is the maximum "
|
||||
"extent at the radius. If this value is, for example {0.5, 1.0}, the ring is "
|
||||
"only shown between radius/2 and radius. It defaults to {0.0, 1.0}."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo NightFactorInfo = {
|
||||
"NightFactor",
|
||||
"Night Factor",
|
||||
"This value is a multiplicative factor that is applied to the side of the rings "
|
||||
"that is facing away from the Sun. If this value is equal to '1', no darkening "
|
||||
"of the night side occurs."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo TransparencyInfo = {
|
||||
"Transparency",
|
||||
"Transparency",
|
||||
"This value determines the transparency of part of the rings depending on the "
|
||||
"color values. For this value v, the transparency is equal to length(color) / v."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -58,38 +91,47 @@ documentation::Documentation RenderableRings::Documentation() {
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyTexture,
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
"The one dimensional texture that is used for both sides of the ring.",
|
||||
TextureInfo.description,
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeySize,
|
||||
SizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
"The radius of the rings in meters.",
|
||||
SizeInfo.description,
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyOffset,
|
||||
OffsetInfo.identifier,
|
||||
new DoubleVector2Verifier,
|
||||
"The offset that is used to limit the width of the rings. Each of the "
|
||||
"two values is a value between 0 and 1, where 0 is the center of the "
|
||||
"ring and 1 is the maximum extent at the radius. If this value is, for "
|
||||
"example {0.5, 1.0}, the ring is only shown between radius/2 and radius. "
|
||||
"It defaults to {0.0, 1.0}.",
|
||||
OffsetInfo.description,
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
NightFactorInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
NightFactorInfo.description,
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
TransparencyInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
TransparencyInfo.description,
|
||||
Optional::Yes
|
||||
}
|
||||
}
|
||||
},
|
||||
Exhaustive::Yes
|
||||
};
|
||||
}
|
||||
|
||||
RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _texturePath({ "Texture", "Texture", "" }) // @TODO Missing documentation
|
||||
, _size({ "Size", "Size", "" }, 1.f, 0.f, std::pow(1.f, 25.f)) // @TODO Missing documentation
|
||||
, _offset({ "Offset", "Offset", "" }, glm::vec2(0, 1.f), glm::vec2(0.f), glm::vec2(1.f)) // @TODO Missing documentation
|
||||
, _nightFactor({ "NightFactor", "Night Factor", "" }, 0.33f, 0.f, 1.f) // @TODO Missing documentation
|
||||
, _transparency({ "Transparency", "Transparency", "" }, 0.15f, 0.f, 1.f) // @TODO Missing documentation
|
||||
, _texturePath(TextureInfo)
|
||||
, _size(SizeInfo, 1.f, 0.f, 1e25)
|
||||
, _offset(OffsetInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(1.f))
|
||||
, _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f)
|
||||
, _transparency(TransparencyInfo, 0.15f, 0.f, 1.f)
|
||||
, _shader(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _textureFile(nullptr)
|
||||
@@ -106,26 +148,37 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary)
|
||||
"RenderableRings"
|
||||
);
|
||||
|
||||
_size = static_cast<float>(dictionary.value<double>(KeySize));
|
||||
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
|
||||
setBoundingSphere(_size);
|
||||
addProperty(_size);
|
||||
_size.onChange([&]() { _planeIsDirty = true; });
|
||||
addProperty(_size);
|
||||
|
||||
_texturePath = absPath(dictionary.value<std::string>(KeyTexture));
|
||||
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
|
||||
_textureFile = std::make_unique<File>(_texturePath);
|
||||
|
||||
if (dictionary.hasKeyAndValue<glm::vec2>(KeyOffset)) {
|
||||
_offset = dictionary.value<glm::vec2>(KeyOffset);
|
||||
if (dictionary.hasKey(OffsetInfo.identifier)) {
|
||||
_offset = dictionary.value<glm::vec2>(OffsetInfo.identifier);
|
||||
}
|
||||
addProperty(_offset);
|
||||
|
||||
|
||||
_texturePath.onChange([&]() { loadTexture(); });
|
||||
addProperty(_texturePath);
|
||||
_texturePath.onChange([&](){ loadTexture(); });
|
||||
|
||||
_textureFile->setCallback([&](const File&) { _textureIsDirty = true; });
|
||||
|
||||
if (dictionary.hasKey(NightFactorInfo.identifier)) {
|
||||
_nightFactor = static_cast<float>(
|
||||
dictionary.value<double>(NightFactorInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_nightFactor);
|
||||
|
||||
if (dictionary.hasKey(TransparencyInfo.identifier)) {
|
||||
_transparency = static_cast<float>(
|
||||
dictionary.value<double>(TransparencyInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_transparency);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,6 @@ namespace {
|
||||
const char* _loggerCat = "RenderableStars";
|
||||
|
||||
const char* KeyFile = "File";
|
||||
const char* KeyTexture = "Texture";
|
||||
const char* KeyColorMap = "ColorMap";
|
||||
|
||||
const int8_t CurrentCacheVersion = 1;
|
||||
|
||||
@@ -79,6 +77,48 @@ namespace {
|
||||
|
||||
float speed;
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo PsfTextureInfo = {
|
||||
"Texture",
|
||||
"Point Spread Function Texture",
|
||||
"The path to the texture that should be used as a point spread function for the "
|
||||
"stars."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo ColorTextureInfo = {
|
||||
"ColorMap",
|
||||
"ColorBV Texture",
|
||||
"The path to the texture that is used to convert from the B-V value of the star "
|
||||
"to its color. The texture is used as a one dimensional lookup function."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo ColorOptionInfo = {
|
||||
"ColorOption",
|
||||
"Color Option",
|
||||
"This value determines which quantity is used for determining the color of the "
|
||||
"stars."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo TransparencyInfo = {
|
||||
"Transparency",
|
||||
"Transparency",
|
||||
"This value is a multiplicative factor that is applied to the transparency of "
|
||||
"all stars."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo ScaleFactorInfo = {
|
||||
"ScaleFactor",
|
||||
"Scale Factor",
|
||||
"This value is used as a multiplicative factor that is applied to the apparent "
|
||||
"size of each star."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo MinBillboardSizeInfo = {
|
||||
"MinBillboardSize",
|
||||
"Min Billboard Size",
|
||||
"This value is used as a lower limit on the size of stars that are rendered. Any "
|
||||
"stars that have a smaller apparent size will be discarded entirely."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -103,20 +143,42 @@ documentation::Documentation RenderableStars::Documentation() {
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyTexture,
|
||||
PsfTextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
"The path to the texture that should be used as a point spread function "
|
||||
"for the stars. The path is relative to the location of the .mod file "
|
||||
"and can contain file system token.",
|
||||
PsfTextureInfo.description,
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyColorMap,
|
||||
ColorTextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
"The path to the texture that is used to convert from the B-V value of "
|
||||
"the star to its color. The texture is used as a one dimensional lookup "
|
||||
"function.",
|
||||
ColorTextureInfo.description,
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
ColorOptionInfo.identifier,
|
||||
new StringInListVerifier({
|
||||
"Color", "Velocity", "Speed"
|
||||
}),
|
||||
ColorOptionInfo.description,
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
TransparencyInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
TransparencyInfo.description,
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
ScaleFactorInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
ScaleFactorInfo.description,
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
MinBillboardSizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
MinBillboardSizeInfo.description,
|
||||
Optional::Yes
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -125,20 +187,17 @@ documentation::Documentation RenderableStars::Documentation() {
|
||||
|
||||
RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _pointSpreadFunctionTexturePath({ "PsfTexture", "Point Spread Function Texture", "" }) // @TODO Missing documentation
|
||||
, _pointSpreadFunctionTexturePath(PsfTextureInfo)
|
||||
, _pointSpreadFunctionTexture(nullptr)
|
||||
, _pointSpreadFunctionTextureIsDirty(true)
|
||||
, _colorTexturePath({ "ColorTexture", "ColorBV Texture", "" }) // @TODO Missing documentation
|
||||
, _colorTexturePath(ColorTextureInfo)
|
||||
, _colorTexture(nullptr)
|
||||
, _colorTextureIsDirty(true)
|
||||
, _colorOption(
|
||||
{ "ColorOption", "Color Option", "" }, // @TODO Missing documentation
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
, _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _dataIsDirty(true)
|
||||
, _alphaValue({ "AlphaValue", "Transparency", "" }, 1.f, 0.f, 1.f) // @TODO Missing documentation
|
||||
, _scaleFactor({ "ScaleFactor", "Scale Factor", "" }, 1.f, 0.f, 10.f) // @TODO Missing documentation
|
||||
, _minBillboardSize({ "MinBillboardSize", "Min Billboard Size", "" }, 1.f, 1.f, 100.f) // @TODO Missing documentation
|
||||
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
|
||||
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 10.f)
|
||||
, _minBillboardSize(MinBillboardSizeInfo, 1.f, 1.f, 100.f)
|
||||
, _program(nullptr)
|
||||
, _speckFile("")
|
||||
, _nValuesPerStar(0)
|
||||
@@ -161,34 +220,62 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
|
||||
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
|
||||
|
||||
//_colorOption.addOptions({
|
||||
// { ColorOption::Color, "Color" },
|
||||
// { ColorOption::Velocity, "Velocity" },
|
||||
// { ColorOption::Speed, "Speed" }
|
||||
//});
|
||||
_colorOption.addOption(ColorOption::Color, "Color");
|
||||
_colorOption.addOption(ColorOption::Velocity, "Velocity");
|
||||
_colorOption.addOption(ColorOption::Speed, "Speed");
|
||||
_colorOption.addOptions({
|
||||
{ ColorOption::Color, "Color" },
|
||||
{ ColorOption::Velocity, "Velocity" },
|
||||
{ ColorOption::Speed, "Speed" }
|
||||
});
|
||||
if (dictionary.hasKey(ColorOptionInfo.identifier)) {
|
||||
const std::string colorOption = dictionary.value<std::string>(
|
||||
ColorOptionInfo.identifier
|
||||
);
|
||||
if (colorOption == "Color") {
|
||||
_colorOption = ColorOption::Color;
|
||||
}
|
||||
else if (colorOption == "Velocity") {
|
||||
_colorOption = ColorOption::Velocity;
|
||||
}
|
||||
else {
|
||||
_colorOption = ColorOption::Speed;
|
||||
}
|
||||
}
|
||||
_colorOption.onChange([&] { _dataIsDirty = true; });
|
||||
addProperty(_colorOption);
|
||||
|
||||
_colorOption.onChange([&]{ _dataIsDirty = true;});
|
||||
|
||||
addProperty(_pointSpreadFunctionTexturePath);
|
||||
_pointSpreadFunctionTexturePath.onChange(
|
||||
[&]{ _pointSpreadFunctionTextureIsDirty = true; }
|
||||
);
|
||||
_pointSpreadFunctionFile->setCallback(
|
||||
[&](const File&) { _pointSpreadFunctionTextureIsDirty = true; }
|
||||
);
|
||||
addProperty(_pointSpreadFunctionTexturePath);
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange([&]{ _colorTextureIsDirty = true; });
|
||||
_colorTextureFile->setCallback(
|
||||
[&](const File&) { _colorTextureIsDirty = true; }
|
||||
);
|
||||
addProperty(_colorTexturePath);
|
||||
|
||||
if (dictionary.hasKey(TransparencyInfo.identifier)) {
|
||||
_alphaValue = static_cast<float>(
|
||||
dictionary.value<double>(TransparencyInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_alphaValue);
|
||||
|
||||
if (dictionary.hasKey(ScaleFactorInfo.identifier)) {
|
||||
_scaleFactor = static_cast<float>(
|
||||
dictionary.value<double>(ScaleFactorInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_scaleFactor);
|
||||
|
||||
if (dictionary.hasKey(MinBillboardSizeInfo.identifier)) {
|
||||
_minBillboardSize = static_cast<float>(
|
||||
dictionary.value<double>(MinBillboardSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
addProperty(_minBillboardSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,70 +23,108 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/space/rendering/simplespheregeometry.h>
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
|
||||
namespace {
|
||||
const char* _loggerCat = "SimpleSphereGeometry";
|
||||
|
||||
const char* keyRadius = "Radius";
|
||||
const char* keySegments = "Segments";
|
||||
static const openspace::properties::Property::PropertyInfo RadiusInfo = {
|
||||
"Radius",
|
||||
"Radius",
|
||||
"This value specifies the radius of this sphere in meters."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo SegmentsInfo = {
|
||||
"Segments",
|
||||
"Segments",
|
||||
"This value specifies the number of segments that this sphere is split into."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace::planetgeometry {
|
||||
|
||||
documentation::Documentation SimpleSphereGeometry::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"SimpleSphereGeometry",
|
||||
"space_geometry_simplesphere",
|
||||
{
|
||||
{
|
||||
"Type",
|
||||
new StringEqualVerifier("SimpleSphereGeometry"),
|
||||
"",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
RadiusInfo.identifier,
|
||||
new OrVerifier(
|
||||
new DoubleVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
RadiusInfo.description,
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
SegmentsInfo.identifier,
|
||||
new IntVerifier,
|
||||
SegmentsInfo.description,
|
||||
Optional::No
|
||||
}
|
||||
},
|
||||
Exhaustive::Yes
|
||||
};
|
||||
}
|
||||
|
||||
SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
|
||||
: PlanetGeometry()
|
||||
, _radius(
|
||||
{ "Radius", "Radius", "" }, // @TODO Missing documentation
|
||||
glm::vec3(1.f, 1.f, 1.f),
|
||||
glm::vec3(0.f, 0.f, 0.f),
|
||||
glm::vec3(std::pow(10.f, 20.f), std::pow(10.f, 20.f), std::pow(10.f, 20.f)))
|
||||
, _segments({ "Segments", "Segments", "" }, 20, 1, 5000) // @TODO Missing documentation
|
||||
, _radius(RadiusInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(std::pow(10.f, 20.f)))
|
||||
, _segments(SegmentsInfo, 20, 1, 5000)
|
||||
, _sphere(nullptr)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"SimpleSphereGeometry"
|
||||
);
|
||||
|
||||
float sphereRadius = 0.f;
|
||||
glm::vec3 ellipsoidRadius;
|
||||
if (dictionary.getValue(keyRadius, sphereRadius)) {
|
||||
_radius = { sphereRadius, sphereRadius, sphereRadius };
|
||||
} else if (dictionary.getValue(keyRadius, ellipsoidRadius)) {
|
||||
_radius = ellipsoidRadius;
|
||||
} else {
|
||||
LERROR("SimpleSphereGeometry did not provide a key '"
|
||||
<< keyRadius << "'");
|
||||
if (dictionary.hasKeyAndValue<double>(RadiusInfo.identifier)) {
|
||||
const float r = static_cast<float>(
|
||||
dictionary.value<double>(RadiusInfo.identifier)
|
||||
);
|
||||
_radius = { r, r, r };
|
||||
}
|
||||
else {
|
||||
_radius = dictionary.value<glm::vec3>(RadiusInfo.identifier);
|
||||
}
|
||||
|
||||
double segments = 0;
|
||||
if (dictionary.getValue(keySegments, segments)) {
|
||||
_segments = static_cast<int>(segments);
|
||||
} else {
|
||||
LERROR("SimpleSphereGeometry did not provide a key '"
|
||||
<< keySegments << "'");
|
||||
}
|
||||
_segments = dictionary.value<int>(SegmentsInfo.identifier);
|
||||
|
||||
// The shader need the radii values but they are not changeable runtime
|
||||
// TODO: Possibly add a scaling property @AA
|
||||
addProperty(_radius);
|
||||
// Changing the radius/scaling should affect the shader but not the geometry? @AA
|
||||
_radius.onChange(std::bind(&SimpleSphereGeometry::createSphere, this));
|
||||
_radius.onChange([&]() { createSphere(); });
|
||||
addProperty(_radius);
|
||||
|
||||
_segments.onChange([&]() { createSphere(); });
|
||||
addProperty(_segments);
|
||||
_segments.onChange(std::bind(&SimpleSphereGeometry::createSphere, this));
|
||||
}
|
||||
|
||||
SimpleSphereGeometry::~SimpleSphereGeometry() {
|
||||
}
|
||||
SimpleSphereGeometry::~SimpleSphereGeometry() {}
|
||||
|
||||
bool SimpleSphereGeometry::initialize(Renderable* parent)
|
||||
{
|
||||
bool SimpleSphereGeometry::initialize(Renderable* parent) {
|
||||
bool success = PlanetGeometry::initialize(parent);
|
||||
createSphere();
|
||||
return success;
|
||||
}
|
||||
|
||||
void SimpleSphereGeometry::deinitialize() {
|
||||
if (_sphere)
|
||||
delete _sphere;
|
||||
delete _sphere;
|
||||
_sphere = nullptr;
|
||||
}
|
||||
|
||||
@@ -94,13 +132,11 @@ void SimpleSphereGeometry::render() {
|
||||
_sphere->render();
|
||||
}
|
||||
|
||||
void SimpleSphereGeometry::createSphere(){
|
||||
void SimpleSphereGeometry::createSphere() {
|
||||
const glm::vec3 radius = _radius.value();
|
||||
_parent->setBoundingSphere(std::max(std::max(radius[0], radius[1]), radius[2]));
|
||||
|
||||
if(_sphere)
|
||||
delete _sphere;
|
||||
|
||||
delete _sphere;
|
||||
_sphere = new PowerScaledSphere(glm::vec4(radius, 0.0), _segments);
|
||||
_sphere->initialize();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace openspace {
|
||||
class PowerScaledSphere;
|
||||
} // namespace openspace
|
||||
|
||||
namespace openspace::documentation { struct Documentation; }
|
||||
|
||||
namespace openspace::planetgeometry {
|
||||
|
||||
class SimpleSphereGeometry : public PlanetGeometry {
|
||||
@@ -46,6 +48,8 @@ public:
|
||||
void deinitialize() override;
|
||||
void render() override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
void createSphere();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user