I am realize rope based on Newton. But I have probleb...
Posted: Sun Nov 19, 2006 8:50 am
I am realize rope beased on Newton Physic.
I am create many small objects (size=1,1,1) and connect it by ball constraint.
To and of rope I am connect Big object - size=(10,10,10)
I am test it. It looks a real. But when bigobject touch small objects, my project is crashed.
I am debugged project and has noticed: project crash on
Why such can occur?
My project:
http://www.webpolit.com/irr/NewtonRope.rar
Please help me.
I am create many small objects (size=1,1,1) and connect it by ball constraint.
Code: Select all
ISceneManager* smgr = device->getSceneManager();
//Create Rope connected to prev box
NewtonBody *link0,*link1;
link0 = firstSegment.Body;
vector3df lastPos = firstSegment.Node->getPosition();
for(int i=0;i<Count;i++)
{
NewtonCollision* collision = NewtonCreateBox(nWorld,1, 1, 1 , NULL);
link1 = NewtonCreateBody (nWorld, collision);
NewtonBodySetLinearDamping (link1, 0.2f);
vector3df angularDamp (0.2f, 0.2f, 0.2f);
NewtonBodySetAngularDamping (link1, &angularDamp.X);
vector3df newPos = lastPos;
matrix4 mat;
newPos+=segmentOffset;
ISceneNode* node = smgr->addCubeSceneNode(1);
node->setPosition(newPos);
mat.setTranslation(newPos);
NewtonBodySetUserData(link1, node);
NewtonBodySetMatrix(link1, &mat.M[0]);
NewtonBodySetMassMatrix (link1, 1, 1.0f, 1.0f, 1.0f);
NewtonBodySetTransformCallback(link1, FishungLineSetMeshTransformEvent);
NewtonBodySetForceAndTorqueCallback(link1, FishungLineApplyForceAndTorqueEvent);
NewtonReleaseCollision (nWorld, collision);
SFishungLineSegment segment;
segment.Joint=NewtonConstraintCreateBall (nWorld, &lastPos.X,link0, link1);
segment.Body = link1;
segment.Node = node;
Segments.push_back(segment);
lastPos = newPos;
link0 = link1;
}
I am test it. It looks a real. But when bigobject touch small objects, my project is crashed.
I am debugged project and has noticed: project crash on
Code: Select all
NewtonUpdate(nWorld, 0.01);
My project:
http://www.webpolit.com/irr/NewtonRope.rar
Please help me.