views:

125

answers:

1

I'm using FarSeer and XNA.

Is there an easy way to resize or scale a FarSeer body ?

Thanks.

A: 

Hi. I was looking for a solution to this and stumbled upon your thread at the official forum. Here's what I could gather from looking at the official forum posts and the Farseer source code:

When using body factory, the width/height/radius parameters are supplied to calculate its moment of inertia only. The body class itself doesn't have width/height fields or properties.

I think what you are looking for is how to resize geom, which is the thing matters in collision detections.

The Geom class (rectangles, circles and whatnot) doesn't have width/height/radius fields or properties either. Instead it is defined by a set of vertices, so in order to resize the geom we will need the ability to modify vertices. The geom class has a public method for this:

    /// <summary>
    /// Sets the vertices of the geom.
    /// </summary>
    /// <param name="vertices">The vertices.</param>
    public void SetVertices(Vertices vertices)
    {
        vertices.ForceCounterClockWiseOrder();
        localVertices = new Vertices(vertices);
        worldVertices = new Vertices(vertices);

        AABB.Update(ref vertices);
    }

For resizing we just need to perform arithmetic operations on the vertices. Haven't had time to test it out myself but this should be where we start.

Dan7