Wednesday, August 7, 2013

Can't set PolygonShape vertices Box2D

Can't set PolygonShape vertices Box2D

I'm using Box2D in Java with LIBGDX. I'm trying to create a triangle using
PolygonShape. Upon calling setVertices my code crashes. There is no error
code, or stack trace for me to follow.
Excuse the lengthy numbers. They are the exact numbers being calculated.
The routine is more complicated than this, but this is all that's needed
to solve the problem here.
PolygonShape shape = new PolygonShape();
//app crashes on call to set.
shape.set(new float[] { 0.26666668f, -0.043010756f, -0.008602151f,
-0.18064517f, -0.18064517f, -0.26666668f });
I've ensured my vertices are in counter-clockwise order. These points
define a simple convex triangle.
Could someone tell me what I'm doing wrong here?

No comments:

Post a Comment