Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Nicolas Pope
ftl
Commits
033b8ceb
Commit
033b8ceb
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Improve camera controls
parent
7a579ee3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#11094
passed
5 years ago
Stage: all
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/reconstruct/src/main.cpp
+13
-8
13 additions, 8 deletions
applications/reconstruct/src/main.cpp
with
13 additions
and
8 deletions
applications/reconstruct/src/main.cpp
+
13
−
8
View file @
033b8ceb
...
...
@@ -470,7 +470,7 @@ static void run() {
Eigen
::
Vector3f
eye
(
0.0
f
,
0.0
f
,
0.0
f
);
Eigen
::
Vector3f
centre
(
0.0
f
,
0.0
f
,
-
4.0
f
);
Eigen
::
Vector3f
up
(
0
,
1.0
f
,
0
);
Eigen
::
Vector3f
lookPoint
(
0.0
f
,
1
.0
f
,
-
4.0
f
);
Eigen
::
Vector3f
lookPoint
(
0.0
f
,
0
.0
f
,
-
4.0
f
);
Eigen
::
Matrix4f
viewPose
;
float
lerpSpeed
=
0.4
f
;
...
...
@@ -478,22 +478,27 @@ static void run() {
display_merged
.
onKey
([
&
paused
,
&
eye
,
&
centre
](
int
key
)
{
LOG
(
INFO
)
<<
"Key = "
<<
key
;
if
(
key
==
32
)
paused
=
!
paused
;
else
if
(
key
==
81
)
eye
[
0
]
+=
0.02
f
;
else
if
(
key
==
83
)
eye
[
0
]
-=
0.02
f
;
else
if
(
key
==
84
)
eye
[
2
]
+=
0.02
f
;
else
if
(
key
==
82
)
eye
[
2
]
-=
0.02
f
;
else
if
(
key
==
81
||
key
==
83
)
{
// TODO Should rotate around lookAt object, but requires correct depth
Eigen
::
Quaternion
<
float
>
q
;
q
=
Eigen
::
AngleAxis
<
float
>
((
key
==
81
)
?
0.01
f
:
-
0.01
f
,
Eigen
::
Vector3f
(
0.0
,
1.0
f
,
0.0
f
));
eye
=
(
q
*
(
eye
-
centre
))
+
centre
;
}
else
if
(
key
==
84
||
key
==
82
)
{
float
scalar
=
(
key
==
84
)
?
0.99
f
:
1.01
f
;
eye
=
((
eye
-
centre
)
*
scalar
)
+
centre
;
}
});
// TODO(Nick) Calculate "camera" properties of viewport.
MouseAction
mouseact
=
[
&
inputs
,
&
lookPoint
,
&
viewPose
](
int
event
,
int
ux
,
int
uy
,
int
)
{
LOG
(
INFO
)
<<
"Mouse "
<<
ux
<<
","
<<
uy
;
if
(
event
==
1
)
{
// click
const
float
x
=
((
float
)
ux
-
inputs
[
0
].
params
.
m
x
)
/
inputs
[
0
].
params
.
fx
;
const
float
y
=
((
float
)
uy
-
inputs
[
0
].
params
.
m
y
)
/
inputs
[
0
].
params
.
fy
;
const
float
x
=
((
float
)
ux
-
inputs
[
0
].
params
.
m
_imageWidth
/
2
)
/
inputs
[
0
].
params
.
fx
;
const
float
y
=
((
float
)
uy
-
inputs
[
0
].
params
.
m
_imageHeight
/
2
)
/
inputs
[
0
].
params
.
fy
;
const
float
depth
=
-
4.0
f
;
Eigen
::
Vector4f
camPos
(
x
*
depth
,
y
*
depth
,
depth
,
1.0
);
Eigen
::
Vector4f
worldPos
=
viewPose
*
camPos
;
lookPoint
=
Eigen
::
Vector3f
(
worldPos
[
0
],
worldPos
[
1
],
worldPos
[
2
]);
LOG
(
INFO
)
<<
"Look at: "
<<
worldPos
;
}
};
::
setMouseAction
(
"Image"
,
mouseact
);
...
...
@@ -545,7 +550,7 @@ static void run() {
// Set virtual camera transformation matrix
//Eigen::Affine3f transform(Eigen::Translation3f(cam_x,0.0f,cam_z));
centre
+=
(
lookPoint
-
centre
)
*
(
lerpSpeed
*
0.1
f
);
viewPose
=
lookAt
<
float
>
(
eye
,
centre
,
up
);
// transform.matrix();
viewPose
=
lookAt
<
float
>
(
eye
,
centre
,
up
)
.
inverse
()
;
// transform.matrix();
// Call GPU renderer and download result into OpenCV mat
rays
.
render
(
scene
.
getHashData
(),
scene
.
getHashParams
(),
inputs
[
0
].
gpu
,
viewPose
);
...
...
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