F2 toggles world rendering.
F3 toggles the debug overlay.
F4 toggles audio.
+F5 toggles camera mode.
Controls are interpreted by scancode, meaning you don't have to break your
fingers when you're on an AZERTY. WSAD will be ZSQD there and the above
void SetVideo(bool) override;
void SetHUD(bool) override;
void SetDebug(bool) override;
+ void NextCamera() override;
void Exit() override;
void OnLineSubmit(const std::string &) override;
#include "../app/Environment.hpp"
#include "../app/init.hpp"
+#include "../geometry/distance.hpp"
#include "../model/Model.hpp"
#include "../io/WorldSave.hpp"
#include "../world/ChunkIndex.hpp"
}
}
+void InteractiveState::NextCamera() {
+ if (iszero(master.GetEnv().viewport.CameraOffset())) {
+ master.GetEnv().viewport.OffsetCamera(glm::vec3(0.0f, 0.0f, -5.0f));
+ } else {
+ master.GetEnv().viewport.OffsetCamera(glm::vec3(0.0f, 0.0f, 0.0f));
+ }
+}
+
void InteractiveState::Exit() {
save.Write(player);
master.Quit();
void MoveCursor(const glm::vec3 &) noexcept;
const glm::mat4 &Cursor() const noexcept { return cursor; }
+ void OffsetCamera(const glm::vec3 &o) noexcept { cam_offset = o; }
+ const glm::vec3 &CameraOffset() const noexcept { return cam_offset; }
+
BlockLighting &ChunkProgram() noexcept;
DirectionalLighting &EntityProgram() noexcept;
DirectionalLighting &HUDProgram() noexcept;
glm::mat4 cursor;
+ glm::vec3 cam_offset;
+
BlockLighting chunk_prog;
DirectionalLighting entity_prog;
PlainColor color_prog;
: cam()
, canv()
, cursor(1.0f)
+, cam_offset(0.0f)
, chunk_prog()
, entity_prog()
, sky_prog()
void Viewport::WorldPosition(const glm::mat4 &t) noexcept {
- const glm::vec3 offset(0.0f, 0.0f, 0.0f);
- //const glm::vec3 offset(0.0f, 0.0f, -5.0f);
- cam.View(glm::translate(glm::inverse(t), glm::vec3(t * glm::vec4(offset, 0.0f))));
+ cam.View(glm::translate(glm::inverse(t), glm::vec3(t * glm::vec4(cam_offset, 0.0f))));
ChunkProgram().SetView(cam.View());
sky_prog.Activate();
SkyBoxProgram().SetView(cam.View());
#include "../app/Config.hpp"
#include "../app/Environment.hpp"
#include "../app/init.hpp"
+#include "../geometry/distance.hpp"
#include "../io/WorldSave.hpp"
#include <SDL.h>
}
}
+void MasterState::NextCamera() {
+ if (iszero(env.viewport.CameraOffset())) {
+ env.viewport.OffsetCamera(glm::vec3(0.0f, 0.0f, -5.0f));
+ } else {
+ env.viewport.OffsetCamera(glm::vec3(0.0f, 0.0f, 0.0f));
+ }
+}
+
void MasterState::Exit() {
save.Write(player);
env.state.Switch(&unload);
void SetVideo(bool) override;
void SetHUD(bool) override;
void SetDebug(bool) override;
+ void NextCamera() override;
void Exit() override;
void OnLineSubmit(const std::string &) override;
struct ClientController {
+ /// enable or disable audio output
virtual void SetAudio(bool) = 0;
+ /// enable or disable world rendering
virtual void SetVideo(bool) = 0;
+ /// enable or disable HUD rendering
virtual void SetHUD(bool) = 0;
+ /// enable or disable debug rendering
virtual void SetDebug(bool) = 0;
+ /// change camera mode of world rendering
+ virtual void NextCamera() = 0;
+
+ /// terminate the application
virtual void Exit() = 0;
};
TOGGLE_VIDEO,
TOGGLE_HUD,
TOGGLE_DEBUG,
+ CAMERA_NEXT,
EXIT,
};
break;
case Keymap::TOGGLE_AUDIO:
- config.audio.enabled = !config.audio.enabled;
- client_ctrl.SetAudio(config.audio.enabled);
+ client_ctrl.SetAudio(!config.audio.enabled);
break;
case Keymap::TOGGLE_VIDEO:
- config.video.world = !config.video.world;
- client_ctrl.SetVideo(config.video.world);
+ client_ctrl.SetVideo(!config.video.world);
break;
case Keymap::TOGGLE_HUD:
- config.video.hud = !config.video.hud;
- client_ctrl.SetHUD(config.video.hud);
+ client_ctrl.SetHUD(!config.video.hud);
break;
case Keymap::TOGGLE_DEBUG:
- config.video.debug = !config.video.debug;
- client_ctrl.SetDebug(config.video.debug);
+ client_ctrl.SetDebug(!config.video.debug);
+ break;
+ case Keymap::CAMERA_NEXT:
+ client_ctrl.NextCamera();
break;
default:
Map(SDL_SCANCODE_F2, TOGGLE_VIDEO);
Map(SDL_SCANCODE_F3, TOGGLE_DEBUG);
Map(SDL_SCANCODE_F4, TOGGLE_AUDIO);
+ Map(SDL_SCANCODE_F5, CAMERA_NEXT);
Map(SDL_SCANCODE_ESCAPE, EXIT);
}
{ "toggle_video", Keymap::TOGGLE_VIDEO },
{ "toggle_hud", Keymap::TOGGLE_HUD },
{ "toggle_debug", Keymap::TOGGLE_DEBUG },
+ { "camera_next", Keymap::CAMERA_NEXT },
{ "exit", Keymap::EXIT },
};