views:

60

answers:

1

hello, i'm using box2d 2.1.2 with cocos2d 0.99.4

in my world, everything is light, there is no sensation about dropping a stone or a box !! everything falling slowly at the same speed

b2Vec2 gravity; 
gravity.Set(0.0f, -10.0f);
bool doSleep = true;
world = new b2World(gravity, doSleep);

and my objects :

b2BodyDef *TBodyDef = new b2BodyDef;
    TBodyDef->position.Set(100, 200);
    b2Body *TBody = world->CreateBody(TBodyDef);
    TBody->SetType(b2_dynamicBody);
    TBody->SetAwake(true);
    b2CircleShape TCircleShape;
    TCircleShape.m_radius = 20;
    b2FixtureDef TFixtureDef;
    TFixtureDef.shape = &TCircleShape;
    TFixtureDef.friction = 0.1;
    TFixtureDef.density = 0.1;
    TFixtureDef.restitution = 1;
    TFixtureDef.filter.categoryBits = COLLISION_BIT_GP;
    TFixtureDef.filter.maskBits = COLLISION_BIT_TERRAIN;
    TBody->CreateFixture(&TFixtureDef);

    b2BodyDef *TBodyDef1 = new b2BodyDef;
    TBodyDef1->position.Set(200, 200);
    b2Body *TBody1 = world->CreateBody(TBodyDef1);
    TBody1->SetType(b2_dynamicBody);
    TBody1->SetAwake(true);
    b2CircleShape TCircleShape1;
    TCircleShape1.m_radius = 20;
    b2FixtureDef TFixtureDef1;
    TFixtureDef1.shape = &TCircleShape;
    TFixtureDef1.friction = 0.1;
    TFixtureDef1.density = 0.5;
    TFixtureDef1.restitution = 1;
    TFixtureDef1.filter.categoryBits = COLLISION_BIT_GP;
    TFixtureDef1.filter.maskBits = COLLISION_BIT_TERRAIN;
    TBody1->CreateFixture(&TFixtureDef1);

and my step :

int32 velocityIterations = 8;
int32 positionIterations = 3;

world->Step(dt, velocityIterations, positionIterations);

density changes nothing about the speed of falling. what is missing to make it as fluid as this : link text

thank you for your help

+1  A: 

An objects density does not affect the speed it falls at.

Negating air-resistance and other generally negligible effects all objects DO fall at the same speed.

How to test this: Pick up something light (e.g. your friends iPhone 4) and something heavy (your old CRT) and drop them out of a window at exactly the same time.

CiscoIPPhone
you mean that at the surface of moon, one kg of cotton falling down at the same speed that one kg of steel ??
Yes, that is true. I don't have anything more to add.
CiscoIPPhone
hehe ok :=)if i add to this function a more iteration, it would be more fluidbut is it a correct way to do it ??-(void) tick:(ccTime)dt{ int32 velocityIterations = 8; int32 positionIterations = 3; for (int32 i = 0; i < 10; ++i) { world->Step(dt, velocityIterations, positionIterations); world->ClearForces(); } }
but i preferred your first answer before changing ti to this one :=)
I don't know why that would be more fluid since you are doing more calculations a frame...it might be best to ask on the box2D forum.
CiscoIPPhone
Sorry I can't help more =0
CiscoIPPhone
well indeed, you are right, in fact it is not changing the distance my ball is covering when launched, hmmm i'm waiting for approval from box2d administrator :=) anyway thank you for your help :=)
finally, got my problem, it was because my bodies were huge, i did not used PTM_RATIO, oufff :=)