1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add third person view

This commit is contained in:
BlockMen 2014-01-08 13:47:53 +01:00
parent e149d1ad9a
commit a1db9242ec
19 changed files with 270 additions and 22 deletions

View file

@ -977,6 +977,8 @@ bool nodePlacementPrediction(Client &client,
return false;
}
bool is_third_person = false;
static void show_chat_menu(FormspecFormSource* current_formspec,
TextDest* current_textdest, IWritableTextureSource* tsrc,
IrrlichtDevice * device, Client* client, std::string text)
@ -1470,6 +1472,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
f32 camera_yaw = 0; // "right/left"
f32 camera_pitch = 0; // "up/down"
int current_camera_mode = CAMERA_MODE_FIRST; // start in first-person view
/*
Clouds
*/
@ -2251,7 +2255,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
else{
s32 dx = input->getMousePos().X - displaycenter.X;
s32 dy = input->getMousePos().Y - displaycenter.Y;
if(invert_mouse)
if(invert_mouse || player->camera_mode == CAMERA_MODE_THIRD_FRONT)
dy = -dy;
//infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
@ -2659,9 +2663,21 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
LocalPlayer* player = client.getEnv().getLocalPlayer();
float full_punch_interval = playeritem_toolcap.full_punch_interval;
float tool_reload_ratio = time_from_last_punch / full_punch_interval;
if(input->wasKeyDown(getKeySetting("keymap_camera_mode"))) {
if (current_camera_mode == CAMERA_MODE_FIRST)
current_camera_mode = CAMERA_MODE_THIRD;
else if (current_camera_mode == CAMERA_MODE_THIRD)
current_camera_mode = CAMERA_MODE_THIRD_FRONT;
else
current_camera_mode = CAMERA_MODE_FIRST;
}
player->camera_mode = current_camera_mode;
tool_reload_ratio = MYMIN(tool_reload_ratio, 1.0);
camera.update(player, dtime, busytime, screensize,
tool_reload_ratio);
camera.update(player, dtime, busytime, screensize, tool_reload_ratio,
current_camera_mode, client.getEnv());
camera.step(dtime);
v3f player_position = player->getPosition();
@ -2717,6 +2733,10 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
core::line3d<f32> shootline(camera_position,
camera_position + camera_direction * BS * (d+1));
// prevent player pointing anything in front-view
if (current_camera_mode == CAMERA_MODE_THIRD_FRONT)
shootline = core::line3d<f32>(0,0,0,0,0,0);
ClientActiveObject *selected_object = NULL;
PointedThing pointed = getPointedThing(
@ -3507,7 +3527,9 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/*
Wielded tool
*/
if(show_hud && (player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE))
if(show_hud &&
(player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE) &&
current_camera_mode < CAMERA_MODE_THIRD)
{
// Warning: This clears the Z buffer.
camera.drawWieldedTool();