Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightworld rotation scaling issues (lights will not rotate) #33

Open
RichardEllicott opened this issue Aug 3, 2017 · 3 comments
Open

Comments

@RichardEllicott
Copy link

RichardEllicott commented Aug 3, 2017

okay, i have confirmed lightworld rotates (sort of), if i put in the love.graphics.rotate into the actual lightworld function bit, in my code, in ee_engine.lua:


lightWorld:draw(function() --this is the lightworld pass

            love.graphics.rotate(camera.rotation)

            for _,entity in pairs(self.entities) do
                entity:lightdraw()
            end
        end)

i found if i omit, the scaling and translation, it is the closest to working correctly.

i found also, the sequence is important, so lightworld has received the scaling and translation, it is important other draws follow the same sequence (rotation MUST be last)

this investigation suggests the code on the main page might be wrong?? you are not supposed to scale and translate in love.draw()

Please, have a look at my code, at least try using the controls to see. It has WSAD directions, QE scale, and RF rotate.

You can switch on (in ee_engine.lua) a non-lightpass, with Engine.draw_non_lightpass = true

I have managed to get both passes to exactly match each other.

Sorry i am so long winded, the fundamental issue is, the lights do not rotate with the scene, if you rotate my (attempted) camera, you will find the lights do not rotate (so lightworld sprites rotate fine, it's lights do not).

EntityEngine.zip

This little framework, i was hoping to integrate all this stuff, light, physics, camera, and eventually UDP, into one thing bases on the usual sort of Unity style component model. The best bit so far is the physics are optional :)

Summary of code:
main.lua
ee_engine.lua --the singleton
ee_entity.lua --the in game objects

@RichardEllicott
Copy link
Author

RichardEllicott commented Aug 3, 2017

i still kinda like this product and think i might just decide not to use rotation, but it would be nice to solve this, and i may have highlighted someting strange about setting translations to the lightworld:

lightWorld:update(dt)
  lightWorld:setTranslation(x, y, scale)

when you're also then doing it again in:

love.graphics.translate(x, y)
    love.graphics.scale(scale)

in my attached example, i do not make them two second ones (except for non-lightworld pass).... i have managed to make it all line up!

@RichardEllicott
Copy link
Author

also my code is free as in free, if any code i made was useful to people i'd be honoured to have helped (but it may not be to people's tastes here as they tend to make these bits themselves)

@RichardEllicott
Copy link
Author

in love 2d, the official way to make the sequence is:

translate
rotate
scale

to line things up correct, translate needs to occur first i believe (rotate and scale could be interchanged in sequence)... this is handy, as lightdraw will only rotate it appears if you chuck the rotate inside it?

something is not right with this, perhaps it's a shame that lightworld could not be a fundamental part of love 2d itself, i feel this would be the best thing, we're trying to line up a now very complicated sequence of translations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant