Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CGoGN
CGoGN
Commits
57c9da21
Commit
57c9da21
authored
Mar 13, 2015
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'develop'
Develop See merge request !53
parents
f0299e5a
6a6268ee
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
403 additions
and
139 deletions
+403
-139
Apps/Examples/CMakeLists.txt
Apps/Examples/CMakeLists.txt
+7
-5
Apps/Examples/frame_manip.cpp
Apps/Examples/frame_manip.cpp
+7
-0
Apps/Examples/frame_manip.h
Apps/Examples/frame_manip.h
+9
-3
Apps/Examples/volumeExplorer.cpp
Apps/Examples/volumeExplorer.cpp
+4
-42
Apps/Examples/volumeExplorer.h
Apps/Examples/volumeExplorer.h
+2
-2
CGoGN/include/Algo/Render/GL2/colorPerFaceRender.h
CGoGN/include/Algo/Render/GL2/colorPerFaceRender.h
+2
-2
CGoGN/include/Algo/Render/GL2/colorPerFaceRender.hpp
CGoGN/include/Algo/Render/GL2/colorPerFaceRender.hpp
+3
-3
CGoGN/include/Algo/Render/GL2/topo3Render.h
CGoGN/include/Algo/Render/GL2/topo3Render.h
+4
-0
CGoGN/include/Algo/Render/GL2/topo3Render.hpp
CGoGN/include/Algo/Render/GL2/topo3Render.hpp
+18
-2
CGoGN/include/Algo/Render/GL2/topoPrimalRender.h
CGoGN/include/Algo/Render/GL2/topoPrimalRender.h
+4
-0
CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp
CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp
+16
-2
CGoGN/include/Algo/Render/GL2/topoRender.h
CGoGN/include/Algo/Render/GL2/topoRender.h
+4
-0
CGoGN/include/Utils/Shaders/shaderColorPerVertex.h
CGoGN/include/Utils/Shaders/shaderColorPerVertex.h
+10
-1
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.frag
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.frag
+22
-0
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.vert
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.vert
+17
-0
CGoGN/include/Utils/Shaders/shaderSimpleColor.h
CGoGN/include/Utils/Shaders/shaderSimpleColor.h
+11
-3
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.frag
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.frag
+20
-0
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.vert
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.vert
+12
-0
CGoGN/src/Algo/Render/topoGenRender.cpp
CGoGN/src/Algo/Render/topoGenRender.cpp
+14
-1
CGoGN/src/Utils/Shaders/shaderColorPerVertex.cpp
CGoGN/src/Utils/Shaders/shaderColorPerVertex.cpp
+49
-34
CGoGN/src/Utils/Shaders/shaderSimpleColor.cpp
CGoGN/src/Utils/Shaders/shaderSimpleColor.cpp
+54
-37
CGoGN/src/Utils/shaderMutator.cpp
CGoGN/src/Utils/shaderMutator.cpp
+102
-0
CMakeLists.txt
CMakeLists.txt
+11
-1
apps_cmake.txt
apps_cmake.txt
+1
-1
No files found.
Apps/Examples/CMakeLists.txt
View file @
57c9da21
...
...
@@ -14,7 +14,7 @@ add_executable( frame_manip frame_manip.cpp ${frame_manip_moc} )
target_link_libraries
(
frame_manip
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
#need to define that we use Qt (only once per cmake directory!)
qt_use_cgogn_modules
(
frame_manip
)
qt_wrap_cpp
(
texturesExample_moc texturesExample.h
)
add_executable
(
texturesExample texturesExample.cpp
${
texturesExample_moc
}
)
target_link_libraries
(
texturesExample
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
...
...
@@ -40,10 +40,12 @@ qt_wrap_cpp( viewer_moc viewer.h )
add_executable
(
viewer viewer.cpp
${
viewer_moc
}
${
viewer_ui
}
)
target_link_libraries
(
viewer
${
CGoGN_LIBS
}
${
NUMERICAL_LIBS
}
${
CGoGN_EXT_LIBS
}
)
qt_wrap_ui
(
clipping_ui clipping.ui
)
qt_wrap_cpp
(
clipping_moc clipping.h
)
add_executable
(
clipping clipping.cpp
${
clipping_ui
}
${
clipping_moc
}
)
target_link_libraries
(
clipping
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
IF
(
CGoGN_GCC_4_9
)
qt_wrap_ui
(
clipping_ui clipping.ui
)
qt_wrap_cpp
(
clipping_moc clipping.h
)
add_executable
(
clipping clipping.cpp
${
clipping_ui
}
${
clipping_moc
}
)
target_link_libraries
(
clipping
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
ENDIF
()
qt_wrap_ui
(
volumeExplorer_ui volumeExplorer.ui
)
qt_wrap_cpp
(
volumeExplorer_moc volumeExplorer.h
)
...
...
Apps/Examples/frame_manip.cpp
View file @
57c9da21
...
...
@@ -140,6 +140,13 @@ void MyQT::cb_redraw()
(
*
it
)
->
draw
();
}
m_nbFrames
++
;
if
(
m_nbFrames
>=
40
)
{
std
::
cout
<<
40000.0
/
m_frame_ch
.
elapsed
()
<<
" fps"
<<
std
::
endl
;
m_nbFrames
=
0
;
m_frame_ch
.
start
();
}
}
void
MyQT
::
cb_mousePress
(
int
/*button*/
,
int
x
,
int
y
)
...
...
Apps/Examples/frame_manip.h
View file @
57c9da21
...
...
@@ -27,9 +27,11 @@
#include <iostream>
#include "Utils/Qt/qtSimple.h"
//#include "Utils/Qt/qtSimple.h"
#include "Utils/Qt/qtQGLV.h"
#include "Utils/frameManipulator.h"
#include "Utils/drawer.h"
#include "Utils/chrono.h"
// forward definitions (minimize includes)
namespace
CGoGN
{
namespace
Algo
{
namespace
Render
{
namespace
GL2
{
class
MapRender
;
}}}}
...
...
@@ -43,10 +45,11 @@ using namespace CGoGN ;
* A class for a little interface and rendering
*/
class
MyQT
:
public
Utils
::
QT
::
SimpleQ
T
class
MyQT
:
public
Utils
::
QT
::
SimpleQ
GLV
{
Q_OBJECT
public:
// render
Algo
::
Render
::
GL2
::
MapRender
*
m_render
;
...
...
@@ -68,7 +71,10 @@ public:
// width of cube of pickable
unsigned
int
NBP
;
MyQT
()
:
m_render
(
NULL
),
m_positionVBO
(
NULL
),
NBP
(
2
){}
Utils
::
Chrono
m_frame_ch
;
unsigned
int
m_nbFrames
;
MyQT
()
:
m_render
(
NULL
),
m_positionVBO
(
NULL
),
NBP
(
2
),
m_nbFrames
(
0
){}
// callbacks of simpleQT to overdefine:
void
cb_redraw
();
...
...
Apps/Examples/volumeExplorer.cpp
View file @
57c9da21
...
...
@@ -73,16 +73,12 @@ void MyQT::clipping_onoff(bool x)
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
float
d
=
-
(
pos
*
normal
);
m_explode_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
m_topo_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
}
else
{
m_explode_render
->
setNoClippingPlane
();
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_sh1
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_sh2
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_topo_render
->
setNoClippingPlane
();
}
updateGL
();
}
...
...
@@ -206,7 +202,7 @@ void MyQT::cb_initGL()
{
// create the renders
m_topo_render
=
new
Algo
::
Render
::
GL2
::
Topo3RenderMap
<
PFP
>
();
m_explode_render
=
new
Algo
::
Render
::
GL2
::
ExplodeVolumeRender
(
true
,
true
,
true
);
m_explode_render
=
new
Algo
::
Render
::
GL2
::
ExplodeVolumeRender
(
true
,
true
,
true
);
// SelectorDartNoBoundary<MAP> nb(myMap);
m_topo_render
->
updateData
(
myMap
,
position
,
0.8
f
,
0.8
f
,
0.8
f
);
...
...
@@ -217,8 +213,6 @@ void MyQT::cb_initGL()
m_explode_render
->
setBackColor
(
Geom
::
Vec4f
(
0.9
f
,
0.9
f
,
0.9
f
,
1.0
f
));
m_explode_render
->
setColorLine
(
Geom
::
Vec4f
(
0.8
f
,
0.2
f
,
0.2
f
,
1.0
f
));
m_sh1
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_topo_render
->
shader1
());
m_sh2
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_topo_render
->
shader2
());
registerShader
(
m_explode_render
->
shaderFaces
());
registerShader
(
m_explode_render
->
shaderLines
());
...
...
@@ -227,15 +221,6 @@ void MyQT::cb_initGL()
m_frame
=
new
Utils
::
FrameManipulator
();
m_frame
->
setSize
(
m_WidthObj
/
2.0
f
);
m_sh1
->
insertClippingCode
();
m_sh2
->
insertClippingCode
();
clip_id1
=
m_sh1
->
addClipPlane
();
clip_id2
=
m_sh2
->
addClipPlane
();
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
m_PosObj
);
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
m_PosObj
);
m_explode_render
->
setClippingPlane
(
Geom
::
Vec4f
(
0
,
0
,
1
,
m_PosObj
*
Geom
::
Vec3f
(
0
,
0
,
-
1
)));
}
...
...
@@ -370,9 +355,8 @@ void MyQT::cb_mouseMove(int buttons, int x, int y)
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
float
d
=
-
(
pos
*
normal
);
m_explode_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_topo_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
m_begX
=
x
;
m_begY
=
y
;
...
...
@@ -484,28 +468,6 @@ int main(int argc, char **argv)
dock
.
slider_explode_face
->
setValue
(
100
);
sqt
.
clipping_onoff
(
true
);
// Utils::Chrono ch;
// ch.start();
// float vol = Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms // val="<<vol<< std::endl;
// std::cout << "Compute Volume ->"<< std::endl;
// ch.start();
// vol = Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// et on attend la fin.
return
app
.
exec
();
}
Apps/Examples/volumeExplorer.h
View file @
57c9da21
...
...
@@ -93,8 +93,8 @@ class MyQT: public Utils::QT::SimpleQGLV
int
clip_id2
;
// shader of toporender3
Utils
::
ClippingShader
*
m_sh1
;
Utils
::
ClippingShader
*
m_sh2
;
//
Utils::ClippingShader* m_sh1;
//
Utils::ClippingShader* m_sh2;
Utils
::
Chrono
m_frame_ch
;
unsigned
int
m_nbFrames
;
...
...
CGoGN/include/Algo/Render/GL2/colorPerFaceRender.h
View file @
57c9da21
...
...
@@ -71,7 +71,7 @@ public:
*/
template
<
typename
PFP
,
unsigned
int
ORBIT
>
void
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
positions
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
::
IMPL
>&
colorPerXXX
)
;
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
positions
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
>&
colorPerXXX
)
;
/**
* update drawing buffers
...
...
@@ -85,7 +85,7 @@ public:
*/
template
<
typename
PFP
,
unsigned
int
ORBIT
>
void
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboNormal
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
positions
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
normals
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
::
IMPL
>&
colorPerXXX
)
;
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
positions
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
normals
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
>&
colorPerXXX
)
;
/**
...
...
CGoGN/include/Algo/Render/GL2/colorPerFaceRender.hpp
View file @
57c9da21
...
...
@@ -51,7 +51,7 @@ m_nbTris(0)
template
<
typename
PFP
,
unsigned
int
ORBIT
>
void
ColorPerFaceRender
::
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
positions
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
::
IMPL
>&
colorPerXXX
)
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
positions
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
>&
colorPerXXX
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -101,8 +101,8 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor
template
<
typename
PFP
,
unsigned
int
ORBIT
>
void
ColorPerFaceRender
::
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboNormal
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
positions
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
normals
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
::
IMPL
>&
colorPerXXX
)
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
positions
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
normals
,
const
AttributeHandler
<
typename
PFP
::
VEC3
,
ORBIT
,
typename
PFP
::
MAP
>&
colorPerXXX
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
CGoGN/include/Algo/Render/GL2/topo3Render.h
View file @
57c9da21
...
...
@@ -158,6 +158,10 @@ public:
Utils
::
GLSLShader
*
shader1
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader1
);
}
Utils
::
GLSLShader
*
shader2
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader2
);
}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setNoClippingPlane
();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
...
...
CGoGN/include/Algo/Render/GL2/topo3Render.hpp
View file @
57c9da21
...
...
@@ -71,8 +71,8 @@ Topo3Render<PFP>::Topo3Render():
m_vbo3->setDataSize(3);
m_vbo4->setDataSize(3);
m_shader1
=
new
Utils
::
ShaderSimpleColor
();
m_shader2
=
new
Utils
::
ShaderColorPerVertex
();
m_shader1 = new Utils::ShaderSimpleColor(
true,false
);
m_shader2 = new Utils::ShaderColorPerVertex(
true,false
);
// binding VBO - VA
m_vaId = m_shader1->setAttributePosition(m_vbo1);
...
...
@@ -109,6 +109,22 @@ Topo3Render<PFP>::~Topo3Render()
delete[] m_bufferDartPosition;
}
template<typename PFP>
void Topo3Render<PFP>::setClippingPlane(const Geom::Vec4f& plane)
{
m_shader1->setClippingPlane(plane);
m_shader2->setClippingPlane(plane);
}
template<typename PFP>
void Topo3Render<PFP>::setNoClippingPlane()
{
this->setClippingPlane(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f));
}
template<typename PFP>
void Topo3Render<PFP>::setDartWidth(float dw)
{
...
...
CGoGN/include/Algo/Render/GL2/topoPrimalRender.h
View file @
57c9da21
...
...
@@ -148,6 +148,10 @@ public:
Utils
::
GLSLShader
*
shader1
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader1
);
}
Utils
::
GLSLShader
*
shader2
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader2
);
}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setNoClippingPlane
();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
...
...
CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp
View file @
57c9da21
...
...
@@ -62,8 +62,8 @@ TopoPrimalRender<PFP>::TopoPrimalRender():
m_vbo1
->
setDataSize
(
3
);
m_vbo2
->
setDataSize
(
3
);
m_shader1
=
new
Utils
::
ShaderSimpleColor
();
m_shader2
=
new
Utils
::
ShaderColorPerVertex
();
m_shader1
=
new
Utils
::
ShaderSimpleColor
(
true
,
false
);
m_shader2
=
new
Utils
::
ShaderColorPerVertex
(
true
,
false
);
// binding VBO - VA
m_vaId
=
m_shader1
->
setAttributePosition
(
m_vbo1
);
...
...
@@ -98,6 +98,20 @@ TopoPrimalRender<PFP>::~TopoPrimalRender()
delete
[]
m_bufferDartPosition
;
}
template
<
typename
PFP
>
void
TopoPrimalRender
<
PFP
>::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_shader1
->
setClippingPlane
(
plane
);
m_shader2
->
setClippingPlane
(
plane
);
}
template
<
typename
PFP
>
void
TopoPrimalRender
<
PFP
>::
setNoClippingPlane
()
{
this
->
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
template
<
typename
PFP
>
void
TopoPrimalRender
<
PFP
>::
setDartWidth
(
float
dw
)
{
...
...
CGoGN/include/Algo/Render/GL2/topoRender.h
View file @
57c9da21
...
...
@@ -177,6 +177,10 @@ public:
*/
~
TopoGenRender
();
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setNoClippingPlane
();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
...
...
CGoGN/include/Utils/Shaders/shaderColorPerVertex.h
View file @
57c9da21
...
...
@@ -43,6 +43,8 @@ protected:
// shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderClipText
;
static
std
::
string
fragmentShaderClipText
;
VBO
*
m_vboPos
;
VBO
*
m_vboCol
;
...
...
@@ -50,10 +52,15 @@ protected:
CGoGNGLuint
m_unif_alpha
;
float
m_opacity
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
void
restoreUniformsAttribs
();
public:
ShaderColorPerVertex
(
bool
black_is_transparent
=
false
);
ShaderColorPerVertex
(
bool
withClipping
=
false
,
bool
black_is_transparent
=
false
);
/**
* set the VBO of position (vec3)
...
...
@@ -71,6 +78,8 @@ public:
void
setOpacity
(
float
op
);
float
getOpacity
()
const
{
return
m_opacity
;}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
};
}
// namespace Utils
...
...
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.frag
0 → 100644
View file @
57c9da21
// ShaderColorPerVertex::fragmentShaderClipText
PRECISION
;
VARYING_FRAG
vec3
color
;
VARYING_FRAG
vec3
posClip
;
uniform
vec4
planeClip
;
uniform
float
alpha
;
FRAG_OUT_DEF
;
void
main
()
{
if
(
dot
(
planeClip
,
vec4
(
posClip
,
1
.
0
))
>
0
.
0
)
discard
;
#ifdef BLACK_TRANSPARENCY
if
(
dot
(
color
,
color
)
==
0
.
0
)
discard
;
#endif
FRAG_OUT
=
vec4
(
color
,
alpha
);
}
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.vert
0 → 100644
View file @
57c9da21
// ShaderColorPerVertex::vertexShaderClipText
ATTRIBUTE
vec3
VertexPosition
;
ATTRIBUTE
vec3
VertexColor
;
uniform
mat4
ModelViewProjectionMatrix
;
VARYING_VERT
vec3
color
;
VARYING_VERT
vec3
posClip
;
INVARIANT_POS
;
void
main
()
{
posClip
=
VertexPosition
;
color
=
VertexColor
;
gl_Position
=
ModelViewProjectionMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
}
CGoGN/include/Utils/Shaders/shaderSimpleColor.h
View file @
57c9da21
...
...
@@ -43,22 +43,30 @@ protected:
// shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderClipText
;
static
std
::
string
fragmentShaderClipText
;
//
uniform locations
//
/ color
CGoGNGLuint
m_unif_color
;
Geom
::
Vec4f
m_color
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
VBO
*
m_vboPos
;
void
restoreUniformsAttribs
();
public:
ShaderSimpleColor
(
bool
back_is_transparent
=
false
);
ShaderSimpleColor
(
bool
withClipping
=
false
,
bool
back_is_transparent
=
false
);
void
setColor
(
const
Geom
::
Vec4f
&
color
);
unsigned
int
setAttributePosition
(
VBO
*
vbo
);
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
};
}
// namespace Utils
...
...
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.frag
0 → 100644
View file @
57c9da21
// ShaderSimpleColor::fragmentShaderClipText
PRECISION
;
uniform
vec4
color
;
uniform
vec4
planeClip
;
VARYING_FRAG
vec3
posClip
;
FRAG_OUT_DEF
;
void
main
()
{
if
(
dot
(
planeClip
,
vec4
(
posClip
,
1
.
0
))
>
0
.
0
)
discard
;
#ifdef BLACK_TRANSPARENCY
if
(
dot
(
color
,
color
)
==
0
.
0
)
discard
;
#endif
FRAG_OUT
=
color
;
}
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.vert
0 → 100644
View file @
57c9da21
// ShaderSimpleColor::vertexShaderClipText
ATTRIBUTE
vec3
VertexPosition
,
VertexNormal
;
uniform
mat4
ModelViewProjectionMatrix
;
VARYING_VERT
vec3
posClip
;
void
main
()
{
posClip
=
VertexPosition
;
gl_Position
=
ModelViewProjectionMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
}
CGoGN/src/Algo/Render/topoGenRender.cpp
View file @
57c9da21
...
...
@@ -66,7 +66,7 @@ TopoGenRender::TopoGenRender(float bs):
m_vbo1
->
setDataSize
(
3
);
m_vbo2
->
setDataSize
(
3
);
m_shader1
=
new
Utils
::
ShaderSimpleColor
();
m_shader1
=
new
Utils
::
ShaderSimpleColor
(
true
,
false
);
// binding VBO - VA
m_vaId
=
m_shader1
->
setAttributePosition
(
m_vbo1
);
...
...
@@ -135,6 +135,19 @@ TopoGenRender::~TopoGenRender()
void
TopoGenRender
::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_shader1
->
setClippingPlane
(
plane
);
}
void
TopoGenRender
::
setNoClippingPlane
()
{
this
->
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
void
TopoGenRender
::
setDartWidth
(
float
dw
)
{
m_topo_dart_width
=
dw
;
...
...
CGoGN/src/Utils/Shaders/shaderColorPerVertex.cpp
View file @
57c9da21
...
...
@@ -33,46 +33,49 @@ namespace Utils
#include "shaderColorPerVertex.vert"
#include "shaderColorPerVertex.frag"
#include "shaderColorPerVertexClip.vert"
#include "shaderColorPerVertexClip.frag"
//std::string ShaderColorPerVertex::vertexShaderText =
// "ATTRIBUTE vec3 VertexPosition;\n"
// "ATTRIBUTE vec3 VertexColor;\n"
// "uniform mat4 ModelViewProjectionMatrix;\n"
// "VARYING_VERT vec3 color;\n"
// "INVARIANT_POS;\n"
// "void main ()\n"
// "{\n"
// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n"
// " color = VertexColor;\n"
// "}";
//
//
//std::string ShaderColorPerVertex::fragmentShaderText =
// "PRECISION;\n"
// "VARYING_FRAG vec3 color;\n"
// "FRAG_OUT_DEF;\n"
// "void main()\n"
// "{\n"
// " FRAG_OUT=vec4(color,0.0);\n"
// "}";
ShaderColorPerVertex
::
ShaderColorPerVertex
(
bool
black_is_transparent
)
ShaderColorPerVertex
::
ShaderColorPerVertex
(
bool
withClipping
,
bool
black_is_transparent
)
{
m_nameVS
=
"ShaderColorPerVertex_vs"
;
m_nameFS
=
"ShaderColorPerVertex_fs"
;
m_nameGS
=
"ShaderColorPerVertex_gs"
;
if
(
withClipping
)
{
m_nameVS
=
"ShaderColorPerVertexClip_vs"
;
m_nameFS
=
"ShaderColorPerVertexClip_fs"
;
m_nameGS
=
""
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderClipText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderClipText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
*
m_unif_planeClip
=
glGetUniformLocation
(
this
->
program_handler
(),
"planeClip"
);
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
)
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
}
else
{
m_nameVS
=
"ShaderColorPerVertex_vs"
;
m_nameFS
=
"ShaderColorPerVertex_fs"
;
m_nameGS
=
"ShaderColorPerVertex_gs"
;
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
}
bind
();
*
m_unif_alpha
=
glGetUniformLocation
(
this
->
program_handler
(),
"alpha"
);
glUniform1f
(
*
m_unif_alpha
,
1.0
f
);
...
...
@@ -99,12 +102,14 @@ unsigned int ShaderColorPerVertex::setAttributeColor(VBO* vbo)
return
id
;
}
void
ShaderColorPerVertex
::
restoreUniformsAttribs
()
{
bind
();
bindVA_VBO
(
"VertexPosition"
,
m_vboPos
);
bindVA_VBO
(
"VertexColor"
,
m_vboCol
);
glUniform1f
(
*
m_unif_alpha
,
m_opacity
);
glUniform4fv
(
*
m_unif_planeClip
,
1
,
m_planeClip
.
data
());
unbind
();
}
...
...
@@ -116,6 +121,16 @@ void ShaderColorPerVertex::setOpacity(float op)