BEPU Collisions

Dec 15, 2012 at 12:19 PM
Edited Dec 15, 2012 at 12:29 PM

Good Morning

Another question in a short time, I know. This is somehow related to http://igf.codeplex.com/discussions/388230...
I'm new to sunburn/igf/xna/3D, and I don't know how the physics integration in igf works, so this is my problem:

I have 2 SceneObjects with BoxCollisionMove and I move one of the via ApplyObjectForce (An fps-camera is attached to this one). When these objects collide, I see the two collision boxes rendered by BEPUPhysicsRenderer turn red, but they are not solid and can move through each other.

Short: How can I make SceneObjects solid?

Barrel.cs

class Barrel : SceneObject, IContentHost{

	public void LoadContent(IContentCatalogue catalogue, ContentManager manager)
	{
		var model = manager.Load<Model>("Models/Barrel");

		foreach (var mesh in model.Meshes)
		{
			AddModelMesh(mesh, null);
		}

		Visibility = ObjectVisibility.RenderedInEditor;

       	 	AffectedByGravity = false;
            
        	CollisionMove = new BoxCollisionMove(this)
        	{
            		Entity =
            		{
             	  		LinearDamping = 0.9999f
            		}
        	};
        	World = Matrix.CreateTranslation(new Vector3(0f, 20f, 0f));

		Entity<ConvexCollidable<BoxShape>> collisionEntity = ((BoxCollisionMove)CollisionMove).Entity;
        	collisionEntity.BecomeKinematic();
	}

    public void UnloadContent(IContentCatalogue catalogue)
    {
    }
}

Map.cs

class Map : SceneObject, IContentHost {
	public void LoadContent(IContentCatalogue catalogue, ContentManager manager) {
		var model = manager.Load<Model>("Models/TestPlane");

		foreach (var mesh in model.Meshes) {
			AddModelMesh(mesh, null);
		}

       		AffectedByGravity = false;
        	CollisionMove = new BoxCollisionMove(this)
        	{
            		Scale = new Vector3(2.0f, 2f, 2.0f)
        	};

		Entity<ConvexCollidable<BoxShape>> collisionEntity = ((BoxCollisionMove)CollisionMove).Entity;
		collisionEntity.BecomeKinematic();
	}

	public void UnloadContent(IContentCatalogue catalogue) {

	}
}

I move the barrel in my PlayerInputBehavior somehow like this:

barrel.CollisionMove.ApplyObjectForce(1f * camera.Rotation.Right * playerInput.ThumbSticks.LeftStick.X);

I added the PhysicsManager of course:

SunBurn.AddManager(new BEPUPhysicsManager(SunBurn));

I'm using IGF 0.9.2.0.

Thanks in advance
Leo

PS: If you see some ugly/unnecessary code, please tell me. 

Coordinator
Dec 17, 2012 at 5:14 PM

As soon as you added a BoxCollisionMove to your SceneObject, the physics follow the same rules as if you were using SunBurn's Physics system.

Thus, make sure that your SceneObject.CollisionType is set to CollisionType.Collide and you should be fine ;)

Dec 17, 2012 at 5:51 PM
Edited Dec 17, 2012 at 5:51 PM

Oh, that was too easy... Well, I'll have vacations soon when I can learn the basics without being braindead from work.

Thank you very much for helping me out! I'm having really much fun with IGF right now.