Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KennethVanhoey
CGoGN
Commits
6c8f11ee
Commit
6c8f11ee
authored
Jun 24, 2011
by
Maire Nicolas
Browse files
Rajout d'une interface permettant de contrôler les différents plans de clipping.
parent
ccbaf38f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/stage_shader.cpp
View file @
6c8f11ee
...
...
@@ -75,14 +75,61 @@ void StageShader::slot_explodTopoPhi3(double c)
updateGL
();
}
void
StageShader
::
slot_pushButton_addPlane
()
{
m_shader
->
setPlaneClipping
(
dock
.
comboBox_PlaneIndex
->
count
()
+
1
);
std
::
string
indexStr
;
std
::
stringstream
ss
;
ss
<<
(
dock
.
comboBox_PlaneIndex
->
count
()
+
1
);
indexStr
=
ss
.
str
();
std
::
string
str
=
"Plane "
+
indexStr
;
dock
.
comboBox_PlaneIndex
->
addItem
(
QString
(
str
.
c_str
()));
dock
.
vertexEdit
->
setPlainText
(
QString
(
m_shader
->
getVertexShaderSrc
()));
dock
.
fragmentEdit
->
setPlainText
(
QString
(
m_shader
->
getFragmentShaderSrc
()));
updateGLMatrices
();
}
void
StageShader
::
slot_pushButton_deletePlane
()
{
m_shader
->
setPlaneClipping
(
dock
.
comboBox_PlaneIndex
->
count
()
-
1
);
dock
.
comboBox_PlaneIndex
->
removeItem
(
dock
.
comboBox_PlaneIndex
->
count
()
-
1
);
dock
.
vertexEdit
->
setPlainText
(
QString
(
m_shader
->
getVertexShaderSrc
()));
dock
.
fragmentEdit
->
setPlainText
(
QString
(
m_shader
->
getFragmentShaderSrc
()));
updateGLMatrices
();
}
void
StageShader
::
slot_comboBox_PlaneIndexChanged
(
int
newIndex
)
{
if
(
newIndex
>=
0
)
{
Geom
::
Vec4f
currPlaneEquation
=
m_shader
->
getClippingPlaneEquation
(
newIndex
);
dock
.
doubleSpinBox_aPlane
->
setValue
(
currPlaneEquation
[
0
]);
dock
.
doubleSpinBox_bPlane
->
setValue
(
currPlaneEquation
[
1
]);
dock
.
doubleSpinBox_cPlane
->
setValue
(
currPlaneEquation
[
2
]);
dock
.
doubleSpinBox_dPlane
->
setValue
(
currPlaneEquation
[
3
]);
}
}
void
StageShader
::
slot_doubleSpinBox_Plane
(
double
c
)
{
float
aPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_aPlane
->
value
();
float
bPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_bPlane
->
value
();
float
cPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_cPlane
->
value
();
float
dPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_dPlane
->
value
();
m_shader
->
setClippingPlaneEquation
(
Geom
::
Vec4f
(
aPlane
,
bPlane
,
cPlane
,
dPlane
));
updateGL
();
if
(
dock
.
comboBox_PlaneIndex
->
currentIndex
()
>=
0
)
{
float
aPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_aPlane
->
value
();
float
bPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_bPlane
->
value
();
float
cPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_cPlane
->
value
();
float
dPlane
=
dynamic_cast
<
Utils
::
QT
::
uiDockInterface
*>
(
dockWidget
())
->
doubleSpinBox_dPlane
->
value
();
m_shader
->
setClippingPlaneEquation
(
Geom
::
Vec4f
(
aPlane
,
bPlane
,
cPlane
,
dPlane
),
dock
.
comboBox_PlaneIndex
->
currentIndex
());
updateGL
();
}
}
void
StageShader
::
slot_doubleSpinBox_ColorAttenuationFactor
(
double
c
)
...
...
@@ -138,6 +185,11 @@ void StageShader::initGUI()
setCallBack
(
dock
.
explod_phi2
,
SIGNAL
(
valueChanged
(
double
)),
SLOT
(
slot_explodTopoPhi2
(
double
)));
setCallBack
(
dock
.
explod_phi3
,
SIGNAL
(
valueChanged
(
double
)),
SLOT
(
slot_explodTopoPhi3
(
double
)));
setCallBack
(
dock
.
pushButton_addPlane
,
SIGNAL
(
clicked
()),
SLOT
(
slot_pushButton_addPlane
()));
setCallBack
(
dock
.
pushButton_deletePlane
,
SIGNAL
(
clicked
()),
SLOT
(
slot_pushButton_deletePlane
()));
setCallBack
(
dock
.
comboBox_PlaneIndex
,
SIGNAL
(
currentIndexChanged
(
int
)),
SLOT
(
slot_comboBox_PlaneIndexChanged
(
int
)));
setCallBack
(
dock
.
doubleSpinBox_aPlane
,
SIGNAL
(
valueChanged
(
double
)),
SLOT
(
slot_doubleSpinBox_Plane
(
double
)));
setCallBack
(
dock
.
doubleSpinBox_bPlane
,
SIGNAL
(
valueChanged
(
double
)),
SLOT
(
slot_doubleSpinBox_Plane
(
double
)));
setCallBack
(
dock
.
doubleSpinBox_cPlane
,
SIGNAL
(
valueChanged
(
double
)),
SLOT
(
slot_doubleSpinBox_Plane
(
double
)));
...
...
@@ -232,8 +284,6 @@ void StageShader::cb_initGL()
m_shader
->
setColor
(
Geom
::
Vec4f
(
0.
,
1.
,
0.
,
0.
));
registerShader
(
m_shader
);
m_shader
->
setPlaneClipping
(
1
);
}
void
StageShader
::
updateVBOprimitives
(
int
upType
)
...
...
Apps/Tuto/stage_shader.h
View file @
6c8f11ee
...
...
@@ -52,6 +52,9 @@
#include
"Utils/cgognStream.h"
#include
"Utils/drawer.h"
#include
<string>
#include
<sstream>
using
namespace
CGoGN
;
struct
PFP
:
public
PFP_STANDARD
...
...
@@ -78,8 +81,8 @@ public:
//Render
bool
m_drawVertices
;
bool
m_drawLines
;
bool
m_drawFaces
;
bool
m_drawTopo
;
bool
m_drawFaces
;
bool
m_drawTopo
;
Algo
::
Render
::
GL2
::
MapRender
*
m_render
;
Algo
::
Render
::
GL2
::
Topo3RenderMapD
*
m_render_topo
;
...
...
@@ -92,13 +95,13 @@ public:
Utils
::
Drawer
*
chips_area
;
Geom
::
Vec3f
m_coeffTopoExplod
;
Geom
::
Vec3f
gPosObj
;
float
gWidthObj
;
Geom
::
Vec3f
gPosObj
;
float
gWidthObj
;
//QT
Utils
::
QT
::
uiDockInterface
dock
;
//QT
Utils
::
QT
::
uiDockInterface
dock
;
StageShader
();
StageShader
();
void
initGUI
();
void
cb_Open
();
...
...
@@ -119,6 +122,11 @@ public slots:
void
slot_explodTopoPhi2
(
double
c
);
void
slot_explodTopoPhi3
(
double
c
);
void
slot_pushButton_addPlane
();
void
slot_pushButton_deletePlane
();
void
slot_comboBox_PlaneIndexChanged
(
int
newIndex
);
void
slot_doubleSpinBox_Plane
(
double
c
);
void
slot_doubleSpinBox_ColorAttenuationFactor
(
double
c
);
...
...
Apps/Tuto/stage_shader.ui
View file @
6c8f11ee
...
...
@@ -7,7 +7,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
324
</width>
<height>
5
2
6
</height>
<height>
56
9
</height>
</rect>
</property>
<property
name=
"allowedAreas"
>
...
...
@@ -188,7 +188,7 @@
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
7
0
</y>
<y>
9
0
</y>
<width>
63
</width>
<height>
28
</height>
</rect>
...
...
@@ -200,14 +200,14 @@
<double>
0.100000000000000
</double>
</property>
<property
name=
"value"
>
<double>
0.
5
00000000000000
</double>
<double>
0.
0
00000000000000
</double>
</property>
</widget>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_bPlane"
>
<property
name=
"geometry"
>
<rect>
<x>
60
</x>
<y>
7
0
</y>
<y>
9
0
</y>
<width>
63
</width>
<height>
28
</height>
</rect>
...
...
@@ -219,14 +219,14 @@
<double>
0.100000000000000
</double>
</property>
<property
name=
"value"
>
<double>
0.
5
00000000000000
</double>
<double>
0.
0
00000000000000
</double>
</property>
</widget>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_cPlane"
>
<property
name=
"geometry"
>
<rect>
<x>
120
</x>
<y>
7
0
</y>
<y>
9
0
</y>
<width>
63
</width>
<height>
28
</height>
</rect>
...
...
@@ -238,14 +238,14 @@
<double>
0.100000000000000
</double>
</property>
<property
name=
"value"
>
<double>
0.
5
00000000000000
</double>
<double>
0.
0
00000000000000
</double>
</property>
</widget>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_dPlane"
>
<property
name=
"geometry"
>
<rect>
<x>
180
</x>
<y>
7
0
</y>
<y>
9
0
</y>
<width>
63
</width>
<height>
28
</height>
</rect>
...
...
@@ -274,7 +274,7 @@
<property
name=
"geometry"
>
<rect>
<x>
10
</x>
<y>
5
0
</y>
<y>
7
0
</y>
<width>
31
</width>
<height>
18
</height>
</rect>
...
...
@@ -287,7 +287,7 @@
<property
name=
"geometry"
>
<rect>
<x>
70
</x>
<y>
5
0
</y>
<y>
7
0
</y>
<width>
31
</width>
<height>
18
</height>
</rect>
...
...
@@ -300,7 +300,7 @@
<property
name=
"geometry"
>
<rect>
<x>
130
</x>
<y>
5
0
</y>
<y>
7
0
</y>
<width>
31
</width>
<height>
18
</height>
</rect>
...
...
@@ -313,7 +313,7 @@
<property
name=
"geometry"
>
<rect>
<x>
190
</x>
<y>
5
0
</y>
<y>
7
0
</y>
<width>
31
</width>
<height>
18
</height>
</rect>
...
...
@@ -326,7 +326,7 @@
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
1
0
0
</y>
<y>
1
4
0
</y>
<width>
201
</width>
<height>
18
</height>
</rect>
...
...
@@ -339,7 +339,7 @@
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
1
2
0
</y>
<y>
1
6
0
</y>
<width>
63
</width>
<height>
28
</height>
</rect>
...
...
@@ -348,6 +348,51 @@
<double>
1.000000000000000
</double>
</property>
</widget>
<widget
class=
"QComboBox"
name=
"comboBox_PlaneIndex"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"geometry"
>
<rect>
<x>
80
</x>
<y>
30
</y>
<width>
99
</width>
<height>
28
</height>
</rect>
</property>
<property
name=
"editable"
>
<bool>
false
</bool>
</property>
<property
name=
"currentIndex"
>
<number>
-1
</number>
</property>
</widget>
<widget
class=
"QPushButton"
name=
"pushButton_addPlane"
>
<property
name=
"geometry"
>
<rect>
<x>
180
</x>
<y>
10
</y>
<width>
51
</width>
<height>
28
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
+
</string>
</property>
</widget>
<widget
class=
"QPushButton"
name=
"pushButton_deletePlane"
>
<property
name=
"geometry"
>
<rect>
<x>
180
</x>
<y>
40
</y>
<width>
51
</width>
<height>
28
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
-
</string>
</property>
</widget>
</widget>
</item>
</layout>
...
...
src/Utils/clippingShader.cpp
View file @
6c8f11ee
...
...
@@ -101,7 +101,7 @@ Geom::Vec4f ClippingShader::getClippingPlaneEquation(int planeIndex)
{
CGoGNerr
<<
"ERROR - "
<<
"ClippingShader::
s
etClippingPlaneEquation"
<<
"ClippingShader::
g
etClippingPlaneEquation"
<<
" - Given plane index is out of range"
<<
CGoGNendl
;
return
Geom
::
Vec4f
(
0.0
,
0.0
,
0.0
,
0.0
);
...
...
@@ -237,7 +237,8 @@ void ClippingShader::setPlaneClipping(int planesCount)
" }
\n
"
"
\n
"
" // Signed distance between the point and the plane
\n
"
" float clip_DistanceToPlane = dot(clip_NonTransformedPos, clip_CurrClipPlane.xyz) + clip_CurrClipPlane.w;
\n
"
" float clip_DistanceToPlane = dot(clip_NonTransformedPos, clip_CurrClipPlane.xyz);
\n
"
" clip_DistanceToPlane += clip_CurrClipPlane.w;
\n
"
" clip_DistanceToPlane /= clip_NPlane;
\n
"
"
\n
"
" // Keep the fragment only if it is 'above' the plane
\n
"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment