Need Help On Player Controller of OgreNewt 2.0

dude3d

04-04-2009 09:44:39

Hi all,

I'm very new to OgreNewt. I need help on utilizing the player controller introduced in OgreNewt2.0.

I got the latest OgreNewt from SVN http://svn.ogre3d.org/svnroot/ogreaddons/branches/ogrenewt/newton20 and compiled it against Newton 2.0 Beta. I want to use the player controller to move my character. The following is my code snippet:


Entity* ent;
SceneNode* node;
Ogre::String name;
Ogre::Vector3 pos = msnCam->_getDerivedPosition();

name = "Body "+Ogre::StringConverter::toString( count++ );

ent = mSceneMgr->createEntity( name, "box.mesh" );
node = mSceneMgr->getRootSceneNode()->createChildSceneNode( name );
node->attachObject( ent );
node->setScale( size );

ent->setMaterialName( "Simple/BumpyMetal" );

OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Box( m_World, size );
OgreNewt::Body* body = new OgreNewt::Body( m_World, col );

Ogre::Vector3 inertia = Ogre::Vector3::ZERO;

body->setMassMatrix( 0.0f, inertia );
body->attachNode( node );
body->setStandardForceCallback();
body->setPositionOrientation( Ogre::Vector3(-5,8,0), Ogre::Quaternion::IDENTITY );
body->unFreeze();

OgreNewt::PlayerController* mOgreNewtPlayerController = new OgreNewt::PlayerController(body);

mOgreNewtPlayerController->setVelocity(4, 0, Ogre::Degree(0));


With the above code, I use a box as the character but the box doesn't move at all. Can anybody give me some suggesting about what I should change to get the box moving and/or how to use the new player controller? I appreciate if you can share some of your code snippets.

Thanks,

Dude3D

melven

04-04-2009 12:45:45

The player controller is not working yet, you need to read the OgreNewt.h first! I cannot continue my work there because there's a bug in the newton beta since january in the convexcast (it only occurs if you are using more than the first result of a convexcast)...