Render laser beams cleanly (no ugly cross-section)
parent
ab6d82e164
commit
4212cbb008
|
@ -51,6 +51,48 @@ end
|
|||
for i=1, 64 do
|
||||
local dirstring = lzr_laser.dec2bin(i, 6)
|
||||
local dirs = lzr_laser.dirstring_to_dirs(dirstring)
|
||||
|
||||
-- Check which textures to render.
|
||||
-- This looks complicated but serves a simple purpose: To prevent the laser cross-section
|
||||
-- to render, so there is a "clean" laser beam look.
|
||||
-- This works because lzr_laser_laser_nocenter.png.
|
||||
local axes = 0
|
||||
local axes_active = {x=false,y=false,z=false}
|
||||
for a=1,3 do
|
||||
if dirs[a] ~= 0 or dirs[a+3] ~= 0 then
|
||||
axes = axes + 1
|
||||
if a == 1 then
|
||||
axes_active.x = true
|
||||
elseif a == 2 then
|
||||
axes_active.y = true
|
||||
elseif a == 3 then
|
||||
axes_active.z = true
|
||||
end
|
||||
end
|
||||
end
|
||||
local tex
|
||||
if axes == 1 then
|
||||
if axes_active.x then
|
||||
tex = { "lzr_laser_laser.png", "lzr_laser_laser.png", "blank.png", "blank.png", "lzr_laser_laser.png" }
|
||||
elseif axes_active.y then
|
||||
tex = { "blank.png", "blank.png", "lzr_laser_laser.png" }
|
||||
else
|
||||
tex = { "lzr_laser_laser.png", "lzr_laser_laser.png", "lzr_laser_laser.png", "lzr_laser_laser.png", "blank.png" }
|
||||
end
|
||||
elseif axes == 2 then
|
||||
if axes_active.x == false then
|
||||
tex = { "lzr_laser_laser_nocenter.png", "lzr_laser_laser_nocenter.png", "lzr_laser_laser.png", "lzr_laser_laser.png", "lzr_laser_laser_nocenter.png" }
|
||||
elseif axes_active.y == false then
|
||||
tex = { "lzr_laser_laser.png", "lzr_laser_laser.png", "lzr_laser_laser_nocenter.png" }
|
||||
else
|
||||
tex = { "lzr_laser_laser_nocenter.png", "lzr_laser_laser_nocenter.png", "lzr_laser_laser_nocenter.png", "lzr_laser_laser_nocenter.png", "lzr_laser_laser.png" }
|
||||
end
|
||||
|
||||
elseif axes == 3 then
|
||||
tex = { "lzr_laser_laser_nocenter.png" }
|
||||
end
|
||||
|
||||
-- Finally register the laser
|
||||
minetest.register_node("lzr_laser:laser_"..dirstring, {
|
||||
description = S("Laser (@1)", dirstring),
|
||||
paramtype = "light",
|
||||
|
@ -58,7 +100,7 @@ for i=1, 64 do
|
|||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
use_texture_alpha = "blend",
|
||||
tiles = { "lzr_laser_laser.png", },
|
||||
tiles = tex,
|
||||
pointable = false,
|
||||
buildable_to = true,
|
||||
node_box = {
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 155 B |
Binary file not shown.
After Width: | Height: | Size: 160 B |
Loading…
Reference in New Issue