ncazanav
03-03-2007 15:22:31
I have used oFusion to export a cube of size 100 (with XForm reset). I am using OgreNewt and I am trying to add a collision box, but I don't manage to have both
my cube mesh and my box collision object overlaped : there is still an offset between the two, it seems that the center are differents
here's what I get

And here is my sample code (it is written with Mogre, but shouldn't be different from the original C++ lib)
1- The creation of the scene :
2- The creation of the Box collsion object :
What's wrong in my code?
my cube mesh and my box collision object overlaped : there is still an offset between the two, it seems that the center are differents
here's what I get
And here is my sample code (it is written with Mogre, but shouldn't be different from the original C++ lib)
1- The creation of the scene :
// /////////////////////////// Manual Scene
Entity planeEnt = mgr.CreateEntity("plane01", "plane01.mesh");
SceneNode planeNode = mgr.RootSceneNode.CreateChildSceneNode("plane01Node");
planeNode.AttachObject(planeEnt);
Vector3 size = new Vector3(1f, 1f, 1f);
Entity boxEnt = mgr.CreateEntity("box04", "box04.mesh");
SceneNode boxNode = mgr.RootSceneNode.CreateChildSceneNode("box04Node");
boxNode.SetScale(size);
boxNode.AttachObject(boxEnt);
boxEnt.SetMaterialName("Murs");
camera = mgr.CreateCamera("Camera02");
camera.Position = new Vector3(-336.414f, 71.1905f, 13.3086f);
camera.Orientation = new Quaternion(-0.501067f, 0.49893f, -0.49893f, -0.501067f);
camera.LookAt(new Vector3(355.638f, 71.1905f, 10.3511f));
mWindow.AddViewport(camera);
Light li = mgr.CreateLight("Omni01");
li.Type = Light.LightTypes.LT_POINT;
li.Position = new Vector3(-155.58f, 153.848f, -121.603f); 2- The creation of the Box collsion object :
// /////////////////////////// Manual Physics
MogreNewt.Collision mCol = new MogreNewt.CollisionPrimitives.Box(mNewtonManager.NewtonWorld, 100*size);
MogreNewt.Body mBoxBody = new MogreNewt.Body(mNewtonManager.NewtonWorld, mCol);
mCol.Dispose();
mBoxBody.attachToNode(boxNode);
// base mass on the size of the object.
float mass = size.x * size.y * size.z * 2.5f;
// calculate the inertia based on box formula and mass
Vector3 inertia = MogreNewt.MomentOfInertia.CalcBoxSolid(mass, size);
mBoxBody.setMassMatrix(mass, inertia);
mBoxBody.setPositionOrientation(boxNode.Position, boxNode.Orientation);What's wrong in my code?