1
\$\begingroup\$

I was always wondering how to add the graphics to a a blob body for example, regardless of what engine or library you are using, i want to know (theoratically) how to move from this state : http://www.youtube.com/watch?v=qHvsER4Ou0w

to something like the blob in this video : http://www.youtube.com/watch?v=ssOaZ3Lrov0

thank you

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I think the easiest way to reproduce that case is to just generate a circle's geometry with many segments to give it nice bending capabilities then map the circle's texture coordinates directly to the blob texture.

Then, for the actual bending to happen, you take the rigid bodies' positions from the physics system and use those to distort their corresponding vertices in the circle.

To do this, you can, for example, get the angle of each rigid body relative to the center of the blob object, then find which vertices in the circle are affected by comparing their angle plus a threshold. Once you know what circle vertices need to be affected by which rigid bodies in the blob simulation, you can simply re compute the vertex of the circle's edge to be at the same distance from the center as the rigid body is.

To get the distance from the center in the blob simulation: float blobVertexDistance = distance(rigidBodyPosition, centerOfBlob);

To compute the new circle vertex position out of a distance and the angle: vec2 newPosition = vec2(cos(angle) * blobVertexDistance, sin(angle) * blobVertexDistance);

Let me know if something is unclear.

This technique works best if you use Triangle Strips to render the circle, if I am not mistaken.

\$\endgroup\$
2
  • \$\begingroup\$ thank you :) so basically we do the physics and then fill inside the body ? \$\endgroup\$ Commented Jun 19, 2014 at 12:39
  • \$\begingroup\$ basically. the circle geometry is re-arranged every frame to match the shape you see in the first video and if the texture coordinates are correct, you automatically obtain what you see in video 2. :) \$\endgroup\$
    – Grimshaw
    Commented Jun 19, 2014 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .