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() ...@@ -84,6 +84,7 @@ void Clipping::slot_pushButton_addPlane()
// Set params // Set params
m_shader->setClipPlaneParamsOrigin(newPlaneId, m_bb.center()); m_shader->setClipPlaneParamsOrigin(newPlaneId, m_bb.center());
pickable->translate(m_bb.center()); pickable->translate(m_bb.center());
pickable->scale(Geom::Vec3f(m_bb.maxSize()*0.5));
// Update shader sources edits // Update shader sources edits
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc())); dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
...@@ -120,9 +121,9 @@ void Clipping::slot_pushButton_addSphere() ...@@ -120,9 +121,9 @@ void Clipping::slot_pushButton_addSphere()
// Set params // Set params
m_shader->setClipSphereParamsCenter(newSphereId, m_bb.center()); 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->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 // Update shader sources edits
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc())); dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
...@@ -152,7 +153,7 @@ void Clipping::slot_pushButton_changeSpheresColor() ...@@ -152,7 +153,7 @@ void Clipping::slot_pushButton_changeSpheresColor()
void Clipping::slot_doubleSpinBox_ColorAttenuationFactor(double c) void Clipping::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{ {
m_shader->setClipColorAttenuationFactor((float)c); m_shader->setClipColorAttenuationFactorAbsolute((float)c);
updateGL(); updateGL();
} }
...@@ -374,6 +375,8 @@ void Clipping::importMesh(std::string& filename) ...@@ -374,6 +375,8 @@ void Clipping::importMesh(std::string& filename)
setParamObject(gWidthObj, gPosObj.data()) ; setParamObject(gWidthObj, gPosObj.data()) ;
updateGLMatrices(); updateGLMatrices();
m_shader->setClipColorAttenuationFactorRelative(m_bb.maxSize(), 5.0);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -302,6 +302,9 @@ ...@@ -302,6 +302,9 @@
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor"> <widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<property name="decimals">
<number>4</number>
</property>
<property name="singleStep"> <property name="singleStep">
<double>1.000000000000000</double> <double>1.000000000000000</double>
</property> </property>
......
...@@ -272,7 +272,14 @@ public: ...@@ -272,7 +272,14 @@ public:
* sets the color attenuation factor * sets the color attenuation factor
* @param colorAttenuationFactor 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 /// gets the color attenuation factor
float getClipColorAttenuationFactor(); float getClipColorAttenuationFactor();
......
...@@ -814,7 +814,7 @@ bool ClippingShader::insertClippingCode() ...@@ -814,7 +814,7 @@ bool ClippingShader::insertClippingCode()
return true; return true;
} }
void ClippingShader::setClipColorAttenuationFactor(float colorAttenuationFactor) void ClippingShader::setClipColorAttenuationFactorAbsolute(float colorAttenuationFactor)
{ {
// Check if it is worth updating values ! // Check if it is worth updating values !
if (colorAttenuationFactor == m_clipColorAttenuationFactor) if (colorAttenuationFactor == m_clipColorAttenuationFactor)
...@@ -827,6 +827,19 @@ void ClippingShader::setClipColorAttenuationFactor(float colorAttenuationFactor) ...@@ -827,6 +827,19 @@ void ClippingShader::setClipColorAttenuationFactor(float colorAttenuationFactor)
sendClipColorAttenuationFactorUniform(); 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() float ClippingShader::getClipColorAttenuationFactor()
{ {
return m_clipColorAttenuationFactor; 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