# Box2D Forums

 It is currently Sat May 18, 2013 4:22 am

 All times are UTC - 8 hours [ DST ]

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Posted: Sun Jul 05, 2009 9:40 pm

Joined: Sun Jul 05, 2009 9:25 pm
Posts: 7
Hi, I guess I have a small problem in logical thinking:
1, The manual states that I should try to multiply every pixel coordinate with 0.01f. 100 pixels would therefore amount to 1 Meter, this means that if I have a box of 50 pixels, I can still use 0.01f as scaling factor right?
2, PolygonDef::SetAsBox in the API reads: Build vertices to represent an axis-aligned box. But which corner of the box will the given coordinates represent?

My problem is essentially that I have various different types of box definitions, (OpenGL: you translate a polygon by its middle point, how does it work with Box2D?)
and I don't get how to calculate/position the Box2D boxes so that they correlate with my actual representations.

Top

 Posted: Sun Jul 05, 2009 10:02 pm
 Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
- Your scale factor must be constant. Also, you must not randomly flip its sign.
- The origin of a box is the center. Same as circles.

Does OpenGL compute the midpoint of polygon's for you? Is it the centroid? In Box2D the origin of a polygon is defined by you implicitly. If you attach a polygon to a body, the polygon's origin coincides with the body's origin (not the center of mass).

Top

 Posted: Sun Jul 05, 2009 11:24 pm

Joined: Sun Jul 05, 2009 9:25 pm
Posts: 7
Thanks, I rewrote the code. The box now bounces straight up with extreme speed...but at least it bounces. Changing gravity or density does not improve on it, why would it bounce into infinite +y space?

Another question: What if my box is not controllable anymore when on ground? Do my objects have to be sleeping (=no physics calculations) to be controllable?

Top

 Posted: Mon Jul 06, 2009 6:18 pm
 Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
I don't know why the box is moving up so fast. Are you setting the restitution values or using the defaults?

TheDemocrat wrote:
Another question: What if my box is not controllable anymore when on ground? Do my objects have to be sleeping (=no physics calculations) to be controllable?

Sorry, I do not understand your question. What do you mean by controllable?

Are you using this definition? http://en.wikipedia.org/wiki/Controllability

Top

 Posted: Tue Jul 07, 2009 3:46 am

Joined: Sun Jul 05, 2009 9:25 pm
Posts: 7
edited: I finally get what the manual meant with "scaling system": Scale down the graphics and at the same time zoom in with the camera.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

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