本文整理汇总了C++中CVehicle::GetRotationLC方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetRotationLC方法的具体用法?C++ CVehicle::GetRotationLC怎么用?C++ CVehicle::GetRotationLC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetRotationLC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateCollisionReaction
void CRigidBody::UpdateCollisionReaction()
{
CVehicle* Car = (CVehicle*)this;
Vector3f OldPosition = m_vPosition;
// update reflection motion
m_vReflection *= RIGIDBODY_REFLECTION_ENTROPY_FACTOR;
m_vPosition = m_translate + m_vReflection;
m_vDirectionWhenDisturbed = m_vPosition - OldPosition;
m_translate = m_vPosition;
m_box.Center() = m_vPosition;
m_sphere.Center() = m_vPosition;
Car->SetVehiclePositionLC(Vector3f(m_vPosition.X(), m_vPosition.Z(), m_vPosition.Y()));
// update angular velocity
m_vRotation *= RIGIDBODY_ROTATION_ENTROPY_FACTOR;
Car->GetRotationLC().Z() += m_vRotation.Y();
// see if reflection has dissipated enough to stop
if (m_vReflection.Length() < RIGIDBODY_REFLECTION_DEATH_FACTOR) {
disturbed = false;
}
}
示例2: DeliverCollisionMessage
void CRigidBody::DeliverCollisionMessage(CCollisionMessage* ColMsg)
{
if (!ColMsg) return;
if (ColMsg->GetCollisionType() == SPHERE_TO_SPHERE) {
HandleSphereToSphereCollision(ColMsg);
return;
}
/****** Deploy to HandlePushCollision() if this is the case ******/
// Push collision not working. Commenting this out for now.
/* if (ColMsg->GetCollisionType() == PUSHED) {
HandlePushCollision(ColMsg);
return;
}
*/
CVehicle* Car = (CVehicle*)ColMsg->GetEntity();
/************** set reflection motion ************/
m_vPosition = m_translate + (*ColMsg->GetReverse())*RIGIDBODY_SPACING_FACTOR;
Vector3f velocityWC;
if (disturbed) {
velocityWC = m_vDirectionWhenDisturbed*80.0f;
}
else {
velocityWC = Car->GetVehicleVelocityWC();
// if reversing, velocityWC will point in opposite direction as actual velocity
if (Car->GetVehicleVelocityLC().X() < 0.0f)
velocityWC *= -1.0f;
}
m_vReflection = velocityWC - 2.0f*(velocityWC.Dot(*ColMsg->GetNormal()))*(*ColMsg->GetNormal());
m_vReflection *= RIGIDBODY_REFLECTION_FACTOR;
m_vDirectionWhenDisturbed = m_vReflection;
Car->SetVehicleVelocityLC(0.0f);
Car->SetVehiclePositionLC(Vector3f(m_vPosition.X(), m_vPosition.Z(), m_vPosition.Y()));
/*************** set angular velocity ******************/
// Compute angle between vehicle heading and plane
Vector3f PlaneEdge = ColMsg->GetPlane()->Edge0();
Vector3f CarHeading = Car->GetVehicleHeadingWC();
float angle = acos(CarHeading.Dot(PlaneEdge)/(PlaneEdge.Length()*CarHeading.Length()));
// spin CW or CCW?
float spin; // magnitude of spin about the y-axis
if (angle > Math<float>::PI/2.0f) { // CCW
spin = Math<float>::PI - angle;
}
else { // CW
spin = -angle;
}
spin *= RIGIDBODY_SPIN_FACTOR;
m_vRotation = Vector3f(0.0f, spin, 0.0f);
/*************** set vectors that are actually used in renderer ************/
/*********************** to the values computed above **********************/
m_translate = m_vPosition;
m_box.Center() = m_vPosition;
m_sphere.Center() = m_vPosition;
Car->GetRotationLC().Z() += spin;
disturbed = true;
/*
CLog::GetLog().Write(LOG_MISC, "\n\n\nreflection = (%f, %f, %f)",
m_vReflection.X(), m_vReflection.Y(), m_vReflection.Z());
CLog::GetLog().Write(LOG_MISC, "direction = (%f, %f, %f)\n\n",
m_vDirectionWhenDisturbed.X(), m_vDirectionWhenDisturbed.Y(), m_vDirectionWhenDisturbed.Z());
*/
}