Box2D Forums

It is currently Tue May 21, 2013 3:15 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: shape vertices?
PostPosted: Mon Apr 09, 2012 6:56 am 
Offline

Joined: Sun Apr 08, 2012 2:24 am
Posts: 3
According to here I could get the shape vertices
viewtopic.php?f=8&t=4302

Looks like this is removed from latest version of box2d.
Do I have to use ComputeAABB now if I want to know the size of my shape? (if it's a polygonshape and not a circle)


Top
 Profile  
 
 Post subject: Re: shape vertices?
PostPosted: Mon Apr 09, 2012 7:34 am 
Offline

Joined: Sun Apr 08, 2012 2:24 am
Posts: 3
Figured it out... This is how you do it:
Code:
for (b2Body* curBody = _world->GetBodyList(); curBody;curBody = curBody->GetNext())
   {
      b2Vec2 position = curBody->GetPosition();
      for (b2Fixture* curFixture = curBody->GetFixtureList(); curFixture;curFixture  = curFixture->GetNext())
      {
         b2Shape* shape = curFixture->GetShape();
         if (shape->m_type == b2Shape::Type::e_circle )
         {
            float radius = shape->m_radius;
            // draw circle
         }
         else if (shape->m_type == b2Shape::Type::e_polygon)
         {
            //b2Vec2 boxExtents = shape->m_vertices[0];
            b2AABB aabb;
            shape->ComputeAABB(&aabb, curBody->GetTransform(), 0);
            
            // draw rectangle from the aabb
         }
      }
      
      
      i++;
   }


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group