本文整理汇总了C++中idAngles::ToMat3方法的典型用法代码示例。如果您正苦于以下问题:C++ idAngles::ToMat3方法的具体用法?C++ idAngles::ToMat3怎么用?C++ idAngles::ToMat3使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idAngles
的用法示例。
在下文中一共展示了idAngles::ToMat3方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Event_SetAngles
/*
================
sdClientScriptEntity::Event_SetAngles
================
*/
void sdClientScriptEntity::Event_SetAngles( const idAngles& ang ) {
idMat3 axis = ang.ToMat3();
SetAxis( axis );
if ( GetPhysics() != NULL ) {
GetPhysics()->SetAxis( axis );
}
}
示例2: Magog_DoMove
//.........这里部分代码省略.........
// calculate what acceleration we are undergoing
idVec3 velAccel = ( newVelocity - velocity ) / frameTime;
// calculate a component due to air resistance
float speed = InchesToMetres( velLength );
float rho = 1.2f;
float sideArea = InchesToMetres( 650.0f ) * InchesToMetres( 650.0f );
float Cd = 0.6f;
float dragForceMagnitude = MetresToInches( 0.5 * Cd * sideArea * rho * speed * speed );
// assume mass is 10,000 -> I know this works nicely
idVec3 dragAccel = ( dragForceMagnitude / 10000.f ) * velDir;
idVec3 desiredAccel = velAccel + dragAccel;
desiredAccel *= 0.4f;
desiredAccel.z += MetresToInches( 9.8f );
// ok, so we desire to be looking at the target
idVec3 forwards = endPoint - origin;
forwards.z = 0.0f;
forwards.Normalize();
if ( orientToEnd ) {
idAngles targetAngles = ang_zero;
targetAngles.yaw = idMath::AngleNormalize180( itemRotation );
forwards = targetAngles.ToForward();
}
// figure out the axes corresponding to this orientation
idVec3 up = desiredAccel;
up.Normalize();
idVec3 right = up.Cross( forwards );
right.Normalize();
forwards = right.Cross( up );
forwards.Normalize();
// convert that to an angles
idAngles desiredAngles = ( idMat3( forwards, right, up ) ).ToAngles();
if ( clampRoll ) {
desiredAngles.roll = idMath::ClampFloat( -9.0f, 9.0f, desiredAngles.roll );
} else {
desiredAngles.roll = idMath::ClampFloat( -30.0f, 30.0f, desiredAngles.roll );
}
desiredAngles.pitch = idMath::ClampFloat( -30.0f, 30.0f, desiredAngles.pitch );
// find the diff between that and what we currently have
idAngles diffAngles = ( desiredAngles - angles ).Normalize180();
diffAngles = diffAngles * 0.1f;
diffAngles = diffAngles / frameTime;
diffAngles *= 0.1f;
// translate the old angular velocity back to an angle diff style value
idAngles oldDiffAngles;
oldDiffAngles.pitch = angVel * currentRight;
oldDiffAngles.yaw = angVel * currentUp;
oldDiffAngles.roll = angVel * currentFwd;
// blend the old and the new to soften the quick changes
diffAngles = oldDiffAngles * 0.9f + diffAngles * 0.1f;
// figure out how much we're trying to change by in a single frame
idAngles angleAccel = diffAngles - oldDiffAngles;
float maxAngleAccel = 45.0f * frameTime;
float maxYawAccel = maxAngleAccel * maxYawScale;
angleAccel.pitch = idMath::ClampFloat( -maxAngleAccel, maxAngleAccel, angleAccel.pitch );
angleAccel.yaw = idMath::ClampFloat( -maxYawAccel, maxYawAccel, angleAccel.yaw );
angleAccel.roll = idMath::ClampFloat( -maxAngleAccel, maxAngleAccel, angleAccel.roll );
diffAngles = oldDiffAngles + angleAccel;
idVec3 newAngVel = diffAngles.pitch * currentRight +
diffAngles.yaw * currentUp +
diffAngles.roll * currentFwd;
// HACK: ensure it never gets below the minimum height
if ( currentHeight < HOVER_HEIGHT_MIN ) {
idVec3 newOrigin = origin;
newOrigin.z = origin.z - currentHeight + HOVER_HEIGHT_MIN;
GetPhysics()->SetOrigin( newOrigin );
} else if ( currentHeight < HOVER_HEIGHT_RESCUE ) {
float oldNewVelLength = newVelocity.Length();
float scale = ( HOVER_HEIGHT_RESCUE - currentHeight ) / ( HOVER_HEIGHT_RESCUE - HOVER_HEIGHT_MIN );
scale = idMath::Sqrt( scale );
float rescueVelocity = scale * ( HOVER_HEIGHT_RESCUE - HOVER_HEIGHT_MIN ) / 0.5f;
float rescueAcceleration = ( rescueVelocity - velocity.z ) / frameTime;
rescueAcceleration = idMath::ClampFloat( 0.0f, 1800.0f, rescueAcceleration );
rescueVelocity = velocity.z + rescueAcceleration * frameTime;
if ( rescueVelocity > newVelocity.z ) {
newVelocity.z = rescueVelocity;
}
newVelocity.Normalize();
newVelocity *= oldNewVelLength;
}
GetPhysics()->SetLinearVelocity( newVelocity );
GetPhysics()->SetAxis( angles.ToMat3() );
GetPhysics()->SetAngularVelocity( newAngVel );
}
示例3: Event_SetJointAngle
/*
================
sdClientAnimated::Event_SetJointAngle
================
*/
void sdClientAnimated::Event_SetJointAngle( jointHandle_t joint, jointModTransform_t transformType, const idAngles& angles ) {
animator.SetJointAxis( joint, transformType, angles.ToMat3() );
}
示例4: UpdateViewAngles
/*
================
hhCameraInterpolator::UpdateViewAngles
================
*/
idAngles hhCameraInterpolator::UpdateViewAngles( const idAngles& viewAngles ) {
return (viewAngles.ToMat3() * GetCurrentAxis()).ToAngles();
}