densidad de un cuerpo, ¿realmente cambia algo?

this is the third time i am asking this. the answers are not clear.

it seems that something is uncleared to all cocos2d-box2d developers about the mass.

no one dont really know how to set the mass of a body, OR do it in another way.

some are using: setDensity y la resetBodyMass which does NOT works for me , and some of them using shapeDef.density=x which is also dont change a thing .

this all thing is uncleared. why does density dont effect the mass ? how can i change my body mass ???

my code, which is NOT effect the mass, is :

    //add body
b2BodyDef spriteBodyDef;
spriteBodyDef.type =b2_dynamicBody; //b2_staticBody;
spriteBodyDef.position.Set(pilot1.position.x/PTM_RATIO,pilot1.position.y/PTM_RATIO);
spriteBodyDef.userData = pilot1;
pilot1Body = world->CreateBody(&spriteBodyDef);    
b2CircleShape spriteShape; //b2polygon-for box shape
spriteShape.m_radius = 15.0/PTM_RATIO;
b2FixtureDef spriteShapeDef;
spriteShapeDef.restitution = 0.4f;
spriteShapeDef.shape = &spriteShape;
spriteShapeDef.density=10.0f;    // why this value is not doing anything ????

can some one direct me on how its works? the BOX2D docs are talking about the version that is not in cocos2d right now.

preguntado el 01 de febrero de 12 a las 14:02

how are you ascertaining that the mass does not change after you change the density values? Can you just double-check pilot1Body->GetMass()), assuming you have done: "pilot1Body->CreateFixture(&spriteShapeDef);" -

i DO get another mass but it does not effect a thing while bodies are moving. for example density of 1000, gives a big mass but the body which is a box, still flip easly when hitten by another body, even if the box should be heavier .. -

Your approach of using b2Fixture::SetDensity and then b2Body::ResetMassData is correct, that should cause GetMass() to give you a different result, and it sounds like you are getting that, so your question seems to be changing now. About this 'easily flippable' behavior, are you only changing one box's density? If you increase all their densities by the same amount, the collisions between them will behave the same as at a lower density, -

if by any chance what you meant by "easily flippable" is the way the bodies bounce against each other, then you need to modify the restitution property using b2Fixture::SetRestitution .. p/s: it's important how you need to ask the correct question to get the correct help ;) -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.