How to convert Box2D coordinates to QGraphicsView coordinates ?
-
Hi, i am trying to use box2D with QGprahicsView but i dont know how much 1meter in box2D is in pixels in qgraphicsview.
I found this small example integrating box2D with QGraphicsView and we can see that this guy uses 1:30 ratio (1m equals to 30 pixels) but i dont know how he knows that?
https://www.geek-share.com/detail/2692030047.html
Because if i put ball on position (300,600), i have to know the ratio to devide coordinates when i use box2D set pos. Is 1:30 ratio true? I dont know how to test this because if i understand correctly i must use graphicsview to draw elements and to use box2D's userData to connect this two libraries to work.Thanks in advance
-
You can use your own ratio (for example 1:50) but Box2D has these limits:
Box2D has been tuned to work well with moving shapes between 0.1 and 10 meters. So this means objects between soup cans and buses in size should work well. Static shapes may be up to 50 meters long without trouble.
I got it from documentation. 1:30 means that your objects must be from 3 pixels to 300 pixels. If you use 1:50 - your objects must be from 5 pixels to 500 pixels.