I try to implement box2d in my C++ game engine
The integration went well and it was quite easy to implement it with my opengl 2d stuff
However , i have a problem that i didnt manage to fix , I want to Applies forces on the body but all my test
with ApplyForce and ApplyImpluse has no effect to my bodies
It s just a simple test with box shapes
my body initialisation looks like this
Code:
pWorld = PhysicsWorld::GetSingleton()->pWorld;
b2BodyDef bodyDef;
this->pos = pos;
this->size = size;
bodyDef.position.Set(pos.x,pos.y);
body = pWorld->CreateBody(&bodyDef);
b2PolygonDef shapeDef;
shapeDef.SetAsBox(size.x*.5f,size.y*.5f);
shapeDef.density = density;
shapeDef.friction = fricton;
shapeDef.restitution = restitution;
body->CreateShape(&shapeDef);
b2BodyDef bDef;
bDef.linearDamping = 0.01f;
bDef.angularDamping = 0.01f;
body->SetMassFromShapes();
ApplyForce code , called latter of a keyboard action
Code:
if (pCore->MouseLeft()){
//c = VGL_Color(1,0,0,1);//
body->ApplyImpulse(b2Vec2(0,10),body->GetWorldCenter());
}
I ve google about ApplyForce/Impulse and this code looks corrects, the simulation is ok , but i m not able to add any forces with ApplyForce/Impulse on my bodies
Any ideas ? what can be wrong ?