CoffeeMan
26-07-2007 09:33:22
Hello all, I am beginner in game developing and ogre and physx, too
I try to make a chain. First idea, to create many spheres and connect it by spherical joints. But i have a problem described bellow code
Bellow my code of creating a chain:
Next I create box that hasn't a sence on gravitation and connect begin of chain with box:
Problem: When I add force to box, all balls begin fast travel around a circle but don't follow the box (that has big mass and slow move)
I try to make a chain. First idea, to create many spheres and connect it by spherical joints. But i have a problem described bellow code
Bellow my code of creating a chain:
body* createSphereBody(float radius, float density, Ogre::Vector3 pos)
{
params<rigidbody> _param;
_param.mScale = Vector3(radius, radius, radius);
return mScale->createBody("", "sphere.2m.mesh", new nxOgre::sphereShape(radius), density, _param, pos);
}
void createChain(body*& beg, body*& end, float xb, float yb, float zb, float xe, float ye, float ze, float m, float n)
{
float dx = (xe-xb)/n;
float dy = (ye-yb)/n;
float dz = (ze-zb)/n;
float dm=m/n;
body *prev = 0, *b;
for (int i = 0; i < n; i++) {
b = createSphereBody(0.02f, dm, Vector3(xb, yb, zb));
if (prev != 0)
joint::createSphericalJoint(prev, b, Vector3(xb+dx/2, yb+dy/2, zb+dz/2));
else beg = b;
prev = b;
xb += dx; yb += dy; zb += dz;
}
end = b;
}
Next I create box that hasn't a sence on gravitation and connect begin of chain with box:
body *beg, *end;
createChain(beg, end, 0,9.90,0, 0,1,0, 10, 30);
body *b = mScene->createBody("thing", "cube.1m.mesh", new nxOgre::cubeShape(1), 100.0f, Vector(0,10,0));
b->setIgnoreGravity(true);
joint::createSphericalJoint(b, beg, Vector3(0, 9.95, 0));
Problem: When I add force to box, all balls begin fast travel around a circle but don't follow the box (that has big mass and slow move)