当前位置: 首页>>代码示例>>C++>>正文


C++ FRotator::GetNormalized方法代码示例

本文整理汇总了C++中FRotator::GetNormalized方法的典型用法代码示例。如果您正苦于以下问题:C++ FRotator::GetNormalized方法的具体用法?C++ FRotator::GetNormalized怎么用?C++ FRotator::GetNormalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FRotator的用法示例。


在下文中一共展示了FRotator::GetNormalized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RLerp

FRotator UKismetMathLibrary::RLerp(FRotator A, FRotator B, float Alpha, bool bShortestPath)
{
	FRotator DeltaAngle = B - A;

	if( bShortestPath )
	{
		DeltaAngle = DeltaAngle.GetNormalized();
	}

	return A + Alpha*DeltaAngle;
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:11,代码来源:KismetMathLibrary.cpp

示例2: ProcessViewRotation

bool UHoatCameraModifierFocusTargetActor::ProcessViewRotation(class AActor* ViewTarget, float DeltaTime,
                                                                FRotator& OutViewRotation, FRotator& OutDeltaRot)
{
    Super::ProcessViewRotation(ViewTarget, DeltaTime, OutViewRotation, OutDeltaRot);

    // Check if we're selecting a target.
    if (!IsValid(ViewTarget))
    {
        return false;
    }

	ITargetingActorInterface* targetingActor = Cast<ITargetingActorInterface>(ViewTarget);

    if (!targetingActor)
    {
        return false;
    }

    if (!targetingActor->IsSelectingTarget())
    {
        return false;
    }

    // Check if there's a selected target.
    AActor* currentTarget = targetingActor->GetCurrentTarget();

    if (IsValid(currentTarget))
    {
        if (currentTarget != LastTarget)
        {
            // We have selected a new target. Compute desired rotation.
            FVector cameraLocation = CameraOwner->GetCameraLocation();
            FVector targetLocation = currentTarget->GetActorLocation();

            // Get rotation delta from current camera rotation to look-at rotation for the target.
            // As the camera position might change depending on its rotation (e.g. for spring arms),
            // we just compute this once per target and store the result.
            // Otherwise, for very close targets, we risk rotating the camera back and forth as its position changes.
            DesiredRotation = UKismetMathLibrary::FindLookAtRotation(cameraLocation, targetLocation);
            LastTarget = currentTarget;
        }

        FRotator currentRotation = OutViewRotation;

        if (SnapSpeed <= 0)
        {
            // Snap immediately.
            OutViewRotation = DesiredRotation;
        }
        else
        {
            FRotator towardsDesired = DesiredRotation - currentRotation;
            FRotator towardsDesiredNormalized = towardsDesired.GetNormalized();

            if (towardsDesiredNormalized.IsNearlyZero())
            {
                // Prevent overshooting.
                OutViewRotation = DesiredRotation;
            }
            else
            {
                // Apply rotation speed.
                FRotator deltaRot = towardsDesiredNormalized * SnapSpeed * DeltaTime;
                OutDeltaRot += deltaRot;
            }
        }
    }
    else
    {
        LastTarget = nullptr;

        // No target selected. Smoothly apply player input.
        FVector2D targetSelectionInput = targetingActor->GetCurrentTargetSelectionInput();

        FRotator deltaRot;
        deltaRot.Yaw = targetSelectionInput.X * RotationSpeed * DeltaTime;
        deltaRot.Pitch = -targetSelectionInput.Y * RotationSpeed * DeltaTime;
        deltaRot.Roll = 0.0f;

        OutDeltaRot += deltaRot;
    }

    // Prevent further camera modifiers from being applied.
    return true;
}
开发者ID:kurayama,项目名称:third-person-camera,代码行数:85,代码来源:HoatCameraModifierFocusTargetActor.cpp


注:本文中的FRotator::GetNormalized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。