Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
0097e8ea
Commit
0097e8ea
authored
Jan 19, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add clipping plane in volume explode rendering for 3map
parent
6de0fa92
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
45 deletions
+89
-45
include/Algo/Render/GL2/explodeVolumeRender.h
include/Algo/Render/GL2/explodeVolumeRender.h
+8
-2
include/Utils/Shaders/shaderExplodeVolumes.geom
include/Utils/Shaders/shaderExplodeVolumes.geom
+25
-20
include/Utils/Shaders/shaderExplodeVolumes.h
include/Utils/Shaders/shaderExplodeVolumes.h
+5
-1
include/Utils/Shaders/shaderExplodeVolumesLines.geom
include/Utils/Shaders/shaderExplodeVolumesLines.geom
+15
-9
include/Utils/Shaders/shaderExplodeVolumesLines.h
include/Utils/Shaders/shaderExplodeVolumesLines.h
+5
-1
src/Utils/Shaders/shaderExplodeVolumes.cpp
src/Utils/Shaders/shaderExplodeVolumes.cpp
+17
-10
src/Utils/Shaders/shaderExplodeVolumesLines.cpp
src/Utils/Shaders/shaderExplodeVolumesLines.cpp
+14
-2
No files found.
include/Algo/Render/GL2/explodeVolumeRender.h
View file @
0097e8ea
...
...
@@ -107,15 +107,21 @@ public:
void
updateData
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
positions
,
const
FunctorSelect
&
good
=
allDarts
);
/**
* draw
* draw
edges
*/
void
drawEdges
();
/**
* draw edges
*/
void
drawFaces
();
void
setExplodeVolumes
(
float
explode
)
{
m_shader
->
setExplodeVolumes
(
explode
);
m_shaderL
->
setExplodeVolumes
(
explode
);}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
p
)
{
m_shader
->
setClippingPlane
(
p
);
m_shaderL
->
setClippingPlane
(
p
);}
void
setNoClippingPlane
()
{
Geom
::
Vec4f
p
(
0.0
f
,
0.0
f
,
10000.0
f
,
100000000000000000000000000.0
f
);
m_shader
->
setClippingPlane
(
p
);
m_shaderL
->
setClippingPlane
(
p
);}
void
setAmbiant
(
const
Geom
::
Vec4f
&
ambiant
)
{
m_shader
->
setAmbiant
(
ambiant
);}
void
setDiffuse
(
const
Geom
::
Vec4f
&
diffuse
)
{
m_shader
->
setDiffuse
(
diffuse
);}
...
...
include/Utils/Shaders/shaderExplodeVolumes.geom
View file @
0097e8ea
...
...
@@ -6,30 +6,35 @@ uniform mat4 ModelViewMatrix;
uniform
vec3
lightPosition
;
uniform
vec4
diffuse
;
uniform
vec4
ambient
;
uniform
vec4
plane
;
VARYING_OUT
vec4
ColorFS
;
void
main
(
void
)
{
vec3
v1
=
POSITION_IN
(
2
).
xyz
-
POSITION_IN
(
1
).
xyz
;
vec3
v2
=
POSITION_IN
(
3
).
xyz
-
POSITION_IN
(
1
).
xyz
;
vec3
N
=
cross
(
v1
,
v2
);
N
=
normalize
(
vec3
(
NormalMatrix
*
vec4
(
N
,
0
.
0
)));
float
d
=
dot
(
plane
,
POSITION_IN
(
0
));
// compute face center & lighting informations
vec4
newPos
=
ModelViewMatrix
*
POSITION_IN
(
1
);
vec3
L
=
normalize
(
lightPosition
-
newPos
.
xyz
);
float
lambertTerm
=
dot
(
N
,
L
);
ColorFS
=
ambient
;
if
(
lambertTerm
>
0
.
0
)
ColorFS
+=
diffuse
*
lambertTerm
;
// Explode in face
for
(
int
i
=
1
;
i
<
NBVERTS_IN
;
i
++
)
if
(
d
>=
0
.
0
)
{
vec4
P
=
explodeV
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explodeV
)
*
POSITION_IN
(
0
);
gl_Position
=
ModelViewProjectionMatrix
*
P
;
EmitVertex
();
vec3
v1
=
POSITION_IN
(
2
).
xyz
-
POSITION_IN
(
1
).
xyz
;
vec3
v2
=
POSITION_IN
(
3
).
xyz
-
POSITION_IN
(
1
).
xyz
;
vec3
N
=
cross
(
v1
,
v2
);
N
=
normalize
(
vec3
(
NormalMatrix
*
vec4
(
N
,
0
.
0
)));
// compute face center & lighting informations
vec4
newPos
=
ModelViewMatrix
*
POSITION_IN
(
1
);
vec3
L
=
normalize
(
lightPosition
-
newPos
.
xyz
);
float
lambertTerm
=
dot
(
N
,
L
);
ColorFS
=
ambient
;
if
(
lambertTerm
>
0
.
0
)
ColorFS
+=
diffuse
*
lambertTerm
;
// Explode in face
for
(
int
i
=
1
;
i
<
NBVERTS_IN
;
i
++
)
{
vec4
P
=
explodeV
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explodeV
)
*
POSITION_IN
(
0
);
gl_Position
=
ModelViewProjectionMatrix
*
P
;
EmitVertex
();
}
EndPrimitive
();
}
EndPrimitive
();
}
include/Utils/Shaders/shaderExplodeVolumes.h
View file @
0097e8ea
...
...
@@ -47,11 +47,13 @@ protected:
GLuint
m_unif_diffuse
;
GLuint
m_unif_lightPos
;
GLuint
m_unif_explodeV
;
GLuint
m_unif_plane
;
float
m_explodeV
;
Geom
::
Vec4f
m_ambiant
;
Geom
::
Vec4f
m_diffuse
;
Geom
::
Vec3f
m_light_pos
;
Geom
::
Vec4f
m_plane
;
VBO
*
m_vboPos
;
...
...
@@ -70,7 +72,9 @@ public:
void
setLightPosition
(
const
Geom
::
Vec3f
&
lp
);
void
setParams
(
float
explodeV
,
const
Geom
::
Vec4f
&
ambiant
,
const
Geom
::
Vec4f
&
diffuse
,
const
Geom
::
Vec3f
&
lightPos
);
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setParams
(
float
explodeV
,
const
Geom
::
Vec4f
&
ambiant
,
const
Geom
::
Vec4f
&
diffuse
,
const
Geom
::
Vec3f
&
lightPos
,
const
Geom
::
Vec4f
&
plane
);
void
setAttributePosition
(
VBO
*
vbo
);
};
...
...
include/Utils/Shaders/shaderExplodeVolumesLines.geom
View file @
0097e8ea
...
...
@@ -3,18 +3,24 @@ uniform float explodeV;
uniform
mat4
ModelViewProjectionMatrix
;
uniform
mat4
NormalMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
vec4
plane
;
uniform
vec4
color
;
VARYING_OUT
vec4
ColorFS
;
void
main
(
void
)
{
ColorFS
=
color
;
for
(
int
i
=
1
;
i
<
NBVERTS_IN
;
i
++
)
float
d
=
dot
(
plane
,
POSITION_IN
(
0
))
;
if
(
d
>=
0
.
0
)
{
vec4
P
=
explodeV
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explodeV
)
*
POSITION_IN
(
0
);
gl_Position
=
ModelViewProjectionMatrix
*
P
;
EmitVertex
();
}
EndPrimitive
();
ColorFS
=
color
;
for
(
int
i
=
1
;
i
<
NBVERTS_IN
;
i
++
)
{
vec4
P
=
explodeV
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explodeV
)
*
POSITION_IN
(
0
);
gl_Position
=
ModelViewProjectionMatrix
*
P
;
EmitVertex
();
}
EndPrimitive
();
}
}
include/Utils/Shaders/shaderExplodeVolumesLines.h
View file @
0097e8ea
...
...
@@ -45,9 +45,11 @@ protected:
// uniform locations
GLuint
m_unif_color
;
GLuint
m_unif_explodeV
;
GLuint
m_unif_plane
;
float
m_explodeV
;
Geom
::
Vec4f
m_color
;
Geom
::
Vec4f
m_plane
;
VBO
*
m_vboPos
;
...
...
@@ -62,7 +64,9 @@ public:
void
setColor
(
const
Geom
::
Vec4f
&
color
);
void
setParams
(
float
explodeV
,
const
Geom
::
Vec4f
&
color
);
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setParams
(
float
explodeV
,
const
Geom
::
Vec4f
&
color
,
const
Geom
::
Vec4f
&
plane
);
void
setAttributePosition
(
VBO
*
vbo
);
};
...
...
src/Utils/Shaders/shaderExplodeVolumes.cpp
View file @
0097e8ea
...
...
@@ -51,14 +51,6 @@ ShaderExplodeVolumes::ShaderExplodeVolumes()
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
glxfrag
.
append
(
fragmentShaderText
);
// std::cout << "----------------------------------------------------------" << std::endl;
// std::cout << glxvert << std::endl;
// std::cout << "----------------------------------------------------------" << std::endl;
// std::cout << glxfrag << std::endl;
// std::cout << "----------------------------------------------------------" << std::endl;
// std::cout << glxgeom << std::endl;
// std::cout << "----------------------------------------------------------" << std::endl;
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_LINES_ADJACENCY_EXT
,
GL_TRIANGLE_STRIP
,
4
);
getLocations
();
...
...
@@ -68,8 +60,9 @@ ShaderExplodeVolumes::ShaderExplodeVolumes()
m_ambiant
=
Geom
::
Vec4f
(
0.05
f
,
0.05
f
,
0.1
f
,
0.0
f
);
m_diffuse
=
Geom
::
Vec4f
(
0.1
f
,
1.0
f
,
0.1
f
,
0.0
f
);
m_light_pos
=
Geom
::
Vec3f
(
10.0
f
,
10.0
f
,
1000.0
f
);
m_plane
=
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1000.
f
,
1000000000000000000000000000.0
f
);
setParams
(
m_explodeV
,
m_ambiant
,
m_diffuse
,
m_light_pos
);
setParams
(
m_explodeV
,
m_ambiant
,
m_diffuse
,
m_light_pos
,
m_plane
);
}
void
ShaderExplodeVolumes
::
getLocations
()
...
...
@@ -78,6 +71,7 @@ void ShaderExplodeVolumes::getLocations()
m_unif_ambiant
=
glGetUniformLocation
(
program_handler
(),
"ambient"
);
m_unif_diffuse
=
glGetUniformLocation
(
program_handler
(),
"diffuse"
);
m_unif_lightPos
=
glGetUniformLocation
(
program_handler
(),
"lightPosition"
);
m_unif_plane
=
glGetUniformLocation
(
program_handler
(),
"plane"
);
}
void
ShaderExplodeVolumes
::
setAttributePosition
(
VBO
*
vbo
)
...
...
@@ -86,12 +80,13 @@ void ShaderExplodeVolumes::setAttributePosition(VBO* vbo)
bindVA_VBO
(
"VertexPosition"
,
vbo
);
}
void
ShaderExplodeVolumes
::
setParams
(
float
explV
,
const
Geom
::
Vec4f
&
ambiant
,
const
Geom
::
Vec4f
&
diffuse
,
const
Geom
::
Vec3f
&
lightPos
)
void
ShaderExplodeVolumes
::
setParams
(
float
explV
,
const
Geom
::
Vec4f
&
ambiant
,
const
Geom
::
Vec4f
&
diffuse
,
const
Geom
::
Vec3f
&
lightPos
,
const
Geom
::
Vec4f
&
plane
)
{
m_explodeV
=
explV
;
m_ambiant
=
ambiant
;
m_diffuse
=
diffuse
;
m_light_pos
=
lightPos
;
m_plane
=
plane
;
bind
();
...
...
@@ -99,6 +94,7 @@ void ShaderExplodeVolumes::setParams(float explV, const Geom::Vec4f& ambiant, co
glUniform4fv
(
m_unif_ambiant
,
1
,
ambiant
.
data
());
glUniform4fv
(
m_unif_diffuse
,
1
,
diffuse
.
data
());
glUniform3fv
(
m_unif_lightPos
,
1
,
lightPos
.
data
());
glUniform4fv
(
m_unif_plane
,
1
,
m_plane
.
data
());
unbind
();
// ??
}
...
...
@@ -132,18 +128,29 @@ void ShaderExplodeVolumes::setLightPosition(const Geom::Vec3f& lp)
glUniform3fv
(
m_unif_lightPos
,
1
,
lp
.
data
());
}
void
ShaderExplodeVolumes
::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_plane
=
plane
;
bind
();
glUniform4fv
(
m_unif_plane
,
1
,
plane
.
data
());
}
void
ShaderExplodeVolumes
::
restoreUniformsAttribs
()
{
m_unif_explodeV
=
glGetUniformLocation
(
program_handler
(),
"explodeV"
);
m_unif_ambiant
=
glGetUniformLocation
(
program_handler
(),
"ambient"
);
m_unif_diffuse
=
glGetUniformLocation
(
program_handler
(),
"diffuse"
);
m_unif_lightPos
=
glGetUniformLocation
(
program_handler
(),
"lightPosition"
);
m_unif_plane
=
glGetUniformLocation
(
program_handler
(),
"plane"
);
bind
();
glUniform1f
(
m_unif_explodeV
,
m_explodeV
);
glUniform4fv
(
m_unif_ambiant
,
1
,
m_ambiant
.
data
());
glUniform4fv
(
m_unif_diffuse
,
1
,
m_diffuse
.
data
());
glUniform3fv
(
m_unif_lightPos
,
1
,
m_light_pos
.
data
());
glUniform4fv
(
m_unif_plane
,
1
,
m_plane
.
data
());
bindVA_VBO
(
"VertexPosition"
,
m_vboPos
);
unbind
();
...
...
src/Utils/Shaders/shaderExplodeVolumesLines.cpp
View file @
0097e8ea
...
...
@@ -58,13 +58,15 @@ ShaderExplodeVolumesLines::ShaderExplodeVolumesLines()
//Default values
m_explodeV
=
0.9
f
;
m_color
=
Geom
::
Vec4f
(
0.05
f
,
0.05
f
,
0.05
f
,
0.0
f
);
setParams
(
m_explodeV
,
m_color
);
m_plane
=
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1000.
f
,
1000000000000000000000000000.0
f
);
setParams
(
m_explodeV
,
m_color
,
m_plane
);
}
void
ShaderExplodeVolumesLines
::
getLocations
()
{
m_unif_explodeV
=
glGetUniformLocation
(
program_handler
(),
"explodeV"
);
m_unif_color
=
glGetUniformLocation
(
program_handler
(),
"color"
);
m_unif_plane
=
glGetUniformLocation
(
program_handler
(),
"plane"
);
}
void
ShaderExplodeVolumesLines
::
setAttributePosition
(
VBO
*
vbo
)
...
...
@@ -73,15 +75,17 @@ void ShaderExplodeVolumesLines::setAttributePosition(VBO* vbo)
bindVA_VBO
(
"VertexPosition"
,
vbo
);
}
void
ShaderExplodeVolumesLines
::
setParams
(
float
explV
,
const
Geom
::
Vec4f
&
color
)
void
ShaderExplodeVolumesLines
::
setParams
(
float
explV
,
const
Geom
::
Vec4f
&
color
,
const
Geom
::
Vec4f
&
plane
)
{
m_explodeV
=
explV
;
m_color
=
color
;
m_plane
=
plane
;
bind
();
glUniform1f
(
m_unif_explodeV
,
explV
);
glUniform4fv
(
m_unif_color
,
1
,
color
.
data
());
glUniform4fv
(
m_unif_plane
,
1
,
m_plane
.
data
());
unbind
();
// ??
}
...
...
@@ -100,15 +104,23 @@ void ShaderExplodeVolumesLines::setColor(const Geom::Vec4f& color)
glUniform4fv
(
m_unif_color
,
1
,
color
.
data
());
}
void
ShaderExplodeVolumesLines
::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_plane
=
plane
;
bind
();
glUniform4fv
(
m_unif_plane
,
1
,
plane
.
data
());
}
void
ShaderExplodeVolumesLines
::
restoreUniformsAttribs
()
{
m_unif_explodeV
=
glGetUniformLocation
(
program_handler
(),
"explodeV"
);
m_unif_color
=
glGetUniformLocation
(
program_handler
(),
"color"
);
m_unif_plane
=
glGetUniformLocation
(
program_handler
(),
"plane"
);
bind
();
glUniform1f
(
m_unif_explodeV
,
m_explodeV
);
glUniform4fv
(
m_unif_color
,
1
,
m_color
.
data
());
glUniform4fv
(
m_unif_plane
,
1
,
m_plane
.
data
());
bindVA_VBO
(
"VertexPosition"
,
m_vboPos
);
unbind
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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