Page 1 of 1

transform component ? (Or alternative to using one)

Posted: Tue Sep 29, 2015 11:13 am
by lots_of_birds
Hello there.

My game involves entities which moves, rotate, often with different rotation centres, and has to carry around several sub-entities that also has to carry sub-entities.

On big frameworks (unreal engine, Unity, etc...) the solution is easy, there is always a kind of scene graph and rotating the root component makes everything dependant move accordingly like magic.

From my research, there doesn't seems to be any transform component/class ready to use for love2d in the libraries.

The only ones I found on the forums are here and there, and neither looks like they are widely used, or usable for the masses ?

1st question : did I miss it ?

2nd question : If I don't use one, is there some alternatives ? (Or what are you using instead of a transform component ?)

Re: transform component ? (Or alternative to using one)

Posted: Tue Sep 29, 2015 11:46 am
by s-ol
There are no such things as components or scene graphs in love, love is a framework, not an engine.
Read up on "opengl transforms" or "transform matrices"; they "stack" automatically. You will also need to use live.graphics.push/pop.

Re: transform component ? (Or alternative to using one)

Posted: Tue Sep 29, 2015 11:58 am
by Fenrir
Yep there's no scenegraph provided with Löve and I didn't found any good library for it too, so for my projects I created a custom one (I worked a lot with OpenSceneGraph so it's mainly inspired by it). It's not a lot of work, you'll need specialized Node classes (Groups, Transforms, Geometries, etc...) and Visitors (mostly draw and update ones) encapsulating Löve features. For instance on my Transform node, when a visitor enters it applies all the transforms:

Code: Select all

love.graphics.push()
love.graphics.translate(...)
love.graphics.rotate(...)
love.graphics.scale(...)
And when it exits, it just pops its state:

Code: Select all

love.graphics.pop()