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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
35f2eb18
Commit
35f2eb18
authored
Mar 18, 2015
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clipping on vectorPerVertexShader
parent
72f0a449
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
29 deletions
+108
-29
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+59
-17
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.geom
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.geom
+12
-5
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.h
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.h
+10
-1
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.vert
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.vert
+3
-0
CGoGN/include/Utils/pointSprite.geom
CGoGN/include/Utils/pointSprite.geom
+1
-1
CGoGN/src/Utils/Shaders/shaderVectorPerVertex.cpp
CGoGN/src/Utils/Shaders/shaderVectorPerVertex.cpp
+18
-1
CGoGN/src/Utils/pointSprite.cpp
CGoGN/src/Utils/pointSprite.cpp
+5
-4
No files found.
Apps/Examples/viewer.cpp
View file @
35f2eb18
...
...
@@ -45,7 +45,7 @@ Viewer::Viewer() :
faceShrinkage
=
1.0
f
;
colClear
=
Geom
::
Vec4f
(
0.2
f
,
0.2
f
,
0.2
f
,
0.1
f
)
;
colDif
=
Geom
::
Vec4f
(
0.
8
f
,
0.9
f
,
0.7
f
,
1.0
f
)
;
colDif
=
Geom
::
Vec4f
(
0.
3
f
,
0.5
f
,
0.2
f
,
1.0
f
)
;
colSpec
=
Geom
::
Vec4f
(
0.9
f
,
0.9
f
,
0.9
f
,
1.0
f
)
;
colNormal
=
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
)
;
shininess
=
80.0
f
;
...
...
@@ -92,31 +92,33 @@ void Viewer::cb_initGL()
m_positionVBO
=
new
Utils
::
VBO
()
;
m_normalVBO
=
new
Utils
::
VBO
()
;
m_phongShader
=
new
Utils
::
ShaderPhong
()
;
m_phongShader
=
new
Utils
::
ShaderPhong
(
true
,
false
,
false
)
;
m_phongShader
->
setAttributePosition
(
m_positionVBO
)
;
m_phongShader
->
setAttributeNormal
(
m_normalVBO
)
;
m_phongShader
->
setAmbiant
(
colClear
)
;
m_phongShader
->
setDiffuse
(
colDif
)
;
m_phongShader
->
setSpecular
(
colSpec
)
;
m_phongShader
->
setShininess
(
shininess
)
;
m_phongShader
->
setBackColor
(
Geom
::
Vec4f
(
0
,
0
,
0.2
,
0
))
;
m_flatShader
=
new
Utils
::
ShaderSimpleFlat
()
;
m_flatShader
=
new
Utils
::
ShaderSimpleFlat
(
true
,
false
)
;
m_flatShader
->
setAttributePosition
(
m_positionVBO
)
;
m_flatShader
->
setAmbiant
(
colClear
)
;
m_flatShader
->
setDiffuse
(
colDif
)
;
// m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0
,0)) ;
// m_flatShader->setExplode(faceShrinkage) ;
m_flatShader
->
setBackColor
(
Geom
::
Vec4f
(
0
,
0
,
0.2
,
0
))
;
m_vectorShader
=
new
Utils
::
ShaderVectorPerVertex
()
;
m_vectorShader
->
setAttributePosition
(
m_positionVBO
)
;
m_vectorShader
->
setAttributeVector
(
m_normalVBO
)
;
m_vectorShader
->
setColor
(
colNormal
)
;
m_simpleColorShader
=
new
Utils
::
ShaderSimpleColor
()
;
m_simpleColorShader
=
new
Utils
::
ShaderSimpleColor
(
true
)
;
m_simpleColorShader
->
setAttributePosition
(
m_positionVBO
)
;
Geom
::
Vec4f
c
(
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
)
;
m_simpleColorShader
->
setColor
(
c
)
;
m_pointSprite
=
new
Utils
::
PointSprite
()
;
m_pointSprite
->
setAttributePosition
(
m_positionVBO
)
;
m_pointSprite
->
setColor
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1.0
f
,
1.0
f
))
;
...
...
@@ -132,25 +134,31 @@ void Viewer::cb_redraw()
{
if
(
m_drawVertices
)
{
glDepthFunc
(
GL_LEQUAL
);
m_pointSprite
->
setSize
(
vertexScaleFactor
)
;
m_render
->
draw
(
m_pointSprite
,
Algo
::
Render
::
GL2
::
POINTS
)
;
}
if
(
m_drawEdges
)
{
glDepthFunc
(
GL_LEQUAL
);
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
1.
,
1.
,
0.
,
0.
)
);
glLineWidth
(
1.0
f
)
;
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
LINES
)
;
}
if
(
m_drawTopo
)
{
glDepthFunc
(
GL_LEQUAL
);
m_topoRender
->
drawTopo
()
;
}
if
(
m_drawFaces
)
{
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
glEnable
(
GL_LIGHTING
)
;
glEnable
(
GL_POLYGON_OFFSET_FILL
)
;
glPolygonOffset
(
1.0
f
,
1.0
f
)
;
glDepthFunc
(
GL_LESS
);
if
(
m_drawEdges
||
m_drawTopo
)
{
glEnable
(
GL_POLYGON_OFFSET_FILL
)
;
glPolygonOffset
(
1.0
f
,
1.0
f
)
;
}
switch
(
m_renderStyle
)
{
case
FLAT
:
...
...
@@ -163,11 +171,7 @@ void Viewer::cb_redraw()
glDisable
(
GL_POLYGON_OFFSET_FILL
)
;
}
if
(
m_drawTopo
)
{
glDepthFunc
(
GL_LEQUAL
);
m_topoRender
->
drawTopo
()
;
}
if
(
m_drawNormals
)
{
...
...
@@ -210,6 +214,32 @@ void Viewer::cb_keyPress(int keycode)
{
switch
(
keycode
)
{
case
'n'
:
m_flatShader
->
setNoClippingPlane
();
m_phongShader
->
setNoClippingPlane
();
m_topoRender
->
setNoClippingPlane
();
m_simpleColorShader
->
setNoClippingPlane
();
m_pointSprite
->
setNoClippingPlane
();
m_vectorShader
->
setNoClippingPlane
();
break
;
case
'N'
:
{
const
Geom
::
Vec3f
&
Pc
=
bb
.
center
();
const
Geom
::
Vec3f
&
Nc
=
bb
.
diag
();
Geom
::
Vec4f
planeClip
(
Nc
[
0
],
Nc
[
1
],
Nc
[
2
],
-
(
Pc
*
Nc
));
m_flatShader
->
setClippingPlane
(
planeClip
);
m_phongShader
->
setClippingPlane
(
planeClip
);
m_topoRender
->
setClippingPlane
(
planeClip
);
m_simpleColorShader
->
setClippingPlane
(
planeClip
);
m_pointSprite
->
setClippingPlane
(
planeClip
);
m_vectorShader
->
setClippingPlane
(
planeClip
);
}
break
;
case
'c'
:
myMap
.
check
();
break
;
...
...
@@ -578,6 +608,18 @@ void Viewer::importMesh(std::string& filename)
m_normalVBO
->
updateData
(
normal
)
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
().
data
())
;
const
Geom
::
Vec3f
&
Pc
=
bb
.
center
();
const
Geom
::
Vec3f
&
Nc
=
bb
.
diag
();
Geom
::
Vec4f
planeClip
(
Nc
[
0
],
Nc
[
1
],
Nc
[
2
],
-
(
Pc
*
Nc
));
// m_flatShader->setClippingPlane(planeClip);
// m_phongShader->setClippingPlane(planeClip);
// m_topoRender->setClippingPlane(planeClip);
// m_simpleColorShader->setClippingPlane(planeClip);
// m_pointSprite->setClippingPlane(planeClip);
// m_vectorShader->setClippingPlane(planeClip);
updateGLMatrices
()
;
std
::
cout
<<
"#vertices -> "
<<
Algo
::
Topo
::
getNbOrbits
<
VERTEX
>
(
myMap
)
<<
std
::
endl
;
...
...
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.geom
View file @
35f2eb18
...
...
@@ -3,11 +3,18 @@
uniform
float
vectorScale
;
uniform
mat4
ModelViewProjectionMatrix
;
VARYING_IN
vec3
VectorAttrib
[];
uniform
vec4
planeClip
;
VARYING_IN
vec3
posClip
[];
void
main
()
{
gl_Position
=
ModelViewProjectionMatrix
*
POSITION_IN
(
0
);
EmitVertex
();
gl_Position
=
ModelViewProjectionMatrix
*
(
POSITION_IN
(
0
)
+
vec4
(
VectorAttrib
[
0
]
*
vectorScale
,
0
.
0
));
EmitVertex
();
EndPrimitive
();
if
(
dot
(
planeClip
,
vec4
(
posClip
[
0
],
1
.
0
))
<=
0
.
0
)
{
gl_Position
=
ModelViewProjectionMatrix
*
POSITION_IN
(
0
);
EmitVertex
();
gl_Position
=
ModelViewProjectionMatrix
*
(
POSITION_IN
(
0
)
+
vec4
(
VectorAttrib
[
0
]
*
vectorScale
,
0
.
0
));
EmitVertex
();
EndPrimitive
();
}
}
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.h
View file @
35f2eb18
...
...
@@ -54,6 +54,10 @@ protected:
VBO
*
m_vboPos
;
VBO
*
m_vboVec
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
void
getLocations
();
void
sendParams
();
...
...
@@ -61,7 +65,7 @@ protected:
void
restoreUniformsAttribs
();
public:
ShaderVectorPerVertex
();
ShaderVectorPerVertex
();
void
setScale
(
float
scale
);
...
...
@@ -70,6 +74,11 @@ public:
unsigned
int
setAttributePosition
(
VBO
*
vbo
);
unsigned
int
setAttributeVector
(
VBO
*
vbo
);
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
inline
void
setNoClippingPlane
()
{
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
};
}
// namespace Utils
...
...
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.vert
View file @
35f2eb18
...
...
@@ -3,9 +3,12 @@
ATTRIBUTE
vec3
VertexPosition
;
ATTRIBUTE
vec3
VertexVector
;
VARYING_VERT
vec3
VectorAttrib
;
VARYING_VERT
vec3
posClip
;
INVARIANT_POS
;
void
main
()
{
posClip
=
VertexPosition
;
VectorAttrib
=
VertexVector
;
gl_Position
=
vec4
(
VertexPosition
,
1
.
0
);
}
CGoGN/include/Utils/pointSprite.geom
View file @
35f2eb18
...
...
@@ -40,7 +40,7 @@ void corner( vec4 center, float x, float y)
void
main
()
{
if
(
dot
(
planeClip
,
vec4
(
posClip
[
0
],
1
.
0
))
<
0
.
0
)
if
(
dot
(
planeClip
,
vec4
(
posClip
[
0
],
1
.
0
))
<
=
0
.
0
)
{
#ifdef WITH_COLOR_PER_VERTEX
colorsprite
=
color
[
0
];
...
...
CGoGN/src/Utils/Shaders/shaderVectorPerVertex.cpp
View file @
35f2eb18
...
...
@@ -37,7 +37,8 @@ namespace Utils
ShaderVectorPerVertex
::
ShaderVectorPerVertex
()
:
m_scale
(
1.0
f
),
m_color
(
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
0.0
f
))
m_color
(
1.0
f
,
0.0
f
,
0.0
f
,
0.0
f
),
m_planeClip
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
)
{
m_nameVS
=
"ShaderVectorPerVertex_vs"
;
m_nameFS
=
"ShaderVectorPerVertex_fs"
;
...
...
@@ -64,6 +65,7 @@ void ShaderVectorPerVertex::getLocations()
bind
();
*
m_uniform_scale
=
glGetUniformLocation
(
this
->
program_handler
(),
"vectorScale"
);
*
m_uniform_color
=
glGetUniformLocation
(
this
->
program_handler
(),
"vectorColor"
);
*
m_unif_planeClip
=
glGetUniformLocation
(
this
->
program_handler
(),
"planeClip"
);
unbind
();
}
...
...
@@ -72,6 +74,9 @@ void ShaderVectorPerVertex::sendParams()
bind
();
glUniform1f
(
*
m_uniform_scale
,
m_scale
);
glUniform4fv
(
*
m_uniform_color
,
1
,
m_color
.
data
());
if
(
*
m_unif_planeClip
>
0
)
glUniform4fv
(
*
m_unif_planeClip
,
1
,
m_planeClip
.
data
());
unbind
();
}
...
...
@@ -120,6 +125,18 @@ void ShaderVectorPerVertex::restoreUniformsAttribs()
unbind
();
}
void
ShaderVectorPerVertex
::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
if
(
*
m_unif_planeClip
>
0
)
{
m_planeClip
=
plane
;
bind
();
glUniform4fv
(
*
m_unif_planeClip
,
1
,
plane
.
data
());
unbind
();
}
}
}
// namespace Utils
}
// namespace CGoGN
CGoGN/src/Utils/pointSprite.cpp
View file @
35f2eb18
...
...
@@ -38,10 +38,11 @@ PointSprite::PointSprite(bool withColorPerVertex, bool withPlane) :
colorPerVertex
(
withColorPerVertex
),
plane
(
withPlane
),
m_size
(
1.0
f
),
m_color
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1.0
f
,
1.0
f
)),
m_lightPos
(
Geom
::
Vec3f
(
100.0
f
,
100.0
f
,
100.0
f
)),
m_ambiant
(
Geom
::
Vec3f
(
0.1
f
,
0.1
f
,
0.1
f
)),
m_eyePos
(
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
0.0
f
))
m_color
(
0.0
f
,
0.0
f
,
1.0
f
,
1.0
f
),
m_lightPos
(
100.0
f
,
100.0
f
,
100.0
f
),
m_ambiant
(
0.1
f
,
0.1
f
,
0.1
f
),
m_eyePos
(
0.0
f
,
0.0
f
,
0.0
f
),
m_planeClip
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
)
{
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
if
(
withColorPerVertex
)
...
...
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