本文整理汇总了C++中FRotator::Normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ FRotator::Normalize方法的具体用法?C++ FRotator::Normalize怎么用?C++ FRotator::Normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FRotator
的用法示例。
在下文中一共展示了FRotator::Normalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNiceRotatorValue
void GetNiceRotatorValue(FRotator& Rotator1, FRotator& Rotator2) {
Rotator1.Normalize();
Rotator2.Normalize();
GetNiceAngleValue(Rotator1.Pitch, Rotator2.Pitch);
GetNiceAngleValue(Rotator1.Yaw, Rotator2.Yaw);
GetNiceAngleValue(Rotator1.Roll, Rotator2.Roll);
}
示例2: MoveForward
void AARCharacter::MoveForward(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
//if (Value < 0)
//{
// float orignal = CharacterMovement->MaxWalkSpeed;
// CharacterMovement->MaxWalkSpeed = CharacterMovement->MaxWalkSpeed / 2;
// FRotator Rotation = GetBaseAimRotation();
// FVector Location; //not used, just need for below.
// //Controller->GetPlayerViewPoint(Location, Rotation);
// Rotation.Normalize();
// FRotator YawRotation(0, Rotation.Yaw, 0);
// //const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis( EAxis::X );
// const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
// AddMovementInput(Direction, Value);
// CharacterMovement->MaxWalkSpeed = orignal;
// return;
//}
FRotator Rotation = GetBaseAimRotation();
FVector Location; //not used, just need for below.
//Controller->GetPlayerViewPoint(Location, Rotation);
Rotation.Normalize();
FRotator YawRotation(0, Rotation.Yaw, 0);
//const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis( EAxis::X );
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
示例3: EditorApplyRotation
void AActor::EditorApplyRotation(const FRotator& DeltaRotation, bool bAltDown, bool bShiftDown, bool bCtrlDown)
{
if( RootComponent != NULL )
{
const FRotator Rot = RootComponent->GetAttachParent() != NULL ? GetActorRotation() : RootComponent->RelativeRotation;
FRotator ActorRotWind, ActorRotRem;
Rot.GetWindingAndRemainder(ActorRotWind, ActorRotRem);
const FQuat ActorQ = ActorRotRem.Quaternion();
const FQuat DeltaQ = DeltaRotation.Quaternion();
const FQuat ResultQ = DeltaQ * ActorQ;
const FRotator NewActorRotRem = FRotator( ResultQ );
FRotator DeltaRot = NewActorRotRem - ActorRotRem;
DeltaRot.Normalize();
if( RootComponent->GetAttachParent() != NULL )
{
RootComponent->SetWorldRotation( Rot + DeltaRot );
}
else
{
// No attachment. Directly set relative rotation (to support winding)
RootComponent->SetRelativeRotation( Rot + DeltaRot );
}
}
else
{
UE_LOG(LogActor, Warning, TEXT("WARNING: EditorApplyRotation %s has no root component"), *GetName() );
}
}
示例4: ProcessViewRotation
void APlayerCameraManager::ProcessViewRotation(float DeltaTime, FRotator& OutViewRotation, FRotator& OutDeltaRot)
{
for( int32 ModifierIdx = 0; ModifierIdx < ModifierList.Num(); ModifierIdx++ )
{
if( ModifierList[ModifierIdx] != NULL &&
!ModifierList[ModifierIdx]->IsDisabled() )
{
if( ModifierList[ModifierIdx]->ProcessViewRotation(ViewTarget.Target, DeltaTime, OutViewRotation, OutDeltaRot) )
{
break;
}
}
}
// Add Delta Rotation
OutViewRotation += OutDeltaRot;
OutDeltaRot = FRotator::ZeroRotator;
if(GEngine->HMDDevice.IsValid() && GEngine->IsStereoscopic3D())
{
// With the HMD devices, we can't limit the view pitch, because it's bound to the player's head. A simple normalization will suffice
OutViewRotation.Normalize();
}
else
{
// Limit Player View Axes
LimitViewPitch( OutViewRotation, ViewPitchMin, ViewPitchMax );
LimitViewYaw( OutViewRotation, ViewYawMin, ViewYawMax );
LimitViewRoll( OutViewRotation, ViewRollMin, ViewRollMax );
}
}
示例5: FindDeathCameraSpot
bool AKinectPlayerController::FindDeathCameraSpot(FVector& CameraLocation, FRotator& CameraRotation)
{
const FVector PawnLocation = GetPawn()->GetActorLocation();
FRotator ViewDir = GetControlRotation();
ViewDir.Pitch = -45.0f;
const float YawOffsets[] = { 0.0f, -180.0f, 90.0f, -90.0f, 45.0f, -45.0f, 135.0f, -135.0f };
const float CameraOffset = 600.0f;
FCollisionQueryParams TraceParams(TEXT("DeathCamera"), true, GetPawn());
for (int32 i = 0; i < ARRAY_COUNT(YawOffsets); i++)
{
FRotator CameraDir = ViewDir;
CameraDir.Yaw += YawOffsets[i];
CameraDir.Normalize();
const FVector TestLocation = PawnLocation - CameraDir.Vector() * CameraOffset;
const bool bBlocked = GetWorld()->LineTraceTest(PawnLocation, TestLocation, ECC_Camera, TraceParams);
if (!bBlocked)
{
CameraLocation = TestLocation;
CameraRotation = CameraDir;
return true;
}
}
return false;
}
示例6: ApplyDelta
void FSpriteSelectedSocket::ApplyDelta(const FVector2D& Delta, const FRotator& Rotation, const FVector& Scale3D, FWidget::EWidgetMode MoveMode)
{
if (UPrimitiveComponent* PreviewComponent = PreviewComponentPtr.Get())
{
UObject* AssociatedAsset = const_cast<UObject*>(PreviewComponent->AdditionalStatObject());
if (UPaperSprite* Sprite = Cast<UPaperSprite>(AssociatedAsset))
{
if (FPaperSpriteSocket* Socket = Sprite->FindSocket(SocketName))
{
const bool bDoRotation = (MoveMode == FWidget::WM_Rotate) || (MoveMode == FWidget::WM_TranslateRotateZ);
const bool bDoTranslation = (MoveMode == FWidget::WM_Translate) || (MoveMode == FWidget::WM_TranslateRotateZ);
const bool bDoScale = MoveMode == FWidget::WM_Scale;
if (bDoTranslation)
{
//@TODO: Currently sockets are in unflipped pivot space,
const FVector Delta3D_UU = (PaperAxisX * Delta.X) + (PaperAxisY * -Delta.Y);
const FVector Delta3D = Delta3D_UU * Sprite->GetPixelsPerUnrealUnit();
Socket->LocalTransform.SetLocation(Socket->LocalTransform.GetLocation() + Delta3D);
}
if (bDoRotation)
{
const FRotator CurrentRot = Socket->LocalTransform.GetRotation().Rotator();
FRotator SocketWinding;
FRotator SocketRotRemainder;
CurrentRot.GetWindingAndRemainder(SocketWinding, SocketRotRemainder);
const FQuat ActorQ = SocketRotRemainder.Quaternion();
const FQuat DeltaQ = Rotation.Quaternion();
const FQuat ResultQ = DeltaQ * ActorQ;
const FRotator NewSocketRotRem = FRotator( ResultQ );
FRotator DeltaRot = NewSocketRotRem - SocketRotRemainder;
DeltaRot.Normalize();
const FRotator NewRotation(CurrentRot + DeltaRot);
Socket->LocalTransform.SetRotation(NewRotation.Quaternion());
}
if (bDoScale)
{
const FVector4 LocalSpaceScaleOffset = Socket->LocalTransform.TransformVector(Scale3D);
Socket->LocalTransform.SetScale3D(Socket->LocalTransform.GetScale3D() + LocalSpaceScaleOffset);
}
}
}
}
}
示例7: MoveRight
void AARCharacter::MoveRight(float Value)
{
if ( (Controller != NULL) && (Value != 0.0f) )
{
FRotator Rotation;
FVector Location; //not used, just need for below.
Controller->GetPlayerViewPoint(Location, Rotation);
Rotation.Normalize();
FRotator YawRotation(0, Rotation.Yaw, 0);
const FVector Direction = FRotationMatrix(YawRotation).GetScaledAxis(EAxis::Y);
// add movement in that direction
AddMovementInput(Direction, Value);
}
}
示例8: ResetOrientation
void FSteamVRHMD::ResetOrientation(float Yaw)
{
FRotator ViewRotation;
ViewRotation = FRotator(TrackingFrame.DeviceOrientation[vr::k_unTrackedDeviceIndex_Hmd]);
ViewRotation.Pitch = 0;
ViewRotation.Roll = 0;
if (Yaw != 0.f)
{
// apply optional yaw offset
ViewRotation.Yaw -= Yaw;
ViewRotation.Normalize();
}
BaseOrientation = ViewRotation.Quaternion();
}
示例9: ResetOrientation
void FOSVRHMD::ResetOrientation(float yaw)
{
FRotator ViewRotation;
ViewRotation = FRotator(CurHmdOrientation);
ViewRotation.Pitch = 0;
ViewRotation.Roll = 0;
ViewRotation.Yaw += BaseOrientation.Rotator().Yaw;
if (yaw != 0.f)
{
// apply optional yaw offset
ViewRotation.Yaw -= yaw;
ViewRotation.Normalize();
}
BaseOrientation = ViewRotation.Quaternion();
}
示例10: ApplyHmdRotation
void FSimpleHMD::ApplyHmdRotation(APlayerController* PC, FRotator& ViewRotation)
{
ViewRotation.Normalize();
GetCurrentPose(CurHmdOrientation);
LastHmdOrientation = CurHmdOrientation;
const FRotator DeltaRot = ViewRotation - PC->GetControlRotation();
DeltaControlRotation = (DeltaControlRotation + DeltaRot).GetNormalized();
// Pitch from other sources is never good, because there is an absolute up and down that must be respected to avoid motion sickness.
// Same with roll.
DeltaControlRotation.Pitch = 0;
DeltaControlRotation.Roll = 0;
DeltaControlOrientation = DeltaControlRotation.Quaternion();
ViewRotation = FRotator(DeltaControlOrientation * CurHmdOrientation);
}
示例11: ApplyHmdRotation
void FOSVRHMD::ApplyHmdRotation(APlayerController* PC, FRotator& ViewRotation)
{
ViewRotation.Normalize();
FQuat lastHmdOrientation, hmdOrientation;
FVector lastHmdPosition, hmdPosition;
UpdateHeadPose(lastHmdOrientation, lastHmdPosition, hmdOrientation, hmdPosition);
const FRotator DeltaRot = ViewRotation - PC->GetControlRotation();
DeltaControlRotation = (DeltaControlRotation + DeltaRot).GetNormalized();
// Pitch from other sources is never good, because there is an absolute up and down that must be respected to avoid motion sickness.
// Same with roll. Retain yaw by default - mouse/controller based yaw movement still isn't pleasant, but
// it's necessary for sitting VR experiences.
DeltaControlRotation.Pitch = 0;
DeltaControlRotation.Roll = 0;
DeltaControlOrientation = DeltaControlRotation.Quaternion();
ViewRotation = FRotator(DeltaControlOrientation * hmdOrientation);
}
示例12: ApplyDelta
void FSpriteSelectedShape::ApplyDelta(const FVector2D& Delta, const FRotator& Rotation, const FVector& Scale3D, FWidget::EWidgetMode MoveMode)
{
if (Geometry.Shapes.IsValidIndex(ShapeIndex))
{
FSpriteGeometryShape& Shape = Geometry.Shapes[ShapeIndex];
const bool bDoRotation = (MoveMode == FWidget::WM_Rotate) || (MoveMode == FWidget::WM_TranslateRotateZ);
const bool bDoTranslation = (MoveMode == FWidget::WM_Translate) || (MoveMode == FWidget::WM_TranslateRotateZ);
const bool bDoScale = MoveMode == FWidget::WM_Scale;
if (bDoTranslation)
{
const FVector WorldSpaceDelta = (PaperAxisX * Delta.X) + (PaperAxisY * Delta.Y);
const FVector2D TextureSpaceDelta = EditorContext->SelectedItemConvertWorldSpaceDeltaToLocalSpace(WorldSpaceDelta);
Shape.BoxPosition += TextureSpaceDelta;
Geometry.GeometryType = ESpritePolygonMode::FullyCustom;
}
if (bDoScale)
{
const float ScaleDeltaX = FVector::DotProduct(Scale3D, PaperAxisX);
const float ScaleDeltaY = FVector::DotProduct(Scale3D, PaperAxisY);
const FVector2D OldSize = Shape.BoxSize;
const FVector2D NewSize(OldSize.X + ScaleDeltaX, OldSize.Y + ScaleDeltaY);
if (!FMath::IsNearlyZero(NewSize.X, KINDA_SMALL_NUMBER) && !FMath::IsNearlyZero(NewSize.Y, KINDA_SMALL_NUMBER))
{
const FVector2D ScaleFactor(NewSize.X / OldSize.X, NewSize.Y / OldSize.Y);
Shape.BoxSize = NewSize;
// Now apply it to the verts
for (FVector2D& Vertex : Shape.Vertices)
{
Vertex.X *= ScaleFactor.X;
Vertex.Y *= ScaleFactor.Y;
}
Geometry.GeometryType = ESpritePolygonMode::FullyCustom;
}
}
if (bDoRotation)
{
//@TODO: This stuff should probably be wrapped up into a utility method (also used for socket editing)
const FRotator CurrentRot(Shape.Rotation, 0.0f, 0.0f);
FRotator SocketWinding;
FRotator SocketRotRemainder;
CurrentRot.GetWindingAndRemainder(SocketWinding, SocketRotRemainder);
const FQuat ActorQ = SocketRotRemainder.Quaternion();
const FQuat DeltaQ = Rotation.Quaternion();
const FQuat ResultQ = DeltaQ * ActorQ;
const FRotator NewSocketRotRem = FRotator(ResultQ);
FRotator DeltaRot = NewSocketRotRem - SocketRotRemainder;
DeltaRot.Normalize();
const FRotator NewRotation(CurrentRot + DeltaRot);
Shape.Rotation = NewRotation.Pitch;
Geometry.GeometryType = ESpritePolygonMode::FullyCustom;
}
}
}
示例13: NormalizedDeltaRotator
FRotator UKismetMathLibrary::NormalizedDeltaRotator(FRotator A, FRotator B)
{
FRotator Delta = A - B;
Delta.Normalize();
return Delta;
}
示例14: Tick
void AFollowRoadCamera::Tick(float Delta) {
if (!Running) {
return;
}
if (!Roadmap) {
return;
}
float SpeedCMs = Speed / 0.036;
float CurrentTime = GetWorld()->GetTimeSeconds();
float TimePassed = CurrentTime - StartTime;
float DistancePassed = TimePassed * SpeedCMs;
if (Rev) {
DistancePassed = MaxDist - DistancePassed;
}
float TValue = SplineInfoDistance.Eval(DistancePassed, 0);
FVector Location = Roadmap->SplineInfo.Eval(TValue, FVector(0, 0, 0));
FVector Tangent = Roadmap->SplineInfo.EvalDerivative(TValue, FVector(0, 0, 0)).GetSafeNormal2D();
FVector Side = FVector::CrossProduct(FVector::UpVector, Tangent);
Location += Tangent * Offset.X;
Location += Side * Offset.Y;
Location += FVector::UpVector * Offset.Z;
FVector LookAtLocation;
if (ReplayPlayer && ReplayPlayer->LookAtActor) {
LookAtLocation = ReplayPlayer->LookAtActor->GetActorLocation();
}
else {
float DistanceLookAt = 0;
if (Rev) {
DistanceLookAt = DistancePassed - LookAtDistance;
}
else {
DistanceLookAt = DistancePassed + LookAtDistance;
}
float TValueLookAt = SplineInfoDistance.Eval(DistanceLookAt, 0);
LookAtLocation = Roadmap->SplineInfo.Eval(TValueLookAt, FVector(0, 0, 0));
FVector LookAtTangent = Roadmap->SplineInfo.EvalDerivative(TValueLookAt, FVector(0, 0, 0)).GetSafeNormal2D();
FVector LookAtSide = FVector::CrossProduct(FVector::UpVector, LookAtTangent);
LookAtLocation += LookAtTangent * LookAtOffset.X;
LookAtLocation += LookAtSide * LookAtOffset.Y;
LookAtLocation += FVector::UpVector * LookAtOffset.Z;
}
FRotator NewRotation = (LookAtLocation - Location).Rotation();
NewRotation.Pitch += DegreesAboveFollow;
if (FirstTick) {
SetActorLocation(Location);
SetActorRotation(NewRotation);
FirstTick = false;
return;
}
FVector LastLocation = GetActorLocation();
FRotator LastRotation = GetActorRotation();
// Note: This will not work if LastRotation and NewRotation are too far from
// each other (more than 20 degrees), however, in that case, nothing will
// work...
GetNiceRotatorValue(NewRotation, LastRotation);
NewRotation = NewRotation * (1-FollowSmooth) + LastRotation * FollowSmooth;
NewRotation.Normalize();
SetActorLocation(Location * 0.1 + LastLocation * 0.9);
SetActorRotation(NewRotation);
}
示例15: NeuronRead
//.........这里部分代码省略.........
int32 FloatsPerBone = 6; // 3 for x,y,z translation and 3 for x,y,z rotation
if (Controller->bDisplacement == false)
{
FloatsPerBone = 3; // If there is no displacement (translation) info we have only 3 floats for rotation left
}
if ((BVHBoneIndex * FloatsPerBone) > Controller->FloatCount)
{
Rotation.Yaw = Rotation.Pitch = Rotation.Roll = 0;
Translation.X = Translation.Y = Translation.Z = 0;
return false;
}
// Get the rotation of the reference pose bone
FQuat RefQuat(FQuat::Identity);
if (Mesh != nullptr && Mesh->SkeletalMesh != nullptr)
{
const FReferenceSkeleton& RefSkeleton(Mesh->SkeletalMesh->RefSkeleton);
int32 RefBoneIndex = Mesh->GetBoneIndex(CustomBoneName);
while (RefBoneIndex != INDEX_NONE)
{
RefQuat = RefSkeleton.GetRefBonePose()[RefBoneIndex].GetRotation() * RefQuat;
RefBoneIndex = RefSkeleton.GetParentIndex(RefBoneIndex);
}
}
//
// Translation
//
if (Controller->bDisplacement == true)
{
// Read translation values and remove BVH reference position
float X = Controller->MotionLine[(BVHBoneIndex * FloatsPerBone) + Controller->Skeleton.Bones[BVHBoneIndex].XPos] - Controller->Skeleton.Bones[BVHBoneIndex].Offset[0];
float Y = Controller->MotionLine[(BVHBoneIndex * FloatsPerBone) + Controller->Skeleton.Bones[BVHBoneIndex].YPos] - Controller->Skeleton.Bones[BVHBoneIndex].Offset[1];
float Z = Controller->MotionLine[(BVHBoneIndex * FloatsPerBone) + Controller->Skeleton.Bones[BVHBoneIndex].ZPos] - Controller->Skeleton.Bones[BVHBoneIndex].Offset[2];
// Map BVH translation to UE4 world coordinate system (Inverse if forward direction is -Y)
if (InverseForward)
{
Translation = FVector(-X, -Z, Y);
}
else
{
Translation = FVector(X, Z, Y);
}
// Map UE4 world translation to bone space
Translation = RefQuat.Inverse().RotateVector(Translation);
}
else
{
Translation.X = Translation.Y = Translation.Z = 0;
}
// Add additional translation
Translation.X += AdditionalTranslation.X;
Translation.Y += AdditionalTranslation.Y;
Translation.Z += AdditionalTranslation.Z;
//
// Rotation
//
// Read rotation values and map to pitch, yaw, roll (y, z, x)
float XR = Controller->MotionLine[(BVHBoneIndex * FloatsPerBone) + Controller->Skeleton.Bones[BVHBoneIndex].XRot] * PI / 180.f;
float YR = Controller->MotionLine[(BVHBoneIndex * FloatsPerBone) + Controller->Skeleton.Bones[BVHBoneIndex].YRot] * PI / 180.f;
float ZR = Controller->MotionLine[(BVHBoneIndex * FloatsPerBone) + Controller->Skeleton.Bones[BVHBoneIndex].ZRot] * PI / 180.f;
// Calculate Rotation Matrix and map to Quaternion
FQuat BVHQuat = CalculateQuat(XR, YR, ZR, Controller->Skeleton.Bones[BVHBoneIndex].RotOrder);
// Map BVH rotation to UE4 world coordinate system (Inverse if forward direction is -Y)
float Y = BVHQuat.Y;
float Z = BVHQuat.Z;
if (InverseForward)
{
BVHQuat.X *= -1.0;
BVHQuat.Y = -Z;
BVHQuat.Z = Y;
}
else
{
BVHQuat.Y = Z;
BVHQuat.Z = Y;
}
// Map UE4 world rotation to bone space
FQuat Quat(RefQuat.Inverse() * BVHQuat * RefQuat);
// Add additional rotation
FQuat AddRot(AdditionalRotation);
Quat *= AddRot;
// Convert to Rotator
Rotation = Quat.Rotator();
Rotation.Normalize();
return true;
}