Commit c32aac62 authored by Maire Nicolas's avatar Maire Nicolas

Rajout d'une méthode pour la normalisation de l'attenuation de couleurs.

parent 4f2f41b6
......@@ -84,6 +84,7 @@ void Clipping::slot_pushButton_addPlane()
// Set params
m_shader->setClipPlaneParamsOrigin(newPlaneId, m_bb.center());
pickable->translate(m_bb.center());
pickable->scale(Geom::Vec3f(m_bb.maxSize()*0.5));
// Update shader sources edits
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
......@@ -120,9 +121,9 @@ void Clipping::slot_pushButton_addSphere()
// Set params
m_shader->setClipSphereParamsCenter(newSphereId, m_bb.center());
m_shader->setClipSphereParamsRadius(newSphereId, (m_bb.maxSize())*1.0);
m_shader->setClipSphereParamsRadius(newSphereId, (m_bb.maxSize())*0.5);
pickable->translate(m_bb.center());
pickable->scale(Geom::Vec3f(m_bb.maxSize()*1.0));
pickable->scale(Geom::Vec3f(m_bb.maxSize()*0.5));
// Update shader sources edits
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
......@@ -152,7 +153,7 @@ void Clipping::slot_pushButton_changeSpheresColor()
void Clipping::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{
m_shader->setClipColorAttenuationFactor((float)c);
m_shader->setClipColorAttenuationFactorAbsolute((float)c);
updateGL();
}
......@@ -374,6 +375,8 @@ void Clipping::importMesh(std::string& filename)
setParamObject(gWidthObj, gPosObj.data()) ;
updateGLMatrices();
m_shader->setClipColorAttenuationFactorRelative(m_bb.maxSize(), 5.0);
}
/*******************************************************************************
......
......@@ -302,6 +302,9 @@
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<property name="decimals">
<number>4</number>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
......
......@@ -272,7 +272,14 @@ public:
* sets the color attenuation factor
* @param colorAttenuationFactor color attenuation factor
*/
void setClipColorAttenuationFactor(float colorAttenuationFactor);
void setClipColorAttenuationFactorAbsolute(float colorAttenuationFactor);
/**
* sets the color attenuation factor according to an object size
* @param size size with which the color attenuation will be normalized
* @param factor attenuation factor
*/
void setClipColorAttenuationFactorRelative(float size, float factor);
/// gets the color attenuation factor
float getClipColorAttenuationFactor();
......
......@@ -814,7 +814,7 @@ bool ClippingShader::insertClippingCode()
return true;
}
void ClippingShader::setClipColorAttenuationFactor(float colorAttenuationFactor)
void ClippingShader::setClipColorAttenuationFactorAbsolute(float colorAttenuationFactor)
{
// Check if it is worth updating values !
if (colorAttenuationFactor == m_clipColorAttenuationFactor)
......@@ -827,6 +827,19 @@ void ClippingShader::setClipColorAttenuationFactor(float colorAttenuationFactor)
sendClipColorAttenuationFactorUniform();
}
void ClippingShader::setClipColorAttenuationFactorRelative(float size, float factor)
{
// Compute the relative color attenuation factor
float colAttFact;
if (size != 0.0)
colAttFact = factor / size;
else
colAttFact = factor;
// Set the resulting factor in absolute
setClipColorAttenuationFactorAbsolute(colAttFact);
}
float ClippingShader::getClipColorAttenuationFactor()
{
return m_clipColorAttenuationFactor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment