Are greeted dear Box2Dler!
I have a problem with the RevoluteJoints. Besides, I have read the documentation several times, asked in another, German forum (Yes, I am from Germany '^-^) and was expelled from there to here. My basic idea with my C ++ practise in addition was to be provided, admittedly, to create a static body and a dynamic one. The dynamic one then will fix with a RevoluteJoint to the static. However, it does not want to turn anyhow. I use, in addition, still the SFML.
Here my definition of the joint and the updating of the Box2D world:
Code:
b2RevoluteJointDef RevJointDef;
RevJointDef.Initialize(MiniRectBody, RectBody, MiniRectBody->GetWorldCenter()); //MiniRectBody is the static one!
RevJointDef.enableLimit = false;
RevJointDef.maxMotorTorque = 100000.0f;
RevJointDef.motorSpeed = 30.0f;
RevJointDef.enableMotor = true;
b2RevoluteJoint *RevJoint = (b2RevoluteJoint*)world->CreateJoint(&RevJointDef);
Code:
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Up))
{
RevJoint->SetMotorSpeed( 50.f);
RevJoint->GetBodyB()->SetAwake(true);
}
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Down))
{
RevJoint->SetMotorSpeed(-50.f);
RevJoint->GetBodyB()->SetAwake(true);
}
world->Step(1.f/960.f, 6, 2);
world->ClearForces();
rec.SetPosition(RectBody->GetPosition().x, RectBody->GetPosition().y);
rec.SetRotation((3/2*b2_pi)*(RectBody->GetAngle()*b2_pi));
Yours sincerely,
Check
HP: Sorry about possible English. :[