Problem with Newton Physics

May 31, 2009 at 11:08 PM


I'm trying to set WorldSize in Newton Lib, but when i set it shows a message:

System.AccessViolationException was unhandled
  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
       at NewtonDynamics.Newton.NewtonSetWorldSize(IntPtr pNewtonWorld, Single[] pMinPoint, Single[] pMaxPoint)
       at GoblinXNA.Physics.NewtonPhysics.set_WorldSize(BoundingBox value) in E:\TCC\GoblinXNAv3.2\GoblinXNAv3.2\src\Physics\NewtonPhysics.cs:line 422
       at TCC.Game1.Initialize() in E:\TCC\Projeto\1.0\TCC\TCC\Game1.cs:line 54
       at Microsoft.Xna.Framework.Game.Run()
       at TCC.Program.Main(String[] args) in E:\TCC\Projeto\1.0\TCC\TCC\Program.cs:line 14

My code

NewtonPhysics physics= new NewtonPhysics();
physics.WorldSize = new BoundingBox(new Vector3(-400f, -200f, -400f), new Vector3(400f, 200f, 400f));


Did anyone try this?

Jun 1, 2009 at 5:35 PM

You need to initialize the physics engine before doing anything with it.

If you do scene.PhysicsEngine = new NewtonPhysics(), then scene class automatically calls the Initialize() function, but if you just do NewtonPhysics physics = new NewtonPhysics(), then you need to call Initialize() yourself.