unstable pyramid made from cylinders

bishopnator

16-09-2008 11:16:29

Hi, I want to try some physics to see how it works, etc. I build pyramid from cylinders, but it is unstable - cylinders fall down by theyself. I see problem in collision between cylinders. I create small hole between cylinder rows - 1mm so after starting I expect, that cylinders fall down a little and whole pyramid will be stable. But they are not. Half cylinder sink to cylinder below and whole pyramid crash.

I draw debug lines and collision models seem to be setup correctly (correspond with graphical representation). I see same behavior with boxes - I looked in examples (OgreNewt examples and NewtonDynamics examples) and I didn't find any differences between my application and these samples in Physics initialization.

Also when cylinders fall to ground (simple box) they roll in circle (like cones) - half of cylinder is sink to this box.

bishopnator

16-09-2008 18:43:27

here are some screenshots for better explaination:
original pyramid:


invalid collision detection:



walaber

17-09-2008 01:09:53

how big are the cylinders, what are you setting the mass to, and how did you calculate the moment of inertia?

bishopnator

17-09-2008 19:42:32

cylinders have following parameters:
float fCylinderRadius = 0.05f;
float fCylinderHeight = 0.15f;
pNwCollision = new OgreNewt::CollisionPrimitives::Cylinder(m_pNwWorld, fCylinderRadius, fCylinderHeight);
float fMass = 1.0f;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcCylinderSolid( fMass, fCylinderRadius, fCylinderHeight );


creating scene and rigid body:
pNwBody = new OgreNewt::Body(m_pNwWorld, pNwCollision);
pEnt = mSceneMgr->createEntity(sEntName, "cylinder.mesh");
pEnt->setMaterialName("cube/rock");
pSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
pSceneNode->setScale(fCylinderHeight, fCylinderRadius, fCylinderRadius);
pSceneNode->attachObject(pEnt);
pNwBody->attachToNode(pSceneNode);
pNwBody->setMassMatrix(fMass, inertia);
pNwBody->setStandardForceCallback();

// calculate initial position and orientation
Ogre::Vector3 p = ... // init
Ogre::Quaternion qRot = ... // init
pNwBody->setPositionOrientation(p, qRot);


Position and orientation is automatically set to scene node, so it seems that is it correct - if you want, I can past whole my OgreNewt init method.