Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Home exam in IMT2531 - Graphics programming.
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
Model registry
Operate
Environments
Monitor
Incidents
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jone Skaara
Home exam in IMT2531 - Graphics programming.
Commits
fd6a6035
Commit
fd6a6035
authored
May 12, 2018
by
JonShard
Browse files
Options
Downloads
Patches
Plain Diff
Added comma, period as navigation keys. Added other input keys.
parent
7e1d5750
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/overkill/Input.hpp
+2
-2
2 additions, 2 deletions
include/overkill/Input.hpp
src/Input.cpp
+72
-31
72 additions, 31 deletions
src/Input.cpp
with
74 additions
and
33 deletions
include/overkill/Input.hpp
+
2
−
2
View file @
fd6a6035
...
...
@@ -18,7 +18,7 @@ namespace overkill
enum
NavigationKey
{
I
,
J
,
K
,
L
,
Y
,
H
,
W
,
A
,
S
,
D
,
N
,
M
I
,
J
,
K
,
L
,
Y
,
H
,
W
,
A
,
S
,
D
,
N
,
M
,
comma
,
period
};
class
Input
...
...
@@ -36,7 +36,7 @@ public:
static
float
m_camRotY
;
static
float
m_camPanX
;
// Factor camera uses for its position/orientation.
static
float
m_camPanY
;
static
bool
m_navKeyPressed
[
1
2
];
// Which navigation keys are pressed. WASD-QE keys.
static
bool
m_navKeyPressed
[
1
4
];
// Which navigation keys are pressed. WASD-QE keys.
static
void
OnInputKeyPress
(
GLFWwindow
*
window
,
int
keyCode
,
int
scanCode
,
int
mods
);
static
void
OnInputKeyHold
(
GLFWwindow
*
window
,
int
keyCode
,
int
scanCode
,
int
mods
);
...
...
This diff is collapsed.
Click to expand it.
src/Input.cpp
+
72
−
31
View file @
fd6a6035
...
...
@@ -15,7 +15,7 @@ namespace overkill
float
Input
::
m_camPanY
=
0
;
bool
Input
::
m_navKeyPressed
[]
=
{
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
};
// Which navigation keys are pressed. WASD-QE keys.
void
Input
::
OnInputKeyPress
(
GLFWwindow
*
window
,
int
keyCode
,
int
/*scanCode*/
,
int
/*
mods
*/
)
void
Input
::
OnInputKeyPress
(
GLFWwindow
*
window
,
int
keyCode
,
int
/*scanCode*/
,
int
mods
)
{
// LOG_DEBUG("Pressing %i, as char: %c\n", keyCode, char(keyCode));
if
(
keyCode
==
GLFW_KEY_ESCAPE
)
...
...
@@ -26,6 +26,45 @@ namespace overkill
else
if
(
keyCode
==
GLFW_KEY_O
)
{
// Terrain lines.
}
// PRESS SPACE to toggle camera mode
else
if
(
keyCode
==
GLFW_KEY_SPACE
)
{
EntityCamera
*
cam
=
(
EntityCamera
*
)
Scene
::
getActiveCamera
();
if
(
cam
!=
nullptr
)
{
cam
->
cycleMode
();
LOG_INFO
(
"Cycled camera mode."
);
}
else
{
LOG_WARN
(
"Main camera not set. The scene most likely loaded incorrectly."
)
}
}
// PRESS TAB to cycle through camera
else
if
(
keyCode
==
GLFW_KEY_TAB
)
{
Scene
::
cycleCameras
();
LOG_INFO
(
"Cycled cameras."
);
}
// PRESS SHIFT + 1 TO RELOAD ShaderSystem
else
if
(
keyCode
==
GLFW_KEY_1
&&
mods
==
GLFW_MOD_SHIFT
)
{
ShaderSystem
::
reload
();
}
// PRESS SHIFT + 2 TO RELOAD MaterialSystem
else
if
(
keyCode
==
GLFW_KEY_2
&&
mods
==
GLFW_MOD_SHIFT
)
{
MaterialSystem
::
reload
();
Init
::
loadOBJFiles
(
false
,
true
,
false
);
}
// PRESS SHIFT + 3 TO RELOAD ModelSystem
else
if
(
keyCode
==
GLFW_KEY_3
&&
mods
==
GLFW_MOD_SHIFT
)
{
ModelSystem
::
reload
();
Init
::
loadOBJFiles
(
false
,
false
,
true
);
}
// PRESS SHIFT + 4 TO RELOAD Scene
else
if
(
keyCode
==
GLFW_KEY_4
&&
mods
==
GLFW_MOD_SHIFT
)
{
Scene
::
reload
();
}
// PRESS 1 TO Set season to spring.
...
...
@@ -44,45 +83,33 @@ namespace overkill
else
if
(
keyCode
==
GLFW_KEY_4
)
{
// Winter.
}
// PRESS 5 TO Set toggle season changing.
else
if
(
keyCode
==
GLFW_KEY_5
)
{
// toggle season change
}
// PRESS 6 TO change daytime to morning.
else
if
(
keyCode
==
GLFW_KEY_6
)
{
// PRESS 0 TO RELOAD Scene
else
if
(
keyCode
==
GLFW_KEY_0
)
{
Scene
::
reload
();
}
// PRESS 7 TO
RELOAD ShaderSystem
// PRESS 7 TO
change daytime to noon
else
if
(
keyCode
==
GLFW_KEY_7
)
{
ShaderSystem
::
reload
();
}
// PRESS 8 TO
RELOAD MaterialSystem
// PRESS 8 TO
change daytime to afternoon
else
if
(
keyCode
==
GLFW_KEY_8
)
{
MaterialSystem
::
reload
();
Init
::
loadOBJFiles
(
false
,
true
,
false
);
}
// PRESS 9 TO
RELOAD ModelSystem
// PRESS 9 TO
change daytime to night
else
if
(
keyCode
==
GLFW_KEY_9
)
{
ModelSystem
::
reload
();
Init
::
loadOBJFiles
(
false
,
false
,
true
);
}
// PRESS SPACE to toggle camera mode
else
if
(
keyCode
==
GLFW_KEY_SPACE
)
{
EntityCamera
*
cam
=
(
EntityCamera
*
)
Scene
::
getActiveCamera
();
if
(
cam
!=
nullptr
)
{
cam
->
cycleMode
();
LOG_INFO
(
"Cycled camera mode."
);
}
else
{
LOG_WARN
(
"Main camera not set. The scene most likely loaded incorrectly."
)
}
// PRESS 0 TO toggle daytime changing.
else
if
(
keyCode
==
GLFW_KEY_0
)
{
}
// PRESS TAB to cycle through camera
else
if
(
keyCode
==
GLFW_KEY_TAB
)
{
Scene
::
cycleCameras
();
LOG_INFO
(
"Cycled cameras."
);
}
// Navigation keys input:
switch
(
keyCode
)
...
...
@@ -99,6 +126,12 @@ namespace overkill
case
GLFW_KEY_D
:
m_navKeyPressed
[
D
]
=
true
;
break
;
case
GLFW_KEY_COMMA
:
m_navKeyPressed
[
comma
]
=
true
;
break
;
case
GLFW_KEY_PERIOD
:
m_navKeyPressed
[
period
]
=
true
;
break
;
case
GLFW_KEY_I
:
m_navKeyPressed
[
I
]
=
true
;
break
;
...
...
@@ -136,7 +169,9 @@ namespace overkill
// LOG_DEBUG("Unpressed %i, as char: %c\n", keyCode, char(keyCode));
switch
(
keyCode
)
{
case
GLFW_KEY_W
:
m_navKeyPressed
[
W
]
=
false
;
break
;
...
...
@@ -149,6 +184,12 @@ namespace overkill
case
GLFW_KEY_D
:
m_navKeyPressed
[
D
]
=
false
;
break
;
case
GLFW_KEY_COMMA
:
m_navKeyPressed
[
comma
]
=
false
;
break
;
case
GLFW_KEY_PERIOD
:
m_navKeyPressed
[
period
]
=
false
;
break
;
case
GLFW_KEY_I
:
m_navKeyPressed
[
I
]
=
false
;
break
;
...
...
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