Adding a configuration value to ProjectionComponent that determines the aspect ratio of the projection texture (default = 1.0)

This commit is contained in:
Alexander Bock
2016-09-01 09:53:56 +02:00
parent 34b1401d99
commit 0060e4782a
10 changed files with 45 additions and 6 deletions
@@ -22,6 +22,7 @@ return {
Observer = "NEW HORIZONS",
Target = "CALLISTO",
Aberration = "NONE",
AspectRatio = 2
},
Instrument = {
Name = "NH_LORRI",
@@ -22,6 +22,7 @@ return {
Observer = "NEW HORIZONS",
Target = "EUROPA",
Aberration = "NONE",
AspectRatio = 2
},
Instrument = {
Name = "NH_LORRI",
@@ -22,6 +22,7 @@ return {
Observer = "NEW HORIZONS",
Target = "GANYMEDE",
Aberration = "NONE",
AspectRatio = 2
},
Instrument = {
Name = "NH_LORRI",
+1
View File
@@ -22,6 +22,7 @@ return {
Observer = "NEW HORIZONS",
Target = "IO",
Aberration = "NONE",
AspectRatio = 2
},
Instrument = {
Name = "NH_LORRI",
@@ -41,6 +41,7 @@ return {
Observer = "NEW HORIZONS",
Target = "JUPITER",
Aberration = "NONE",
AspectRatio = 2
},
DataInputTranslation = {
Instrument = {
@@ -40,6 +40,7 @@ return {
Observer = "NEW HORIZONS",
Target = "CHARON",
Aberration = "NONE",
AspectRatio = 2
},
Instrument = {
Name = "NH_LORRI",
@@ -67,6 +67,7 @@ return {
Observer = "NEW HORIZONS",
Target = "PLUTO",
Aberration = "NONE",
AspectRatio = 2
},
DataInputTranslation = {
Instrument = {
+1
View File
@@ -51,6 +51,7 @@ return {
Observer = "SUN",
Target = BENNU_BODY,
Aberration = "NONE",
AspectRatio = 2
},
DataInputTranslation = {
Instruments = {
@@ -52,6 +52,7 @@ namespace {
const std::string keyTranslation = "DataInputTranslation";
const std::string keyNeedsTextureMapDilation = "Projection.TextureMap";
const std::string keyTextureMapAspectRatio = "Projection.AspectRatio";
const std::string sequenceTypeImage = "image-sequence";
const std::string sequenceTypePlaybook = "playbook";
@@ -196,6 +197,12 @@ bool ProjectionComponent::initializeProjectionSettings(const Dictionary& diction
_needsTextureMapDilation = dictionary.value<bool>(keyNeedsTextureMapDilation);
}
_projectionTextureAspectRatio = 1.f;
if (dictionary.hasKeyAndValue<double>(keyTextureMapAspectRatio)) {
_projectionTextureAspectRatio =
static_cast<float>(dictionary.value<double>(keyTextureMapAspectRatio));
}
return completeSuccess;
}
@@ -579,11 +586,22 @@ std::shared_ptr<ghoul::opengl::Texture> ProjectionComponent::loadProjectionTextu
bool ProjectionComponent::generateProjectionLayerTexture() {
int maxSize = OpenGLCap.max2DTextureSize() / 2;
glm::ivec2 size;
if (_projectionTextureAspectRatio > 1.f) {
size.x = maxSize;
size.y = static_cast<int>(maxSize / _projectionTextureAspectRatio);
}
else {
size.x = static_cast<int>(maxSize * _projectionTextureAspectRatio);
size.y = maxSize;
}
LINFO(
"Creating projection texture of size '" << maxSize << ", " << maxSize / 2 << "'"
"Creating projection texture of size '" << size.x << ", " << size.y << "'"
);
_projectionTexture = std::make_unique<ghoul::opengl::Texture> (
glm::uvec3(maxSize, maxSize / 2, 1),
glm::uvec3(size, 1),
ghoul::opengl::Texture::Format::RGBA
);
if (_projectionTexture) {
@@ -593,7 +611,7 @@ bool ProjectionComponent::generateProjectionLayerTexture() {
if (_needsTextureMapDilation) {
_dilation.texture = std::make_unique<ghoul::opengl::Texture>(
glm::uvec3(maxSize, maxSize / 2, 1),
glm::uvec3(size, 1),
ghoul::opengl::Texture::Format::RGBA
);
@@ -603,7 +621,7 @@ bool ProjectionComponent::generateProjectionLayerTexture() {
}
_dilation.stencilTexture = std::make_unique<ghoul::opengl::Texture>(
glm::uvec3(maxSize, maxSize / 2, 1),
glm::uvec3(size, 1),
ghoul::opengl::Texture::Format::Red,
ghoul::opengl::Texture::Format::Red
);
@@ -622,12 +640,23 @@ bool ProjectionComponent::generateProjectionLayerTexture() {
bool ProjectionComponent::generateDepthTexture() {
int maxSize = OpenGLCap.max2DTextureSize() / 2;
glm::ivec2 size;
if (_projectionTextureAspectRatio > 1.f) {
size.x = maxSize;
size.y = static_cast<int>(maxSize / _projectionTextureAspectRatio);
}
else {
size.x = static_cast<int>(maxSize * _projectionTextureAspectRatio);
size.y = maxSize;
}
LINFO(
"Creating depth texture of size '" << maxSize / 2 << ", " << maxSize / 2 << "'"
"Creating depth texture of size '" << size.x << ", " << size.y << "'"
);
_depthTexture = std::make_unique<ghoul::opengl::Texture>(
glm::uvec3(maxSize / 2, maxSize / 2, 1),
glm::uvec3(size, 1),
ghoul::opengl::Texture::Format::DepthComponent,
GL_DEPTH_COMPONENT32F
);
@@ -108,6 +108,8 @@ protected:
std::unique_ptr<ghoul::opengl::Texture> _depthTexture;
std::shared_ptr<ghoul::opengl::Texture> _placeholderTexture;
float _projectionTextureAspectRatio;
std::string _instrumentID;
std::string _projectorID;
std::string _projecteeID;