Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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
Vulkan2021
VkCV Framework
Commits
2568c8c2
Verified
Commit
2568c8c2
authored
3 years ago
by
Josch Morgenstern
Browse files
Options
Downloads
Patches
Plain Diff
[
#42
] remove window and camera from TrackballCameraController
parent
0f9d1e87
No related branches found
No related tags found
1 merge request
!35
Resolve "Kamera - Trackballkamera"
Pipeline
#25699
passed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/camera/include/vkcv/camera/TrackballCameraController.hpp
+8
-8
8 additions, 8 deletions
.../camera/include/vkcv/camera/TrackballCameraController.hpp
modules/camera/src/vkcv/camera/TrackballCameraController.cpp
+26
-34
26 additions, 34 deletions
modules/camera/src/vkcv/camera/TrackballCameraController.cpp
with
34 additions
and
42 deletions
modules/camera/include/vkcv/camera/TrackballCameraController.hpp
+
8
−
8
View file @
2568c8c2
...
...
@@ -20,13 +20,13 @@ namespace vkcv {
* @brief Updates the position of the camera.
* @return The updated camera position.
*/
glm
::
vec3
updatePosition
();
glm
::
vec3
updatePosition
(
Camera
&
camera
);
/**
* @brief Updates the view matrix of the camera.
* @return The updated view matrix of the camera.
*/
glm
::
mat4
updateView
();
glm
::
mat4
updateView
(
Camera
&
camera
);
/**
* @brief Updates the current radius in respect to the @p offset.
...
...
@@ -58,13 +58,13 @@ namespace vkcv {
* @param[in] xOffset The offset added to the yaw value.
* @param[in] yOffset The offset added to the pitch value.
*/
void
panView
(
double
xOffset
,
double
yOffset
);
void
panView
(
double
xOffset
,
double
yOffset
,
Camera
&
camera
);
/**
* @brief Updates the camera object in respect to @p deltaTime.
* @param deltaTime The time that has passed since last update.
*/
void
updateCamera
(
double
deltaTime
);
void
updateCamera
(
double
deltaTime
,
Camera
&
camera
);
/**
* @brief A callback function for key events. Currently, the trackball camera does not support camera movement.
...
...
@@ -74,7 +74,7 @@ namespace vkcv {
* @param[in] action The key action.
* @param[in] mods The modifier bits.
*/
void
keyCallback
(
int
key
,
int
scancode
,
int
action
,
int
mods
);
void
keyCallback
(
int
key
,
int
scancode
,
int
action
,
int
mods
,
Camera
&
camera
);
/**
* @brief A callback function for mouse scrolling events. Currently, this leads to changes in the field of view
...
...
@@ -82,7 +82,7 @@ namespace vkcv {
* @param[in] offsetX The offset in horizontal direction.
* @param[in] offsetY The offset in vertical direction.
*/
void
scrollCallback
(
double
offsetX
,
double
offsetY
);
void
scrollCallback
(
double
offsetX
,
double
offsetY
,
Camera
&
camera
);
/**
* @brief A callback function for mouse movement events. Currently, this leads to panning the view of the
...
...
@@ -90,7 +90,7 @@ namespace vkcv {
* @param[in] x The horizontal mouse position.
* @param[in] y The vertical mouse position.
*/
void
mouseMoveCallback
(
double
x
,
double
y
);
void
mouseMoveCallback
(
double
x
offset
,
double
y
offset
,
Camera
&
camera
);
/**
* @brief A callback function for mouse button events. Currently, the right mouse button enables panning the
...
...
@@ -99,7 +99,7 @@ namespace vkcv {
* @param[in] action The button action.
* @param[in] mods The modifier bits.
*/
void
mouseButtonCallback
(
int
button
,
int
action
,
int
mods
);
void
mouseButtonCallback
(
int
button
,
int
action
,
int
mods
,
Camera
&
camera
);
};
...
...
This diff is collapsed.
Click to expand it.
modules/camera/src/vkcv/camera/TrackballCameraController.cpp
+
26
−
34
View file @
2568c8c2
...
...
@@ -6,7 +6,7 @@ namespace vkcv {
TrackballCameraController
::
TrackballCameraController
()
{
m_rotationActive
=
false
;
m_radius
=
3.0
f
;
m_radius
=
3.0
f
;
// TODO: Needs to be removed. Radius should only depend on camera
m_cameraSpeed
=
2.5
f
;
m_scrollSensitivity
=
0.2
f
;
}
...
...
@@ -20,31 +20,31 @@ namespace vkcv {
}
}
void
TrackballCameraController
::
panView
(
double
xOffset
,
double
yOffset
)
{
void
TrackballCameraController
::
panView
(
double
xOffset
,
double
yOffset
,
Camera
&
camera
)
{
// handle yaw rotation
float
yaw
=
m_
camera
->
getYaw
()
+
xOffset
*
m_cameraSpeed
;
float
yaw
=
camera
.
getYaw
()
+
xOffset
*
m_cameraSpeed
;
if
(
yaw
<
0.0
f
)
{
yaw
+=
360.0
f
;
}
else
if
(
yaw
>
360.0
f
)
{
yaw
-=
360.0
f
;
}
m_
camera
->
setYaw
(
yaw
);
camera
.
setYaw
(
yaw
);
// handle pitch rotation
float
pitch
=
m_
camera
->
getPitch
()
+
yOffset
*
m_cameraSpeed
;
float
pitch
=
camera
.
getPitch
()
+
yOffset
*
m_cameraSpeed
;
if
(
pitch
<
0.0
f
)
{
pitch
+=
360.0
f
;
}
else
if
(
pitch
>
360.0
f
)
{
pitch
-=
360.0
f
;
}
m_
camera
->
setPitch
(
pitch
);
camera
.
setPitch
(
pitch
);
}
glm
::
vec3
TrackballCameraController
::
updatePosition
()
{
float
yaw
=
m_
camera
->
getYaw
();
float
pitch
=
m_
camera
->
getPitch
();
glm
::
vec3
TrackballCameraController
::
updatePosition
(
Camera
&
camera
)
{
float
yaw
=
camera
.
getYaw
();
float
pitch
=
camera
.
getPitch
();
glm
::
vec3
yAxis
=
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
);
glm
::
vec3
xAxis
=
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
);
...
...
@@ -52,44 +52,38 @@ namespace vkcv {
glm
::
mat4
rotationX
=
glm
::
rotate
(
rotationY
,
glm
::
radians
(
pitch
),
xAxis
);
glm
::
vec3
translate
=
glm
::
vec3
(
0.0
f
,
0.0
f
,
m_radius
);
translate
=
glm
::
vec3
(
rotationX
*
glm
::
vec4
(
translate
,
0.0
f
));
glm
::
vec3
center
=
m_
camera
->
getCenter
();
glm
::
vec3
center
=
camera
.
getCenter
();
glm
::
vec3
position
=
center
+
translate
;
m_
camera
->
setPosition
(
position
);
camera
.
setPosition
(
position
);
glm
::
vec3
up
=
glm
::
vec3
(
rotationX
*
glm
::
vec4
(
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
),
0.0
f
));
m_
camera
->
setUp
(
up
);
camera
.
setUp
(
up
);
return
position
;
}
glm
::
mat4
TrackballCameraController
::
updateView
()
{
updatePosition
();
glm
::
vec3
position
=
m_
camera
->
getPosition
();
glm
::
vec3
center
=
m_
camera
->
getCenter
();
glm
::
vec3
up
=
m_
camera
->
getUp
();
m_
camera
->
lookAt
(
position
,
center
,
up
);
return
m_
camera
->
getView
();
glm
::
mat4
TrackballCameraController
::
updateView
(
Camera
&
camera
)
{
updatePosition
(
camera
);
glm
::
vec3
position
=
camera
.
getPosition
();
glm
::
vec3
center
=
camera
.
getCenter
();
glm
::
vec3
up
=
camera
.
getUp
();
camera
.
lookAt
(
position
,
center
,
up
);
return
camera
.
getView
();
}
void
TrackballCameraController
::
updateRadius
(
double
offset
)
{
setRadius
(
m_radius
-
offset
*
m_scrollSensitivity
);
}
void
TrackballCameraController
::
updateCamera
(
double
deltaTime
)
{
updateView
();
void
TrackballCameraController
::
updateCamera
(
double
deltaTime
,
Camera
&
camera
)
{
updateView
(
camera
);
}
void
TrackballCameraController
::
keyCallback
(
int
key
,
int
scancode
,
int
action
,
int
mods
)
{}
void
TrackballCameraController
::
keyCallback
(
int
key
,
int
scancode
,
int
action
,
int
mods
,
Camera
&
camera
)
{}
void
TrackballCameraController
::
scrollCallback
(
double
offsetX
,
double
offsetY
)
{
void
TrackballCameraController
::
scrollCallback
(
double
offsetX
,
double
offsetY
,
Camera
&
camera
)
{
updateRadius
(
offsetY
);
}
void
TrackballCameraController
::
mouseMoveCallback
(
double
x
,
double
y
)
{
auto
xoffset
=
static_cast
<
float
>
(
x
-
m_lastX
);
auto
yoffset
=
static_cast
<
float
>
(
y
-
m_lastY
);
m_lastX
=
x
;
m_lastY
=
y
;
void
TrackballCameraController
::
mouseMoveCallback
(
double
xoffset
,
double
yoffset
,
Camera
&
camera
)
{
if
(
!
m_rotationActive
){
return
;
}
...
...
@@ -98,16 +92,14 @@ namespace vkcv {
xoffset
*=
sensitivity
;
yoffset
*=
sensitivity
;
panView
(
xoffset
,
yoffset
);
panView
(
xoffset
,
yoffset
,
camera
);
}
void
TrackballCameraController
::
mouseButtonCallback
(
int
button
,
int
action
,
int
mods
)
{
void
TrackballCameraController
::
mouseButtonCallback
(
int
button
,
int
action
,
int
mods
,
Camera
&
camera
)
{
if
(
button
==
GLFW_MOUSE_BUTTON_2
&&
m_rotationActive
==
false
&&
action
==
GLFW_PRESS
){
glfwSetInputMode
(
m_window
->
getWindow
(),
GLFW_CURSOR
,
GLFW_CURSOR_DISABLED
);
m_rotationActive
=
true
;
}
else
if
(
button
==
GLFW_MOUSE_BUTTON_2
&&
m_rotationActive
==
true
&&
action
==
GLFW_RELEASE
){
glfwSetInputMode
(
m_window
->
getWindow
(),
GLFW_CURSOR
,
GLFW_CURSOR_NORMAL
);
m_rotationActive
=
false
;
}
}
...
...
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