• Create Account

### #Actualnkint

Posted 12 July 2012 - 05:59 AM

Hi!
I'm going to code some 3d creatures like snakes or tentacles.
For inspiration i've looked for some code around on the net and i've found this one:
http://www.openproce...org/sketch/8405
ok, i like it.

It is a simple structure: a list of nodes, the first node is the main direction, the other nodes follow the first in a fluid and

wiggly way.

the algorithm is quite easy:

1 calculate the position of the head (the direction of the creature)
2 this procedure is used:

[source lang="java"]void move(float headX, float headY, float headZ) { float dx, dy, dz, d; // node 0: position, direction, orbiting handle nodes[0].x = headX; nodes[0].y = headY; nodes[0].z = headZ; // node 1: muscule count += muscleFreq; nodes[1].x = nodes[0].x ; nodes[1].y = nodes[0].y + PApplet.sin(count) ; nodes[1].z = nodes[0].z + PApplet.cos(count) ; // apply kinetic forces down through body nodes for (int i = 2; i < nodes.length; i++) { dx = nodes[i].x - nodes[i - 2].x; dy = nodes[i].y - nodes[i - 2].y; dz = nodes[i].z - nodes[i - 2].z; d = PApplet.sqrt(dx*dx + dy*dy + dx*dx) *ks; float dx_d = + (dx * girth) / d; float dy_d = + (dy * girth) / d; float dz_d = + (dz * girth) / d; nodes[i].x = nodes[i - 1].x +dx_d; nodes[i].y = nodes[i - 1].y +dy_d; nodes[i].z = nodes[i - 1].z +dz_d; } }[/source]

with girth as a random number near between 5 and 15 and muscleFreq between 0.1 and 0.2 i get nice results.

now, i understand that this is not the real inverse kinematics but.. if i check on google about IK i found a lot of maths and a lot of methods like angles, CCD, Jacobs..
my question is:
i just need to make wiggly creatures. what is this algorithm?
or even.. can you advice me some articles or other way to make chain snake-like creatures?

### #1nkint

Posted 12 July 2012 - 05:21 AM

Hi!
I'm going to code some 3d creatures like snakes or tentacles.
For inspiration i've looked for some code around on the net and i've found this one:
http://www.openprocessing.org/sketch/8405
ok, i like it.

It is a simple structure: a list of nodes, the first node is the main direction, the other nodes follow the first in a fluid and

wiggly way.

the algorithm is quite easy:

1 calculate the position of the head (the direction of the creature)
2 this procedure is used:

for (int i = 2; i < nodes.length; i++) {

dx = nodes[i].x - nodes[i - 2].x;

dy = nodes[i].y - nodes[i - 2].y;

d = sqrt(dx * dx + dy * dy);

nodes[i].x = nodes[i - 1].x + (dx * girth) / d;

nodes[i].y = nodes[i - 1].y + (dy * girth) / d;
}

with girth as a random number near between 5 and 15 i get nice results.

now, i understand that this is an approximation of inverse kinematics but.. if i check on google about IK i found a lot of maths and a lot of methods like angles, CCD, Jacobs..
but.. my question is:
i just need to make wiggly creatures. what is this algorithm?
or even.. can you advice me some articles or other way to make chain snake-like creatures?

PARTNERS