transform component ? (Or alternative to using one)

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
lots_of_birds
Prole
Posts: 13
Joined: Sun Dec 11, 2011 12:09 pm

transform component ? (Or alternative to using one)

Post 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 ?)
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
Fenrir
Party member
Posts: 222
Joined: Wed Nov 27, 2013 9:44 am
Contact:

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

Post 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()
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests