Buckcherry
22-06-2006 21:13:11
Hi everybody,
I do not get to make to work OgreNewt. I do not know where is the error...
I have done the following:
In a class called Main I have defined:
The constructor of this class is like this:
And the createFrameListener method is:
I pass the mWorld as parameter in the MouseQueryListener class:
The MouseQuerListener's constructor is:
To create a physic body I use the function:
But when I run the game, the character does not fall due to the gravity!!!. In fact, there is not collision between bodies, gravity... nothing...
What is wrong?.
Any idea?
I do not get to make to work OgreNewt. I do not know where is the error...
I have done the following:
In a class called Main I have defined:
OgreNewt::World* mWorld;
OgreNewt::BasicFrameListener* mOgreNewtListener;
as Private.The constructor of this class is like this:
Main::Main(): mGUIRenderer(0), mGUISystem(0), mEditorGuiSheet(0)
{
// OgreNewt
mWorld = new OgreNewt::World();
}
And the createFrameListener method is:
void Main::createFrameListener(void)
{
mFrameListener->showDebugOverlay(false);
mRoot->addFrameListener(mFrameListener);
// OgreNewt
mOgreNewtListener = new OgreNewt::BasicFrameListener( mWindow, mSceneMgr, mWorld, 120 );
mRoot->addFrameListener( mOgreNewtListener );
}
I pass the mWorld as parameter in the MouseQueryListener class:
mFrameListener = new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer, mRoot, mGUISystem, mEditorGuiSheet, mWorld);
The MouseQuerListener's constructor is:
MouseQueryListener::MouseQueryListener(RenderWindow* &win, Camera* &cam, SceneManager* &sceneManager, CEGUI::OgreCEGUIRenderer* &renderer, Root* &root, CEGUI::System* &guiSystem, CEGUI::Window* &editorGuiSheet, OgreNewt::World* &mWorld)
: ExampleFrameListener(win, cam, true, true), mGUIRenderer(renderer)
{
...
// OgreNewt
_world = mWorld;
...
}
To create a physic body I use the function:
void createPhysicalBody(OgreNewt::World* &mWorld)
{
// rigid body.
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Cylinder( mWorld, 2, 4 );
mBody = new OgreNewt::Body( mWorld, col );
mBody->attachToNode( mMainNode );
// initial position
mBody->setPositionOrientation( Ogre::Vector3(-2,3,2), Ogre::Quaternion::IDENTITY );
delete col;
Ogre::Real mass = 10.0;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcCylinderSolid( mass, 2, 4 );
mBody->setMassMatrix( mass, inertia );
mBody->setStandardForceCallback();
}
But when I run the game, the character does not fall due to the gravity!!!. In fact, there is not collision between bodies, gravity... nothing...
What is wrong?.
Any idea?