Added luminosity/size and slum controls by datavar in plane clouds.

This commit is contained in:
Jonathas Costa
2017-10-11 14:51:26 -04:00
parent 07cdbb6d59
commit a5243cf4d1
2 changed files with 47 additions and 1 deletions
@@ -132,11 +132,25 @@ namespace {
"This value specifies the path for the textures in disk."
};
static const openspace::properties::Property::PropertyInfo LuminosityInfo = {
"Luminosity",
"Luminosity variable",
"Datavar variable to control the luminosity/size of the astronomical objects."
};
static const openspace::properties::Property::PropertyInfo ScaleLuminosityInfo = {
"ScaleLuminosity",
"ScaleLuminosity variable",
"Scaling control for the luminosity/size of the astronomical objects."
};
static const openspace::properties::Property::PropertyInfo RenderOptionInfo = {
"RenderOptionInfo",
"Render Option",
"Debug option for rendering of billboards and texts."
};
} // namespace
namespace openspace {
@@ -213,6 +227,18 @@ namespace openspace {
Optional::No,
TexturePathInfo.description,
},
{
LuminosityInfo.identifier,
new StringVerifier,
Optional::Yes,
LuminosityInfo.description,
},
{
ScaleFactorInfo.identifier,
new DoubleVerifier,
Optional::Yes,
ScaleFactorInfo.description,
},
}
};
}
@@ -246,8 +272,10 @@ namespace openspace {
, _speckFile("")
, _labelFile("")
, _texturesPath("")
, _luminosityVar("")
, _unit(Parsec)
, _nValuesPerAstronomicalObject(0)
, _sluminosity(1.f)
, _transformationMatrix(glm::dmat4(1.0))
{
using File = ghoul::filesystem::File;
@@ -379,6 +407,14 @@ namespace openspace {
}
_texturesPath = absPath(dictionary.value<std::string>(TexturePathInfo.identifier));
if (dictionary.hasKey(LuminosityInfo.identifier)) {
_luminosityVar = dictionary.value<std::string>(LuminosityInfo.identifier);
}
if (dictionary.hasKey(ScaleLuminosityInfo.identifier)) {
_sluminosity = static_cast<float>(dictionary.value<double>(ScaleLuminosityInfo.identifier));
}
}
bool RenderablePlanesCloud::isReady() const {
@@ -740,7 +776,8 @@ namespace openspace {
dummy.clear();
str >> dummy; // variable name
_variableDataPositionMap.insert({ dummy, _nValuesPerAstronomicalObject });
// +3 because of the x, y and z at the begining of each line.
_variableDataPositionMap.insert({ dummy, _nValuesPerAstronomicalObject + 3});
if (dummy == "orientation") { // 3d vectors u and v
_nValuesPerAstronomicalObject += 6; // We want the number, but the index is 0 based
@@ -998,6 +1035,12 @@ dummy.clear();
v /= 2.f;
v.w = 0.0;
if (!_luminosityVar.empty()) {
float lumS = _fullData[p + _variableDataPositionMap[_luminosityVar]] * _sluminosity;
u *= lumS;
v *= lumS;
}
u *= _scaleFactor;
v *= _scaleFactor;
@@ -132,6 +132,7 @@ namespace openspace {
std::string _speckFile;
std::string _labelFile;
std::string _texturesPath;
std::string _luminosityVar;
Unit _unit;
@@ -141,6 +142,8 @@ namespace openspace {
int _nValuesPerAstronomicalObject;
float _sluminosity;
glm::dmat4 _transformationMatrix;
std::unordered_map<int, RenderingPlane> _renderingPlanesMap;