Zoom - Fun and games

Post Reply
kestral
Member
Posts: 96
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Zoom - Fun and games

by kestral » Post

After finding out about the vignetting mod, I thought it would be an interesting exercise to try to get the binocular zoom mode to show a circular view with a black mask around it.

I got something to work with a recent 5.0dev version by hacking the source code. I'm pretty happy with the results, but it has some major limitations and the overlay mask lags a bit behind the zoom.

Image

Image

This exercise did generate a couple of modding questions.

1) Is there any way for a mod to get the player's current screen resolution or aspect ratio? I need this to put an actually circular window on the screen.

For this hack I used minetest.setting_get("screen_w") and "screen_h", which means the server uses a fixed aspect ratio when it starts, independent of the clients' aspect ratios.

2) The 'Z' key is not available from player:get_player_control(). Is there any other way for a mod to detect when this key is pressed and released?

For this hack I added zoom to player:get_player_control(), by doing the following:
  • added KeyType::ZOOM to the keypress_bits data structure in src/game.cpp,
  • added player->control.zoom in src/network/serverpackethandler.cpp, and
  • added control.zoom to PlayerControl &control in src/script/l_object.cpp.
Not sure this sort of feature is currently possible, but I just thought it was an interesting step in my minetest modding education.

Gearhart
Member
Posts: 15
Joined: Wed May 23, 2018 13:40
IRC: Souleater
In-game: Souleater

Re: Zoom - Fun and games

by Gearhart » Post

nice

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests