c++ - 子弹车addWheel参数

标签 c++ bulletphysics

我正在尝试用 bullet 制作一个简单的光线转换车。它应该是酸车轮上的盒子。

我现在被 btRayvastVehicle::addWheel 的调用困住了,因为我不明白它们到底是什么意思,因为它们在 API 文档中没有很好的记录,而且作为一个非-母语为英语的人,我很难根据他们的名字来推断他们是什么。

让我特别困惑的是,前三个参数究竟是如何定义轮子的位置和方向的。

那么btRaycastVehicle::addWheel的参数到底是做什么的呢?

最佳答案

来自 the documentation btRayvastVehicle::addWheel 方法具有签名

btWheelInfo & btRaycastVehicle::addWheel( const btVector3& connectionPointCS0,
                                          const btVector3& wheelDirectionCS0,
                                          const btVector3& wheelAxleCS,
                                          btScalar suspensionRestLength,
                                          btScalar wheelRadius,
                                          const btVehicleTuning& tuning,
                                          bool  isFrontWheel
                                        )

来自method definition您可以单击每个成员变量以转到标题(不幸的是,它的记录也非常模糊)。

//
// basically most of the code is general for 2 or 4 wheel vehicles, but some of it needs to be reviewed
//
btWheelInfo& btRaycastVehicle::addWheel( const btVector3& connectionPointCS, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel)
{

    btWheelInfoConstructionInfo ci;

    ci.m_chassisConnectionCS = connectionPointCS;
    ci.m_wheelDirectionCS = wheelDirectionCS0;
    ci.m_wheelAxleCS = wheelAxleCS;
    ci.m_suspensionRestLength = suspensionRestLength;
    ci.m_wheelRadius = wheelRadius;
    ci.m_suspensionStiffness = tuning.m_suspensionStiffness;
    ci.m_wheelsDampingCompression = tuning.m_suspensionCompression;
    ci.m_wheelsDampingRelaxation = tuning.m_suspensionDamping;
    ci.m_frictionSlip = tuning.m_frictionSlip;
    ci.m_bIsFrontWheel = isFrontWheel;
    ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm;
    ci.m_maxSuspensionForce = tuning.m_maxSuspensionForce;

    m_wheelInfo.push_back( btWheelInfo(ci));

    btWheelInfo& wheel = m_wheelInfo[getNumWheels()-1];

    updateWheelTransformsWS( wheel , false );
    updateWheelTransform(getNumWheels()-1,false);
    return wheel;
}

所以看起来前 5 个参数基本上描述了每个轮子的位置和方向。第 6 个参数 (tuning) 似乎描述了轮胎的机械特性,例如摩擦力、阻尼等。最后一个参数似乎不言自明。

关于c++ - 子弹车addWheel参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32871496/

相关文章:

c++ - MFC 对话框数据验证失败时恢复数据

c++ - std::map 的插入提示是否有任何位置限制?

c++ - 实现抽象类

javascript - 计算滑动的功率/力量

c++ - 未解析的外部符号 b3Clock

带有来自模板化容器的迭代器的 C++ 函数

c++ - 如何在 GPU 上运行子弹物理解决方案

c++ - 创建新 btConvexHullShape 时 Bullet Physics 第一次机会异常

c++ - 如何使用BulletPhysics SDK清除VS2015中的错误LNK2001?

c++ - 函数模板特化编译错误