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
David Cazier
CGoGN
Commits
54ad00eb
Commit
54ad00eb
authored
May 07, 2015
by
Sylvain Thery
Browse files
Merge branch 'develop' of icube-forge.unistra.fr:thery/cgogn into develop
parents
c12ad123
0ba4ba3f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/Modelling/tuto_oper2.cpp
View file @
54ad00eb
...
...
@@ -49,7 +49,7 @@ int main(int argc, char **argv)
// example code itself
sqt
.
createMap
(
n
);
sqt
.
width
(
5
);
sqt
.
width
(
4.0
);
// set help message in menu
sqt
.
setHelpMsg
(
"First Tuto:
\n
Create two faces
\n
sew them
\n
and affect positions"
);
...
...
@@ -236,14 +236,11 @@ void MyQT::cb_redraw()
glDepthFunc
(
GL_LESS
);
m_render_topo
->
drawTopo
();
glDepthFunc
(
GL_LEQUAL
);
m_render_topo
->
drawColoredDarts
<
MAP
>
(
myMap
);
if
(
m_selected
!=
NIL
)
m_render_topo
->
overdrawDart
(
myMap
,
m_selected
,
11
,
1.0
f
,
0.0
f
,
0.0
f
);
if
(
m_selected2
!=
NIL
)
m_render_topo
->
overdrawDart
(
myMap
,
m_selected2
,
11
,
0.0
f
,
1.0
f
,
0.0
f
);
if
(
!
m_selecteds
.
empty
())
{
...
...
@@ -251,7 +248,7 @@ void MyQT::cb_redraw()
m_render_topo
->
overdrawDart
(
myMap
,
*
it
,
11
,
0.0
f
,
0.0
f
,
1.0
f
);
}
m_render_topo
->
overdrawDart
(
myMap
,
m_selected2
,
11
,
0.0
f
,
1.0
f
,
0.0
f
);
}
...
...
Apps/Tuto/Modelling/tuto_oper3.cpp
View file @
54ad00eb
...
...
@@ -61,6 +61,7 @@ int main(int argc, char **argv)
// final show for redraw
sqt
.
show
();
// and wait for the end
sqt
.
clipping_onoff
(
true
);
return
app
.
exec
();
}
...
...
@@ -73,21 +74,14 @@ void MyQT::clipping_onoff(bool x)
Geom
::
Vec3f
pos
=
m_PlanePick
->
getPosition
();
float
pipo
;
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_sh2
->
setClipPlane
ParamsAll
(
clip_id2
,
normal
,
pos
);
// m_sh3
->setClipPlane
ParamsAll(clip_id3, normal, pos
);
float
d
=
-
(
pos
*
normal
);
m_render_topo
->
setClip
ping
Plane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
]
,
normal
[
2
],
d
)
);
m_render_topo_boundary
->
setClip
ping
Plane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
)
);
}
else
{
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_sh3->setClipPlaneParamsAll(clip_id3, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_sh1
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_sh2
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
// m_sh3->setClipColorAttenuationFactorRelative(0.0f,0.0f);
}
{
m_render_topo
->
setNoClippingPlane
();
}
updateMap
();
updateGL
();
}
...
...
@@ -377,23 +371,6 @@ void MyQT::cb_initGL()
m_PlanePick
=
new
Utils
::
Pickable
(
Utils
::
Pickable
::
GRID
,
1
);
m_frame
=
new
Utils
::
FrameManipulator
();
m_frame
->
setSize
(
bb
.
maxSize
());
m_sh1
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_render_topo
->
shader1
());
m_sh2
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_render_topo
->
shader2
());
// m_sh3 = static_cast<Utils::ClippingShader*>(m_render_topo_boundary->shader1());
m_sh1
->
insertClippingCode
();
m_sh2
->
insertClippingCode
();
// m_sh3->insertClippingCode();
clip_id1
=
m_sh1
->
addClipPlane
();
clip_id2
=
m_sh2
->
addClipPlane
();
// clip_id3 = m_sh3->addClipPlane();
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
bb
.
center
());
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
bb
.
center
());
// m_sh3->setClipPlaneParamsAll(clip_id3, Geom::Vec3f(0,0,1), bb.center());
}
// redraw GL callback (clear and swap already done)
...
...
@@ -554,11 +531,9 @@ void MyQT::cb_mouseMove(int buttons, int x, int y)
Geom
::
Vec3f
pos
=
m_PlanePick
->
getPosition
();
float
pipo
;
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
// m_sh3->setClipPlaneParamsAll(clip_id3, normal, pos);
float
d
=
-
(
pos
*
normal
);
m_render_topo
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_render_topo_boundary
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_begX
=
x
;
m_begY
=
y
;
...
...
Apps/Tuto/Modelling/tuto_oper3.h
View file @
54ad00eb
...
...
@@ -133,10 +133,6 @@ protected:
int
clip_id2
;
int
clip_id3
;
Utils
::
ClippingShader
*
m_sh1
;
Utils
::
ClippingShader
*
m_sh2
;
Utils
::
ClippingShader
*
m_sh3
;
public:
// example of simple map creation
void
createMap
(
int
n
);
...
...
CGoGN/include/Algo/Render/GL2/topo3Render.h
View file @
54ad00eb
...
...
@@ -34,8 +34,11 @@
#include
"Geometry/vector_gen.h"
#include
"Utils/GLSLShader.h"
#include
"Utils/Shaders/shaderSimpleColor.h"
#include
"Utils/Shaders/shaderColorPerVertex.h"
//#include "Utils/Shaders/shaderSimpleColor.h"
//#include "Utils/Shaders/shaderColorPerVertex.h"
#include
"Utils/Shaders/shaderBoldLines.h"
#include
"Utils/Shaders/shaderColorDarts.h"
#include
"Utils/Shaders/shaderDarts.h"
#include
"Utils/vbo_base.h"
#include
"Utils/svg.h"
...
...
@@ -75,8 +78,14 @@ protected:
unsigned
int
m_vaId
;
Utils
::
ShaderSimpleColor
*
m_shader1
;
Utils
::
ShaderColorPerVertex
*
m_shader2
;
//Utils::ShaderSimpleColor* m_shader1;
//Utils::ShaderColorPerVertex* m_shader2;
Utils
::
ShaderBoldLines
*
m_shader1
;
Utils
::
ShaderColorDarts
*
m_shader2
;
Utils
::
ShaderDarts
*
m_shader3
;
std
::
vector
<
Utils
::
GLSLShader
*>
m_shadersVector
;
/**
*number of darts to draw
...
...
@@ -157,6 +166,8 @@ public:
Utils
::
GLSLShader
*
shader1
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader1
);
}
Utils
::
GLSLShader
*
shader2
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader2
);
}
Utils
::
GLSLShader
*
shader3
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader3
);
}
const
std
::
vector
<
Utils
::
GLSLShader
*>&
shaders
()
const
{
return
m_shadersVector
;
}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
...
...
CGoGN/include/Algo/Render/GL2/topo3Render.hpp
View file @
54ad00eb
...
...
@@ -71,8 +71,13 @@ Topo3Render<PFP>::Topo3Render():
m_vbo3
->
setDataSize
(
3
);
m_vbo4
->
setDataSize
(
3
);
m_shader1
=
new
Utils
::
ShaderSimpleColor
(
true
,
false
);
m_shader2
=
new
Utils
::
ShaderColorPerVertex
(
true
,
false
);
m_shader1
=
new
Utils
::
ShaderBoldLines
();
m_shader2
=
new
Utils
::
ShaderColorDarts
();
m_shader3
=
new
Utils
::
ShaderDarts
();
m_shadersVector
.
push_back
(
m_shader1
);
m_shadersVector
.
push_back
(
m_shader2
);
m_shadersVector
.
push_back
(
m_shader3
);
// binding VBO - VA
m_vaId
=
m_shader1
->
setAttributePosition
(
m_vbo1
);
...
...
@@ -80,17 +85,22 @@ Topo3Render<PFP>::Topo3Render():
m_shader2
->
setAttributePosition
(
m_vbo0
);
m_shader2
->
setAttributeColor
(
m_vbo4
);
m_shader3
->
setAttributePosition
(
m_vbo0
);
// registering for auto matrices update
Utils
::
GLSLShader
::
registerShader
(
NULL
,
m_shader1
);
Utils
::
GLSLShader
::
registerShader
(
NULL
,
m_shader2
);
Utils
::
GLSLShader
::
registerShader
(
NULL
,
m_shader3
);
}
template
<
typename
PFP
>
Topo3Render
<
PFP
>::~
Topo3Render
()
{
Utils
::
GLSLShader
::
unregisterShader
(
NULL
,
m_shader3
);
Utils
::
GLSLShader
::
unregisterShader
(
NULL
,
m_shader2
);
Utils
::
GLSLShader
::
unregisterShader
(
NULL
,
m_shader1
);
delete
m_shader3
;
delete
m_shader2
;
delete
m_shader1
;
delete
m_vbo4
;
...
...
@@ -115,6 +125,7 @@ void Topo3Render<PFP>::setClippingPlane(const Geom::Vec4f& plane)
{
m_shader1
->
setClippingPlane
(
plane
);
m_shader2
->
setClippingPlane
(
plane
);
m_shader3
->
setClippingPlane
(
plane
);
}
template
<
typename
PFP
>
...
...
@@ -175,42 +186,10 @@ void Topo3Render<PFP>::drawDarts()
if
(
m_nbDarts
==
0
)
return
;
m_shader2
->
setLineWidth
(
m_topo_dart_width
);
m_shader2
->
enableVertexAttribs
();
glLineWidth
(
m_topo_dart_width
);
glDrawArrays
(
GL_LINES
,
0
,
m_nbDarts
*
2
);
// change the stride to take 1/2 vertices
m_shader2
->
enableVertexAttribs
(
6
*
sizeof
(
GL_FLOAT
));
glPointSize
(
2.0
f
*
m_topo_dart_width
);
glDrawArrays
(
GL_POINTS
,
0
,
m_nbDarts
);
m_shader2
->
disableVertexAttribs
();
//
//// glColor3f(1.0f,1.0f,1.0f);
// glLineWidth(m_topo_dart_width);
// glPointSize(2.0f*m_topo_dart_width);
//
// glBindBuffer(GL_ARRAY_BUFFER, m_VBOBuffers[4]);
// glColorPointer(3, GL_FLOAT, 0, 0);
// glEnableClientState(GL_COLOR_ARRAY);
//
// glBindBuffer(GL_ARRAY_BUFFER, m_VBOBuffers[0]);
// glVertexPointer(3, GL_FLOAT, 0, 0);
// glEnableClientState(GL_VERTEX_ARRAY);
// glDrawArrays(GL_LINES, 0, m_nbDarts*2);
//
// glVertexPointer(3, GL_FLOAT, 6*sizeof(GL_FLOAT), 0);
//
// glBindBuffer(GL_ARRAY_BUFFER, m_VBOBuffers[4]);
// glColorPointer(3, GL_FLOAT, 6*sizeof(GL_FLOAT), 0);
// glDrawArrays(GL_POINTS, 0, m_nbDarts)
// ;
// glDisableClientState(GL_COLOR_ARRAY);
// glDisableClientState(GL_VERTEX_ARRAY);
}
template
<
typename
PFP
>
...
...
@@ -219,24 +198,12 @@ void Topo3Render<PFP>::drawRelation1()
if
(
m_nbDarts
==
0
)
return
;
glLineWidth
(
m_topo_relation_width
);
m_shader1
->
changeVA_VBO
(
m_vaId
,
m_vbo1
);
m_shader1
->
setColor
(
Geom
::
Vec4f
(
0.0
f
,
1.0
f
,
1.0
f
,
0.0
f
));
m_shader1
->
setLineWidth
(
m_topo_relation_width
);
m_shader1
->
enableVertexAttribs
();
glDrawArrays
(
GL_LINES
,
0
,
m_nbRel1
*
2
);
m_shader1
->
disableVertexAttribs
();
// glLineWidth(m_topo_relation_width);
// glColor3f(0.0f,1.0f,1.0f);
// glBindBuffer(GL_ARRAY_BUFFER, m_VBOBuffers[1]);
// glVertexPointer(3, GL_FLOAT, 0, 0);
//
// glEnableClientState(GL_VERTEX_ARRAY);
// glDrawArrays(GL_LINES, 0, m_nbDarts*2);
// glDisableClientState(GL_VERTEX_ARRAY);
}
template
<
typename
PFP
>
...
...
@@ -246,21 +213,11 @@ void Topo3Render<PFP>::drawRelation2()
return
;
m_shader1
->
changeVA_VBO
(
m_vaId
,
m_vbo2
);
m_shader1
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
m_shader1
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
m_shader1
->
setLineWidth
(
m_topo_relation_width
);
m_shader1
->
enableVertexAttribs
();
glDrawArrays
(
GL_QUADS
,
0
,
m_nbRel2
*
4
);
glDrawArrays
(
GL_LINES
,
0
,
m_nbRel1
*
2
);
m_shader1
->
disableVertexAttribs
();
// glLineWidth(m_topo_relation_width);
// glColor3f(1.0f,0.0f,0.0f);
// glBindBuffer(GL_ARRAY_BUFFER, m_VBOBuffers[2]);
// glVertexPointer(3, GL_FLOAT, 0, 0);
//
// glEnableClientState(GL_VERTEX_ARRAY);
// glDrawArrays(GL_QUADS, 0, m_nbRel2*4);
// glDisableClientState(GL_VERTEX_ARRAY);
}
template
<
typename
PFP
>
...
...
@@ -271,20 +228,10 @@ void Topo3Render<PFP>::drawRelation3(Geom::Vec4f c)
m_shader1
->
changeVA_VBO
(
m_vaId
,
m_vbo3
);
m_shader1
->
setColor
(
c
);
m_shader1
->
setLineWidth
(
m_topo_relation_width
);
m_shader1
->
enableVertexAttribs
();
glDrawArrays
(
GL_QUADS
,
0
,
m_nbRel3
*
4
);
glDrawArrays
(
GL_LINES
,
0
,
m_nbRel3
*
2
);
m_shader1
->
disableVertexAttribs
();
// glLineWidth(m_topo_relation_width);
// glColor3f(1.0f,1.0f,0.0f);
// glBindBuffer(GL_ARRAY_BUFFER, m_VBOBuffers[3]);
// glVertexPointer(3, GL_FLOAT, 0, 0);
//
// glEnableClientState(GL_VERTEX_ARRAY);
// glDrawArrays(GL_QUADS, 0, m_nbRel3*4);
// glDisableClientState(GL_VERTEX_ARRAY);
}
template
<
typename
PFP
>
...
...
@@ -301,17 +248,11 @@ void Topo3Render<PFP>::overdrawDart(Dart d, float width, float r, float g, float
{
unsigned
int
indexDart
=
m_attIndex
[
d
];
m_shader1
->
changeVA_VBO
(
m_vaId
,
m_vbo0
);
m_shader1
->
setColor
(
Geom
::
Vec4f
(
r
,
g
,
b
,
0.0
f
));
m_shader1
->
enableVertexAttribs
();
glLineWidth
(
width
);
m_shader3
->
setColor
(
Geom
::
Vec4f
(
r
,
g
,
b
,
0.0
f
));
m_shader3
->
setLineWidth
(
width
);
m_shader3
->
enableVertexAttribs
();
glDrawArrays
(
GL_LINES
,
indexDart
,
2
);
glPointSize
(
2.0
f
*
width
);
glDrawArrays
(
GL_POINTS
,
indexDart
,
1
);
m_shader2
->
disableVertexAttribs
();
m_shader3
->
disableVertexAttribs
();
}
template
<
typename
PFP
>
...
...
@@ -722,17 +663,17 @@ void Topo3RenderMap<PFP>::updateData(MAP& mapx, const VertexAttribute<VEC3, MAP>
if
((
d
<
e
))
{
*
positionF2
++
=
PFP
::
toVec3f
(
fv2
[
d
]);
*
positionF2
++
=
PFP
::
toVec3f
(
fv2x
[
e
]);
//
*positionF2++ = PFP::toVec3f(fv2x[e]);
*
positionF2
++
=
PFP
::
toVec3f
(
fv2
[
e
]);
*
positionF2
++
=
PFP
::
toVec3f
(
fv2x
[
d
]);
//
*positionF2++ = PFP::toVec3f(fv2x[d]);
this
->
m_nbRel2
++
;
}
e
=
mapx
.
phi3
(
d
);
if
(
!
mapx
.
template
isBoundaryMarked
<
3
>(
e
)
&&
(
d
<
e
)
)
{
*
positionF3
++
=
PFP
::
toVec3f
(
fv2
[
d
]);
//
*positionF3++ = PFP::toVec3f(fv2[d]);
*
positionF3
++
=
PFP
::
toVec3f
(
fv2x
[
e
]);
*
positionF3
++
=
PFP
::
toVec3f
(
fv2
[
e
]);
//
*positionF3++ = PFP::toVec3f(fv2[e]);
*
positionF3
++
=
PFP
::
toVec3f
(
fv2x
[
d
]);
this
->
m_nbRel3
++
;
}
...
...
@@ -746,10 +687,10 @@ void Topo3RenderMap<PFP>::updateData(MAP& mapx, const VertexAttribute<VEC3, MAP>
}
this
->
m_vbo3
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
4
*
this
->
m_nbRel3
*
sizeof
(
Geom
::
Vec3f
),
positioniF3
,
GL_STREAM_DRAW
);
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
this
->
m_nbRel3
*
sizeof
(
Geom
::
Vec3f
),
positioniF3
,
GL_STREAM_DRAW
);
this
->
m_vbo2
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
4
*
this
->
m_nbRel2
*
sizeof
(
Geom
::
Vec3f
),
positioniF2
,
GL_STREAM_DRAW
);
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
this
->
m_nbRel2
*
sizeof
(
Geom
::
Vec3f
),
positioniF2
,
GL_STREAM_DRAW
);
this
->
m_vbo1
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
this
->
m_nbRel1
*
sizeof
(
Geom
::
Vec3f
),
positioniF1
,
GL_STREAM_DRAW
);
...
...
@@ -801,10 +742,7 @@ void Topo3RenderGMap<PFP>::updateData(MAP& mapx, const VertexAttribute<VEC3, MAP
this
->
m_bufferDartPosition
=
new
Geom
::
Vec3f
[
2
*
this
->
m_nbDarts
];
Geom
::
Vec3f
*
positionDartBuf
=
reinterpret_cast
<
Geom
::
Vec3f
*>
(
this
->
m_bufferDartPosition
);
// m_vbo0->bind();
// glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW);
// GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// VEC3* positionDartBuf = reinterpret_cast<VEC3*>(PositionDartsBuffer);
std
::
vector
<
Dart
>
vecDartFaces
;
vecDartFaces
.
reserve
(
this
->
m_nbDarts
/
6
);
...
...
CGoGN/include/Utils/Shaders/shaderPointsLines.h
View file @
54ad00eb
...
...
@@ -40,12 +40,12 @@ namespace Utils
class
CGoGN_UTILS_API
ShaderPointsLines
:
public
ClippingShader
{
public:
virtual
void
setLineWidth
(
float
pix
)
=
0
;
virtual
void
setOpacity
(
float
op
)
{}
virtual
unsigned
int
setAttributePosition
(
VBO
*
vbo
)
=
0
;
virtual
unsigned
int
setAttributeColor
(
VBO
*
vbo
)
{
return
0
;
}
virtual
void
setColor
(
const
Geom
::
Vec4f
&
color
)
{}
virtual
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
=
0
;
virtual
void
setLineWidth
(
float
)
=
0
;
virtual
void
setOpacity
(
float
)
{}
virtual
unsigned
int
setAttributePosition
(
VBO
*
)
=
0
;
virtual
unsigned
int
setAttributeColor
(
VBO
*
)
{
return
0
;
}
virtual
void
setColor
(
const
Geom
::
Vec4f
&
)
{}
virtual
void
setClippingPlane
(
const
Geom
::
Vec4f
&
)
=
0
;
virtual
void
setNoClippingPlane
()
=
0
;
};
...
...
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