Page 1 of 8

Loveballs, A love2d Softbody lib

Posted: Wed Oct 08, 2014 3:43 pm
by IndieRetro
LOVEBALLS



Loveballs is a small softbody lib I have been working on for personal projects.
It's pretty easy to use, here is a small example

Documentation

Code: Select all

--Creates a softbody
--smoothing is optional, the default settings are the best, essentially the number is how many nodes to pass in
--tessellate count, the higher the better quality, but anything too large will probably cause performance issues
--setting tessellate count to < 1 or a float/double will result in errors
--if you want some neat effects, try a somewhat high smoothing (6-8), with a tessellate count of 1-2
object = Softbody:new(world, x, y, radius, smoothing, tessellatecount)

--Sets the frequency of the softbody
objecy:setFrequency(f)

--Sets the damping ratio of the body
object:setDamping(d)

--Set friction of outer nodes
object:setFriction(f)

--Updates tesselation, required
object:update()

--Draws the softbody
object:draw()

--Draws only a line, instead of a full polygon
object:draw("line")

--Destroys the softbody
object:destroy()

Credit to Amadiro/Jonathan Ringstad for the tesselate function

Credit to me(Shorefire/Indieretro) and Jonathan Ringstad not required, but appreciated. Feel free to use the lib/code however you want, just as long as you dont claim it as your own.

To do list
-Allow the creation of arbitrary shapes
-Manually set the amount of nodes
-Manually set the size of nodes

Licence: http://opensource.org/licenses/Zlib
Github: https://github.com/siObyte/loveballs


----Update log
+Added tesselate count
+Added destroy function
+Added line width arg to draw
*Major change to node joints (Want to roll the softbody? apply a AngularImpulse to object.sourceBody!)

--Update 15/1/15
*Important change to softbody physics
*Cleaned up a little bit of code
*Renamed loveballs.lua to init.lua, just require the folder now

--Update 1/2/15
+Added getPoints()
+Added setFriction(f)
+Added update()
+Added comments
*Moved tess to update
*Cleaned up code
*Renamed sourceBody to centerBody (for shape & fixture to)

--Update 24/2/15
+New example in the github repo
*Moved source to github
*Fixed a few bugs
*Changed how the lib is required

--Update 27/2/15
+Indexing a softbody will return the node (see readme in repo)
*Removed yaci class lib depend
*Changed over to metatables
*Changed construction syntax a little

Re: Loveballs, A love2d Softbody lib

Posted: Wed Oct 08, 2014 5:07 pm
by undef
That looks really nice!
Reminds me of "The Floor is Jelly".

Re: Loveballs, A love2d Softbody lib

Posted: Wed Oct 08, 2014 5:40 pm
by artofwork
That's really awesome!

Makes me think of boobies :P

Re: Loveballs, A love2d Softbody lib

Posted: Thu Oct 09, 2014 7:16 am
by Fenrir
Really nice, good work!

Re: Loveballs, A love2d Softbody lib

Posted: Wed Oct 15, 2014 9:35 am
by soulaymenc
oh my god so fucking kawai :D :D <3

Re: Loveballs, A love2d Softbody lib

Posted: Wed Oct 15, 2014 2:34 pm
by SiENcE
Looks nice and quitschy.

Re: Loveballs, A love2d Softbody lib

Posted: Fri Oct 17, 2014 12:45 am
by adnzzzzZ
This is really really neat. Is it possible to set different properties to different parts/sides of a blob? Like making it sticky but only on a certain part.

Re: Loveballs, A love2d Softbody lib

Posted: Fri Oct 17, 2014 5:15 am
by IndieRetro
adnzzzzZ wrote:This is really really neat. Is it possible to set different properties to different parts/sides of a blob? Like making it sticky but only on a certain part.
Not currently, I've been working on arbitrary shapes for softbodys, but I will try to implement this soon. There's a very important update I need to release asap. I've found that setting both anchors of the DistanceJoints to the same position on each node, instead of one on the center body and one on the node, results in a much better softbody. This way the softbody rolls instead of sliding when you give the nodes friction, unlike before it would just slide all over the place.

Anywho, more coming soon hopefully..

EDIT: Update's done \o/

Re: Loveballs, A love2d Softbody lib

Posted: Thu Jan 15, 2015 8:12 pm
by IndieRetro
New small update released, small changes but they improve the softbody physics a load. I recommend using the latest version.

Demos are outdated, but the source.zip is updated, also on github.

Re: Loveballs, A love2d Softbody lib

Posted: Wed Jan 21, 2015 12:31 am
by ArchAngel075
Loving this as its giving me some small idea to persue!

It took awhile to adapt to this, since i use onContact callbacks and normals of contacts to set a "isGrounded" variable for the player on the ground so that i can control when one may jump, but sadly the sofBody.fixture isnt exactly the right fixture to call setUserData() on.

After a tweak i now cycle through softBody.nodes and call setUserData() on those fixtures (it even opened for some funky jumping mechanic so i dont mind)

I do mind though the following and #suggestions# :

1. Open a function to fetch each nodes body/fixture/shape for fiddling, i feal dirty some-how using softBody.nodes[n].fixture
2. Method to change the radius of the softBody on the fly.

The following is more of a call for help on how I can go about implementing the feature in my game :
If i take a softBody and by some way "stretch" it and then have it split into two softBodies whom share the same radius that is half the original.
The above is what i hope to achieve as the main mechanic of the game/snippet I am attempting...something of a blob that splits and rejoins as needed but with the REALLY amazing tessellation and wobbles on the way...