2014-09-26 16:48:46 +00:00
|
|
|
local stencils = {}
|
|
|
|
|
|
|
|
function stencils.shadow(geometry, bodies)
|
|
|
|
return function()
|
2014-10-22 02:48:19 +00:00
|
|
|
--cast shadows
|
2014-09-26 16:48:46 +00:00
|
|
|
for i = 1,#geometry do
|
|
|
|
if geometry[i].alpha == 1.0 then
|
|
|
|
love.graphics.polygon("fill", unpack(geometry[i]))
|
|
|
|
end
|
|
|
|
end
|
2014-10-22 02:48:19 +00:00
|
|
|
-- underneath shadows
|
2014-09-26 16:48:46 +00:00
|
|
|
for i = 1, #bodies do
|
|
|
|
if not bodies[i].castsNoShadow then
|
2014-10-22 02:48:19 +00:00
|
|
|
bodies[i]:shadowStencil()
|
2014-09-26 16:48:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-10-22 02:48:19 +00:00
|
|
|
function stencils.colorShadow(bodies)
|
2014-09-26 16:48:46 +00:00
|
|
|
return function()
|
|
|
|
for i = 1, #bodies do
|
2014-10-22 02:48:19 +00:00
|
|
|
if bodies[i].shine and
|
|
|
|
(bodies[i].glowStrength == 0.0 or
|
|
|
|
(bodies[i].type == "image" and not bodies[i].normal))
|
|
|
|
then
|
|
|
|
bodies[i]:shadowStencil()
|
2014-09-26 16:48:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return stencils
|