gravity not work

whw0828

14-04-2009 07:47:54

my entironment:
ogre 1.6
NewtonWin-2.00
OgreNewton 2.0

mOgreNewtListener = new OgreNewt::BasicFrameListener(win, mWorld,60 );
root->addFrameListener( mOgreNewtListener );

Ogre::SceneNode* nodeRobot = sceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Entity* entRobot = sceneMgr->createEntity( "robot", "robot.mesh" );
nodeRobot->attachObject( entRobot );
Ogre::Vector3 size1=Ogre::Vector3(30,10,40);
OgreNewt::Collision* collisionRobot= new OgreNewt::CollisionPrimitives::Box( mWorld,size1);
bodyRobot= new OgreNewt::Body( mWorld, collisionRobot );
bodyRobot->attachNode( nodeRobot );
Ogre::Real mass = 10.0;
Ogre::Vector3 inertia, offset;
// collision->calculateInertialMatrix(inertia, offset);
NewtonConvexCollisionCalculateInertialMatrix(collisionRobot->getNewtonCollision(), &inertia.x, &offset.x );
bodyRobot->setMassMatrix( mass, inertia );
bodyRobot->setStandardForceCallback();
bodyRobot->setPositionOrientation( Ogre::Vector3(500,300,300),Ogre::Quaternion::IDENTITY);



but the object not move
help help

Zero23

14-04-2009 11:39:12

First you dont need to use the newton functions directly
// Use this and then you can use
OgreNewt::ConvexCollision* collisionRobot= new OgreNewt::CollisionPrimitives::Box( mWorld,size1);

// this code here, and dont need to call the Newton function direct!
collision->calculateInertialMatrix(inertia, offset);


And then before you call "bodyRobot->setMassMatrix( mass, inertia );" write this
inertia *= mass;


I hope this help^^

Zero

whw0828

15-04-2009 07:23:59

thanks
i have solved the problem

//default world size is(-100,-100,-100)(100,100,100)
//you should change you world size
mWorld->setWorldSize(Ogre::Vector3(-1800,-100,-1800),Ogre::Vector3(1800,800,1800));