SP and TP cameras
This commit is contained in:
@@ -32,6 +32,7 @@ using std::string;
|
||||
CameraControl::CameraControl(Player* player, const CameraSettings& settings)
|
||||
: player(player),
|
||||
camera(player->camera),
|
||||
currentViewCamera(player->currentViewCamera), //TODO "start view" settings (for custom worlds and minigames, maybe)
|
||||
settings(settings),
|
||||
offset(0.0f, 0.7f, 0.0f) {
|
||||
}
|
||||
@@ -65,7 +66,7 @@ void CameraControl::updateMouse(PlayerInput& input) {
|
||||
camera->rotate(camY, camX, 0);
|
||||
}
|
||||
|
||||
void CameraControl::update(PlayerInput& input, float delta) {
|
||||
void CameraControl::update(PlayerInput& input, float delta, Chunks* chunks) {
|
||||
Hitbox* hitbox = player->hitbox;
|
||||
|
||||
offset = vec3(0.0f, 0.7f, 0.0f);
|
||||
@@ -106,6 +107,25 @@ void CameraControl::update(PlayerInput& input, float delta) {
|
||||
zoomValue *= C_ZOOM;
|
||||
camera->zoom = zoomValue * dt + camera->zoom * (1.0f - dt);
|
||||
}
|
||||
|
||||
if (input.cameraMode) { //ugly but effective
|
||||
if (player->currentViewCamera == camera)
|
||||
player->currentViewCamera = player->SPCamera;
|
||||
else if (player->currentViewCamera == player->SPCamera)
|
||||
player->currentViewCamera = player->TPCamera;
|
||||
else if (player->currentViewCamera == player->TPCamera)
|
||||
player->currentViewCamera = camera;
|
||||
}
|
||||
if (player->currentViewCamera == player->SPCamera) {
|
||||
player->SPCamera->position = chunks->rayCastToObstacle(camera->position, camera->front, 3.0f);
|
||||
player->SPCamera->dir = -camera->dir;
|
||||
player->SPCamera->front = -camera->front;
|
||||
}
|
||||
else if (player->currentViewCamera == player->TPCamera) {
|
||||
player->TPCamera->position = chunks->rayCastToObstacle(camera->position, -camera->front, 3.0f);
|
||||
player->TPCamera->dir = camera->dir;
|
||||
player->TPCamera->front = camera->front;
|
||||
}
|
||||
}
|
||||
|
||||
vec3 PlayerController::selectedBlockPosition;
|
||||
@@ -150,7 +170,7 @@ void PlayerController::updateKeyboard() {
|
||||
input.cheat = Events::active(BIND_MOVE_CHEAT);
|
||||
input.jump = Events::active(BIND_MOVE_JUMP);
|
||||
input.zoom = Events::active(BIND_CAM_ZOOM);
|
||||
|
||||
input.cameraMode = Events::jactive(BIND_CAM_MODE);
|
||||
input.noclip = Events::jactive(BIND_PLAYER_NOCLIP);
|
||||
input.flight = Events::jactive(BIND_PLAYER_FLIGHT);
|
||||
|
||||
@@ -166,7 +186,7 @@ void PlayerController::updateCamera(float delta, bool movement) {
|
||||
if (movement) {
|
||||
camControl.updateMouse(input);
|
||||
}
|
||||
camControl.update(input, delta);
|
||||
camControl.update(input, delta, level->chunks);
|
||||
}
|
||||
|
||||
void PlayerController::resetKeyboard() {
|
||||
|
||||
Reference in New Issue
Block a user