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
2cd066b1
Commit
2cd066b1
authored
7 years ago
by
JonShard
Browse files
Options
Downloads
Patches
Plain Diff
Moved sun rotation to dayTime value. NOw prints time of day to gui.
parent
31b0108f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
assets/scenes/terrain.yml
+1
-1
1 addition, 1 deletion
assets/scenes/terrain.yml
include/overkill/Input.hpp
+4
-1
4 additions, 1 deletion
include/overkill/Input.hpp
src/Input.cpp
+9
-27
9 additions, 27 deletions
src/Input.cpp
src/main.cpp
+21
-0
21 additions, 0 deletions
src/main.cpp
with
35 additions
and
29 deletions
assets/scenes/terrain.yml
+
1
−
1
View file @
2cd066b1
...
...
@@ -101,7 +101,7 @@ pointlight: blueish
hasSun
:
1
dirlight
:
distantSunLight
rotation
:
0 0
0
angleVelocity
:
0
2
0
0
angleVelocity
:
0 0
0
intensities
:
1 1
1
...
...
This diff is collapsed.
Click to expand it.
include/overkill/Input.hpp
+
4
−
1
View file @
2cd066b1
...
...
@@ -29,7 +29,6 @@ private:
// Member hacked in for the exam. Move to a appropirate classes or containers
// for a good impolementation of the exam task:
static
bool
m_dayMoving
;
static
bool
m_marker
;
public:
...
...
@@ -51,6 +50,10 @@ public:
static
float
m_planeMinSpeed
;
static
float
m_planeMaxSpeed
;
static
bool
m_dayMoving
;
static
float
m_timeOfDay
;
static
float
m_maxDay
;
static
void
OnInputKeyPress
(
GLFWwindow
*
window
,
int
keyCode
,
int
scanCode
,
int
mods
);
static
void
OnInputKeyHold
(
GLFWwindow
*
window
,
int
keyCode
,
int
scanCode
,
int
mods
);
static
void
OnInputKeyUnpress
(
GLFWwindow
*
window
,
int
keyCode
,
int
scanCode
,
int
mods
);
...
...
This diff is collapsed.
Click to expand it.
src/Input.cpp
+
9
−
27
View file @
2cd066b1
...
...
@@ -10,9 +10,11 @@ namespace overkill
bool
Input
::
m_marker
=
false
;
float
Input
::
m_season
=
0
;
float
Input
::
m_maxSeason
=
360
;
float
Input
::
m_planeSpeed
=
0.006
;
float
Input
::
m_planeMinSpeed
=
0.001
;
float
Input
::
m_planeMaxSpeed
=
0.026
;
float
Input
::
m_planeSpeed
=
0.016
;
float
Input
::
m_planeMinSpeed
=
0.004
;
float
Input
::
m_planeMaxSpeed
=
0.056
;
float
Input
::
m_timeOfDay
=
0
;
float
Input
::
m_maxDay
=
24
;
float
Input
::
m_fovy
=
C
::
FOV
;
float
Input
::
m_cursorX
=
0
;
...
...
@@ -91,39 +93,19 @@ namespace overkill
// PRESS 6 TO change daytime to morning.
else
if
(
keyCode
==
GLFW_KEY_6
)
{
Entity
*
sun
=
Scene
::
getEntityByTag
(
"distantSunLight"
);
if
(
sun
==
nullptr
)
{
LOG_ERROR
(
"No Sun in scene by tag distantSunLight"
);
// Terminates app.
}
sun
->
setRotation
(
glm
::
vec3
(
0
,
-
180
,
0
));
m_timeOfDay
=
4
;
}
// PRESS 7 TO change daytime to noon
else
if
(
keyCode
==
GLFW_KEY_7
)
{
Entity
*
sun
=
Scene
::
getEntityByTag
(
"distantSunLight"
);
if
(
sun
==
nullptr
)
{
LOG_ERROR
(
"No Sun in scene by tag distantSunLight"
);
// Terminates app.
}
sun
->
setRotation
(
glm
::
vec3
(
0
,
-
90
,
0
));
m_timeOfDay
=
10
;
}
// PRESS 8 TO change daytime to afternoon
else
if
(
keyCode
==
GLFW_KEY_8
)
{
Entity
*
sun
=
Scene
::
getEntityByTag
(
"distantSunLight"
);
if
(
sun
==
nullptr
)
{
LOG_ERROR
(
"No Sun in scene by tag distantSunLight"
);
// Terminates app.
}
sun
->
setRotation
(
glm
::
vec3
(
0
,
-
45
,
0
));
m_timeOfDay
=
14
;
}
// PRESS 9 TO change daytime to night
else
if
(
keyCode
==
GLFW_KEY_9
)
{
Entity
*
sun
=
Scene
::
getEntityByTag
(
"distantSunLight"
);
if
(
sun
==
nullptr
)
{
LOG_ERROR
(
"No Sun in scene by tag distantSunLight"
);
// Terminates app.
}
sun
->
setRotation
(
glm
::
vec3
(
0
,
0
,
0
));
m_timeOfDay
=
0
;
}
// PRESS 0 TO toggle daytime changing.
else
if
(
keyCode
==
GLFW_KEY_0
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
21
−
0
View file @
2cd066b1
...
...
@@ -119,6 +119,8 @@ int main(int argc, char** args)
"
\n
Frame rate: %d
\n
Last frame dt: %f
\n
Total runtime: %f
\n\n
"
,
oldFrameRate
,
dt
,
t
);
float
seasonSpeed
=
20
;
// Basicly days per second.
float
dayCycleSpeed
=
3
;
// Update season:
if
(
Input
::
m_seasonMoving
)
{
Input
::
m_season
+=
seasonSpeed
*
dt
;
...
...
@@ -139,6 +141,25 @@ int main(int argc, char** args)
program
.
bind
();
GLCall
(
glUniform1f
(
program
.
getUniformLocation
(
"season"
),
Input
::
m_season
));
// Update day:
if
(
Input
::
m_dayMoving
)
{
Input
::
m_timeOfDay
+=
dayCycleSpeed
*
dt
;
}
if
(
Input
::
m_timeOfDay
>
Input
::
m_maxDay
)
{
Input
::
m_timeOfDay
=
0
;
}
ImGui
::
Text
(
"Time of day: %d:%d"
,
int
(
Input
::
m_timeOfDay
),
int
(
Input
::
m_timeOfDay
*
60
)
%
60
);
Entity
*
sun
=
Scene
::
getEntityByTag
(
"distantSunLight"
);
// Rotate sun.
if
(
sun
==
nullptr
)
{
LOG_ERROR
(
"No Sun in scene by tag distantSunLight"
);
// Terminates app.
}
sun
->
setRotation
(
glm
::
vec3
(
0
,
(
Input
::
m_timeOfDay
/
Input
::
m_maxDay
)
*
360
,
0
));
// Plane controls:
Entity
*
plane
=
Scene
::
getEntityByTag
(
"planeCore"
);
if
(
plane
==
nullptr
)
...
...
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