Putty Problem

Topics: User Forum
May 8, 2009 at 11:57 AM

Hi guys! This is my first post as a Farseer convert, although I have been playing with the libraries for a month or two now (it's in my nature to lurk, sadly - something I'm trying to change). Before I ask my question, I'd like to say how impressed I am with Farseer. Not just with the library itself (which would be reason enough to harp on about it), but also with the level of co-operation I've seen on the discussion boards in this time, and how committed the developers and project co-ordinators are. To say I'm taken aback by such dedication is quite the understatement.

Right, now that I've blown my beans of respect and appreciation, time to talk about my problem:

I'm working on a technical proof-of-concept that hinges on the idea of a 2D platform-style game in which the player guides an amorphous blob of putty around various obstacles in an effort to reach/find whatever it is that living blobs of putty desire in this world [insert weird back-story here]. Now, clearly, the Farseer engine is an obvious choice for composing the physics of such a blob, but I'm running into a few problems.

I've succeeded in creating something of a stepping-stone towards that goal: by instancing a ring of a small physics-circles that are connected by a perimeter of dampened springs. These circles are then additionally connected by less rigid springs to a central sphere. Imagine a spoked wheel composed of physics-circles and springs and you'll be about there.

This amalgamated object has about the same physical properties as a balloon filled with water. Unfortunately, just by decreasing the springs' relative ridgidity and dampning factor, this does not produce the desired result of an amorphous blob of putty. Instead, the perimeter spheres and springs tend to overlap and get tangled, whereas the previously high rigidity of the springs used to keep such anomalies in check.

So, in short - I can create, with Farseer, a balloon filled with water. I just don't seem to be able to create the next logical step - my titular blob of controllable putty.

I had the idea of adding an additional perimeter layer that acted like a 'skin' for the blob, but I'm not sure if this would work.

Any ideas? I'd have posted the code here, but it's really quite messy - I tend to work on a single 'construction' project for everything I do, so there's a lot of irrelevant code.

P.S. Apologies for the length of this post - I do tend to go on a bit.


May 8, 2009 at 12:58 PM

@cpt_pik3y: Great to recieve complements. About your problem, I would recomend creating a skin of rectangles (you could use the Path class to create this) held together with revolute joints and then interconnect the skin of rectangles with springs. The only trick should be finding the perfect values to acheive the effect you desire and rendering. Let me know how this works.

May 8, 2009 at 1:03 PM

Hi Matt, thanks for the reply - that's a great idea! I'll give your solution a try and let you know how I get on, probably tonight or tomorrow. Thanks again for your help!

May 8, 2009 at 3:43 PM

Okay, so that turned out to be a superb idea, cheers Matt. I've now managed to get it working. It's not perfect, but as you've already said, some tweaking of the spring/joint parameters should finish the job. I'm still having a minor issue with the joints getting 'tangled' but we'll see how it is once the tweaking is done.

In the end, I didn't use the Path functions (predominantly because I'd not used them before - once I clean up the code, I'll probably use Paths instead of my current solution). I also used Pin joints offset between the segments to achieve the desired effect rather than Revolute joints, but the effect is much the same.

I'll keep tweaking, improving, and tidying up the code. Once it's finished, if you/anyone is interested, I'll post it for all to see(?).

Once that's finished, I'll start thinking about how to render a blob-like graphic over the top so it isn't quite so angular-looking - I'm thinking that a superimposed bezier-curve of some kind might do the trick, but I'll leave that particular conundrum for later!

Thanks again!

May 8, 2009 at 4:34 PM

That's great. I can't wait to see it.

May 9, 2009 at 12:33 AM

i read this article a while ago (http://cowboyprogramming.com/2007/01/05/blob-physics/). I have never actually tried it so i don't know if it works. But you may be interested.

You can probably ignore all the maths and just look at the design of thier blob.


p.s. it is probably similar to how you ended up doing it, however the system they are using, just has point masses rather than geometrys with an area. Which doesn't exactly match how you would have to do it in Farseer so that you get collisions.

May 11, 2009 at 1:22 PM

@mattbelcher: okay, I'll drop the code on a post when I'm finished. It'd be lovely to have actually gotten something done these past few days, but work is keeping me pretty busy so I'll have to play it by ear...!

@MattF: thanks for the link, great article (and a nice coding blog overall) - it's quite spooky how similar our working solutions were to the same problem, eh? Except I'm a bit like the poor-relation to his genius; he's talking about forces, mathematics, and physical theory, whereas I just take the MacGuyver approach and throw random stuff together until something [sort of] works. Which reminds me; I think I've still got that hang-glider made from cloth and litter in my garage, must dig it out... XD

Cheers for the input guys; I'm looking forward to putting this particular obstacle to bed, and I've got a feeling the end is in sight!

May 12, 2009 at 12:18 PM

@cpt_pik3y: lol, didn't macgyver use bamboo and an engine from a cement mixer to make his hanglider. Oh wait, that was an ultra-light... lol