Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
masterarbeit-kai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Philipp Adolf
masterarbeit-kai
Commits
f3db4192
Commit
f3db4192
authored
Jul 10, 2017
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move to camera
parent
642265e6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
56 deletions
+96
-56
Camera.cpp
3_PointCloud/Camera.cpp
+74
-1
Camera.h
3_PointCloud/Camera.h
+16
-3
main.cpp
3_PointCloud/main.cpp
+6
-52
No files found.
3_PointCloud/Camera.cpp
View file @
f3db4192
...
...
@@ -17,7 +17,7 @@ Camera::Camera(vec3 position) : Camera(position, vec3(0.0f, 0.0f, 0.0f)) {
Camera
::
Camera
(
vec3
position
,
vec3
lookAt
)
{
// rotation = glm::gtx::quaternion::angleAxis(degrees(45), RotationAxis
);
cameraMove
=
glm
::
vec3
(
0.0
f
,
0.0
f
,
0.0
f
);
this
->
position
=
position
;
vec3
dir
=
normalize
(
lookAt
-
position
);
verticalAngle
=
asinf
(
dir
.
y
);
...
...
@@ -63,3 +63,76 @@ void Camera::applyMatrix()
gluLookAt
(
position
.
x
,
position
.
y
,
position
.
z
,
p
.
x
,
p
.
y
,
p
.
z
,
up
.
x
,
up
.
y
,
up
.
z
);
}
void
Camera
::
mouseButton
(
int
button
,
int
state
,
int
x
,
int
y
)
{
lastX
=
x
;
lastY
=
y
;
}
void
Camera
::
mouseMove
(
int
x
,
int
y
)
{
rotate
(
lastX
-
x
,
lastY
-
y
);
lastX
=
x
;
lastY
=
y
;
}
void
Camera
::
keyPressed
(
unsigned
char
key
,
int
x
,
int
y
)
{
switch
(
key
)
{
case
'w'
:
cameraMove
+=
(
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
's'
:
cameraMove
+=
(
glm
::
vec3
(
-
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
'a'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
-
1.0
f
));
break
;
case
'd'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
1.0
f
));
break
;
case
'q'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
break
;
case
'e'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
-
1.0
f
,
0.0
f
));
break
;
}
}
void
Camera
::
keyReleased
(
unsigned
char
key
,
int
x
,
int
y
)
{
switch
(
key
)
{
case
'w'
:
cameraMove
-=
(
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
's'
:
cameraMove
-=
(
glm
::
vec3
(
-
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
'a'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
-
1.0
f
));
break
;
case
'd'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
1.0
f
));
break
;
case
'q'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
break
;
case
'e'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
-
1.0
f
,
0.0
f
));
break
;
}
}
void
Camera
::
tick
()
{
/*
int timeSinceStart = glutGet(GLUT_ELAPSED_TIME);
int deltaTime = timeSinceStart - oldTimeSinceStart;
oldTimeSinceStart = timeSinceStart;
*/
move
(
cameraMove
);
}
3_PointCloud/Camera.h
View file @
f3db4192
...
...
@@ -11,7 +11,7 @@
class
Camera
{
p
ublic
:
p
rivate
:
glm
::
vec3
direction
;
glm
::
vec3
position
;
glm
::
vec3
up
;
...
...
@@ -22,13 +22,26 @@ public:
float
horizontalAngle
=
(
float
)
-
M_PI
/
2
;
float
verticalAngle
=
(
float
)
-
M_PI
/
8
;
void
move
(
glm
::
vec3
relative
);
void
rotate
(
int
dx
,
int
dy
);
//glut tracking
glm
::
vec3
cameraMove
;
int
lastX
,
lastY
;
public
:
Camera
();
Camera
(
glm
::
vec3
position
);
Camera
(
glm
::
vec3
position
,
glm
::
vec3
lookAt
);
~
Camera
();
void
move
(
glm
::
vec3
relative
);
void
rotate
(
int
dx
,
int
dy
);
void
keyPressed
(
unsigned
char
key
,
int
x
,
int
y
);
void
keyReleased
(
unsigned
char
key
,
int
x
,
int
y
);
void
mouseButton
(
int
button
,
int
state
,
int
x
,
int
y
);
void
mouseMove
(
int
x
,
int
y
);
void
tick
();
void
applyMatrix
();;
...
...
3_PointCloud/main.cpp
View file @
f3db4192
...
...
@@ -47,7 +47,6 @@ bool frameValidPoints[width*height];
std
::
vector
<
glm
::
vec3
>
points
;
std
::
vector
<
unsigned
char
>
colors
;
// Kinect Variables
IKinectSensor
*
sensor
;
// Kinect sensor
IMultiSourceFrameReader
*
reader
;
// Kinect data source
...
...
@@ -56,7 +55,7 @@ ICoordinateMapper* mapper; // Converts between depth, color, and 3d coor
SteamTracking
*
steamTracking
=
nullptr
;
glm
::
mat4x4
*
currentControlerPos
=
nullptr
;
Camera
mainCam
;
glm
::
vec3
cameraMove
;
static
bool
writeFile
=
false
;
static
bool
captureFrame
=
false
;
...
...
@@ -277,7 +276,7 @@ void drawElementArray(drawData data, GLenum mode) {
void
mainRenderLoop
()
{
steamTracking
->
processEvents
();
mainCam
.
move
(
cameraMove
);
mainCam
.
tick
(
);
//get controler pos
...
...
@@ -344,6 +343,7 @@ void mainRenderLoop() {
void
keyPressed
(
unsigned
char
key
,
int
x
,
int
y
)
{
mainCam
.
keyPressed
(
key
,
x
,
y
);
switch
(
key
)
{
case
'y'
:
std
::
cout
<<
"Capturing Frame Keyboard"
<<
std
::
endl
;
...
...
@@ -353,24 +353,6 @@ void keyPressed(unsigned char key, int x, int y)
std
::
cout
<<
"writing File"
<<
std
::
endl
;
writeFile
=
true
;
break
;
case
'w'
:
cameraMove
+=
(
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
's'
:
cameraMove
+=
(
glm
::
vec3
(
-
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
'a'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
-
1.0
f
));
break
;
case
'd'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
1.0
f
));
break
;
case
'q'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
break
;
case
'e'
:
cameraMove
+=
(
glm
::
vec3
(
0.0
f
,
-
1.0
f
,
0.0
f
));
break
;
case
27
:
// Escape key
exit
(
0
);
break
;
...
...
@@ -383,42 +365,15 @@ void keyPressed(unsigned char key, int x, int y)
}
void
keyReleased
(
unsigned
char
key
,
int
x
,
int
y
)
{
switch
(
key
)
{
case
'w'
:
cameraMove
-=
(
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
's'
:
cameraMove
-=
(
glm
::
vec3
(
-
1.0
f
,
0.0
f
,
0.0
f
));
break
;
case
'a'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
-
1.0
f
));
break
;
case
'd'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
1.0
f
));
break
;
case
'q'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
break
;
case
'e'
:
cameraMove
-=
(
glm
::
vec3
(
0.0
f
,
-
1.0
f
,
0.0
f
));
break
;
default:
break
;
}
mainCam
.
keyReleased
(
key
,
x
,
y
);
}
void
mouseButton
(
int
button
,
int
state
,
int
x
,
int
y
)
{
lastX
=
x
;
lastY
=
y
;
mainCam
.
mouseButton
(
button
,
state
,
x
,
y
);
}
void
mouseMove
(
int
x
,
int
y
)
{
mainCam
.
rotate
(
lastX
-
x
,
lastY
-
y
);
lastX
=
x
;
lastY
=
y
;
mainCam
.
mouseMove
(
x
,
y
);
}
void
captureNextFrame
(
vr
::
VREvent_t
event
)
...
...
@@ -431,7 +386,6 @@ void captureNextFrame(vr::VREvent_t event)
int
main
(
int
argc
,
char
*
argv
[])
{
cameraMove
=
glm
::
vec3
(
0.0
f
,
0.0
f
,
0.0
f
);
std
::
cout
<<
"Starting Kinect VR Point Cloud creator
\n
"
;
if
(
!
init
(
argc
,
argv
))
return
1
;
if
(
!
initKinect
())
return
1
;
...
...
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