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
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
80265842
Commit
80265842
authored
Mar 20, 2015
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'develop'
Develop See merge request !55
parents
3ae34e1a
4f4e657d
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
657 additions
and
396 deletions
+657
-396
Apps/CMakeLists.txt
Apps/CMakeLists.txt
+5
-1
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+59
-17
CGoGN/CMakeLists.txt
CGoGN/CMakeLists.txt
+1
-3
CGoGN/include/Utils/Shaders/shaderPhong.frag
CGoGN/include/Utils/Shaders/shaderPhong.frag
+6
-0
CGoGN/include/Utils/Shaders/shaderPhong.h
CGoGN/include/Utils/Shaders/shaderPhong.h
+17
-3
CGoGN/include/Utils/Shaders/shaderPhongClip.frag
CGoGN/include/Utils/Shaders/shaderPhongClip.frag
+69
-0
CGoGN/include/Utils/Shaders/shaderPhongClip.vert
CGoGN/include/Utils/Shaders/shaderPhongClip.vert
+41
-0
CGoGN/include/Utils/Shaders/shaderSimpleColor.h
CGoGN/include/Utils/Shaders/shaderSimpleColor.h
+3
-0
CGoGN/include/Utils/Shaders/shaderSimpleFlat.frag
CGoGN/include/Utils/Shaders/shaderSimpleFlat.frag
+6
-0
CGoGN/include/Utils/Shaders/shaderSimpleFlat.h
CGoGN/include/Utils/Shaders/shaderSimpleFlat.h
+20
-5
CGoGN/include/Utils/Shaders/shaderSimpleFlatClip.frag
CGoGN/include/Utils/Shaders/shaderSimpleFlatClip.frag
+64
-0
CGoGN/include/Utils/Shaders/shaderSimpleFlatClip.vert
CGoGN/include/Utils/Shaders/shaderSimpleFlatClip.vert
+30
-0
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
+6
-1
CGoGN/include/Utils/pointSprite.h
CGoGN/include/Utils/pointSprite.h
+10
-0
CGoGN/include/Utils/pointSprite.vert
CGoGN/include/Utils/pointSprite.vert
+3
-0
CGoGN/src/Utils/Shaders/shaderPhong.cpp
CGoGN/src/Utils/Shaders/shaderPhong.cpp
+57
-15
CGoGN/src/Utils/Shaders/shaderSimpleFlat.cpp
CGoGN/src/Utils/Shaders/shaderSimpleFlat.cpp
+54
-13
CGoGN/src/Utils/Shaders/shaderVectorPerVertex.cpp
CGoGN/src/Utils/Shaders/shaderVectorPerVertex.cpp
+18
-1
CGoGN/src/Utils/pointSprite.cpp
CGoGN/src/Utils/pointSprite.cpp
+17
-4
CMakeLists.txt
CMakeLists.txt
+6
-1
README.md
README.md
+116
-92
README_APPS.TXT
README_APPS.TXT
+0
-74
README_MAC.TXT
README_MAC.TXT
+0
-24
README_VISUAL.TXT
README_VISUAL.TXT
+0
-126
SCHNApps/CMakeLists.txt
SCHNApps/CMakeLists.txt
+5
-1
SCHNApps/src/schnapps.cpp
SCHNApps/src/schnapps.cpp
+6
-2
apps_cmake.txt
apps_cmake.txt
+9
-7
build/.gitigonre
build/.gitigonre
+2
-0
buildDebug/.gitigonre
buildDebug/.gitigonre
+2
-0
No files found.
Apps/CMakeLists.txt
View file @
80265842
...
...
@@ -19,7 +19,11 @@ IF (WIN32)
ENDIF
()
ELSE
()
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/
${
CMAKE_BUILD_TYPE
}
)
SET
(
EXECUTABLE_OUTPUT_PATH
${
CGoGN_ROOT_DIR
}
/bin/
${
CMAKE_BUILD_TYPE
}
)
IF
(
APPLE
)
SET
(
EXECUTABLE_OUTPUT_PATH
${
CGoGN_ROOT_DIR
}
/bin/
${
CMAKE_BUILD_TYPE
}
/Contents/MacOS/
)
ELSE
()
SET
(
EXECUTABLE_OUTPUT_PATH
${
CGoGN_ROOT_DIR
}
/bin/
${
CMAKE_BUILD_TYPE
}
)
ENDIF
()
ENDIF
()
#include_directories(
...
...
Apps/Examples/viewer.cpp
View file @
80265842
...
...
@@ -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/CMakeLists.txt
View file @
80265842
...
...
@@ -107,11 +107,9 @@ link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )
IF
(
CGoGN_ONELIB
)
IF
(
CGoGN_WITH_QT
)
add_definitions
(
-DCGoGN_QT_DLL_EXPORT
)
add_library
(
cgogn
${
files_topology
}
${
files_container
}
${
files_algo
}
${
files_utils_withQt
}
)
qt_use_modules
(
cgogn Gui OpenGL Xml Svg
)
IF
(
${
CGoGN_DESIRED_QT_VERSION
}
STREQUAL
"5"
)
qt_use_modules
(
cgogn Widgets
)
ENDIF
()
ELSE
()
add_library
(
cgogn
${
files_topology
}
${
files_container
}
${
files_algo
}
${
files_utils
}
)
ENDIF
()
...
...
CGoGN/include/Utils/Shaders/shaderPhong.frag
View file @
80265842
...
...
@@ -9,6 +9,8 @@ uniform vec4 materialDiffuse;
uniform
vec4
materialSpecular
;
uniform
vec4
materialAmbient
;
uniform
float
shininess
;
uniform
vec4
backColor
;
FRAG_OUT_DEF
;
void
main
()
{
...
...
@@ -51,6 +53,10 @@ void main()
float
specular
=
pow
(
max
(
dot
(
R
,
E
),
0
.
0
),
shininess
);
finalColor
+=
materialSpecular
*
specular
;
}
else
{
finalColor
=
backColor
;
}
#endif
FRAG_OUT
=
finalColor
;
}
CGoGN/include/Utils/Shaders/shaderPhong.h
View file @
80265842
...
...
@@ -48,8 +48,10 @@ protected:
bool
m_with_eyepos
;
// shader sources OGL3
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderClipText
;
static
std
::
string
fragmentShaderClipText
;
// uniform locations
CGoGNGLuint
m_unif_ambiant
;
...
...
@@ -58,6 +60,7 @@ protected:
CGoGNGLuint
m_unif_shininess
;
CGoGNGLuint
m_unif_lightPos
;
CGoGNGLuint
m_unif_eyePos
;
CGoGNGLuint
m_unif_backColor
;
//values
Geom
::
Vec4f
m_ambiant
;
...
...
@@ -66,11 +69,16 @@ protected:
float
m_shininess
;
Geom
::
Vec3f
m_lightPos
;
Geom
::
Vec3f
m_eyePos
;
Geom
::
Vec4f
m_backColor
;
VBO
*
m_vboPos
;
VBO
*
m_vboNormal
;
VBO
*
m_vboColor
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
void
getLocations
();
void
sendParams
();
...
...
@@ -78,7 +86,7 @@ protected:
void
restoreUniformsAttribs
();
public:
ShaderPhong
(
bool
doubleSided
=
false
,
bool
withEyePosition
=
false
);
ShaderPhong
(
bool
withClipping
=
false
,
bool
doubleSided
=
false
,
bool
withEyePosition
=
false
);
// inviduals parameter setting functions
void
setAmbiant
(
const
Geom
::
Vec4f
&
ambiant
);
...
...
@@ -90,6 +98,8 @@ public:
void
setShininess
(
float
shininess
);
void
setLightPosition
(
const
Geom
::
Vec3f
&
lp
);
void
setBackColor
(
const
Geom
::
Vec4f
&
back
);
/// set eye position for VR environement
void
setEyePosition
(
const
Geom
::
Vec3f
&
ep
);
...
...
@@ -117,6 +127,10 @@ public:
// optional attributes
unsigned
int
setAttributeColor
(
VBO
*
vbo
);
void
unsetAttributeColor
();
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/shaderPhongClip.frag
0 → 100644
View file @
80265842
//ShaderPhong::fragmentShaderClipText
PRECISION
;
VARYING_FRAG
vec3
EyeVector
,
Normal
,
LightDir
;
#ifdef WITH_COLOR
VARYING_FRAG
vec3
Color
;
#endif
uniform
vec4
materialDiffuse
;
uniform
vec4
materialSpecular
;
uniform
vec4
materialAmbient
;
uniform
float
shininess
;
uniform
vec4
backColor
;
uniform
vec4
planeClip
;
VARYING_FRAG
vec3
posClip
;
FRAG_OUT_DEF
;
void
main
()
{
if
(
dot
(
planeClip
,
vec4
(
posClip
,
1
.
0
))
>
0
.
0
)
discard
;
vec3
N
=
normalize
(
Normal
);
vec3
L
=
normalize
(
LightDir
);
//float lambertTerm = clamp(dot(N,L),0.0,1.0);
vec4
finalColor
=
materialAmbient
;
#ifdef DOUBLE_SIDED
float
lambertTerm
;
vec4
diffuseColor
=
materialDiffuse
;
if
(
!
gl_FrontFacing
)
{
N
*=
-
1
.
0
;
lambertTerm
=
clamp
(
dot
(
N
,
L
),
0
.
0
,
1
.
0
);
}
else
lambertTerm
=
clamp
(
dot
(
N
,
L
),
0
.
0
,
1
.
0
);
#ifndef WITH_COLOR
finalColor
+=
materialDiffuse
*
lambertTerm
;
#else
finalColor
+=
vec4
((
Color
*
lambertTerm
),
0
.
0
)
;
#endif
vec3
E
=
normalize
(
EyeVector
);
vec3
R
=
reflect
(
-
L
,
N
);
float
specular
=
pow
(
max
(
dot
(
R
,
E
),
0
.
0
),
shininess
);
finalColor
+=
materialSpecular
*
specular
;
#else
float
lambertTerm
=
clamp
(
dot
(
N
,
L
),
0
.
0
,
1
.
0
);
if
(
gl_FrontFacing
)
{
#ifndef WITH_COLOR
finalColor
+=
materialDiffuse
*
lambertTerm
;
#else
finalColor
+=
vec4
((
Color
*
lambertTerm
),
0
.
0
)
;
#endif
vec3
E
=
normalize
(
EyeVector
);
vec3
R
=
reflect
(
-
L
,
N
);
float
specular
=
pow
(
max
(
dot
(
R
,
E
),
0
.
0
),
shininess
);
finalColor
+=
materialSpecular
*
specular
;
}
else
{
finalColor
=
backColor
;
}
#endif
FRAG_OUT
=
finalColor
;
}
CGoGN/include/Utils/Shaders/shaderPhongClip.vert
0 → 100644
View file @
80265842
//ShaderPhong::vertexShaderClipText
ATTRIBUTE
vec3
VertexPosition
,
VertexNormal
;
#ifdef WITH_COLOR
ATTRIBUTE
vec3
VertexColor
;
#endif
uniform
mat4
ModelViewProjectionMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
mat4
NormalMatrix
;
uniform
vec3
lightPosition
;
VARYING_VERT
vec3
EyeVector
,
Normal
,
LightDir
;
#ifdef WITH_COLOR
VARYING_VERT
vec3
Color
;
#endif
#ifdef WITH_EYEPOSITION
uniform
vec3
eyePosition
;
#endif
VARYING_VERT
vec3
posClip
;
INVARIANT_POS
;
void
main
()
{
Normal
=
vec3
(
NormalMatrix
*
vec4
(
VertexNormal
,
0
.
0
));
vec3
Position
=
vec3
(
ModelViewMatrix
*
vec4
(
VertexPosition
,
1
.
0
));
LightDir
=
lightPosition
-
Position
;
#ifdef WITH_EYEPOSITION
EyeVector
=
eyePosition
-
Position
;
#else
EyeVector
=
-
Position
;
#endif
#ifdef WITH_COLOR
Color
=
VertexColor
;
#endif
posClip
=
VertexPosition
;
gl_Position
=
ModelViewProjectionMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
}
CGoGN/include/Utils/Shaders/shaderSimpleColor.h
View file @
80265842
...
...
@@ -67,6 +67,9 @@ public:
unsigned
int
setAttributePosition
(
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/shaderSimpleFlat.frag
View file @
80265842
...
...
@@ -10,6 +10,8 @@ uniform vec4 materialDiffuse;
uniform
vec4
materialSpecular
;
uniform
vec4
materialAmbient
;
uniform
float
shininess
;
uniform
vec4
backColor
;
FRAG_OUT_DEF
;
void
main
()
...
...
@@ -47,6 +49,10 @@ void main()
finalColor
+=
vec4
((
Color
*
lambertTerm
),
0
.
0
)
;
#endif
}
else
{
finalColor
=
backColor
;
}
#endif
FRAG_OUT
=
finalColor
;
}
CGoGN/include/Utils/Shaders/shaderSimpleFlat.h
View file @
80265842
...
...
@@ -48,22 +48,31 @@ protected:
bool
m_with_eyepos
;
// shader sources OGL3
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderClipText
;
static
std
::
string
fragmentShaderClipText
;
// uniform locations
CGoGNGLuint
m_unif_ambiant
;
CGoGNGLuint
m_unif_diffuse
;
CGoGNGLuint
m_unif_lightPos
;
CGoGNGLuint
m_unif_backColor
;
//values
Geom
::
Vec4f
m_ambiant
;
Geom
::
Vec4f
m_diffuse
;
Geom
::
Vec3f
m_lightPos
;
Geom
::
Vec4f
m_backColor
;
VBO
*
m_vboPos
;
VBO
*
m_vboColor
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
void
getLocations
();
void
sendParams
();
...
...
@@ -71,16 +80,17 @@ protected:
void
restoreUniformsAttribs
();
public:
ShaderSimpleFlat
(
bool
doubleSided
=
false
);
ShaderSimpleFlat
(
bool
withClipping
=
false
,
bool
doubleSided
=
false
);
// inviduals parameter setting functions
void
setAmbiant
(
const
Geom
::
Vec4f
&
ambiant
);
void
setDiffuse
(
const
Geom
::
Vec4f
&
diffuse
);
void
setLightPosition
(
const
Geom
::
Vec3f
&
lp
);
void
setBackColor
(
const
Geom
::
Vec4f
&
back
);
const
Geom
::
Vec4f
&
getAmbiant
()
const
{
return
m_ambiant
;
}
const
Geom
::
Vec4f
&
getDiffuse
()
const
{
return
m_diffuse
;
}
...
...
@@ -98,6 +108,11 @@ public:
// optional attributes
unsigned
int
setAttributeColor
(
VBO
*
vbo
);
void
unsetAttributeColor
();
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/shaderSimpleFlatClip.frag
0 → 100644
View file @
80265842
//ShaderSimpleFlat::fragmentShaderClipText
PRECISION
;
VARYING_FRAG
vec3
LightDir
;
VARYING_FRAG
vec3
Position
;
#ifdef WITH_COLOR
VARYING_FRAG
vec3
Color
;
#endif
uniform
vec4
materialDiffuse
;
uniform
vec4
materialSpecular
;
uniform
vec4
materialAmbient
;
uniform
float
shininess
;
uniform
vec4
backColor
;
FRAG_OUT_DEF
;
uniform
vec4
planeClip
;
VARYING_FRAG
vec3
posClip
;
void
main
()
{
if
(
dot
(
planeClip
,
vec4
(
posClip
,
1
.
0
))
>
0
.
0
)
discard
;
vec3
DX
=
dFdx
(
Position
);
vec3
DY
=
dFdy
(
Position
);
vec3
N
=
normalize
(
cross
(
DX
,
DY
));
vec3
L
=
normalize
(
LightDir
);
vec4
finalColor
=
materialAmbient
;
#ifdef DOUBLE_SIDED
float
lambertTerm
;
vec4
diffuseColor
=
materialDiffuse
;
if
(
!
gl_FrontFacing
)
{
N
*=
-
1
.
0
;
lambertTerm
=
clamp
(
dot
(
N
,
L
),
0
.
0
,
1
.
0
);
}
else
lambertTerm
=
clamp
(
dot
(
N
,
L
),
0
.
0
,
1
.
0
);
#ifndef WITH_COLOR
finalColor
+=
materialDiffuse
*
lambertTerm
;
#else
finalColor
+=
vec4
((
Color
*
lambertTerm
),
0
.
0
)
;
#endif
#else
float
lambertTerm
=
clamp
(
dot
(
N
,
L
),
0
.
0
,
1
.
0
);
if
(
gl_FrontFacing
)
{
#ifndef WITH_COLOR
finalColor
+=
materialDiffuse
*
lambertTerm
;
#else
finalColor
+=
vec4
((
Color
*
lambertTerm
),
0
.
0
)
;
#endif
}
else
{
finalColor
=
backColor
;
}
#endif
FRAG_OUT
=
finalColor
;
}
CGoGN/include/Utils/Shaders/shaderSimpleFlatClip.vert
0 → 100644
View file @
80265842
//ShaderSimpleFlat::vertexShaderClipText
ATTRIBUTE
vec3
VertexPosition
,
VertexNormal
;
#ifdef WITH_COLOR
ATTRIBUTE
vec3
VertexColor
;
#endif
uniform
mat4
ModelViewProjectionMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
vec3
lightPosition
;
VARYING_VERT
vec3
LightDir
;
VARYING_VERT
vec3
Position
;
VARYING_VERT
vec3
posClip
;
#ifdef WITH_COLOR
VARYING_VERT
vec3
Color
;
#endif
INVARIANT_POS
;
void
main
()
{
Position
=
vec3
(
ModelViewMatrix
*
vec4
(
VertexPosition
,
1
.
0
));
LightDir
=
lightPosition
-
Position
;
#ifdef WITH_COLOR
Color
=
VertexColor
;
#endif
posClip
=
VertexPosition
;
gl_Position
=
ModelViewProjectionMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
}
CGoGN/include/Utils/Shaders/shaderVectorPerVertex.geom
View file @
80265842
...
...
@@ -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 @
80265842
...
...
@@ -54,6 +54,10 @@ protected:
VBO
*
m_vboPos
;
VBO
*
m_vboVec
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
void
getLocations
();