Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Dario Seyb
edge-of-space
Commits
7ea2a7d5
Commit
7ea2a7d5
authored
Jan 15, 2016
by
David Gilbert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New movement mode: Press F2 for the old one, F3 for the new one. Spacebar to stop instantly.
Also fixed the error in the moonshader.
parent
fd666247
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
18 deletions
+62
-18
data/shader/planets/moon_texture.glsl
data/shader/planets/moon_texture.glsl
+2
-1
src/game/include/engine/scene/PlayerSystem.hpp
src/game/include/engine/scene/PlayerSystem.hpp
+11
-1
src/game/src/engine/scene/OrbitalSimulationSystem.cpp
src/game/src/engine/scene/OrbitalSimulationSystem.cpp
+1
-0
src/game/src/engine/scene/PlayerSystem.cpp
src/game/src/engine/scene/PlayerSystem.cpp
+47
-15
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
+1
-1
No files found.
data/shader/planets/moon_texture.glsl
View file @
7ea2a7d5
#pragma import "../noise/noise3d.glsl"
#define M_PI 3.1415926535897932384626433832795
#define SAMPLE_ANGLE__NORMAL_VECTOR 0.0005
float
getHeight
(
vec3
normalizedPosInModelspace
)
{
return
(
fbm_3d
(
normalizedPosInModelspace
,
4
,
80
.)
/
2
.
+
2
*
fbm_3d
(
normalizedPosInModelspace
,
2
,
1
.
25
));
...
...
@@ -10,7 +11,7 @@ vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNorma
return
vec4
(.
1
,
.
1
,
.
1
,
.
1
);
}
vec3
getDisplacedPosition_modelspace
(
vec3
normalizedPosInModelspace
,
vec3
normalizedNormal
)
{
vec3
texture_
getDisplacedPosition_modelspace
(
vec3
normalizedPosInModelspace
,
vec3
normalizedNormal
)
{
float
noiseValue
=
getHeight
(
normalizedPosInModelspace
);
vec3
newPosition
=
normalizedPosInModelspace
+
normalizedNormal
*
0
.
00
8
*
noiseValue
;
return
newPosition
;
...
...
src/game/include/engine/scene/PlayerSystem.hpp
View file @
7ea2a7d5
...
...
@@ -39,7 +39,16 @@ private:
Camera
::
Handle
camera
;
bool
m_keyState
[
SDL_NUM_SCANCODES
];
double
speed
=
5
;
bool
movementMode
=
1
;
double
speed
=
10
;
double
velocity
=
0
;
double
acceleration
=
2
;
double
mass
=
1000.0
;
double
momentum
=
0
;
glm
::
dmat4
directionRot
;
void
handleKeyboard
(
KeyboardEvent
e
);
void
handleMouse
(
MouseEvent
e
);
...
...
@@ -96,6 +105,7 @@ public:
cameraTransform
->
rotation
=
r
;
cockpitCamTransform
->
rotation
=
r
;
skyboxCamTransform
->
rotation
=
r
;
directionRot
=
r
;
}
void
attachToParent
(
Entity
e
)
{
...
...
src/game/src/engine/scene/OrbitalSimulationSystem.cpp
View file @
7ea2a7d5
...
...
@@ -272,6 +272,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
return
planetEntity
;
}
void
OrbitalSimulationSystem
::
showTrajectories
()
{
for
(
Entity
e
:
trajectories
)
{
e
.
component
<
Drawable
>
()
->
visible
=
!
e
.
component
<
Drawable
>
()
->
visible
;
...
...
src/game/src/engine/scene/PlayerSystem.cpp
View file @
7ea2a7d5
...
...
@@ -276,6 +276,8 @@ bool PlayerSystem::startup() {
camera
=
m_mainCamera
.
assign
<
Camera
>
(
50
,
1
,
20000000
);
camera
->
isMain
=
true
;
cameraTransform
->
position
=
glm
::
dvec3
(
0
,
0
,
1000
);
directionRot
=
cameraTransform
->
rotation
;
m_cockpitCamera
=
m_scene
->
create
();
cockpitCamTransform
=
m_cockpitCamera
.
assign
<
Transform
>
();
...
...
@@ -361,8 +363,8 @@ void PlayerSystem::handleMouse(MouseEvent e) {
glm
::
dvec3
worldCoords
=
glm
::
unProject
(
winCoords
,
glm
::
inverse
(
model
)
,
proj
,
v
);
std
::
cout
<<
worldCoords
.
x
<<
" "
<<
worldCoords
.
y
<<
" "
<<
worldCoords
.
z
<<
"
\n
"
;
for
(
Entity
e
:
m_scene
->
entities_with_components
<
Transform
,
Planet
>
())
{
/*
for (Entity e : m_scene->entities_with_components<Transform, Planet>()) {
if (e.component<Planet>()->name == "Moon") {
continue;
}
...
...
@@ -372,7 +374,9 @@ void PlayerSystem::handleMouse(MouseEvent e) {
attachToParent(e);
setPosition(glm::dvec3(e.component<Transform>()->scale.x + 100, 0, 0));
}
}
*/
}
break
;
case
SDL_MOUSEMOTION
:
{
...
...
@@ -385,6 +389,10 @@ void PlayerSystem::handleMouse(MouseEvent e) {
cameraTransform
->
rotation
=
glm
::
rotate
(
cameraTransform
->
rotation
,
mouseMove
.
x
*
0.001
,
up
);
cameraTransform
->
rotation
=
glm
::
rotate
(
cameraTransform
->
rotation
,
mouseMove
.
y
*
0.001
,
glm
::
dvec3
(
1
,
0
,
0
));
skyboxCamTransform
->
rotation
=
cameraTransform
->
rotation
;
auto
directionUp
=
rotate
(
camera
->
worldUp
,
glm
::
inverse
(
directionRot
));
directionRot
=
glm
::
rotate
(
directionRot
,
mouseMove
.
x
*
0.001
,
up
);
directionRot
=
glm
::
rotate
(
directionRot
,
mouseMove
.
y
*
0.001
,
glm
::
dvec3
(
1
,
0
,
0
));
}
break
;
}
...
...
@@ -401,19 +409,18 @@ void PlayerSystem::update(float dt) {
glm
::
dvec3
moveDir
(
0
);
glm
::
dvec2
rotDir
(
0
);
double
speedMod
=
1.0
;
// Move the camera based on WASD keyboard input
// Opt Movement mode:
// Move the camera based on WASD keyboard input
if
(
!
ImGui
::
GetIO
().
WantCaptureKeyboard
)
{
if
(
m_keyState
[
SDL_SCANCODE_W
])
moveDir
-=
glm
::
dvec3
(
0
,
0
,
1
);
if
(
m_keyState
[
SDL_SCANCODE_S
])
moveDir
+=
glm
::
dvec3
(
0
,
0
,
1
);
if
(
m_keyState
[
SDL_SCANCODE_A
])
moveDir
-=
glm
::
dvec3
(
1
,
0
,
0
);
if
(
m_keyState
[
SDL_SCANCODE_D
])
moveDir
+=
glm
::
dvec3
(
1
,
0
,
0
);
if
(
m_keyState
[
SDL_SCANCODE_SPACE
])
{
moveDir
+=
glm
::
dvec3
(
0
,
1
,
0
);
}
if
(
m_keyState
[
SDL_SCANCODE_LSHIFT
])
speedMod
=
100
;
if
(
m_keyState
[
SDL_SCANCODE_LCTRL
])
speedMod
=
10000
;
if
(
m_keyState
[
SDL_SCANCODE_F2
])
movementMode
=
0
;
if
(
m_keyState
[
SDL_SCANCODE_F3
])
movementMode
=
1
;
// Handle cockpit camera:
if
(
m_keyState
[
SDL_SCANCODE_LEFT
])
rotDir
+=
glm
::
dvec2
(
1
,
0
);
if
(
m_keyState
[
SDL_SCANCODE_RIGHT
])
rotDir
-=
glm
::
dvec2
(
1
,
0
);
if
(
m_keyState
[
SDL_SCANCODE_UP
])
rotDir
+=
glm
::
dvec2
(
0
,
1
);
...
...
@@ -423,13 +430,36 @@ void PlayerSystem::update(float dt) {
cockpitCamTransform
->
rotation
=
glm
::
rotate
(
cockpitCamTransform
->
rotation
,
rotDir
.
x
*
0.05
,
up
);
cockpitCamTransform
->
rotation
=
glm
::
rotate
(
cockpitCamTransform
->
rotation
,
rotDir
.
y
*
0.05
,
glm
::
dvec3
(
1
,
0
,
0
));
// Rotate the camera based on the mouse movement
cameraTransform
->
rotation
=
glm
::
rotate
(
cameraTransform
->
rotation
,
rotDir
.
x
*
0.05
,
up
);
cameraTransform
->
rotation
=
glm
::
rotate
(
cameraTransform
->
rotation
,
rotDir
.
y
*
0.05
,
glm
::
dvec3
(
1
,
0
,
0
));
if
(
moveDir
.
x
!=
0
||
moveDir
.
y
||
moveDir
.
z
!=
0
)
{
moveDir
=
rotate
(
glm
::
normalize
(
moveDir
),
cameraTransform
->
rotation
);
cameraTransform
->
position
+=
moveDir
*
static_cast
<
double
>
(
dt
)
*
speed
*
speedMod
;
if
(
movementMode
==
0
)
{
if
(
m_keyState
[
SDL_SCANCODE_W
])
moveDir
-=
glm
::
dvec3
(
0
,
0
,
1
);
if
(
m_keyState
[
SDL_SCANCODE_S
])
moveDir
+=
glm
::
dvec3
(
0
,
0
,
1
);
if
(
m_keyState
[
SDL_SCANCODE_A
])
moveDir
-=
glm
::
dvec3
(
1
,
0
,
0
);
if
(
m_keyState
[
SDL_SCANCODE_D
])
moveDir
+=
glm
::
dvec3
(
1
,
0
,
0
);
if
(
m_keyState
[
SDL_SCANCODE_SPACE
])
{
moveDir
+=
glm
::
dvec3
(
0
,
1
,
0
);
}
if
(
m_keyState
[
SDL_SCANCODE_LSHIFT
])
speedMod
=
100
;
if
(
m_keyState
[
SDL_SCANCODE_LCTRL
])
speedMod
=
10000
;
// TODO:
velocity
=
0
;
if
(
moveDir
.
x
!=
0
||
moveDir
.
y
||
moveDir
.
z
!=
0
)
{
moveDir
=
rotate
(
glm
::
normalize
(
moveDir
),
cameraTransform
->
rotation
);
cameraTransform
->
position
+=
moveDir
*
static_cast
<
double
>
(
dt
)
*
speed
*
speedMod
;
}
}
else
{
if
(
m_keyState
[
SDL_SCANCODE_LSHIFT
])
speedMod
=
2
;
if
(
m_keyState
[
SDL_SCANCODE_W
])
velocity
+=
acceleration
*
speedMod
;
//if (m_keyState[SDL_SCANCODE_S]) moveDir += glm::dvec3(0, 0, 1);
//if (m_keyState[SDL_SCANCODE_A]) moveDir -= glm::dvec3(1, 0, 0);
if
(
m_keyState
[
SDL_SCANCODE_S
])
velocity
-=
acceleration
*
speedMod
;
if
(
m_keyState
[
SDL_SCANCODE_SPACE
])
velocity
=
0
;
cameraTransform
->
position
+=
glm
::
normalize
(
glm
::
vec3
(
directionRot
*
glm
::
vec4
{
0
,
0
,
-
1
,
0
}))
*
static_cast
<
double
>
(
dt
)
*
velocity
;
}
}
...
...
@@ -450,6 +480,7 @@ void PlayerSystem::update(float dt) {
if
(
dist
>
r
*
2.5
)
{
cameraTransform
->
position
+=
cameraTransform
->
parent
->
position
;
cameraTransform
->
parent
=
cameraTransform
->
parent
->
parent
;
camera
->
worldUp
=
glm
::
vec3
(
0
,
1
,
0
);
//parentEntity = sun; //fixme
}
...
...
@@ -496,6 +527,7 @@ void PlayerSystem::update(float dt) {
cameraTransform
->
position
=
cameraTransform
->
position
-
transform
->
position
;
cameraTransform
->
lastPosition
=
cameraTransform
->
lastPosition
-
transform
->
lastPosition
;
cameraTransform
->
parent
=
transform
;
velocity
=
0
;
parentEntity
=
p
;
break
;
}
...
...
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
View file @
7ea2a7d5
...
...
@@ -299,7 +299,7 @@ void AtmosphereTestScene::switchToMainScene() {
m_renderer
->
getRenderPassTarget
(
"Console"
_sh
),
nullptr
,
nullptr
,
skyboxMaterial
.
prog
,
false
,
RenderQueue
::
OPAQUE
,
GL_BACK
},
0
,
cockpitPassId
);
console
.
assign
<
Transform
>
();
auto
consoleTransform
=
console
.
assign
<
Transform
>
();
soundTrack
=
m_audio
->
createSound
(
"chipzel - Spectra - 01 Spectra.mp3"
,
SoundMode
::
MODE_2D
);
consoleSoundSource
=
console
.
assign
<
SoundSource
>
(
soundTrack
);
...
...
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