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

Author Topic: SFML Box2D another example  (Read 28484 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML Box2D another example
« Reply #15 on: March 05, 2012, 08:03:40 am »
You should have posted in your other thread, seems like it's the same problem.

Maybe the Box2D position refers to the center of the circle. That would be inconsistent with what we found out yesterday about rectangles, but it would explain what you see.

You should definitely read the documentation of Box2D to know which local point of shapes the "position" member refers to.
Laurent Gomila - SFML developer

lask1

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SFML Box2D another example
« Reply #16 on: March 01, 2013, 09:00:48 pm »
lol the Box2D system is in radians while sfml is in degrees


void CBox::update() {
    m_shape.SetRotation( m_body->GetAngle() * (180/3.14) );
    m_shape.SetPosition( m_body->GetPosition().x*PPM, m_body->GetPosition().y*PPM);
}
 

That is the change I made and now it works perfect.

lask1

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SFML Box2D another example
« Reply #17 on: March 04, 2013, 08:28:10 pm »
lol the Box2D system is in radians while sfml is in degrees


void CBox::update() {
    m_shape.SetRotation( m_body->GetAngle() * (180/3.14) );
    m_shape.SetPosition( m_body->GetPosition().x*PPM, m_body->GetPosition().y*PPM);
}
 

That is the change I made and now it works perfect.

Nevermind something still need to be changed.

void CBox::update() {
    m_shape.SetRotation( -m_body->GetAngle() * (180/3.14159265359) );
    m_shape.SetPosition( m_body->GetPosition().x*PPM, m_body->GetPosition().y*PPM);
}
 

Now it is perfect.