开发者

what physical properties for balls should be set?

following physical properties of the balls is being used:

  • golfball

    // Create circle shape
    b2Circl开发者_如何学运维eShape circle;
    circle.m_radius = 15.5/PTM_RATIO;
    
    // Create ball shape definition and add to body
    b2FixtureDef ballShapeDef;
    ballShapeDef.shape = &circle;
    ballShapeDef.density = 5000.0f;
    ballShapeDef.friction = 10.0f;
    ballShapeDef.restitution = 0.2f;
    
    ballFixture = ballBody->CreateFixture(&ballShapeDef);
    
  • cricketball

    // Create circle shape
    b2CircleShape circle;
    circle.m_radius = 17.0/PTM_RATIO;
    
    // Create ball shape definition and add to body
    b2FixtureDef ballShapeDef;
    ballShapeDef.shape = &circle;
    ballShapeDef.density = 5000.0f;
    ballShapeDef.friction = 10.0f;
    ballShapeDef.restitution = 0.4f;
    
    ballFixture = ballBody->CreateFixture(&ballShapeDef);
    
  • ironball

    // Create circle shape
    b2CircleShape circle;
    circle.m_radius = 23.0/PTM_RATIO;
    
    // Create ball shape definition and add to body
    b2FixtureDef ballShapeDef;
    ballShapeDef.shape = &circle;
    ballShapeDef.density = 5000.0f;
    ballShapeDef.friction = 10.0f;
    ballShapeDef.restitution = 0.0f;
    
    ballFixture = ballBody->CreateFixture(&ballShapeDef);
    
  • soccerball:

    // Create circle shape
    b2CircleShape circle;
    circle.m_radius = 24.0/PTM_RATIO;
    
    // Create ball shape definition and add to body
    b2FixtureDef ballShapeDef;
    ballShapeDef.shape = &circle;
    ballShapeDef.density = 5000.0f;
    ballShapeDef.friction = 10.0f;
    ballShapeDef.restitution = 0.8f;
    
    ballFixture = ballBody->CreateFixture(&ballShapeDef);
    
  • basketball:

    // Create circle shape
    b2CircleShape circle;
    circle.m_radius = 24.0/PTM_RATIO;
    
    // Create ball shape definition and add to body
    b2FixtureDef ballShapeDef;
    ballShapeDef.shape = &circle;
    ballShapeDef.density = 5000.0f;
    ballShapeDef.friction = 10.0f;
    ballShapeDef.restitution = 0.6f;        
    ballFixture = ballBody->CreateFixture(&ballShapeDef);
    

Being a newbie, all I have implemented is based on guesses, and I'm having some troubles like stucked obstacle, damn slow motion on slant obstacle, and many other, so if there any better solution, please put them.


First, I don't suggest you to use density more then 100. It will provide bad simulation. Keep the density in range 1 - 100. Like the sizes of the bodies in range [0.1, 10] for dynamic bodies and up to 50 for static (it's from box2d documentation). Usually friction is set between 0 and 1 (also from box2d documentation). So you have to work in your own units to feet the ranges. For example you can measure density as grams per 1 cubic santimeter.

To evaluate ball's density you need to know it's radius and mass. In this case you are able to found density as m/V, where V is the volume.

To measure restitution find some videos on youtube and see how high the ball bounces when thrown. The restitution will be h2/h1, where h1 initial height, h2 - height after bounce


I don't think there is any real answer to this, you will likely have to go with what seems best to you. A few comments though: the density is extremely high, friction should be between 0-1, golf ball restitution is actually quite high. I would suggest starting with density of 1 and friction of around 0.5 and adjust from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜