vilgeits
20-02-2006 10:27:16
i've use ogrenewt long ago when it was not an official addon, my code works fine but i try to update it and nothing works
i try to put a simply code in my app and.... noway
The cylinders were created but it didn't move
thanks in advance
i try to put a simply code in my app and.... noway
if (iInputDevice->isKeyDown(Ogre::KC_9))
{
// we get the position and direction from the camera...
Ogre::Vector3 dir, vec;
Ogre::Quaternion camorient = iCamera->getOrientation();
vec = Ogre::Vector3(0,0,-1);
dir = camorient * vec;
// then make the visual object (again a cylinder)
Entity* ent;
SceneNode* node;
Ogre::String name;
Ogre::Vector3 pos = iCamera->getPosition();
name = "Body "+Ogre::StringConverter::toString( count++ );
ent = iSceneManager->createEntity( name, "cylinder.mesh" );
node = iSceneManager->getRootSceneNode()->createChildSceneNode( name );
node->attachObject( ent );
node->setScale(10,10,10);
ent->setMaterialName( "Simple/dirt01" );
ent->setNormaliseNormals(true);
// again, make the collision shape.
OgreNewt::Collision* col2 = new OgreNewt::CollisionPrimitives::Cylinder(NF_World, 10, 10);
// then make the rigid body.
OgreNewt::Body* body = new OgreNewt::Body( NF_World, col2 );
//no longer need the collision shape object
delete col2;
// something new: moment of inertia for the body. this describes how much the body "resists"
// rotation on each axis. realistic values here make for MUCH more realistic results. luckily
// OgreNewt has some helper functions for calculating these values for many primitive shapes!
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcSphereSolid( 10.0, 1.0 );
body->setMassMatrix( 10.0, inertia );
// attach to the scene node.
body->attachToNode( node );
// this is a standard callback that simply add a gravitational force (-9.8*mass) to the body.
body->setStandardForceCallback();
// set the initial orientation and velocity!
body->setPositionOrientation( pos, camorient );
body->setVelocity( (dir * 50.0) );
}
The cylinders were created but it didn't move
thanks in advance