Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4616922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:03:05+00:00 2026-05-22T02:03:05+00:00

Body b; while ((b=box2d.physics.PhysicssWorld.world.getBodyList().getNext())!=null) { Shape shape; while ((shape=b.getShapeList().getNext())!=null) { Log.e(name,+b.getUserData().toString()+ +shape+ ); opengl.saveMatrix();

  • 0
        Body b;
        while ((b=box2d.physics.PhysicssWorld.world.getBodyList().getNext())!=null) {

                   Shape shape;
                   while ((shape=b.getShapeList().getNext())!=null) {

                        Log.e("name",""+b.getUserData().toString()+" "+shape+" ");

                        opengl.saveMatrix();
                            Meshes.select(b.getUserData().toString())
                                    .translate((b.getPosition().x)*RATIO, (b.getPosition().y)*RATIO)
                                    .rotate((int) ((int) b.getAngle()* (180 / Math.PI)), 0, 0, 1)
                                    .draw(shape, 1,1,1);

                        opengl.loadMatrix();

                   }


        }

I d like to get my bodies’s shape, but i cant get anything, only null.. why?

never run this line: Log.e(“name”,””+b.getUserData().toString()+” “+shape+” “);

so shape=b.getShapeList().getNext()) always null…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:03:05+00:00Added an answer on May 22, 2026 at 2:03 am

    I’m just starting out with Box2D myself. So far as I understand the library, the primary means of getting the shapes of bodies is through their fixtures. From the fixture you get a b2Shape pointer – but, because its methods are virtual, you’ll probably need to cast it as a b2PolygonShape/b2CircleShape pointer for it to be useful. Here’s some code along those lines:

    void DoStuffWithShapes(b2World *World)
    {
        b2Body * B = World->GetBodyList();
        while(B != NULL)
        {
            b2Fixture* F = B->GetFixtureList();             
            while(F != NULL)
            {
                switch (F->GetType())
                {
                    case b2Shape::e_circle:
                    {
                        b2CircleShape* circle = (b2CircleShape*) F->GetShape();                     
                        /* Do stuff with a circle shape */
                    }
                    break;
    
                    case b2Shape::e_polygon:
                    {
                        b2PolygonShape* poly = (b2PolygonShape*) F->GetShape();
                        /* Do stuff with a polygon shape */
                    }
                    break;
                }
                F = F->GetNext();
            }
    
            B = B->GetNext();
        }       
    }
    

    Some other things to note: the .getNext() function of b2Body returns a pointer – this is an implementation of a linked list. The same is true for b2Fixture::GetNext(). There’s some unfamiliar stuff (to me) in your code, so I can’t say for sure, but it might work fine if you simply go through and make sure your variables match up with the return types of the Box2D functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Internet Explorer 7 body onmousemove or document.onmousemove events only seem to fire while
I know that fast moving bodies in Box2d world cause tunneling effect and pass
<html> <body> <input type=text onFocus=javascript:findPosY()/> <script type=text/javascript> eval( function findPosY(){alert(OK);}); </script> </body> </html> While
I am making a game using Andengine/Box2D physics addon. I experienced the random crashes
I have been using two libraries, SFML and Box2D, while at the same time
I'm trying to move player body while contact with teleport but setTransform isn't executed.This
Taken from Programming ruby 1.9 book: def my_while(cond, &body) while cond.call body.call end end
While compiling a while loop without a body, I saw this message: warning: suggest
What is the functional body of a program? I thought it was its functions'
I've inherited a body of Visual C++ source that consists of about a dozen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.