Did you commit on github? I don't see any new updates . Thanks for keeping the plugin alive! Another suggestion would be to implement z-map, although from my perspective that looks to be difficult to implement based on the current structure of the plugin(Unless I am too dumb to see that it's already implemented).drunken_thor wrote:Just an update, I pretty much implemented scaling and rotating of light bodies, there is just some inaccuracy in them so the object get slightly smaller if you rotate them and scaling does not match up with how love.graphics.draw scales so it will be a different size depending on the scale.
Löve "Light vs. Shadow" Engine v2
Re: Löve "Light vs. Shadow" Engine v2
- drunken_thor
- Citizen
- Posts: 75
- Joined: Wed Oct 01, 2014 12:14 am
- Location: Toronto, Canada
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
I just pushed a rotation_and_scaling branch on github, you can check it out there. I ended making rectangles into polygons to eliminate some extra code and I think I am going to have to approach rotating and scaling from a different way because to address the inaccuracy issues/
- drunken_thor
- Citizen
- Posts: 75
- Joined: Wed Oct 01, 2014 12:14 am
- Location: Toronto, Canada
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
Okay I have finally finished scaling and rotating most things I am not sure I did scaling circles now that I think about it.....
Anyways it is all merged into master now so try it out and let me know what it means. If you have problems it is all tagged you can use the 2.0 tag.
Anyways it is all merged into master now so try it out and let me know what it means. If you have problems it is all tagged you can use the 2.0 tag.
- drunken_thor
- Citizen
- Posts: 75
- Joined: Wed Oct 01, 2014 12:14 am
- Location: Toronto, Canada
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
okay finished circles now as well!
Re: Löve "Light vs. Shadow" Engine v2
I am having trouble with rotation.. First of all if I have a "rectangle" type shadow, I get an error as "self.unit_data" is nil in body.lua 126. However when I swap the type to Image, the issue I described before shows up again. Heres a screen shot(Note: it's rotated by 180 degrees):
- 8bitDaemon
- Prole
- Posts: 5
- Joined: Sat Nov 16, 2013 3:32 am
Re: Löve "Light vs. Shadow" Engine v2
I'm having some issues with implementing the engine with my camera. Basically my camera and the light engine don't line up, or the light engine will cancel out the cameras zoom and stuff like that. I'm not using HUMP but a different one that includes parallax and camera boundaries. The damn camera works wonderfully until I try to put the lights through it. Heres the code for the camera:
Heres the snippet where my draw is
Yeah, I know I"m calling the lightWorld:draw before the camera:set while having the function end before the camera is unset, but It's the only way I can get it to work at all.
any help would be appreciated>
Code: Select all
camera = {}
camera._x = 0
camera._y = 0
camera.scaleX = 1
camera.scaleY = 1
camera.rotation = 0
camera.layers = {}
--creates layers for parralax
function camera:newLayer(scale, func)
table.insert(self.layers, {draw = func, scale = scale})
table.sort(self.layers, function(a,b) return a.scale < b.scale end)
end
--draws the parralax layers
function camera:draw()
local bx, by = self._x, self._y
for _, v in ipairs(self.layers) do
self._x = bx *v.scale
self._y = by *v.scale
camera:set()
v.draw()
camera:unset()
end
end
--attaches the camear
function camera:set()
love.graphics.push()
love.graphics.rotate(-self.rotation)
love.graphics.scale(self.scaleX, self.scaleY)
love.graphics.translate(-self._x, -self._y)
end
--detaches the camera
function camera:unset()
love.graphics.pop()
end
--moves the camera
function camera:move(dx, dy)
self._x = self._x + (dx or 0)
self._y = self._y + (dy or 0)
end
function camera:rotate(dr)
self.rotation = self.rotation + dr
end
function camera:scale(sx, sy)
sx = sx or 1
self.scaleX = self.scaleX * sx
self.scaleY = self.scaleY * (sy or sx)
end
function camera:setX(value)
if self._bounds then
self._x = math.clamp(value, self._bounds.x1, self._bounds.x2)
else
self._x = value
end
end
function camera:setY(value)
if self._bounds then
self._y = math.clamp(value, self._bounds.y1, self._bounds.y2)
else
self._y = value
end
end
function camera:setPosition(x, y)
if x then self:setX(x) end
if y then self:setY(y) end
end
function camera:setScale(sx, sy)
self.scaleX = sx or self.scaleX
self.scaleY = sy or self.scaleY
end
function camera:getBounds()
return unpack(self._bounds)
end
function camera:getPos()
return self._x, self._y
end
--sets the bounding box for the camera
function camera:setBounds(x1, y1, x2, y2)
self._bounds = { x1 = x1, y1 = y1, x2 = x2, y2 = y2 }
end
Code: Select all
function love.draw()
lightWorld:draw(function()
camera:draw()
camera:set()
--normal drawing stuff here--
end)
camera:unset()
end
any help would be appreciated>
- drunken_thor
- Citizen
- Posts: 75
- Joined: Wed Oct 01, 2014 12:14 am
- Location: Toronto, Canada
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
You need to change your camera because normal usage of this would be something like this8bitDaemon wrote: Heres the snippet where my draw isany help would be appreciated>Code: Select all
function love.draw() lightWorld:draw(function() camera:draw() camera:set() --normal drawing stuff here-- end) camera:unset() end
Code: Select all
function love.draw()
lightWorld:setTranslation(camera._x, camera.y, camera.scaleX, camera.scale)
camera:set()
lightWorld:draw(function()
for _, v in ipairs(camera.layers) do
v.draw()
end
end)
camera:unset()
end
- drunken_thor
- Citizen
- Posts: 75
- Joined: Wed Oct 01, 2014 12:14 am
- Location: Toronto, Canada
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
Do you have any code I can see? unit_data is set when you create a rectangle and should never change after that so if it is nil you might be doing something I did not predict.Relazy wrote:I am having trouble with rotation.. First of all if I have a "rectangle" type shadow, I get an error as "self.unit_data" is nil in body.lua 126. However when I swap the type to Image, the issue I described before shows up again. Heres a screen shot(Note: it's rotated by 180 degrees):
Re: Löve "Light vs. Shadow" Engine v2
This is a very noob question, but I'm trying to get a quick test to work and I am failing miserably. I'm sure I am missing something obvious. I just want to draw a tiny space ship and a light.
This results in the following, even though I *think* the light should be right next to the ship.
Like I say, I am probably missing something obvious. What am I doing wrong? Thanks!
Code: Select all
local LightWorld = require "lib/lightworld"
function love.load(arg)
camera = { x = 0, y = 0, scale = 1 }
x = 300
y = 400
z = 1
img = love.graphics.newImage("res/tinyship.png")
img_normal = love.graphics.newImage("res/tinyship_normal.png")
img_glow = love.graphics.newImage("res/tinyship_glow.png")
lightWorld = LightWorld({
ambient = {55,55,55},
refractionStrength = 32.0,
refractionVisibility = 0.75,
shadowBlur = 0.0
})
sunLight = lightWorld:newLight(0,0,255,127,63,500)
sunLight:setPosition(300,350,1)
sunLight:setGlowStrength(0.3)
sunLight:setVisible(true)
sunLight:setRange(300)
playerImageTest = lightWorld:newImage(img, x, y)
playerImageTest:setNormalMap(img_normal)
playerImageTest:setGlowMap(img_glow)
end
function love.update(dt)
lightWorld:update(dt)
sunLight:setPosition(200/camera.scale, 200/camera.scale, z)
end
function love.draw()
love.graphics.setBackgroundColor(40,40,40)
lightWorld:setTranslation(camera.x, camera.y, camera.scale)
love.graphics.push()
love.graphics.translate(camera.x, camera.y)
love.graphics.scale(camera.scale)
lightWorld:draw(function()
love.graphics.setColor(255, 255, 255)
love.graphics.draw(img, x - img:getWidth() * 0.5, y - img:getHeight() * 0.5)
end)
love.graphics.pop()
love.graphics.setBlendMode("alpha")
end
Like I say, I am probably missing something obvious. What am I doing wrong? Thanks!
- drunken_thor
- Citizen
- Posts: 75
- Joined: Wed Oct 01, 2014 12:14 am
- Location: Toronto, Canada
- Contact:
Re: Löve "Light vs. Shadow" Engine v2
This library works by blending the background with the lighting you need to draw a background of some sort (not just set the background color)Magicked wrote:This is a very noob question, but I'm trying to get a quick test to work and I am failing miserably. I'm sure I am missing something obvious. I just want to draw a tiny space ship and a light.
This results in the following, even though I *think* the light should be right next to the ship.Code: Select all
local LightWorld = require "lib/lightworld" function love.load(arg) camera = { x = 0, y = 0, scale = 1 } x = 300 y = 400 z = 1 img = love.graphics.newImage("res/tinyship.png") img_normal = love.graphics.newImage("res/tinyship_normal.png") img_glow = love.graphics.newImage("res/tinyship_glow.png") lightWorld = LightWorld({ ambient = {55,55,55}, refractionStrength = 32.0, refractionVisibility = 0.75, shadowBlur = 0.0 }) sunLight = lightWorld:newLight(0,0,255,127,63,500) sunLight:setPosition(300,350,1) sunLight:setGlowStrength(0.3) sunLight:setVisible(true) sunLight:setRange(300) playerImageTest = lightWorld:newImage(img, x, y) playerImageTest:setNormalMap(img_normal) playerImageTest:setGlowMap(img_glow) end function love.update(dt) lightWorld:update(dt) sunLight:setPosition(200/camera.scale, 200/camera.scale, z) end function love.draw() love.graphics.setBackgroundColor(40,40,40) lightWorld:setTranslation(camera.x, camera.y, camera.scale) love.graphics.push() love.graphics.translate(camera.x, camera.y) love.graphics.scale(camera.scale) lightWorld:draw(function() love.graphics.setColor(255, 255, 255) love.graphics.draw(img, x - img:getWidth() * 0.5, y - img:getHeight() * 0.5) end) love.graphics.pop() love.graphics.setBlendMode("alpha") end
Like I say, I am probably missing something obvious. What am I doing wrong? Thanks!
Who is online
Users browsing this forum: No registered users and 3 guests