use texture rotation to increase angular res and use less textures

This commit is contained in:
whosit 2021-05-23 01:18:24 +03:00
parent bbc137b18b
commit 1184f125ad
18 changed files with 12 additions and 6 deletions

View File

@ -87,22 +87,28 @@ local function show_hud_waypoint(player, point_pos, name, icon_name)
local size_x = 9
local size_y = 16
local angle_steps = 8 -- number pre-rotated textures
local angle_steps = 9 -- number pre-rotated textures
-- vector pointing towards point_pos
local v = vector.subtract(point_pos, player:get_pos())
-- angle relative to player position
local angle = math.atan2(v.x, v.z)
-- snap/round to increments and convert to degrees
local angle_snap = round(angle/(2*math.pi) * angle_steps) * (360 / angle_steps) % 360
local angle_quad = math.floor(angle/(2*math.pi) * 4) * (360 / 4) % 360
local angle_quad_map = {[0] = "I", [90] = "R270", [180] = "R180", [270] = "R90"}
local angle_snap = round(angle/(2*math.pi) * angle_steps * 4) * (360 / (angle_steps * 4)) % 360
local angle_quad_step = (angle_snap - angle_quad) % 90
local arrow_texture = ("arrow_%03d.png"):format(angle_snap)
local arrow_texture = ("arrow_%03d.png"):format(angle_quad_step)
-- TODO it's possible to color the texture: use it to make waypoints have different colors
--local arrow_texture = arrow_texture .. "^[multiply:#11FFFF"
local hud_id3 = player:hud_add({
hud_elem_type = "compass",
size = {x=-size_x,y=-size_y},
--scale = {x=0.5,y=0.5}, -- unused
text = arrow_texture,
text = arrow_texture .. "^[transform" .. angle_quad_map[angle_quad],
--alignment = {x=1,y=1}, -- top-left?
alignment = {x=100/size_x,y=100/size_y*0.7}, -- above cursor
--offset = {x=0,y=0}, -- in pixels?

View File

@ -1,9 +1,9 @@
input="compass_arrow.svg"
size=64
angles=8
angles=9
for rot in `seq 0 $((angles - 1))`; do
#inkscape -w ${size} -h ${size} compass_arrow.svg -o "$out"
angle=$((360 / angles * rot))
angle=$((90 / angles * rot))
out="textures/arrow_"$(printf "%03d" $angle)".png"
convert -density 384 -background none -distort SRT $angle -gravity center -resize ${size}x${size} "$input" "$out"
done

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

After

Width:  |  Height:  |  Size: 1005 B

BIN
textures/arrow_010.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
textures/arrow_020.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
textures/arrow_030.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
textures/arrow_040.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
textures/arrow_050.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
textures/arrow_060.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
textures/arrow_070.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
textures/arrow_080.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB