[Solved] Ball wouldn't fall..

nikhil

15-10-2006 03:55:46

Hi

I'm tryin to basically get a ball to fall down and hit the mesh below.. The ball isn't responding to the following code:


OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Ellipsoid(m_World, Ogre::Vector3(1,1,1));
OgreNewt::Body* body = new OgreNewt::Body( m_World, col );
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcSphereSolid( 10.0, 1.0 );
body->setMassMatrix( 10.0, inertia );
body->attachToNode( mSceneMgr->getSceneNode("ballnode1") );
body->setStandardForceCallback();
body->setPositionOrientation(Vector3(0,150,130), Quaternion::IDENTITY);



I've created a listener for physics.. which basically contains code from the basicFrameListener:-

bool frameStarted(const FrameEvent& evt)
{
m_elapsed += evt.timeSinceLastFrame;

if ((m_elapsed > m_update) && (m_elapsed < (1.0f)) )
{
while (m_elapsed > m_update)
{
m_World->update( m_update );
m_elapsed -= m_update;
}
}
else
{
if (m_elapsed < (m_update))
{
// not enough time has passed this loop, so ignore for now.
}
else
{
m_World->update( m_elapsed );

m_elapsed = 0.0f; // reset the elapsed time so we don't become "eternally behind".
}
}
return true;
}


I've the listener added to the root..

i'm using the exampleframework too.. :lol:

nikhil

15-10-2006 04:04:50

also can u tell me what would happen if i just've



m_World->update( 0.02);
return true;


in the frameStarted event

wht if for just testing purposes i want the physics thing to be simulated at all times.. will this do the trick..???

thanks

nikhil

walaber

15-10-2006 07:33:20

yes you can do that.

as for why it isn't falling,
body->setPositionOrientation(Vector3(0,150,130), Quaternion::IDENTITY); the default size of the Newton world is (-100,-100,-100) to (100,100,100). so your Y coord is outside the default world.

make the world larger by calling setWorldSize() on the OgreNewt::World object.

nikhil

15-10-2006 09:33:24

yes you can do that.

as for why it isn't falling,
body->setPositionOrientation(Vector3(0,150,130), Quaternion::IDENTITY); the default size of the Newton world is (-100,-100,-100) to (100,100,100). so your Y coord is outside the default world.

make the world larger by calling setWorldSize() on the OgreNewt::World object.


hey... cool.. i'll try that.. plz include that info whn u update te tutorial.. this is important.. because sometimes.. people like me... follow the tutorials.. they like to use different variable values.. or do changes in stuff they are already using as a tutorial..

thnks...
nikhil

nikhil

15-10-2006 11:11:42

YAY..

finally Newton is working... :P

thnks walaber..