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
5f18375b
Commit
5f18375b
authored
Jan 22, 2013
by
Sylvain Thery
Browse files
add render explode volume with smooth faces (to be continued)
parent
8db5ec3f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/volumeExplorer.cpp
View file @
5f18375b
...
...
@@ -469,6 +469,12 @@ int main(int argc, char **argv)
prim
.
hexaGrid_topo
(
nb
,
nb
,
nb
);
prim
.
embedHexaGrid
(
1.0
f
,
1.0
f
,
1.0
f
);
for
(
unsigned
int
i
=
position
.
begin
();
i
!=
position
.
end
();
position
.
next
(
i
))
{
PFP
::
VEC3
pert
(
float
(
double
(
rand
())
/
RAND_MAX
/
20.0
),
float
(
double
(
rand
())
/
RAND_MAX
/
20.0
),
float
(
double
(
rand
())
/
RAND_MAX
/
20.0
));
position
[
i
]
+=
pert
;
}
color
=
myMap
.
addAttribute
<
PFP
::
VEC3
,
VOLUME
>
(
"color"
);
TraversorW
<
PFP
::
MAP
>
tra
(
myMap
);
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
...
...
SCHNApps/Plugins/render/render.ui
View file @
5f18375b
...
...
@@ -56,16 +56,16 @@
</property>
</widget>
</item>
<item
row=
"2"
column=
"2"
alignment=
"Qt::AlignRight"
>
<item
row=
"2"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"button_refreshVBOs"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
Preferr
ed"
vsizetype=
"Fixed"
>
<sizepolicy
hsizetype=
"
Fix
ed"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"layoutDirection"
>
<enum>
Qt::
LeftToRigh
t
</enum>
<enum>
Qt::
RightToLef
t
</enum>
</property>
<property
name=
"text"
>
<string>
Refresh
</string>
...
...
@@ -75,11 +75,7 @@
</layout>
</item>
<item>
<widget
class=
"Line"
name=
"line"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
<widget
class=
"Line"
name=
"line"
/>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"check_renderVertices"
>
...
...
include/Algo/Render/GL2/explodeVolumeRender.h
View file @
5f18375b
...
...
@@ -32,6 +32,7 @@
#include
"Topology/generic/attributeHandler.h"
#include
"Topology/generic/functor.h"
#include
"Utils/vbo_base.h"
#include
"Utils/Shaders/shaderExplodeSmoothVolumes.h"
#include
"Utils/Shaders/shaderExplodeVolumes.h"
#include
"Utils/Shaders/shaderExplodeVolumesLines.h"
...
...
@@ -54,6 +55,10 @@ protected:
Utils
::
ShaderExplodeVolumes
*
m_shader
;
Utils
::
ShaderExplodeSmoothVolumes
*
m_shaderS
;
bool
m_smooth
;
bool
m_cpf
;
bool
m_ef
;
...
...
@@ -81,7 +86,7 @@ public:
* @param withColorPerFace affect a color per face
* @param withExplodeFace shrinj each face
*/
ExplodeVolumeRender
(
bool
withColorPerFace
=
false
,
bool
withExplodeFace
=
false
)
;
ExplodeVolumeRender
(
bool
withColorPerFace
=
false
,
bool
withExplodeFace
=
false
,
bool
withSmoothFaces
=
false
)
;
/**
* Destructor
...
...
@@ -104,8 +109,8 @@ public:
* @param positions attribute of position vertices
* @param good selector
*/
template
<
typename
PFP
>
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
FunctorSelect
&
good
=
allDarts
)
;
//
template<typename PFP>
//
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good = allDarts) ;
/**
* update all drawing buffers
...
...
@@ -117,6 +122,10 @@ public:
template
<
typename
PFP
>
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerFace
,
const
FunctorSelect
&
good
=
allDarts
)
;
template
<
typename
PFP
>
void
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerFace
,
const
FunctorSelect
&
good
=
allDarts
)
;
/**
* draw edges
*/
...
...
include/Algo/Render/GL2/explodeVolumeRender.hpp
View file @
5f18375b
...
...
@@ -41,8 +41,9 @@ namespace Render
namespace
GL2
{
inline
ExplodeVolumeRender
::
ExplodeVolumeRender
(
bool
withColorPerFace
,
bool
withExplodeFace
)
:
m_cpf
(
withColorPerFace
),
m_ef
(
withExplodeFace
),
m_globalColor
(
0.7
f
,
0.7
f
,
0.7
f
)
inline
ExplodeVolumeRender
::
ExplodeVolumeRender
(
bool
withColorPerFace
,
bool
withExplodeFace
,
bool
withSmoothFaces
)
:
m_cpf
(
withColorPerFace
),
m_ef
(
withExplodeFace
),
m_smooth
(
withSmoothFaces
),
m_nbTris
(
0
),
m_nbLines
(
0
),
m_globalColor
(
0.7
f
,
0.7
f
,
0.7
f
)
{
m_vboPos
=
new
Utils
::
VBO
();
m_vboPos
->
setDataSize
(
3
);
...
...
@@ -54,15 +55,18 @@ inline ExplodeVolumeRender::ExplodeVolumeRender(bool withColorPerFace, bool with
m_vboPosLine
=
new
Utils
::
VBO
();
m_vboPosLine
->
setDataSize
(
3
);
m_shader
=
new
Utils
::
ShaderExplodeVolumes
(
withColorPerFace
,
withExplodeFace
);
m_shaderL
=
new
Utils
::
ShaderExplodeVolumesLines
();
// m_shader->setAmbiant(Geom::Vec4f(0.1f,0.1f,0.1f,0.0f));
// m_shader->setDiffuse(Geom::Vec4f(1.0f,1.0f,0.1f,0.0f));
//m_shaderL->setColor(Geom::Vec4f(1.0f,1.0f,1.0f,0.0f));
//m_shaderL->setColor(Geom::Vec4f(0.113f,0.337f,0.0f,0.113f));
if
(
m_smooth
)
{
m_shaderS
=
new
Utils
::
ShaderExplodeSmoothVolumes
(
withColorPerFace
,
withExplodeFace
);
m_shader
=
NULL
;
}
else
{
m_shader
=
new
Utils
::
ShaderExplodeVolumes
(
withColorPerFace
,
withExplodeFace
);
m_shaderS
=
NULL
;
}
m_shaderL
=
new
Utils
::
ShaderExplodeVolumesLines
();
m_shaderL
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
1.0
f
,
1.0
f
,
0.0
f
));
}
...
...
@@ -72,19 +76,110 @@ inline ExplodeVolumeRender::~ExplodeVolumeRender()
delete
m_vboPos
;
delete
m_vboColors
;
delete
m_vboPosLine
;
delete
m_shader
;
if
(
m_shader
!=
NULL
)
delete
m_shader
;
if
(
m_shaderS
!=
NULL
)
delete
m_shaderS
;
delete
m_shaderL
;
}
//template<typename PFP>
//void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good)
//{
// if (m_cpf)
// {
// CGoGNerr<< "ExplodeVolumeRender: problem wrong update fonction use the other" << CGoGNendl;
// return;
// }
//
// typedef typename PFP::VEC3 VEC3;
// typedef typename PFP::REAL REAL;
//
// VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
// Algo::Volume::Geometry::Parallel::computeCentroidVolumes<PFP>(map, positions, centerVolumes, good);
//
// std::vector<VEC3> buffer;
// buffer.reserve(16384);
//
// TraversorCell<typename PFP::MAP, PFP::MAP::FACE_OF_PARENT> traFace(map, good);
//
// for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
// {
// if (m_ef)
// {
// VEC3 centerFace = Algo::Surface::Geometry::faceCentroid<PFP>(map, d, positions);
// Dart a = d;
// Dart b = map.phi1(a);
// Dart c = map.phi1(b);
//
// // loop to cut a polygon in triangle on the fly (works only with convex faces)
// do
// {
// buffer.push_back(centerVolumes[d]);
// buffer.push_back(positions[d]);
// buffer.push_back(positions[b]);
// buffer.push_back(positions[c]);
// buffer.push_back(centerFace); // not used
// buffer.push_back(centerFace);
// b = c;
// c = map.phi1(b);
//
// } while (c != d);
// }
// else
// {
// Dart a = d;
// Dart b = map.phi1(a);
// Dart c = map.phi1(b);
//
// // loop to cut a polygon in triangle on the fly (works only with convex faces)
// do
// {
// buffer.push_back(centerVolumes[d]);
// buffer.push_back(positions[d]);
// buffer.push_back(positions[b]);
// buffer.push_back(positions[c]);
// b = c;
// c = map.phi1(b);
//
// } while (c != d);
// }
// }
//
// m_nbTris = buffer.size()/4;
//
// m_vboPos->allocate(buffer.size());
// VEC3* ptrPos = reinterpret_cast<VEC3*>(m_vboPos->lockPtr());
// memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
// m_vboPos->releasePtr();
// m_shader->setAttributePosition(m_vboPos);
//
// buffer.clear();
//
// TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map, good);
// for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
// {
// buffer.push_back(centerVolumes[d]);
// buffer.push_back(positions[d]);
// buffer.push_back(positions[map.phi1(d)]);
// }
//
// m_nbLines = buffer.size()/3;
//
// m_vboPosLine->allocate(buffer.size());
//
// ptrPos = reinterpret_cast<VEC3*>(m_vboPosLine->lockPtr());
// memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
//
// m_vboPosLine->releasePtr();
// m_shaderL->setAttributePosition(m_vboPosLine);
//}
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
update
Data
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
FunctorSelect
&
good
)
void
ExplodeVolumeRender
::
update
Smooth
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerXXX
,
const
FunctorSelect
&
good
)
{
if
(
m_cpf
)
{
CGoGNerr
<<
"ExplodeVolumeRender: problem wrong update fonction use the other"
<<
CGoGNendl
;
return
;
}
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -94,47 +189,86 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferColors
;
bufferColors
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferNormals
;
bufferNormals
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
normals
;
bufferNormals
.
reserve
(
20
);
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
FACE_OF_PARENT
>
traFace
(
map
,
good
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
if
(
m_cpf
)
{
if
(
m_ef
)
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
// compute normals
normals
.
clear
();
Dart
a
=
d
;
do
{
VEC3
v1
=
Algo
::
Surface
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
a
,
position
);
Dart
e
=
map
.
phi1
(
a
);
VEC3
v2
=
Algo
::
Surface
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
e
,
position
);
VEC3
N
=
v1
^
v2
;
N
.
normalize
();
normals
.
push_back
(
N
);
}
while
(
a
!=
d
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
std
::
vector
<
VEC3
>::
iterator
in
=
normals
.
begin
();
a
=
d
;
Dart
b
=
map
.
phi1
(
a
);
Dart
c
=
map
.
phi1
(
b
);
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
{
buffer
.
push_back
(
centerVolumes
[
d
]);
bufferColors
.
push_back
(
centerFace
);
bufferNormals
.
push_back
(
centerFace
);
// unsused just for fill
buffer
.
push_back
(
positions
[
d
]);
bufferColors
.
push_back
(
colorPerXXX
[
d
]);
bufferNormals
.
push_back
(
normals
.
back
());
buffer
.
push_back
(
positions
[
b
]);
bufferColors
.
push_back
(
colorPerXXX
[
b
]);
bufferNormals
.
push_back
(
*
in
++
);
buffer
.
push_back
(
positions
[
c
]);
buffer
.
push_back
(
c
enterFace
);
// not used
buffer
.
push_back
(
centerFace
);
buffer
Colors
.
push_back
(
c
olorPerXXX
[
c
]);
buffer
Normals
.
push_back
(
*
in
++
);
b
=
c
;
c
=
map
.
phi1
(
b
);
}
while
(
c
!=
d
);
}
else
}
else
{
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
Dart
b
=
map
.
phi1
(
a
);
Dart
c
=
map
.
phi1
(
b
);
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
{
buffer
.
push_back
(
centerVolumes
[
d
]);
bufferColors
.
push_back
(
centerFace
);
bufferNormals
.
push_back
(
centerFace
);
buffer
.
push_back
(
positions
[
d
]);
bufferColors
.
push_back
(
m_globalColor
);
bufferNormals
.
push_back
();
buffer
.
push_back
(
positions
[
b
]);
bufferColors
.
push_back
(
m_globalColor
);
bufferNormals
.
push_back
();
buffer
.
push_back
(
positions
[
c
]);
bufferColors
.
push_back
(
m_globalColor
);
bufferNormals
.
push_back
();
b
=
c
;
c
=
map
.
phi1
(
b
);
}
while
(
c
!=
d
);
}
}
...
...
@@ -147,14 +281,20 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
m_vboPos
->
releasePtr
();
m_shader
->
setAttributePosition
(
m_vboPos
);
m_vboColors
->
allocate
(
bufferColors
.
size
());
VEC3
*
ptrCol
=
reinterpret_cast
<
VEC3
*>
(
m_vboColors
->
lockPtr
());
memcpy
(
ptrCol
,
&
bufferColors
[
0
],
bufferColors
.
size
()
*
sizeof
(
VEC3
));
m_vboColors
->
releasePtr
();
m_shader
->
setAttributeColor
(
m_vboColors
);
buffer
.
clear
();
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
EDGE_OF_PARENT
>
traEdge
(
map
,
good
);
for
(
Dart
d
=
traEdge
.
begin
();
d
!=
traEdge
.
end
();
d
=
traEdge
.
next
())
{
buffer
.
push_back
(
centerVolumes
[
d
]);
buffer
.
push_back
(
positions
[
d
]);
buffer
.
push_back
(
positions
[
map
.
phi1
(
d
)]);
buffer
.
push_back
(
centerVolumes
[
d
]);
buffer
.
push_back
(
positions
[
d
]);
buffer
.
push_back
(
positions
[
map
.
phi1
(
d
)]);
}
m_nbLines
=
buffer
.
size
()
/
3
;
...
...
@@ -168,15 +308,23 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
m_shaderL
->
setAttributePosition
(
m_vboPosLine
);
}
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerXXX
,
const
FunctorSelect
&
good
)
{
if
(
!
m_cpf
)
// if (!m_cpf)
// {
// CGoGNerr<< "ExplodeVolumeRender: problem wrong update fonction use the other" << CGoGNendl;
// return;
// }
if
(
m_smooth
)
{
CGoGNerr
<<
"ExplodeVolumeRender: problem wrong update fonction use the other"
<<
CGoGNendl
;
return
;
}
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -188,44 +336,57 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
std
::
vector
<
VEC3
>
bufferColors
;
// bool withColors = (positions == colorPerXXX);
bool
withColors
=
true
;
if
(
withColors
)
bufferColors
.
reserve
(
16384
);
bufferColors
.
reserve
(
16384
);
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
FACE_OF_PARENT
>
traFace
(
map
,
good
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
if
(
m_cpf
)
{
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
Dart
b
=
map
.
phi1
(
a
);
Dart
c
=
map
.
phi1
(
b
);
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
buffer
.
push_back
(
centerVolumes
[
d
]);
bufferColors
.
push_back
(
centerFace
);
buffer
.
push_back
(
positions
[
d
]);
if
(
m_cpf
)
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
Dart
b
=
map
.
phi1
(
a
);
Dart
c
=
map
.
phi1
(
b
);
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
{
buffer
.
push_back
(
centerVolumes
[
d
]);
bufferColors
.
push_back
(
centerFace
);
buffer
.
push_back
(
positions
[
d
]);
bufferColors
.
push_back
(
colorPerXXX
[
d
]);
else
bufferColors
.
push_back
(
m_globalColor
);
buffer
.
push_back
(
positions
[
b
]);
if
(
m_cpf
)
buffer
.
push_back
(
positions
[
b
]);
bufferColors
.
push_back
(
colorPerXXX
[
b
]);
else
bufferColors
.
push_back
(
m_globalColor
);
buffer
.
push_back
(
positions
[
c
]);
if
(
m_cpf
)
buffer
.
push_back
(
positions
[
c
]);
bufferColors
.
push_back
(
colorPerXXX
[
c
]);
else
b
=
c
;
c
=
map
.
phi1
(
b
);
}
while
(
c
!=
d
);
}
}
else
{
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
Dart
b
=
map
.
phi1
(
a
);
Dart
c
=
map
.
phi1
(
b
);
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
{
buffer
.
push_back
(
centerVolumes
[
d
]);
bufferColors
.
push_back
(
centerFace
);
buffer
.
push_back
(
positions
[
d
]);
bufferColors
.
push_back
(
m_globalColor
);
b
=
c
;
c
=
map
.
phi1
(
b
);
}
while
(
c
!=
d
);
buffer
.
push_back
(
positions
[
b
]);
bufferColors
.
push_back
(
m_globalColor
);
buffer
.
push_back
(
positions
[
c
]);
bufferColors
.
push_back
(
m_globalColor
);
b
=
c
;
c
=
map
.
phi1
(
b
);
}
while
(
c
!=
d
);
}
}
m_nbTris
=
buffer
.
size
()
/
4
;
...
...
@@ -236,15 +397,11 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
m_vboPos
->
releasePtr
();
m_shader
->
setAttributePosition
(
m_vboPos
);
if
(
withColors
)
{
m_vboColors
->
allocate
(
bufferColors
.
size
());
VEC3
*
ptrCol
=
reinterpret_cast
<
VEC3
*>
(
m_vboColors
->
lockPtr
());
memcpy
(
ptrCol
,
&
bufferColors
[
0
],
bufferColors
.
size
()
*
sizeof
(
VEC3
));
m_vboColors
->
releasePtr
();
m_shader
->
setAttributeColor
(
m_vboColors
);
}
m_vboColors
->
allocate
(
bufferColors
.
size
());
VEC3
*
ptrCol
=
reinterpret_cast
<
VEC3
*>
(
m_vboColors
->
lockPtr
());
memcpy
(
ptrCol
,
&
bufferColors
[
0
],
bufferColors
.
size
()
*
sizeof
(
VEC3
));
m_vboColors
->
releasePtr
();
m_shader
->
setAttributeColor
(
m_vboColors
);
buffer
.
clear
();
...
...
@@ -270,10 +427,7 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
inline
void
ExplodeVolumeRender
::
drawFaces
()
{
m_shader
->
enableVertexAttribs
();
// if (m_cpf)
// glDrawArrays(GL_TRIANGLES_ADJACENCY_EXT , 0 , m_nbTris*6 );
// else
glDrawArrays
(
GL_LINES_ADJACENCY_EXT
,
0
,
m_nbTris
*
4
);
glDrawArrays
(
GL_LINES_ADJACENCY_EXT
,
0
,
m_nbTris
*
4
);
m_shader
->
disableVertexAttribs
();
}
...
...
include/Utils/Shaders/shaderExplodeSmoothVolumes.frag
0 → 100644
View file @
5f18375b
// ShaderExplodeSmoothVolumes::fragmentShaderText
VARYING_FRAG
vec4
ColorFS
;
void
main
()
{
gl_FragColor
=
ColorFS
;
}
include/Utils/Shaders/shaderExplodeSmoothVolumes.geom
0 → 100644
View file @
5f18375b
// ShaderExplodeSmoothVolumes::geometryShaderText
uniform
float
explodeV
;
uniform
float
explodeF
;
uniform
mat4
ModelViewProjectionMatrix
;
uniform
mat4
NormalMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
vec3
lightPosition
;
uniform
vec4
ambient
;
uniform
vec4
backColor
;
uniform
vec4
plane
;
VARYING_IN
vec3
colorVertex
[
4
];
VARYING_IN
vec3
normalVertex
[
4
];
VARYING_OUT
vec4
ColorFS
;
void
main
(
void
)
{
float
d
=
dot
(
plane
,
POSITION_IN
(
0
));
if
(
d
<=
0
.
0
)
{
for
(
int
i
=
1
;
i
<=
3
;
i
++
)
{
// explode in face
vec4
P
=
explodeF
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explodeF
)
*
vec4
(
colorVertex
[
0
],
1
.
0
);
// compute vextex illum from pos & normal
vec3
L
=
normalize
(
lightPosition
-
P
.
xyz
);
vec3
N
=
normalize
(
vec3
(
NormalMatrix
*
vec4
(
normalVertex
[
i
],
0
.
0
)));
float
lambertTerm
=
dot
(
N
,
L
);
// explode in volume
vec4
Q
=
explodeV
*
P
+
(
1
.
0
-
explodeV
)
*
POSITION_IN
(
0
);
gl_Position
=
ModelViewProjectionMatrix
*
Q
;
if
(
lambertTerm
>
0
.
0
)
ColorFS
=
ambient
+
vec4
(
colorVertex
[
i
]
*
lambertTerm
,
1
.
0
);
else
ColorFS
=
ambient
-
backColor
*
lambertTerm
;
EmitVertex
();
}
EndPrimitive
();
}
}
include/Utils/Shaders/shaderExplodeSmoothVolumes.h
0 → 100644
View file @
5f18375b
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __CGOGN_SHADER_EXPLODE_SMOOTH_VOLUMES__
#define __CGOGN_SHADER_EXPLODE_SMOOTH_VOLUMES__
#include
"Utils/GLSLShader.h"
#include
"Geometry/vector_gen.h"