gpt4 book ai didi

iphone - 应该设置球的哪些物理属性?

转载 作者:行者123 更新时间:2023-12-03 20:53:59 26 4
gpt4 key购买 nike

正在使用球的以下物理属性:

  • 高尔夫球

    // Create circle shape
    b2CircleShape 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);
  • 板球

    // 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);
  • 铁球

    // 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);
  • 足球:

    // 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);
  • 篮球:

    // 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);

作为一个新手,我所实现的一切都是基于猜测,并且我遇到了一些麻烦,例如卡住的障碍物、倾斜障碍物上该死的慢动作等等,所以如果有更好的解决方案,请提出。

最佳答案

首先,我不建议您使用超过 100 的密度。它会提供糟糕的模拟效果。将密度保持在 1 - 100 范围内。就像动态物体的物体尺寸在 [0.1, 10] 范围内,静态物体的尺寸最大为 50(来自 box2d 文档)。通常摩擦力设置在 0 和 1 之间(也来自 box2d 文档)。因此,您必须在自己的单位中工作才能覆盖范围。例如,您可以测量密度为克每 1 立方米。

要评估球的密度,您需要知道它的半径和质量。在这种情况下,您可以发现密度为 m/V,其中 V 是体积。

要测量恢复原状,请在 YouTube 上查找一些视频,看看球抛出时弹跳的高度。恢复将为 h2/h1,其中 h1 初始高度,h2 - 弹跳后的高度

关于iphone - 应该设置球的哪些物理属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6571041/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com