[solved] framelistener required?

Arcanor

06-04-2007 01:22:26

I'm brand new to OgreNewt. I've been running through the initial tutorial at: http://www.ogre3d.org/wiki/index.php/Newton_Game_Dynamics
and trying to integrate basic gravity into my existing ogre application. I use a manual render loop instead of ogre's framelisteners.

Here's what I've done:
- compiled everything needed, and #include <OgreNewt.h> in my screen manager
- when creating my world's starting objects, I instantiate mWorld, then setup collision and body for an ogre entity (a simple cube positioned in the air), as follows:
mWorld = new OgreNewt::World();
OgreNewt::Collision* collision;
OgreNewt::Body* body;
Ogre::Vector3 size;
Ogre::Real mass;
Ogre::Vector3 inertia;
Entity* ent;
SceneNode* entNode;

ent = mSceneMgr->createEntity("test/cube", "box.mesh");
ent->setMaterialName("SOLID/TEX/abstract_a032.jpg");
entNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
entNode->attachObject(ent);
size = Vector3(30, 30, 30);
entNode->setScale(size);
collision = new OgreNewt::CollisionPrimitives::Box(mWorld, size);
body = new OgreNewt::Body(mWorld, collision);
body->attachToNode(entNode);
body->setPositionOrientation(Vector3(0, 273, 150), Quaternion::IDENTITY);
delete collision;
mass = 10.0;
inertia = OgreNewt::MomentOfInertia::CalcBoxSolid(mass, size);
body->setMassMatrix(mass, inertia);
body->setStandardForceCallback();


- During my main program loop, I'm calling mWorld->update(time_in_seconds), but my box is not falling for some reason.

Do I need to define a framelistener for ogrenewt, or should I be okay with just calling mWorld->update(time_in_sec)?

Or have I missed something else in my code?

thanks in advance. :)

walaber

06-04-2007 01:32:54

there's nothing wrong with your update code, you don't need a framelistener.

the problem is that you are placing the box outside the limtis of the World. it defautls to a size of (-100,-100,-100) to (100,100,100).

if you need a bigger world, set the world size to something bigger.


but also remember that Newton works best with a scale of 1 unit = 1 meter.

Arcanor

06-04-2007 01:37:52

Thanks walaber, that did the trick. :)

Now I need to scale everything down a bit...