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
e4e5071d
Commit
e4e5071d
authored
2 years ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
Added screen to world coordinates conversion (broken)
parent
f5a3a766
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/camera_arcball.hpp
+25
-0
25 additions, 0 deletions
include/camera_arcball.hpp
with
25 additions
and
0 deletions
include/camera_arcball.hpp
+
25
−
0
View file @
e4e5071d
...
...
@@ -4,6 +4,7 @@
#include
<glm/gtc/matrix_transform.hpp>
#define _USE_MATH_DEFINES
#include
<math.h>
#include
<screendefs.hpp>
class
Camera
{
public:
...
...
@@ -25,6 +26,30 @@ public:
glm
::
vec3
GetViewDir
()
const
{
return
normalize
(
m_lookAt
-
m_eye
);
}
glm
::
vec3
GetRightVector
()
const
{
return
glm
::
normalize
(
glm
::
cross
(
m_lookAt
-
m_eye
,
m_upVector
));
}
glm
::
vec2
GetWorldXyFromMouse
(
float
mx
,
float
my
)
const
{
//calculate point in center of screen
glm
::
vec3
p_eye
=
m_eye
;
glm
::
vec3
p_sCenter
=
m_eye
+
0.1
f
*
GetViewDir
();
glm
::
vec3
curr_up
=
normalize
(
glm
::
cross
(
GetRightVector
(),
GetViewDir
()));
//extent of screen in width and height
//0.1 away from eye, spans 45 (see call to glm::perspective in main.cpp)
//float s_extent_h = 0.2 * std::tan(3.14159265 * 45 / 180.);
float
s_extent_h
=
0.2
f
*
std
::
tan
(
3.14159265
*
45
/
180.
/
2.
);
float
s_extent_w
=
WIDTH
/
static_cast
<
float
>
(
HEIGHT
)
*
s_extent_h
;
glm
::
vec3
p_mouse
=
p_sCenter
+
(
mx
-
0.5
f
)
*
s_extent_w
*
0.5
f
*
GetRightVector
()
+
(
my
-
0.5
f
)
*
s_extent_h
*
0.5
f
*
curr_up
;
//TODO: Potentially needs (1-my) instead of my
glm
::
vec3
r
=
glm
::
normalize
(
p_mouse
-
p_eye
);
if
(
std
::
abs
(
r
.
z
)
>
0.00001
)
{
float
t
=
-
p_mouse
.
z
/
r
.
z
;
glm
::
vec3
res_p
=
p_mouse
+
t
*
r
;
return
glm
::
vec2
(
res_p
.
x
,
res_p
.
y
);
}
else
{
return
glm
::
vec2
(
std
::
copysign
(
r
.
x
,
999999.
),
std
::
copysign
(
r
.
y
,
999999.
));
}
}
void
SetCameraView
(
glm
::
vec3
eye
,
glm
::
vec3
lookat
,
glm
::
vec3
up
)
{
m_eye
=
std
::
move
(
eye
);
m_lookAt
=
std
::
move
(
lookat
);
...
...
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