This project has moved and is read-only. For the latest updates, please go here.

incorrecet collisons when gemos collide

May 20, 2009 at 10:11 AM
Edited May 20, 2009 at 10:20 AM

hi i have a got problems with my collision detection when a gemos has been created using the createpolygon metord.


To make things simple iv uploaded a video showing the problem.


the video is here Video


My code for creating the polygons is here


 public void CreateVectorObj(Vector2 Pos, int mass, float inRotation, bool IsStatic, Texture2D sprite, bool on)
            inizalized = true;
            size = new Vector2(sprite.Width, sprite.Height);

            uint[] data = new uint[sprite.Width * sprite.Height];

            //Transfer the texture data to the array

            //Calculate the vertices from the array
            Vertices verts = Vertices.CreatePolygon(data, sprite.Width, sprite.Height,Vector2.Zero,1,1f);
            //Make sure that the origin of the texture is the centroid (real center of geometry)
            center = verts.GetCentroid();

            //Use the body factory to create the physics body
            body = BodyFactory.Instance.CreatePolygonBody(parent.physicsSimulator, verts, mass);

            Col = GeomFactory.Instance.CreatePolygonGeom(parent.physicsSimulator, body, verts,0);
            body.Position = Pos;
            body.Enabled = on;
            body.IsStatic = IsStatic;
            body.Rotation = inRotation;

            //body.LinearDragCoefficient = 0.01f;




your help greatly appreciated.

May 20, 2009 at 10:47 AM
Edited May 20, 2009 at 10:48 AM

haha, very cool error description with video.

have a look at the manual -> Known issues, 2. Geometries going into each other

May 20, 2009 at 1:49 PM

You need more vertices along the edges. Try using Vertices.SubDivideEdge() on the polygon.