diff --git a/adf_loader/version_1_0/adf_loader_1_0.cpp b/adf_loader/version_1_0/adf_loader_1_0.cpp index 867a102a1..61cf330fc 100644 --- a/adf_loader/version_1_0/adf_loader_1_0.cpp +++ b/adf_loader/version_1_0/adf_loader_1_0.cpp @@ -1162,6 +1162,7 @@ bool ADFLoader_1_0::loadLightAttribs(YAML::Node *a_node, afLightAttributes *attr YAML::Node spotExponentNode = node["spot exponent"]; YAML::Node shadowQualityNode = node["shadow quality"]; YAML::Node cuttOffAngleNode = node["cutoff angle"]; + YAML::Node attenuationNode = node["attenuation"]; bool valid = true; @@ -1214,6 +1215,13 @@ bool ADFLoader_1_0::loadLightAttribs(YAML::Node *a_node, afLightAttributes *attr attribs->m_cuttoffAngle = cuttOffAngleNode.as(); } + if (attenuationNode.IsDefined()){ + attribs->m_attenuationDefined = true; + if (attenuationNode["constant"].IsDefined()) attribs->m_constantAttenuation = attenuationNode["constant"].as(); + if (attenuationNode["linear"].IsDefined()) attribs->m_linearAttenuation = attenuationNode["linear"].as(); + if (attenuationNode["quadratic"].IsDefined()) attribs->m_quadraticAttenuation = attenuationNode["quadratic"].as(); + } + return valid; } diff --git a/ambf_framework/afAttributes.h b/ambf_framework/afAttributes.h index bc527b73c..77b676437 100644 --- a/ambf_framework/afAttributes.h +++ b/ambf_framework/afAttributes.h @@ -623,10 +623,18 @@ struct afLightAttributes: public afBaseObjectAttributes afLightAttributes(){ m_spotExponent = 0.7; m_cuttoffAngle = 0.7; + m_constantAttenuation = 1.0; + m_linearAttenuation = 0.0; + m_quadraticAttenuation = 0.0; + m_attenuationDefined = false; } double m_spotExponent; double m_cuttoffAngle; + double m_constantAttenuation; + double m_linearAttenuation; + double m_quadraticAttenuation; + bool m_attenuationDefined; afVector3d m_direction; afShadowQualityType m_shadowQuality; diff --git a/ambf_framework/afFramework.cpp b/ambf_framework/afFramework.cpp index 4ed92c94a..b479e4773 100644 --- a/ambf_framework/afFramework.cpp +++ b/ambf_framework/afFramework.cpp @@ -7216,6 +7216,12 @@ bool afLight::createFromAttribs(afLightAttributes *a_attribs) m_spotLight->setCutOffAngleDeg(a_attribs->m_cuttoffAngle * (180/3.14)); m_spotLight->setShadowMapEnabled(true); + if (a_attribs->m_attenuationDefined){ + m_spotLight->setAttConstant(a_attribs->m_constantAttenuation); + m_spotLight->setAttLinear(a_attribs->m_linearAttenuation); + m_spotLight->setAttQuadratic(a_attribs->m_quadraticAttenuation); + } + switch (a_attribs->m_shadowQuality) { case afShadowQualityType::NO_SHADOW: m_spotLight->setShadowMapEnabled(false); @@ -8302,7 +8308,7 @@ bool afVolume::createFromAttribs(afVolumeAttributes *a_attribs) m_voxelObject = new cVoxelObject(); // Setting transparency before setting the texture ensures that the rendering does not show empty spaces as black // and the depth point cloud is able to see the volume - m_voxelObject->setTransparencyLevel(1.0); +// m_voxelObject->setTransparencyLevel(1.0); cTexture3dPtr texture = cTexture3d::create(); texture->setImage(m_multiImage); diff --git a/external/chai3d/src/lighting/CSpotLight.cpp b/external/chai3d/src/lighting/CSpotLight.cpp index d5b6ef388..c2e0721f8 100644 --- a/external/chai3d/src/lighting/CSpotLight.cpp +++ b/external/chai3d/src/lighting/CSpotLight.cpp @@ -181,6 +181,11 @@ void cSpotLight::renderLightSource(cRenderOptions& a_options) // set cutoff angle glLightf(m_glLightNumber, GL_SPOT_CUTOFF, m_cutOffAngleDeg); + // Set Attenuation Constants + glLightf(m_glLightNumber, GL_CONSTANT_ATTENUATION, getAttConstant()); + glLightf(m_glLightNumber, GL_LINEAR_ATTENUATION, getAttLinear()); + glLightf(m_glLightNumber, GL_QUADRATIC_ATTENUATION, getAttQuadratic()); + #endif }