Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

If that is even what it is called. What I am trying to do it: http://asterisq.com/products/constellation/roamer/demo

Can someone please point me to towards a book or in vaguely the right direction? I don't even know where to start or what physics/maths to read about?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

What you're looking at is called a force-directed graph. Google for that and you should find some helpful documentation. The math is surprisingly straightforward.

share|improve this answer
    
You are my hero! I can't even begin to tell you how many hours of my time you have saved. –  Duncan Edwards Dec 8 '10 at 17:46
add comment

Vector maths is a must, you shouldn't need more than the basic parts for this, but the rest is generally very recommendable for a game programmer, so if you skip the cool stuff for now be sure to get back on the topic sometime. From there you could read about ragdoll physics, though a lot of sources for that may be "heavier" than what you need, so I'll just sketch out how I presume the animation works.

It runs a set number of updates per second.
For every update it iterate over all pairs of objects.
If the objects are too close each of the two objects will be moved a little away the other.
If they are connected and too far from one another each object will be moved a little closer to the other.
In both cases, the more the distance is off, the more they should move. Try for instance moving the objects 1/10 of what they are are off the target.
It's probably best to not move the objects immediately when you do the calculation, but rather for each object sum the movement over an entire update and execute it only after the movement relative to all the other objects has been calculated.

Note:
This setup does not use velocity and acceleration as one would with common ragdoll physics, that is on purpose since the goal is to spread the nodes out nicely rather than simulate real physics.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.