benlora11
17-09-2008 04:33:03
Hi all
I got a cricket ball , i believed it was because the CollisionPrimitives size was too small, it penetrated the floor when the ball dropped from 1 m height above the floor. I analyzed it and find out if the size of the Ellipsoid is around Vector3(0.06,0.06,0.06) or less, it will penetrate the floor. If the Ellipsoid size is around Vector3(0.065,0.065,0.065) or more, it will not penetrate. I couldn't solve the problem, I wish you guys could give me an answer.I really want to keep the size of the ball smaller than 0.06.
And one thing might worth mention was my sport field terrain. It was export from Google sketchup model, it is a flat field only. I use the TreeCollision or ConvexHull to wrap the terrain just like in the OgreNewt demo 5.
Here is the code of the ball and it physic setup.
Terrain code
I got a cricket ball , i believed it was because the CollisionPrimitives size was too small, it penetrated the floor when the ball dropped from 1 m height above the floor. I analyzed it and find out if the size of the Ellipsoid is around Vector3(0.06,0.06,0.06) or less, it will penetrate the floor. If the Ellipsoid size is around Vector3(0.065,0.065,0.065) or more, it will not penetrate. I couldn't solve the problem, I wish you guys could give me an answer.I really want to keep the size of the ball smaller than 0.06.
And one thing might worth mention was my sport field terrain. It was export from Google sketchup model, it is a flat field only. I use the TreeCollision or ConvexHull to wrap the terrain just like in the OgreNewt demo 5.
Here is the code of the ball and it physic setup.
//Ball
ent = mgr->createEntity("ballEntity","cricketball.mesh");
node =mgr->getSceneNode("FloorNode")->createChildSceneNode("ballNode");
node->attachObject(ent);
//Ball physic
col = new OgreNewt::CollisionPrimitives::Ellipsoid(mWorld,Vector3(0.06,0.06,0.06));
//col = new OgreNewt::CollisionPrimitives::ConvexHull(mWorld,node);
OgreNewt::Body* Ballbody = new OgreNewt::Body(mWorld, col);
delete col;
Ballbody->attachToNode(node);
Ballbody->setPositionOrientation(Vector3(0,1,0),Ogre::Quaternion::IDENTITY);
Ogre::Real mass = 0.163; //cricet ball weight standard : 163gram
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcEllipsoidSolid( mass,Vector3(0.05,0.05,0.05));
Ballbody->setMassMatrix( mass, inertia );
Ballbody->setStandardForceCallback();
Terrain code
//terrain
//Ogre::Vector3 size(1,1,1);
mgr->setAmbientLight(ColourValue(0.25, 0.25, 0.25));
ent = mgr->createEntity("GroundEntity", "scene.mesh");
ent->setCastShadows(false);
node = mgr->getRootSceneNode()->createChildSceneNode("FloorNode");
node->attachObject(ent);
//node->setScale(size);
//terrain physic
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld, node,false);
OgreNewt::Body* floorbody = new OgreNewt::Body(mWorld, col);
delete col;
floorbody->attachToNode(node);
floorbody->setPositionOrientation(Ogre::Vector3(0,0,0), Ogre::Quaternion::IDENTITY );