An object that is at rest will stay at rest (unfortunately)

m00se

08-09-2011 15:07:46

Hey everyone!
I'm new to the forum, but have read a lot here which made me able to get Mogre running in combination with MogreNewt.
The CreateScene method is called first, followed by an infinite loop of UpdateScene (makes sense I think).


public void CreateScene()
{
mEngine.SceneMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f);

SceneNode boneNode = mEngine.SceneMgr.RootSceneNode.CreateChildSceneNode();
boneNode.Position = new Vector3(0f, 10f, 0f);

Entity bone = mEngine.SceneMgr.CreateEntity("bone", "bone.mesh");
boneNode.AttachObject(bone);
boneNode.ShowBoundingBox = true;

world = new World();
world.SetWorldSize(new Vector3(-50, 0, -50), new Vector3(50, 50, 50));
world.SetFrictionModel(World.FrictionModelMode.FM_EXACT);

ConvexCollision boneColi = new MogreNewt.CollisionPrimitives.Cylinder(world, 3, 5, 1);
Body boneBody = new Body(world, boneColi);

boneBody.AttachNode(boneNode);
boneBody.SetMassMatrix(5, new Vector3(1,1,1));
boneBody.IsGravityEnabled = true;
}

public void UpdateScene()
{
world.CollisionUpdate();
mEngine.Update();
}


So, I can see my "bone", rotate around it using some keyboard input, but it does not fall down.

Anyone knows why my "bone" takes Newton's first law a bit to literally?

P.S. sorry for the C#; I'm a bit to lazy to do C++

ianhfar

09-09-2011 15:04:58

Can you determine that the visual model ( the scenenode) and the newton body are placed at the same place?
Once you have attached your scenenode then place the body using SetPositionOrientation(...)

It might help, if you can visualise the newton world by using

world.DebuggerInstance.Init(mEngine.SceneMgr);
world.DebuggerInstance.ShowDebugInformation();

in your render loop eg. UpdateScene()

world.DebuggerInstance.ShowDebugInformation(false, false);

hope this helps