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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KennethVanhoey
CGoGN
Commits
17bd0a69
Commit
17bd0a69
authored
Mar 11, 2013
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scalar attribute rendering plugin update
parent
f84dbc6f
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
226 additions
and
46 deletions
+226
-46
SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp
...ins/differentialProperties/src/differentialProperties.cpp
+1
-1
SCHNApps/Plugins/render/include/render.h
SCHNApps/Plugins/render/include/render.h
+1
-1
SCHNApps/Plugins/render/src/render.cpp
SCHNApps/Plugins/render/src/render.cpp
+2
-2
SCHNApps/Plugins/render/src/renderDockTab.cpp
SCHNApps/Plugins/render/src/renderDockTab.cpp
+1
-1
SCHNApps/Plugins/renderScalar/forms/renderScalar.ui
SCHNApps/Plugins/renderScalar/forms/renderScalar.ui
+27
-7
SCHNApps/Plugins/renderScalar/include/renderScalar.h
SCHNApps/Plugins/renderScalar/include/renderScalar.h
+5
-2
SCHNApps/Plugins/renderScalar/include/renderScalarDockTab.h
SCHNApps/Plugins/renderScalar/include/renderScalarDockTab.h
+2
-1
SCHNApps/Plugins/renderScalar/src/renderScalar.cpp
SCHNApps/Plugins/renderScalar/src/renderScalar.cpp
+39
-10
SCHNApps/Plugins/renderScalar/src/renderScalarDockTab.cpp
SCHNApps/Plugins/renderScalar/src/renderScalarDockTab.cpp
+31
-9
SCHNApps/bin/init.py
SCHNApps/bin/init.py
+6
-4
include/Utils/Shaders/shaderScalarField.frag
include/Utils/Shaders/shaderScalarField.frag
+4
-4
include/Utils/Shaders/shaderScalarField.h
include/Utils/Shaders/shaderScalarField.h
+18
-0
include/Utils/Shaders/shaderScalarField.vert
include/Utils/Shaders/shaderScalarField.vert
+40
-2
include/Utils/Shaders/shaderVectorPerVertex.h
include/Utils/Shaders/shaderVectorPerVertex.h
+2
-1
include/Utils/vbo_base.h
include/Utils/vbo_base.h
+1
-1
src/Utils/Shaders/shaderScalarField.cpp
src/Utils/Shaders/shaderScalarField.cpp
+46
-0
No files found.
SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp
View file @
17bd0a69
...
...
@@ -226,7 +226,7 @@ void DifferentialPropertiesPlugin::computeCurvature(
PFP2
::
MAP
*
map
=
mh
->
getMap
();
Algo
::
Surface
::
Geometry
::
computeAnglesBetweenNormalsOnEdges
<
PFP2
>
(
*
map
,
position
,
edgeAngle
);
Algo
::
Surface
::
Geometry
::
computeCurvatureVertices_NormalCycles_Projected
<
PFP2
>
(
*
map
,
0.0
2
f
*
mh
->
getBBdiagSize
(),
position
,
normal
,
edgeAngle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
);
Algo
::
Surface
::
Geometry
::
computeCurvatureVertices_NormalCycles_Projected
<
PFP2
>
(
*
map
,
0.0
1
f
*
mh
->
getBBdiagSize
(),
position
,
normal
,
edgeAngle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
);
computeCurvatureLastParameters
[
mapName
]
=
ComputeCurvatureParameters
(
...
...
SCHNApps/Plugins/render/include/render.h
View file @
17bd0a69
...
...
@@ -111,7 +111,7 @@ public slots:
void
changePositionVBO
(
View
*
view
,
MapHandlerGen
*
map
,
Utils
::
VBO
*
vbo
,
bool
fromUI
=
false
);
void
changeNormalVBO
(
View
*
view
,
MapHandlerGen
*
map
,
Utils
::
VBO
*
vbo
,
bool
fromUI
=
false
);
void
changeRenderVertices
(
View
*
view
,
MapHandlerGen
*
map
,
bool
b
,
bool
fromUI
=
false
);
void
changeVerticesScaleFactor
(
View
*
view
,
MapHandlerGen
*
map
,
int
i
,
bool
fromUI
=
false
);
void
changeVerticesScaleFactor
(
View
*
view
,
MapHandlerGen
*
map
,
float
f
,
bool
fromUI
=
false
);
void
changeRenderEdges
(
View
*
view
,
MapHandlerGen
*
map
,
bool
b
,
bool
fromUI
=
false
);
void
changeRenderFaces
(
View
*
view
,
MapHandlerGen
*
map
,
bool
b
,
bool
fromUI
=
false
);
void
changeFacesStyle
(
View
*
view
,
MapHandlerGen
*
map
,
FaceShadingStyle
style
,
bool
fromUI
=
false
);
...
...
SCHNApps/Plugins/render/src/render.cpp
View file @
17bd0a69
...
...
@@ -287,10 +287,10 @@ void RenderPlugin::changeRenderVertices(View* view, MapHandlerGen* map, bool b,
}
}
void
RenderPlugin
::
changeVerticesScaleFactor
(
View
*
view
,
MapHandlerGen
*
map
,
int
i
,
bool
fromUI
)
void
RenderPlugin
::
changeVerticesScaleFactor
(
View
*
view
,
MapHandlerGen
*
map
,
float
f
,
bool
fromUI
)
{
ParameterSet
*
params
=
h_viewParams
[
view
];
params
->
perMap
[
map
->
getName
()]
->
verticesScaleFactor
=
i
/
50.0
;
params
->
perMap
[
map
->
getName
()]
->
verticesScaleFactor
=
f
;
if
(
view
->
isCurrentView
())
{
...
...
SCHNApps/Plugins/render/src/renderDockTab.cpp
View file @
17bd0a69
...
...
@@ -127,7 +127,7 @@ void RenderDockTab::verticesScaleFactorChanged(int i)
{
View
*
view
=
m_window
->
getCurrentView
();
MapHandlerGen
*
map
=
m_currentParams
->
selectedMap
;
m_plugin
->
changeVerticesScaleFactor
(
view
,
map
,
i
,
true
);
m_plugin
->
changeVerticesScaleFactor
(
view
,
map
,
i
/
50.0
,
true
);
}
}
...
...
SCHNApps/Plugins/renderScalar/forms/renderScalar.ui
View file @
17bd0a69
...
...
@@ -13,11 +13,11 @@
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"Q
VBoxLayout"
name=
"vertical
Layout"
>
<item>
<layout
class=
"Q
GridLayout"
name=
"grid
Layout"
>
<item
row=
"0"
column=
"0"
colspan=
"2"
>
<widget
class=
"QListWidget"
name=
"mapList"
/>
</item>
<item>
<item
row=
"1"
column=
"0"
colspan=
"2"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QLabel"
name=
"label_2"
>
...
...
@@ -38,21 +38,41 @@
</item>
</layout>
</item>
<item>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Scalar
s
:
</string>
<string>
Scalar :
</string>
</property>
</widget>
</item>
<item>
<item
row=
"3"
column=
"0"
colspan=
"2"
>
<widget
class=
"QListWidget"
name=
"list_scalarVBO"
>
<property
name=
"selectionMode"
>
<enum>
QAbstractItemView::MultiSelection
</enum>
</property>
</widget>
</item>
<item>
<item
row=
"4"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Expansion :
</string>
</property>
</widget>
</item>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QSlider"
name=
"slider_expansion"
>
<property
name=
"maximum"
>
<number>
10
</number>
</property>
<property
name=
"pageStep"
>
<number>
1
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item
row=
"5"
column=
"0"
colspan=
"2"
>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
SCHNApps/Plugins/renderScalar/include/renderScalar.h
View file @
17bd0a69
...
...
@@ -21,7 +21,9 @@ struct PerMapParameterSet
PerMapParameterSet
(
MapHandlerGen
*
map
);
Utils
::
VBO
*
positionVBO
;
std
::
vector
<
Utils
::
VBO
*>
scalarVBO
;
Utils
::
VBO
*
scalarVBO
;
float
scalarMin
,
scalarMax
;
int
expansion
;
};
struct
ParameterSet
...
...
@@ -82,7 +84,8 @@ public slots:
void
changeSelectedMap
(
View
*
view
,
MapHandlerGen
*
map
);
void
changePositionVBO
(
View
*
view
,
MapHandlerGen
*
map
,
Utils
::
VBO
*
vbo
,
bool
fromUI
=
false
);
void
changeSelectedScalarsVBO
(
View
*
view
,
MapHandlerGen
*
map
,
const
std
::
vector
<
Utils
::
VBO
*>&
vbos
,
bool
fromUI
=
false
);
void
changeScalarVBO
(
View
*
view
,
MapHandlerGen
*
map
,
Utils
::
VBO
*
vbo
,
bool
fromUI
=
false
);
void
changeExpansion
(
View
*
view
,
MapHandlerGen
*
map
,
int
i
,
bool
fromUI
=
false
);
};
}
// namespace SCHNApps
...
...
SCHNApps/Plugins/renderScalar/include/renderScalarDockTab.h
View file @
17bd0a69
...
...
@@ -33,7 +33,8 @@ public slots:
void
selectedMapChanged
();
void
positionVBOChanged
(
int
index
);
void
selectedScalarsVBOChanged
();
void
selectedScalarVBOChanged
();
void
expansionChanged
(
int
i
);
void
addVBOToList
(
Utils
::
VBO
*
vbo
);
};
...
...
SCHNApps/Plugins/renderScalar/src/renderScalar.cpp
View file @
17bd0a69
...
...
@@ -9,7 +9,9 @@ namespace SCHNApps
{
PerMapParameterSet
::
PerMapParameterSet
(
MapHandlerGen
*
map
)
:
positionVBO
(
NULL
)
positionVBO
(
NULL
),
scalarVBO
(
NULL
),
expansion
(
0
)
{
bool
positionFound
=
false
;
...
...
@@ -58,14 +60,14 @@ void RenderScalarPlugin::redraw(View* view)
foreach
(
MapHandlerGen
*
m
,
maps
)
{
PerMapParameterSet
*
p
=
params
->
perMap
[
m
->
getName
()];
if
(
p
->
positionVBO
!=
NULL
)
if
(
p
->
positionVBO
!=
NULL
&&
p
->
scalarVBO
!=
NULL
)
{
m_scalarShader
->
setAttributePosition
(
p
->
positionVBO
)
;
for
(
std
::
vector
<
Utils
::
VBO
*>::
const_iterator
it
=
p
->
scalarVBO
.
begin
();
it
!=
p
->
scalarVBO
.
end
();
++
it
)
{
m_scalarShader
->
setAttributeScalar
(
*
it
)
;
m
->
draw
(
m_scalarShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
}
m_scalarShader
->
setAttributePosition
(
p
->
positionVBO
);
m_scalarShader
->
setAttributeScalar
(
p
->
scalarVBO
);
m_scalarShader
->
setMinValue
(
p
->
scalarMin
);
m_scalarShader
->
setMaxValue
(
p
->
scalarMax
)
;
m_scalarShader
->
setExpansion
(
p
->
expansion
)
;
m
->
draw
(
m_scalarShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
}
}
}
...
...
@@ -195,10 +197,37 @@ void RenderScalarPlugin::changePositionVBO(View* view, MapHandlerGen* map, Utils
}
}
void
RenderScalarPlugin
::
changeSelectedScalarsVBO
(
View
*
view
,
MapHandlerGen
*
map
,
const
std
::
vector
<
Utils
::
VBO
*>&
vbos
,
bool
fromUI
)
void
RenderScalarPlugin
::
changeScalarVBO
(
View
*
view
,
MapHandlerGen
*
map
,
Utils
::
VBO
*
vbo
,
bool
fromUI
)
{
ParameterSet
*
params
=
h_viewParams
[
view
];
PerMapParameterSet
*
perMap
=
params
->
perMap
[
map
->
getName
()];
perMap
->
scalarVBO
=
vbo
;
if
(
vbo
!=
NULL
)
{
const
VertexAttribute
<
PFP2
::
REAL
>&
attr
=
map
->
getAttribute
<
PFP2
::
REAL
,
VERTEX
>
(
QString
::
fromStdString
(
vbo
->
name
()));
perMap
->
scalarMin
=
1e20
;
perMap
->
scalarMax
=
-
1e20
;
for
(
unsigned
int
i
=
attr
.
begin
();
i
!=
attr
.
end
();
attr
.
next
(
i
))
{
perMap
->
scalarMin
=
attr
[
i
]
<
perMap
->
scalarMin
?
attr
[
i
]
:
perMap
->
scalarMin
;
perMap
->
scalarMax
=
attr
[
i
]
>
perMap
->
scalarMax
?
attr
[
i
]
:
perMap
->
scalarMax
;
}
}
if
(
view
->
isCurrentView
())
{
if
(
!
fromUI
)
m_dockTab
->
refreshUI
(
params
);
view
->
updateGL
();
}
}
void
RenderScalarPlugin
::
changeExpansion
(
View
*
view
,
MapHandlerGen
*
map
,
int
i
,
bool
fromUI
)
{
ParameterSet
*
params
=
h_viewParams
[
view
];
params
->
perMap
[
map
->
getName
()]
->
scalarVBO
=
vbos
;
params
->
perMap
[
map
->
getName
()]
->
expansion
=
i
;
if
(
view
->
isCurrentView
())
{
...
...
SCHNApps/Plugins/renderScalar/src/renderScalarDockTab.cpp
View file @
17bd0a69
...
...
@@ -19,7 +19,8 @@ RenderScalarDockTab::RenderScalarDockTab(Window* w, RenderScalarPlugin* p) :
connect
(
mapList
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedMapChanged
()));
connect
(
combo_positionVBO
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
positionVBOChanged
(
int
)));
connect
(
list_scalarVBO
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedScalarsVBOChanged
()));
connect
(
list_scalarVBO
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedScalarVBOChanged
()));
connect
(
slider_expansion
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
expansionChanged
(
int
)));
}
void
RenderScalarDockTab
::
refreshUI
(
ParameterSet
*
params
)
...
...
@@ -47,6 +48,7 @@ void RenderScalarDockTab::refreshUI(ParameterSet* params)
QList
<
Utils
::
VBO
*>
vbos
=
map
->
getVBOList
();
unsigned
int
j
=
0
;
unsigned
int
k
=
0
;
for
(
int
i
=
0
;
i
<
vbos
.
count
();
++
i
)
{
unsigned
int
dataSize
=
vbos
[
i
]
->
dataSize
();
...
...
@@ -60,10 +62,13 @@ void RenderScalarDockTab::refreshUI(ParameterSet* params)
else
if
(
dataSize
==
1
)
{
list_scalarVBO
->
addItem
(
QString
::
fromStdString
(
vbos
[
i
]
->
name
()));
if
(
std
::
find
(
p
->
scalarVBO
.
begin
(),
p
->
scalarVBO
.
end
(),
vbos
[
i
])
!=
p
->
scalarVBO
.
end
())
list_scalarVBO
->
item
(
j
)
->
setSelected
(
true
);
if
(
vbos
[
i
]
==
p
->
scalarVBO
)
list_scalarVBO
->
item
(
k
)
->
setSelected
(
true
);
++
k
;
}
}
slider_expansion
->
setSliderPosition
(
p
->
expansion
);
}
++
i
;
}
...
...
@@ -91,17 +96,34 @@ void RenderScalarDockTab::positionVBOChanged(int index)
}
}
void
RenderScalarDockTab
::
selectedScalarsVBOChanged
()
void
RenderScalarDockTab
::
selectedScalarVBOChanged
()
{
if
(
!
b_refreshingUI
)
{
View
*
view
=
m_window
->
getCurrentView
();
MapHandlerGen
*
map
=
m_currentParams
->
selectedMap
;
QList
<
QListWidgetItem
*>
selectedItems
=
list_scalarVBO
->
selectedItems
();
if
(
!
selectedItems
.
empty
())
{
foreach
(
QListWidgetItem
*
item
,
selectedItems
)
{
if
(
item
!=
list_scalarVBO
->
currentItem
())
item
->
setSelected
(
false
);
}
m_plugin
->
changeScalarVBO
(
view
,
map
,
map
->
getVBO
(
list_scalarVBO
->
currentItem
()
->
text
()),
true
);
}
else
m_plugin
->
changeScalarVBO
(
view
,
map
,
NULL
,
true
);
}
}
void
RenderScalarDockTab
::
expansionChanged
(
int
i
)
{
if
(
!
b_refreshingUI
)
{
View
*
view
=
m_window
->
getCurrentView
();
MapHandlerGen
*
map
=
m_currentParams
->
selectedMap
;
QList
<
QListWidgetItem
*>
currentItems
=
list_scalarVBO
->
selectedItems
();
std
::
vector
<
Utils
::
VBO
*>
vbos
;
foreach
(
QListWidgetItem
*
item
,
currentItems
)
vbos
.
push_back
(
map
->
getVBO
(
item
->
text
()));
m_plugin
->
changeSelectedScalarsVBO
(
view
,
map
,
vbos
,
true
);
m_plugin
->
changeExpansion
(
view
,
map
,
i
,
true
);
}
}
...
...
SCHNApps/bin/init.py
View file @
17bd0a69
importPlugin
=
schnapps
.
loadPlugin
(
"ImportSurface"
);
renderPlugin
=
schnapps
.
loadPlugin
(
"Render"
);
renderVectorPlugin
=
schnapps
.
loadPlugin
(
"RenderVector"
);
renderScalarPlugin
=
schnapps
.
loadPlugin
(
"RenderScalar"
);
renderTopoSurfacePlugin
=
schnapps
.
loadPlugin
(
"RenderTopoSurface"
);
differentialPropertiesPlugin
=
schnapps
.
loadPlugin
(
"DifferentialProperties"
);
subdivisionPlugin
=
schnapps
.
loadPlugin
(
"SubdivideSurface"
);
surfaceDeformationPlugin
=
schnapps
.
loadPlugin
(
"SurfaceDeformation"
);
obj
=
importPlugin
.
importFromFile
(
"/home/kraemer/Media/Data/surface/midRes/cow_
3
k.off"
);
obj
=
importPlugin
.
importFromFile
(
"/home/kraemer/Media/Data/surface/midRes/cow_
11
k.off"
);
v
=
schnapps
.
getView
(
"view_0"
);
schnapps
.
linkViewAndPlugin
(
v
.
getName
(),
renderPlugin
.
getName
());
schnapps
.
linkViewAndPlugin
(
v
.
getName
(),
renderVectorPlugin
.
getName
());
schnapps
.
linkViewAndPlugin
(
v
.
getName
(),
renderTopoSurfacePlugin
.
getName
());
schnapps
.
linkViewAndPlugin
(
v
.
getName
(),
renderScalarPlugin
.
getName
());
#schnapps.linkViewAndPlugin(v.getName(), renderTopoSurfacePlugin.getName());
schnapps
.
linkViewAndPlugin
(
v
.
getName
(),
surfaceDeformationPlugin
.
getName
());
schnapps
.
linkViewAndMap
(
v
.
getName
(),
obj
.
getName
());
#
differentialPropertiesPlugin.computeNormal(obj.getName());
#
differentialPropertiesPlugin.computeCurvature(obj.getName());
differentialPropertiesPlugin
.
computeNormal
(
obj
.
getName
());
differentialPropertiesPlugin
.
computeCurvature
(
obj
.
getName
());
include/Utils/Shaders/shaderScalarField.frag
View file @
17bd0a69
...
...
@@ -6,9 +6,9 @@ VARYING_FRAG float scalar;
FRAG_OUT_DEF
;
void
main
()
{
float
s
=
scalar
*
3
0
.
0
;
if
(
s
-
floor
(
s
)
<=
0
.
01
)
gl_FragColor
=
vec4
(
0
.
0
);
else
// float s = scalar * 2
0.0;
//
if( s - floor(s) <= 0.01 )
// gl_FragColor = vec4(0.0);
//
else
gl_FragColor
=
vec4
(
color
,
0
.
0
);
}
include/Utils/Shaders/shaderScalarField.h
View file @
17bd0a69
...
...
@@ -42,9 +42,21 @@ protected:
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
CGoGNGLuint
m_uniform_minValue
;
CGoGNGLuint
m_uniform_maxValue
;
CGoGNGLuint
m_uniform_expansion
;
float
m_minValue
;
float
m_maxValue
;
int
m_expansion
;
VBO
*
m_vboPos
;
VBO
*
m_vboScal
;
void
getLocations
();
void
sendParams
();
void
restoreUniformsAttribs
();
public:
...
...
@@ -53,6 +65,12 @@ public:
unsigned
int
setAttributePosition
(
VBO
*
vbo
);
unsigned
int
setAttributeScalar
(
VBO
*
vbo
);
void
setMinValue
(
float
f
);
void
setMaxValue
(
float
f
);
void
setExpansion
(
int
i
);
};
}
// namespace Utils
...
...
include/Utils/Shaders/shaderScalarField.vert
View file @
17bd0a69
...
...
@@ -3,10 +3,39 @@
ATTRIBUTE
vec3
VertexPosition
;
ATTRIBUTE
float
VertexScalar
;
uniform
mat4
ModelViewProjectionMatrix
;
uniform
float
minValue
;
uniform
float
maxValue
;
uniform
int
expansion
;
VARYING_VERT
vec3
color
;
VARYING_VERT
float
scalar
;
INVARIANT_POS
;
#define M_PI 3.1415926535897932384626433832795
float
scale_and_clamp_to_0_1
(
float
x
,
float
min
,
float
max
)
{
float
v
=
(
x
-
min
)
/
(
max
-
min
);
return
v
<
0
.
0
?
0
.
0
:
(
v
>
1
.
0
?
1
.
0
:
v
);
}
float
scale_expand_within_0_1
(
float
x
,
int
n
)
{
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
x
=
(
1
.
0
-
cos
(
M_PI
*
x
))
/
2
.
0
;
for
(
int
i
=
-
1
;
i
>=
n
;
i
--
)
x
=
acos
(
1
.
0
-
2
.
0
*
x
)
/
M_PI
;
return
x
;
}
float
scale_expand_towards_1
(
float
x
,
int
n
)
{
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
x
=
sin
(
x
*
M_PI
/
2
.
0
);
for
(
int
i
=
-
1
;
i
>=
n
;
i
--
)
x
=
asin
(
x
)
*
2
.
0
/
M_PI
;
return
x
;
}
vec3
color_map_blue_white_red
(
float
x
)
{
vec3
c
=
vec3
(
0
);
...
...
@@ -32,6 +61,15 @@ vec3 color_map_blue_white_red(float x)
void
main
()
{
gl_Position
=
ModelViewProjectionMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
color
=
color_map_blue_white_red
(
VertexScalar
);
scalar
=
VertexScalar
;
float
value
=
scale_expand_within_0_1
(
scale_and_clamp_to_0_1
(
VertexScalar
,
minValue
,
maxValue
),
expansion
);
color
=
color_map_blue_white_red
(
value
);
scalar
=
value
;
}
include/Utils/Shaders/shaderVectorPerVertex.h
View file @
17bd0a69
...
...
@@ -26,6 +26,7 @@
#define __CGOGN_SHADER_VPV__
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
namespace
CGoGN
...
...
@@ -34,7 +35,7 @@ namespace CGoGN
namespace
Utils
{
class
ShaderVectorPerVertex
:
public
GLSL
Shader
class
ShaderVectorPerVertex
:
public
Clipping
Shader
{
protected:
// shader sources
...
...
include/Utils/vbo_base.h
View file @
17bd0a69
...
...
@@ -98,7 +98,7 @@ public:
const
std
::
string
&
name
()
const
{
return
m_name
;
}
/**
* get name
* get
type
name
*/
const
std
::
string
&
typeName
()
const
{
return
m_typeName
;
}
...
...
src/Utils/Shaders/shaderScalarField.cpp
View file @
17bd0a69
...
...
@@ -46,6 +46,28 @@ ShaderScalarField::ShaderScalarField()
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
// get and fill uniforms
getLocations
();
sendParams
();
}
void
ShaderScalarField
::
getLocations
()
{
bind
();
*
m_uniform_minValue
=
glGetUniformLocation
(
this
->
program_handler
(),
"minValue"
);
*
m_uniform_maxValue
=
glGetUniformLocation
(
this
->
program_handler
(),
"maxValue"
);
*
m_uniform_expansion
=
glGetUniformLocation
(
this
->
program_handler
(),
"expansion"
);
unbind
();
}
void
ShaderScalarField
::
sendParams
()
{
bind
();
glUniform1f
(
*
m_uniform_minValue
,
m_minValue
);
glUniform1f
(
*
m_uniform_maxValue
,
m_maxValue
);
glUniform1i
(
*
m_uniform_expansion
,
m_expansion
);
unbind
();
}
unsigned
int
ShaderScalarField
::
setAttributePosition
(
VBO
*
vbo
)
...
...
@@ -66,6 +88,30 @@ unsigned int ShaderScalarField::setAttributeScalar(VBO* vbo)
return
id
;
}
void
ShaderScalarField
::
setMinValue
(
float
f
)
{
bind
();
glUniform1f
(
*
m_uniform_minValue
,
f
);
m_minValue
=
f
;
unbind
();
}
void
ShaderScalarField
::
setMaxValue
(
float
f
)
{
bind
();
glUniform1f
(
*
m_uniform_maxValue
,
f
);
m_maxValue
=
f
;
unbind
();
}
void
ShaderScalarField
::
setExpansion
(
int
f
)
{
bind
();
glUniform1i
(
*
m_uniform_expansion
,
f
);
m_expansion
=
f
;
unbind
();
}
void
ShaderScalarField
::
restoreUniformsAttribs
()
{
bind
();
...
...
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