Ball and socket problem

blackskull

01-05-2010 00:26:39

I'm making a snake via chain of clusters connected with joints(ball and socket). They're being collected in a vector.
It's being moved by it's force callback like this:
void Snake::forceCallback(OgreNewt::Body *body, float timeStep, int threadIndex)
{

Vector3 newVel(body->getOrientation()*velocity/timeStep); //velocity is being set by the S, W keys

Vector3 gravity(body->getOrientation()*Vector3(0, -60, 0)/timeStep);

Vector3 newRot(body->getOrientation()*rotation); //rotation is being set by A, D keys

body->setOmega(newRot);

body->setVelocity(newVel);

body->setForce(gravity);

}


The method that creates each piece of the tail with its joint
void Snake::expandSnake(int count)
{
for(count; count>0; count--)
{
snakeLength++;
prev = snakeVector.back().getCollisionBody();
String name = "Cluster"+Ogre::StringConverter::toString(snakeLength);
Cluster cluster(name, pWorld, col, snakeVector.back().getPosition(), snakeVector.back().getOrientation());
snakeBody.push_back(cluster);

joint = new OgreNewt::BallAndSocket(snakeVector.back().getCollisionBody(), prev, prev->getPosition());
//OgreNewt::Joint* joint = new OgreNewt::BallAndSocket(prev, snakeVector.back().getCollisionBody(), Vector3::ZERO);
}

}


And Cluster is an object that contains the ogrenewt body and the node and entity of one piece of the tail.

Well the problem is that when I move the snake only the head moves, but the tails stays in place...

PS: I also noticed that with joints attached I have weird physics behavior - the forces have different power over the body or something?!?