hi,
My game sdk( marmalade ) will rotate objects in counterclockwise for +ve values and clockwise for -ve values and box2d does the same, i am getting opposite rotation values while collision response is happening.
for example:
if i am having static box in my middle of the screen and dynamic box is falling from upwards, and bottom right of dynamic box is colliding with top left of static box, my dynamic body is rotating in clockwise direction rather than anticlockwise and i am getting -ve values from body->getAngle() instead of +ve values.
This works fine if i am reversing the angle while applying to sprite transformation
float _x = dynamicBody->getPosition().x;
float _y = dynamicBody->getPosition().y;
float angle = dynamicBody->getAngle();
TransformSprite->rotate( -angle ); // angle applied in opposite direction.
TransformSprite->translate( _x, _y );
// orgin - top left of the screen. gravity = 10. (Box2D v2.2.0)
At first i thought my sdk(marmalade) rotation values are in opposite direction to box2d but later when i applied the follwing code.
//update
float newAngle = 1.0f; // radians
dynamicBody->setTransform( dynamicBody>getPosition(), newAngle );// box2d transformation
//render
float _x = dynamicBody->getPosition().x;
float _y = dynamicBody->getPosition().y;
float angle = dynamicBody->getAngle();
TransformSprite->rotate( angle ); // angle is same..
TransformSprite->translate( _x, _y );
// body is rotating in counterclockwise direction as i expected while using setTransform method, i dont know why my collision response is giving angle in opposite direction..
My game sdk( marmalade ) will rotate objects in counterclockwise for +ve values and clockwise for -ve values and box2d does the same, i am getting opposite rotation values while collision response is happening.
for example:
if i am having static box in my middle of the screen and dynamic box is falling from upwards, and bottom right of dynamic box is colliding with top left of static box, my dynamic body is rotating in clockwise direction rather than anticlockwise and i am getting -ve values from body->getAngle() instead of +ve values.
This works fine if i am reversing the angle while applying to sprite transformation
float _x = dynamicBody->getPosition().x;
float _y = dynamicBody->getPosition().y;
float angle = dynamicBody->getAngle();
TransformSprite->rotate( -angle ); // angle applied in opposite direction.
TransformSprite->translate( _x, _y );
// orgin - top left of the screen. gravity = 10. (Box2D v2.2.0)
At first i thought my sdk(marmalade) rotation values are in opposite direction to box2d but later when i applied the follwing code.
//update
float newAngle = 1.0f; // radians
dynamicBody->setTransform( dynamicBody>getPosition(), newAngle );// box2d transformation
//render
float _x = dynamicBody->getPosition().x;
float _y = dynamicBody->getPosition().y;
float angle = dynamicBody->getAngle();
TransformSprite->rotate( angle ); // angle is same..
TransformSprite->translate( _x, _y );
// body is rotating in counterclockwise direction as i expected while using setTransform method, i dont know why my collision response is giving angle in opposite direction..