Box2D Forums

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

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Jul 05, 2009 9:40 pm 
Offline

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
 Profile  
 
PostPosted: Sun Jul 05, 2009 10:02 pm 
Offline
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
 Profile  
 
PostPosted: Sun Jul 05, 2009 11:24 pm 
Offline

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
 Profile  
 
PostPosted: Mon Jul 06, 2009 6:18 pm 
Offline
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
 Profile  
 
PostPosted: Tue Jul 07, 2009 3:46 am 
Offline

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. :roll:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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 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