Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How to convert Box2D coordinates to QGraphicsView coordinates ?
Forum Updated to NodeBB v4.3 + New Features

How to convert Box2D coordinates to QGraphicsView coordinates ?

Scheduled Pinned Locked Moved Unsolved Game Development
2 Posts 2 Posters 525 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lowzyyy
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • 8Observer88 Offline
      8Observer88 Offline
      8Observer8
      wrote on last edited by 8Observer8
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved