Newton and OGRE arn't mixing...[SOLVED]

Los Frijoles

18-10-2007 21:29:23

Solved on the normal OGRE Forums...

I am trying to make a Newton's Balls demo thingy using OgreNewt.

I am not sure what I am doing wrong, but here is the effect:

http://www.youtube.com/watch?v=Lvg-hnm1cOY

And here is the code:

//create the balls and stand for physics
Entity* theBall;
OgreNewt::Collision* col;
for(int i = 0;i<5;i++)
{
theBall = mSceneMgr->createEntity("TheBall"+i, "MetalBall.mesh");
mBalls[i] = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mBalls[i]->attachObject(theBall);
mBalls[i]->setPosition(Vector3(2-i,0,4.5));
mBalls[i]->setOrientation(Quaternion(Degree(90),Vector3(1,0,0)));

col = new OgreNewt::CollisionPrimitives::Ellipsoid(mWorld,Vector3(1,1,1));
pBalls[i] = new OgreNewt::Body(mWorld,col);
pBalls[i]->attachToNode(mBalls[i]);
pBalls[i]->setMassMatrix(1,OgreNewt::MomentOfInertia::CalcEllipsoidSolid(1,Vector3(1,1,1)));
pBalls[i]->setPositionOrientation(Vector3(2-i,0,4.5),Quaternion::IDENTITY);
pBalls[i]->setCustomForceAndTorqueCallback( BallScreensaverApp::physicsGrav );

col = new OgreNewt::CollisionPrimitives::Box(mWorld,Vector3(1,1,1));
pStandL[i] = new OgreNewt::Body(mWorld,col);
pStandL[i]->setPositionOrientation(Vector3(2-i,-2,4.5),Quaternion::IDENTITY);
pStandL[i]->setCustomForceAndTorqueCallback( BallScreensaverApp::physicsGrav );

col = new OgreNewt::CollisionPrimitives::Box(mWorld,Vector3(1,1,1));
pStandR[i] = new OgreNewt::Body(mWorld,col);
pStandR[i]->setPositionOrientation(Vector3(2-i,2,4.5),Quaternion::IDENTITY);
pStandR[i]->setCustomForceAndTorqueCallback( BallScreensaverApp::physicsGrav );

col = new OgreNewt::CollisionPrimitives::Cylinder(mWorld,0.05,4);
pLineL[i] = new OgreNewt::Body(mWorld,col);
pLineL[i]->setCustomForceAndTorqueCallback( BallScreensaverApp::physicsGrav );
pLineR[i] = new OgreNewt::Body(mWorld,col);
pLineR[i]->setCustomForceAndTorqueCallback( BallScreensaverApp::physicsGrav );

//bJointL[i] = new OgreNewt::BasicJoints::BallAndSocket(mWorld,pBalls[i],pLineL[i],Vector3(2-i,0,4.5));
//bJointR[i] = new OgreNewt::BasicJoints::BallAndSocket(mWorld,pBalls[i],pLineR[i],Vector3(2-i,0,4.5));
//tJointL[i] = new OgreNewt::BasicJoints::BallAndSocket(mWorld,pLineL[i],pStandL[i],Vector3(2-i,-2,4.5));
//tJointR[i] = new OgreNewt::BasicJoints::BallAndSocket(mWorld,pLineR[i],pStandR[i],Vector3(2-i,2,4.5));
}


It looks to me like there is some sort of offset problem. I have no idea what I am doing wrong and the debug boxes for OgreNewt will not turn on for some reason. What do you guys think?