RichTufty
06-03-2007 18:19:33
OK, I have a SceneNode attached to a Body (elipsoid) and have the camera attached to the SceneNode. I want to apply velocity to the Body so that the camera moves with the Body, and so that the body can have collision detection.
I am setting the correct velocity to the Body, i know this because i can see the values in debug.
I have set the size of the world to be very large.
I thought maybe that the world wasn't updating, but when i turn gravity on, the camera falls to the ground, which is great, but my other forces aren't working.
Am i completely missing something?!
I am using Mogre + MogreNewt.
Here's some of my code:
I call this every frame:
This bit of code is based on another thread in the forum
Am i missing anything?! Any help would be much appreciated!
Cheers,
Tufty
I am setting the correct velocity to the Body, i know this because i can see the values in debug.
I have set the size of the world to be very large.
I thought maybe that the world wasn't updating, but when i turn gravity on, the camera falls to the ground, which is great, but my other forces aren't working.
Am i completely missing something?!
I am using Mogre + MogreNewt.
Here's some of my code:
newtonWorld = new World();
newtonWorld.setWorldSize(new Mogre.Vector3(-10000, -10000, -10000), new Mogre.Vector3(10000, 10000, 10000));
Mogre.Vector3 cameraSize = new Mogre.Vector3(1f, 1f, 1f);
Collision cameraCollision = new MogreNewt.CollisionPrimitives.Ellipsoid(newtonWorld, cameraSize);
cameraBody = new Body(newtonWorld, cameraCollision);
cameraCollision.Dispose();
cameraBody.setMassMatrix(10.0f, MomentOfInertia.CalcEllipsoidSolid(10.0f, cameraSize));
cameraBody.attachToNode(cameraNode);
I call this every frame:
newtonWorld.update(elapsedTime);
This bit of code is based on another thread in the forum
if (keyState[DXI.Key.RightArrow]) {
direction = get_body_orientation(cameraBody) * Mogre.Vector3.NEGATIVE_UNIT_X;
update = true;
}
velocity = cameraBody.getVelocity() * new Mogre.Vector3(0, 1f, 0) + direction * 30f * fps_speed;
cameraBody.setVelocity(velocity);
Am i missing anything?! Any help would be much appreciated!
Cheers,
Tufty