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

drawing pictures offset from center

Jun 18, 2009 at 3:23 AM

I understand that textures need to be drawn centered on the center of a physics body to get the rotation correct.

Is there any way, using an 'offset from center' vector2 to get the origin to draw it off center? and keep the rotation corrent?

Jun 18, 2009 at 4:06 AM
Edited Jun 18, 2009 at 4:08 AM

Below is an example of something I do, that might be applicable for your situation.  Basically, those vectors came from some paths on my drawing.  The last line is probably unnessasary, but I refer to the verts later on.  When I create the graphics I add the translate transform below.

Vertices vertsSensor = new Vertices();
new Vector2(8, 10));
new Vector2(12, 10));
new Vector2(12, 190));
new Vector2(8, 190));
center = vertsSensor.GetCentroid();
ref graphicsCenter);

... later on

TranslateTransform translateTrans = new TranslateTransform();
translateTrans.X = center.X * -1.0;
translateTrans.Y = center.Y * -1.0;

Jun 18, 2009 at 4:58 AM

does this take into account rotation?

I just find it hard to center images over the physics body.

Jun 18, 2009 at 2:27 PM

For Rotation I just have a rotation transform and every "turn" I make sure the rotation is in sync with the body's rotation.  I think I'm not quite understanding what you want to do, maybe an example of what you're trying to accomplish will help?  If you want the graphics to appear off, in my example you could just add an arbitrary amount to center, and then that translate tranform will always be off.

I'm doing this in Silverlight, are you doing an XNA project?  Seems like we needs a FP General, Silverlight/WPF and XNA discussion group

Jun 22, 2009 at 1:49 PM

have a look a this thread: