Hey guys. Is there a way to get all vertices of a physicsbody shape from the related node?
Actually I want something like this:
b2Vec2 point = originalPolygon->GetVertex(i);
Thanks
Hey guys. Is there a way to get all vertices of a physicsbody shape from the related node?
Actually I want something like this:
b2Vec2 point = originalPolygon->GetVertex(i);
Thanks
Hello everybody; I found solution. In below code you are able to get “shape” of a “physicsbody” :
PhysicsBody* physicsBody; //Physicsbody of something; PhysicsShapePolygon* shapePolygon; //This is null for now; //Below line does the magic: shapePolygon = dynamic_cast<PhysicsShapePolygon*>(physicsBody->getFirstShape());
To get vertices:
std::vector<Vec2> points;
for(int i = 0; i < shapePolygon->getPointsCount(); i++)
{
points.push_back(shapePolygon->getPoint(i));
}
Voila. Now you have a vector of vertices of related shape.