Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nt1100 analyser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engeler
nt1100 analyser
Commits
52602b8e
Commit
52602b8e
authored
2 years ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
Added framebuffer, surface height lookup
parent
0dad947a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/heightmap.hpp
+5
-0
5 additions, 0 deletions
include/heightmap.hpp
src/heightmap.cpp
+27
-2
27 additions, 2 deletions
src/heightmap.cpp
with
32 additions
and
2 deletions
include/heightmap.hpp
+
5
−
0
View file @
52602b8e
...
...
@@ -4,6 +4,7 @@
#include
<glad/glad.h>
#include
<SDL.h>
#include
<colorscheme.hpp>
#include
<framebuffer.hpp>
#include
<string>
#include
<vector>
...
...
@@ -22,6 +23,9 @@ public:
virtual
void
upload
()
override
;
virtual
void
unload
()
override
;
//get deformation height in um at screen coordinate
float
getSurfaceHeight
(
unsigned
x
,
unsigned
y
,
glm
::
mat4
projection
,
glm
::
mat4
view
,
glm
::
mat4
model
);
private:
//filename of origin
std
::
string
_filename
;
...
...
@@ -40,4 +44,5 @@ private:
float
_scale
;
GLuint
_numElements
;
std
::
shared_ptr
<
Colorscheme
>
_colorscheme_ptr
;
std
::
shared_ptr
<
Framebuffer
>
_framebuffer_ptr
;
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/heightmap.cpp
+
27
−
2
View file @
52602b8e
...
...
@@ -57,6 +57,7 @@ Heightmap::Heightmap(std::string filename): _filename(filename) {
_minZ
=
min
(
_data
,
2
,
3
);
_maxZ
=
max
(
_data
,
2
,
3
);
_zRangeUm
=
(
_maxZ
-
_minZ
)
/
10.
;
//in um
std
::
cout
<<
"Identified z range: "
<<
_zRangeUm
<<
" um ("
<<
_minZ
<<
" - "
<<
_maxZ
<<
")"
<<
std
::
endl
;
/*Throw if _zRange is less than 1 A (i.e. it's probably 0)*/
if
(
_zRangeUm
<
1e-4
)
{
throw
Nt1100_exception
(
"Heightmap::Heightmap(std::string): z range is too close to zero ("
+
std
::
to_string
(
_zRangeUm
)
+
")"
);
...
...
@@ -71,8 +72,8 @@ Heightmap::Heightmap(std::string filename): _filename(filename) {
}
}
//recalculate _minZ, maxZ
_minZ
=
min
(
_data
,
2
,
3
);
_maxZ
=
max
(
_data
,
2
,
3
);
_minZ
=
min
(
_data
,
2
,
3
);
//should be 0
_maxZ
=
max
(
_data
,
2
,
3
);
//should be 1
/*Initialize Renderer Infrastructure*/
glGenBuffers
(
1
,
&
_vbo
);
...
...
@@ -150,6 +151,9 @@ Heightmap::Heightmap(std::string filename): _filename(filename) {
_shader_ptr
->
setFloat
(
"bad_z_value"
,
static_cast
<
float
>
(
BAD_Z_VALUE
));
_shader_ptr
->
setInt
(
"colorscheme"
,
0
);
_shader_ptr
->
unuse
();
/*Setup Framebuffer*/
_framebuffer_ptr
=
std
::
make_shared
<
Framebuffer
>
();
}
else
{
throw
Nt1100_exception
(
"Heightmap::Heightmap(std::string): File "
+
filename
+
" contents are empty."
);
...
...
@@ -183,4 +187,25 @@ void Heightmap::unload() {
bool
Heightmap
::
is
(
const
std
::
string
filename
)
const
{
return
_filename
==
filename
;
}
float
Heightmap
::
getSurfaceHeight
(
unsigned
x
,
unsigned
y
,
glm
::
mat4
projection
,
glm
::
mat4
view
,
glm
::
mat4
model
)
{
_framebuffer_ptr
->
bind
();
glClearColor
(
0.
f
,
0.
f
,
0.
f
,
1.0
f
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
draw
(
projection
,
view
,
model
);
auto
color
=
_framebuffer_ptr
->
getPixel
(
x
,
y
);
float
defo_um
=
_colorscheme_ptr
->
color2value
(
color
[
0
],
color
[
1
],
color
[
2
]);
_framebuffer_ptr
->
unbind
();
if
(
defo_um
!=
-
1.
)
{
return
defo_um
*
_zRangeUm
;
}
else
{
return
-
1.
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment