Ive got two for loops going to get the bodies from my world and then the shapes from my bodies, is there any way to then get the verticies from the shape (if it is a polygon) or the radius (if it is a circle). I had quite a thorough dig around in the b2Shape.h and b2Shape.cpp code but I couldn't find anything. I really need this if I want to render it using opengl (as I want to draw lines from each verticy to the other, like in the debug draw, and I have a function to render a circle given the centre and the radius.
is this because:
1. Its simply not possible.
2. I should be getting the b2PolygonShape or b2CircleShape from the body and if so how should I do this.
here is my code if it is any help
Thanks in advance!
ps, Im working in c++
is this because:
1. Its simply not possible.
2. I should be getting the b2PolygonShape or b2CircleShape from the body and if so how should I do this.
here is my code if it is any help
Code:
printf("{\n");
for (b2Body* b = myWorld->GetBodyList(); b; b = b->GetNext())
{
printf(" {\n");
b2Vec2 position = b->GetPosition();
float32 angle = b->GetAngle();
printf(" %4.2f %4.2f %4.2f\n", position.x, position.y, angle);
//b->WakeUp();
for (b2Shape* s = b->GetShapeList(); s; s = s->GetNext())
{
b2ShapeType SHAPETYPE = s->GetType();
switch(SHAPETYPE){
case -1:
printf(" Unknown Shape\n");
break;
case 0:
printf(" Circle Shape\n");
//b2CircleShape* CS = s;
//float RAD = s->GetRadius();
//printf("%f\n",RAD);
break;
case 1:
printf(" Polygon Shape\n");
break;
case 2:
printf(" Shape type count\n");
break;
default:
printf(" ????????\n");
break;
}
}
printf(" }\n");
} printf("}\n");
for (b2Body* b = myWorld->GetBodyList(); b; b = b->GetNext())
{
printf(" {\n");
b2Vec2 position = b->GetPosition();
float32 angle = b->GetAngle();
printf(" %4.2f %4.2f %4.2f\n", position.x, position.y, angle);
//b->WakeUp();
for (b2Shape* s = b->GetShapeList(); s; s = s->GetNext())
{
b2ShapeType SHAPETYPE = s->GetType();
switch(SHAPETYPE){
case -1:
printf(" Unknown Shape\n");
break;
case 0:
printf(" Circle Shape\n");
//b2CircleShape* CS = s;
//float RAD = s->GetRadius();
//printf("%f\n",RAD);
break;
case 1:
printf(" Polygon Shape\n");
break;
case 2:
printf(" Shape type count\n");
break;
default:
printf(" ????????\n");
break;
}
}
printf(" }\n");
} printf("}\n");
Thanks in advance!
ps, Im working in c++