Box2D - getting vertices

BlitzMax Forums/Brucey's Modules/Box2D - getting vertices

Rick_72(Posted 2010) [#1]
Hello world! ;-)

I wonder if there's a simpler solution than this one (I bet there is; but it's hidding from me): in order to use my own render methods I store the vertices of an object within the user data. Using position and angle I can render the object. But this calculation is done twice since it is already done by B2D. Is there any way to get the B2D vertices directly instead of calculating them?

Thanks for your help!
Rick


Rick_72(Posted 2010) [#2]
Found something:

bmx_b2polygonshape_getvertices(_shape.b2ObjectPtr)

But this also does *not* provide the transformed coordiantes. How do I get the transformed stuff?


Rick_72(Posted 2010) [#3]
Nobody?

Here's a way to get the non-transformed (that's actually not what we want to find!) vertices:

	Local Shape:b2Shape = _BODY.GetShapeList()
	Local _shape:b2PolygonShape = New b2PolygonShape
	_shape = b2PolygonShape(Shape)
	Local _vec:b2Vec2[] = _Shape.GetCoreVertices()


If one has a body called _BODY get the shape list calling GetShapeList(). Only the type b2PolygonShape offers the method GetCoreVertices() so you have to cast Shape first into b2PolygonShape.

You then have to transform the vertices regarding rotation and translation unless you know a way to get the transformed stuff directly. If so please post here!