mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
Fix body shadow
This commit is contained in:
parent
9d48adb46b
commit
600d02ca63
14
lib/body.lua
14
lib/body.lua
@ -382,10 +382,6 @@ end
|
|||||||
|
|
||||||
-- set glass color
|
-- set glass color
|
||||||
function body:setColor(r, g, b)
|
function body:setColor(r, g, b)
|
||||||
if r > 1 then r = r / 255 end
|
|
||||||
if g > 1 then g = r / 255 end
|
|
||||||
if b > 1 then b = r / 255 end
|
|
||||||
|
|
||||||
self.red = r
|
self.red = r
|
||||||
self.green = g
|
self.green = g
|
||||||
self.blue = b
|
self.blue = b
|
||||||
@ -689,7 +685,7 @@ function body:drawShadow(light)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setColor(self.red, self.green, self.blue, self.alpha)
|
love.graphics.setColor(self.red / 255, self.green / 255, self.blue / 255, self.alpha / 255)
|
||||||
if self.shadowType == "polygon" then
|
if self.shadowType == "polygon" then
|
||||||
self:drawPolyShadow(light)
|
self:drawPolyShadow(light)
|
||||||
elseif self.shadowType == "circle" then
|
elseif self.shadowType == "circle" then
|
||||||
@ -779,10 +775,10 @@ function body:drawImageShadow(light)
|
|||||||
local shadowY = (length * math.cos(shadowRotation) + 1.0) * shadowStartY
|
local shadowY = (length * math.cos(shadowRotation) + 1.0) * shadowStartY
|
||||||
|
|
||||||
self.shadowMesh:setVertices({
|
self.shadowMesh:setVertices({
|
||||||
{shadowX, shadowY, 0, 0, self.red, self.green, self.blue, self.alpha},
|
{shadowX, shadowY, 0, 0, self.red / 255, self.green / 255, self.blue / 255, self.alpha / 255},
|
||||||
{shadowX + self.imgWidth, shadowY, 1, 0, self.red, self.green, self.blue, self.alpha},
|
{shadowX + self.imgWidth, shadowY, 1, 0, self.red / 255, self.green / 255, self.blue / 255, self.alpha / 255},
|
||||||
{self.imgWidth, shadowStartY, 1, 1, self.red, self.green, self.blue, self.alpha},
|
{self.imgWidth, shadowStartY, 1, 1, self.red / 255, self.green / 255, self.blue / 255, self.alpha / 255},
|
||||||
{0, shadowStartY, 0, 1, self.red, self.green, self.blue, self.alpha}
|
{0, shadowStartY, 0, 1, self.red / 255, self.green / 255, self.blue / 255, self.alpha / 255}
|
||||||
})
|
})
|
||||||
|
|
||||||
love.graphics.draw(self.shadowMesh, self.x, self.y, self.rotation, self.scalex, self.scaley, self.ox, self.oy)
|
love.graphics.draw(self.shadowMesh, self.x, self.y, self.rotation, self.scalex, self.scaley, self.ox, self.oy)
|
||||||
|
@ -104,7 +104,6 @@ function light_world:draw(cb)
|
|||||||
_ = self.disableReflection or self:drawReflection( self.l,self.t,self.w,self.h,self.s)
|
_ = self.disableReflection or self:drawReflection( self.l,self.t,self.w,self.h,self.s)
|
||||||
end)
|
end)
|
||||||
self.post_shader:drawWith(self.render_buffer, self.l, self.t, self.s)
|
self.post_shader:drawWith(self.render_buffer, self.l, self.t, self.s)
|
||||||
-- love.graphics.draw(self.shadow_buffer)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw normal shading
|
-- draw normal shading
|
||||||
@ -169,7 +168,9 @@ function light_world:drawShadows(l,t,w,h,s)
|
|||||||
shader = self.shadowShader,
|
shader = self.shadowShader,
|
||||||
stencil = function()
|
stencil = function()
|
||||||
local angle = light.direction - (light.angle / 2.0)
|
local angle = light.direction - (light.angle / 2.0)
|
||||||
love.graphics.arc("fill", (light.x + l/s) * s, (light.y + t/s) * s, light.range, angle, angle + light.angle)
|
love.graphics.arc(
|
||||||
|
"fill", (light.x + l/s) * s, (light.y + t/s) * s, light.range, angle, angle + light.angle
|
||||||
|
)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user