Commit 2b0a7d41 authored by Maire Nicolas's avatar Maire Nicolas

Gestion du clipping 'inverse' par sphère avec rayon négatif.

Gestion du et/ou clipping, et ajout de l'option dans l'interface Qt de stage_shader.
parent 0c2544c8
......@@ -163,12 +163,6 @@ void StageShader::slot_doubleSpinBox_PlaneOrigin(double c)
}
}
void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{
m_shader->setClipColorAttenuationFactor((float)c);
updateGL();
}
void StageShader::slot_doubleSpinBox_GridDisplaySize(double c)
{
m_shader->setClipPlanesDisplaySize((float)c);
......@@ -206,7 +200,7 @@ void StageShader::slot_pushButton_addSphere()
std::string indexStr;
std::stringstream ss;
ss << (dock.comboBox_PlaneIndex->count() + 1);
ss << (dock.comboBox_SphereIndex->count() + 1);
indexStr = ss.str();
std::string str = "Sphere " + indexStr;
......@@ -287,6 +281,25 @@ void StageShader::slot_doubleSpinBox_SphereGridColor(double c)
updateGL();
}
void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{
m_shader->setClipColorAttenuationFactor((float)c);
updateGL();
}
void StageShader::slot_horizontalSlider_ClippingMode(int i)
{
if (i == 0)
m_shader->setClipMode(Utils::ClippingShader::CLIPPING_MODE_AND);
else if (i == 1)
m_shader->setClipMode(Utils::ClippingShader::CLIPPING_MODE_OR);
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
updateGLMatrices();
}
void StageShader::button_compile()
{
QString st1 = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->vertexEdit->toPlainText();
......@@ -351,7 +364,6 @@ void StageShader::initGUI()
setCallBack(dock.doubleSpinBox_PlaneOriginy, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
setCallBack(dock.doubleSpinBox_PlaneOriginz, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
setCallBack(dock.doubleSpinBox_ColorAttenuationFactor, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
setCallBack(dock.doubleSpinBox_GridDisplaySize, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_GridDisplaySize(double)));
setCallBack(dock.spinBox_GridResolutionX, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolutionX(int)));
setCallBack(dock.spinBox_GridResolutionY, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolutionY(int)));
......@@ -364,7 +376,6 @@ void StageShader::initGUI()
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClipColorAttenuationFactor());
dock.doubleSpinBox_GridDisplaySize->setValue(m_shader->getClipPlanesDisplaySize());
dock.spinBox_GridResolutionX->setValue(m_shader->getClipPlanesDisplayXRes());
dock.spinBox_GridResolutionY->setValue(m_shader->getClipPlanesDisplayYRes());
......@@ -399,6 +410,18 @@ void StageShader::initGUI()
dock.doubleSpinBox_SphereGridColorG->setValue(spheresCol[1]);
dock.doubleSpinBox_SphereGridColorB->setValue(spheresCol[2]);
setCallBack(dock.doubleSpinBox_ColorAttenuationFactor, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
setCallBack(dock.horizontalSlider_ClippingMode, SIGNAL(valueChanged(int)), SLOT(slot_horizontalSlider_ClippingMode(int)));
dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClipColorAttenuationFactor());
Utils::ClippingShader::clippingMode clipMode = m_shader->getClipMode();
if (clipMode == Utils::ClippingShader::CLIPPING_MODE_AND)
dock.horizontalSlider_ClippingMode->setValue(0);
else if (clipMode == Utils::ClippingShader::CLIPPING_MODE_OR)
dock.horizontalSlider_ClippingMode->setValue(1);
}
void StageShader::cb_Open()
......
......@@ -133,7 +133,6 @@ public slots:
void slot_doubleSpinBox_PlaneVec2(double c);
void slot_doubleSpinBox_PlaneOrigin(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_doubleSpinBox_GridDisplaySize(double c);
void slot_spinBox_GridResolutionX(int i);
void slot_spinBox_GridResolutionY(int i);
......@@ -151,6 +150,9 @@ public slots:
void slot_spinBox_SphereGridResolutionY(int i);
void slot_doubleSpinBox_SphereGridColor(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_horizontalSlider_ClippingMode(int i);
void button_compile();
};
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>424</width>
<height>534</height>
<height>501</height>
</rect>
</property>
<property name="allowedAreas">
......@@ -34,7 +34,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget_3">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_Object">
<attribute name="title">
......@@ -201,9 +201,9 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Clipping">
<widget class="QWidget" name="tab_PlaneClipping">
<attribute name="title">
<string>Plane Clipping</string>
<string>Plane Clip</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
......@@ -219,7 +219,7 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_12">
<item row="3" column="2">
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridColorG">
<property name="maximum">
<double>1.000000000000000</double>
......@@ -229,59 +229,42 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_GridResolution">
<property name="text">
<string>Res.</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_ColorAttenuationFactor">
<property name="text">
<string>Color Att.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QSpinBox" name="spinBox_GridResolutionX">
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<property name="singleStep">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_GridColor">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridDisplaySize">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<widget class="QLabel" name="label_GridSize">
<property name="text">
<string>Size</string>
</property>
</widget>
</item>
<item row="3" column="3">
<item row="2" column="3">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridColorB">
<property name="maximum">
<double>1.000000000000000</double>
......@@ -291,7 +274,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridColorR">
<property name="maximum">
<double>1.000000000000000</double>
......@@ -301,7 +284,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="1" column="2">
<widget class="QSpinBox" name="spinBox_GridResolutionY">
<property name="maximum">
<number>200</number>
......@@ -523,9 +506,9 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<widget class="QWidget" name="tab_SphereClipping">
<attribute name="title">
<string>Sphere Clipping</string>
<string>Sphere Clip</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
......@@ -742,6 +725,51 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_GlobalClipping">
<attribute name="title">
<string>Global Clip</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0">
<widget class="QLabel" name="label_ColorAttenuationFactor">
<property name="text">
<string>Color Att.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<property name="singleStep">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_ClippingMode">
<property name="text">
<string>Clipping Mode</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="horizontalSlider_ClippingMode">
<property name="maximum">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......
......@@ -72,6 +72,8 @@ void Stage_shader_number_two::initGUI()
setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ;
setCallBack(dock.doubleSpinBox_color_attenuation, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
dock.doubleSpinBox_color_attenuation->setValue(m_phongShader->getClipColorAttenuationFactor());
}
void Stage_shader_number_two::cb_initGL()
......@@ -118,6 +120,8 @@ void Stage_shader_number_two::cb_initGL()
registerShader(m_simpleColorShader) ;
registerShader(m_pointSprite) ;
m_phongShader->insertClippingCode();
m_phongShader->setClipPlanesCount(1);
}
......
......@@ -389,6 +389,9 @@ private:
public:
/// enum used to choose which clipping mode to use
enum clippingMode { CLIPPING_MODE_AND, CLIPPING_MODE_OR };
/**
* insert clipping instructions into shader source code
* @warning this function is designed for shaders which *do not* use a geometry shader
......@@ -404,6 +407,15 @@ public:
/// get the color attenuation factor for clipping
float getClipColorAttenuationFactor();
/*
* set the clipping mode
* @param clipMode clipping mode
*/
void setClipMode(clippingMode clipMode);
/// get the clipping mode
clippingMode getClipMode();
private:
/// to control clipping code has been inserted before clipping objects have been added
......@@ -415,6 +427,9 @@ private:
/// color attenuation factor uniform id
GLint m_unif_clipColorAttenuationFactor;
/// clipping mode
clippingMode m_clipMode;
/***********************************************
*
......
This diff is collapsed.
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