Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have drew a hemi-sphere by myself, and would like to do basic jellyfish animation by animating the vertices of the hemi-sphere. I tried a lot of experiments but it seems I'm doing it wrong. I need hints or idea on about doing it.

This is the code on how to draw a hemi-sphere. I don't know what values actually to play with to animate the sphere as a jellyfish.

for(float phi = 0.0; phi < 1.567; phi += factor) {


        for(float theta = 0.0; theta < 2*3.14 + factor; theta += factor) 
            x = rh * sin(phi) * cos(theta);
            z = rh * sin(phi) * sin(theta);
            y = -rh * cos(phi);

            gl::vertex(Vec3f(x, y, z));

            x = rh * sin(phi + factor) * cos(theta);
            z = rh * sin(phi + factor) * sin(theta);
            y = -rh * cos(phi + factor);

            gl::vertex(Vec3f(x, y, z));

share|improve this question
You should explain more about what you've tried and why/how it didn't work. Is it not drawing correctly? Is it not animating correctly? Sounds interesting though. – Byte56 Apr 16 '12 at 22:29
@Byte56 Updated – Moaz Apr 16 '12 at 22:32
Check this out.. – Chuck D Apr 16 '12 at 23:34

I see. Your update tells me that you are much further from results than I first thought. You're actually looking for an algorithm to define the movement of a jellyfish. That's very complex and is likely thesis level work.

In fact it is thesis level work. See Dave Rudolf's paper (PDF) on the subject. Additionally Marcin Ignac has done some work with the topic.

Perhaps there's some simpler method that I'm not thinking of, but if the linked sites are not suitable for your purposes I think you may be asking for too much. Good luck.

share|improve this answer
I have already look at those links. I actually need more resources. – Moaz Apr 16 '12 at 23:43

So what you want is a contraction and expansion of the sides in a peristaltic motion to make it look like it's pushing itself. I haven't tried this but the idea should work, it's similar to a cheap waving flag simulation. It is by no means a physical simulation.

First thing you need is a delta Time (dt) to govern how fast the animation will run, and this generates the wave. Second thing you will need is a scale value that you can tweak to make the animation look as good as it can.

What you want to do is modify all your xyz values by a wave based on the values of phi and dt, this will make it change from top to bottom of your hemisphere plus animate over time.

dt is expressed in seconds, a typical frame taking 0.033 to draw. phi ranges from 0 at the top of your hemisphere where you don't want any animation and gets bigger the lower it goes which will make the peristaltic wave larger at the bottom. Scale is needed to tune how big the wave is, a subjective measure of what looks good.

In this example note that x,y and z are all multiplied by the same value. Both sets of your xyz values in the original code would be modified like this each loop.

// setup
    dt = 0.033; // modify to make the wave longer or shorter periodicity
    scale = 1.0;  // modify to make the wave bigger or smaller
    modifier = -cos(dt) * phi * scale;;
// in the loop
    x = rh * sin(phi) * cos(theta);
    x *= modifier;
    z = rh * sin(phi) * sin(theta);
    z *= modifier;
    y = -rh * cos(phi);
    y *= modifier;
share|improve this answer
Unfortunately, it is not animating. What about the 2nd part of drawing the hemi-sphere, should I remove it ? – Moaz Apr 17 '12 at 0:01
Nice. Getting some kind of vertex groups system implemented would make this work even better, that way the whole structure can rotate and move more freely without needing to worry about "what is above what". – Byte56 Apr 17 '12 at 0:02
@AhmedSaleh I must make a change: add "static float acc = 0;" and then every entry "acc += dt;" then "-cos(acc)" instead of "-cos(dt);" and you will animate. Sorry =) Both sets of xyz in your inner loop should be multiplied by that same modifier. – Patrick Hughes Apr 17 '12 at 1:27
@Byte56 that part will be easy, as will scaling/translating because the original vertices are built in a 0..1 range. – Patrick Hughes Apr 17 '12 at 1:29

Your Answer


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.