This project has moved. For the latest updates, please go here.

Polygon Collision....

Dec 27, 2007 at 7:53 AM
Edited Dec 27, 2007 at 11:25 AM
Taking the QuickStart example , I replaced the Initialize() which contained Rectangle bodies to Polygonal.
When the objects collide along their sides, one object goes into the other.
I tried to check if body1's geometry collides with body2's geometry, but there is no collision happening at that time.
Could you help me to find out?
I have used 0 gravity.
The replaced code is as follows:
protected override void Initialize() {
// TODO: Add your initialization logic here

//set update to be fixed at 100 fps
IsFixedTimeStep = true;
TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 10); //10 ms --> 100 fps for physics update

//create the simulator with gravity = 200
physicsSimulator = new PhysicsSimulator(new Vector2(0,0));

Vertices v = new Vertices();
v.Add(new Vector2(-95, -95));
v.Add(new Vector2(-95, 95));
v.Add(new Vector2(95, 95));
v.Add(new Vector2(95, -95));
//create body for box 1
boxBody1 = BodyFactory.Instance.CreateBody(physicsSimulator, 10, v.CalculateMomentOfInertia());
//set the bodies position and make it static so it won't move.
boxBody1.Position = new Vector2(400, 100);
boxBody1.IsStatic = true;

//create the geometry for box 1
//boxGeom1 = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, boxBody1, 190, 190);

boxGeom1 = GeomFactory.Instance.CreatePolygonGeom(physicsSimulator, boxBody1, v, 1);
boxGeom1.CollisionResponseEnabled = true;

//create the body for box 2 and set it's position
boxBody2 = BodyFactory.Instance.CreateBody(physicsSimulator, 10, v.CalculateMomentOfInertia());
boxBody2.Position = new Vector2(400, 400);

//create the geometry for box 2
//GeomFactory.Instance.GridCellSizeAABBFactor = 0.1f;
boxGeom2 = GeomFactory.Instance.CreatePolygonGeom(physicsSimulator, boxBody2, v, 0);
boxGeom2.CollisionResponseEnabled = true;

//create a revolute joint between the two boxes
//revoluteJoint = JointFactory.Instance.CreateRevoluteJoint(physicsSimulator,boxBody1, boxBody2,new Vector2(400,300));

Dec 27, 2007 at 3:03 PM
Please look here:

and here:

The first url may well have the answer to your question.
Dec 28, 2007 at 4:26 PM
correct, you must have some vertices along the edges of your rectangle, not just the corners.