子弹车addWheel参数
bullet vehicle addWheel parameters
我正在尝试用子弹制作一个简单的光线投射车。应该是酸溜溜的盒子。
我现在被 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 您可以单击每个成员变量转到 header(不幸的是,这也非常模糊地记录)。
//
// 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
) 似乎描述了轮胎的机械性能,例如摩擦力、阻尼等。最后一个参数似乎 self-explanatory.
我正在尝试用子弹制作一个简单的光线投射车。应该是酸溜溜的盒子。
我现在被 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 您可以单击每个成员变量转到 header(不幸的是,这也非常模糊地记录)。
//
// 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
) 似乎描述了轮胎的机械性能,例如摩擦力、阻尼等。最后一个参数似乎 self-explanatory.