Width and Height from Fixture

Topics: User Forum
Jan 6, 2011 at 6:56 PM


I'm creating a ragdoll body by creating limbs via FixtureFactory and attaching them using JointFactory. The FixtureFactory calls return a fixture for me to reference the object. My question is though, how do I retrieve the width and height of the object from that (I need it for drawing the doll correctly).

Is the value I use to create the shape stored anywhere? Or do I really have to subclass Elliptic Fixture and store the width/height fields there?



Jan 6, 2011 at 8:46 PM

Shouldn't you have these values anyway, cause you used them to create the fixtures in the first place?

Also you can always get the associated shape via Fixture.Shape and cast it to the correct shapetype (stored in Fixture.ShapeType).

Jan 6, 2011 at 10:02 PM

FPE only have 2 kinds of shapes:


As polygons can be anything from a line to a chiliagon (1000 edges), there is no way to know the dimensions of the polygon after creation. We could hack around this by providing dimensions for simple polygons such as rectangles, but we choose not to. (keep it simple)

As you supplied the dimensions in the first place, you should already beware of the size of the shape. I would recommend you save the size somewhere and if you need it, attach it to the UserData property of the fixture.