Scaling Bodies and Geoms

Topics: User Forum
Jun 26, 2009 at 5:02 PM

I'm currently using an implementation of the "textures to vertices" steps to create custom shaped bodies and geoms based on a texture.  My long term plan is to create an editor in winforms that allows "drawing" of a series of points overtop a texture, saving that to a file, and loading that file at runtime to create bodies and geoms (anyone done anything like this already?).

In the meantime, I can create a custom body and geom from a texture, however, that limits the size of the body and geom to be exactly the size of the texture.  If I wanted to scale this object in XNA, I can scale the texture itself, but is there a way to scale the size of the body and geom?  Alternatively, if this isn't possible, can the set of Vertices that is created from the texture scalable, before creating the body and geom from it?

Jun 27, 2009 at 11:53 AM

What I did to be able to scale the Vertices is this:

Vector2 tmp = new Vector2(scale, scale);
verts.Scale(ref tmp);

I was messing around and found figured out to do that... it works for Polygons or shapes where you manually create your vertices, but I haven't found scaling for pre-set shapes yet.

Coordinator
Jun 27, 2009 at 6:47 PM

@DJester:

Yes, something like that has been done before. By myself actually. It was a long time ago before I took over the Farseer Physics project as a maintainer. It was called PolygonMapper. I still have the source in my private source control I think, if you have any question regarding it or want to take a look at the code, you are welcome to contact me and I will send it to you.

Jun 29, 2009 at 3:32 PM

@Random12345:  Thanks.  I thought something like that could be done, but hadn't looked into getting it to work yet.  Thanks for the code.

@genbox:  Message sent.  This would be VERY useful for my project, and for others as well, if I can wrestle something out of it.