Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Align SFML object with Box2D objects  (Read 1288 times)

0 Members and 3 Guests are viewing this topic.

MuhammadYaseen

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Align SFML object with Box2D objects
« on: February 01, 2014, 04:32:28 pm »
Greetings!

I have setup a basic project to get SFML and Box2D working together. I have got basic rendering to work and I am able to create bodies.

Problem however is that my SFML RectagleShape doesn't align properly with Box2d body.

In the attachement, pinkish rectangle is SFML's RectangleShape and Light green object is what I getting from Box2D debug draw. As you can see there is a problem.

Here is the code : https://gist.github.com/muhammadyaseen/8753692

I am aware of the MKS to Pixel conversion and that SFML's center by default is at (0,0).

I have (i believe) taken care of these things, but still experiencing this problem.

Any help is appreciated.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Align SFML object with Box2D objects
« Reply #1 on: February 01, 2014, 04:52:50 pm »
Looks as if the debug draw code uses 32 pixels per meter, not 30 like your code does.
Back to C++ gamedev with SFML in May 2023

MuhammadYaseen

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Align SFML object with Box2D objects
« Reply #2 on: February 01, 2014, 04:56:30 pm »
Thank you!

You might not believe, I have been trying to solve this issue since friday (Learned a few things this way, though).

I suspected it would be something trivial I am missing.

Renders perfectly now , thanks again.

 

anything