Quall
18-02-2009 23:44:15
Hello, I am going through some basic newton examples but am having trouble getting the body to update without setting the velocity myself. If anyone sees something I am doing wrong or has some input on helping I would appreciate it.
I set up a basic body and scene node:
Then in my update loop, I do this:
The body does not seem to move at all. I try adding local and global force as well, with no results. I do not set any callbacks because there is nothing to collide with in the scene, are they required? When I call this, it sets the velocity and the body then moves a little.
I set up a basic body and scene node:
World _NewtonWorld = new World();
SceneNode node = _SceneManager.RootSceneNode.CreateChildSceneNode();
Entity ent = _SceneManager.CreateEntity( "Juno" , "Juno.mesh" );
node.AttachObject( ent );
node.SetPosition( 0 , 0 , 0 );
float mass = 1000;
Collision col = new CollisionPrimitives.Capsule( _NewtonWorld , ent.BoundingRadius , ent.BoundingBox.Size.y );
Body nodebody = new Body( _NewtonWorld , col );
nodebody.SetMassMatrix( mass , MogreNewt.MomentOfInertia.CalcCylinderSolid( mass , ent.BoundingRadius , ent.BoundingBox.Size.y ) );
nodebody.AttachToNode( node );
nodebody.IsGravityEnabled = false; //gravity does nothing?
Then in my update loop, I do this:
Vector3 force = new Vector3( 0 , -98f , 0 ); //sim gravity force
force *= 1000;
nodebody.AddForce( force );
_NewtonWorld.Update( timeSinceLastUpdate );
The body does not seem to move at all. I try adding local and global force as well, with no results. I do not set any callbacks because there is nothing to collide with in the scene, are they required? When I call this, it sets the velocity and the body then moves a little.
nodebody.Velocity = new Vector3( -10f , 0 , 0 );