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


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

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


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

示例1: ConvertCSRotationToBoneSpace

FQuat UAnimGraphNode_SkeletalControlBase::ConvertCSRotationToBoneSpace(const USkeletalMeshComponent* SkelComp, FRotator& InCSRotator, FA2CSPose& MeshBases, const FName& BoneName, const EBoneControlSpace Space)
{
	FQuat OutQuat = FQuat::Identity;

	if (MeshBases.IsValid())
	{
		int32 MeshBoneIndex = SkelComp->GetBoneIndex(BoneName);

		FVector RotAxis;
		float RotAngle;
		InCSRotator.Quaternion().ToAxisAndAngle(RotAxis, RotAngle);

		switch (Space)
		{
			// World Space, no change in preview window
		case BCS_WorldSpace:
		case BCS_ComponentSpace:
			// Component Space, no change.
			OutQuat = InCSRotator.Quaternion();
			break;

		case BCS_ParentBoneSpace:
		{
			const int32 ParentIndex = MeshBases.GetParentBoneIndex(MeshBoneIndex);
			if (ParentIndex != INDEX_NONE)
			{
				FTransform ParentTM = MeshBases.GetComponentSpaceTransform(ParentIndex);
				ParentTM = ParentTM.Inverse();
				//Calculate the new delta rotation
				FVector4 BoneSpaceAxis = ParentTM.TransformVector(RotAxis);
				FQuat DeltaQuat(BoneSpaceAxis, RotAngle);
				DeltaQuat.Normalize();
				OutQuat = DeltaQuat;
			}
		}
			break;

		case BCS_BoneSpace:
		{
			FTransform BoneTM = MeshBases.GetComponentSpaceTransform(MeshBoneIndex);
			BoneTM = BoneTM.Inverse();
			FVector4 BoneSpaceAxis = BoneTM.TransformVector(RotAxis);
			//Calculate the new delta rotation
			FQuat DeltaQuat(BoneSpaceAxis, RotAngle);
			DeltaQuat.Normalize();
			OutQuat = DeltaQuat;
		}
			break;
		}
	}

	return OutQuat;
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:53,代码来源:AnimGraphNode_SkeletalControlBase.cpp

示例2: StartupModule

void FDevicePlugin::StartupModule()
{
	pDrvIface = new CLSDRVIFACE();

	for (int i = 0; i < NUM_SENSORS; i++)
	{
		recalibQuat[i].W = 1.0;
		recalibQuat[i].X = 0.0;
		recalibQuat[i].Y = 0.0;
		recalibQuat[i].Z = 0.0;

		ueCalibQuat[i].W = 1.0;
		ueCalibQuat[i].X = 0.0;
		ueCalibQuat[i].Y = 0.0;
		ueCalibQuat[i].Z = 0.0;
	}

	FRotator tempRot;

	tempRot.Yaw = 0.0;
	tempRot.Pitch = -80.0;
	tempRot.Roll = 0.0;
	ueCalibQuat[0] = tempRot.Quaternion();
	ueCalibQuat[0].X *= -1.0;
	ueCalibQuat[0].Z *= -1.0;

	tempRot.Yaw = -90.0;
	tempRot.Pitch = 0.0;
	tempRot.Roll = 180.0;
	ueCalibQuat[1] = tempRot.Quaternion();
	ueCalibQuat[1].X *= -1.0;
	ueCalibQuat[1].Z *= -1.0;

	tempRot.Yaw = 0.0;
	tempRot.Pitch = 80.0;
	tempRot.Roll = 180.0;
	ueCalibQuat[2] = tempRot.Quaternion();
	//ueCalibQuat[2].X *= -1;

	tempRot.Yaw = -90.0;
	tempRot.Pitch = 0.0;
	tempRot.Roll = 0.0;
	ueCalibQuat[3] = tempRot.Quaternion();
	/*float temp = ueCalibQuat[3].Y;
	ueCalibQuat[3].Y = ueCalibQuat[3].Z;
	ueCalibQuat[3].Z = temp;*/
	//ueCalibQuat[2].X *= -1;
	// This code will execute after your module is loaded into memory (but after global variables are initialized, of course.)
}
开发者ID:sidg-vr-geek,项目名称:deviceplugin_12_5,代码行数:49,代码来源:DevicePlugin.cpp

示例3: 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);
				}
			}
		}
	}
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:49,代码来源:SocketEditing.cpp

示例4: Tick

void ADuckTower::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	/*
	AActor *actor = GetAttachParentActor();
	FVector actor2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation();
	FRotator newRotation = FRotationMatrix::MakeFromX(actor2 - actor->GetActorLocation()).Rotator();
	GetAttachParentActor()->SetActorRotation(newRotation);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, actor->GetName());
	*//*
	FVector actor2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation();
	FVector actor = GetAttachParentActor()->GetActorLocation();
	FVector Direction = actor - actor2;
	FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
	GetAttachParentActor()->SetActorRotation(test);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, actor2.ToString());
	*/
	//GetAttachParentActor()->SetActorLocation(FVector(0.0f, 0.0f, (float)testNumber));
	//testNumber += 1.f;
	APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn();
	FVector actor2 = player->GetActorLocation(); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10;
	FVector actor = GetActorLocation();
	FVector Direction = actor - actor2;
	FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
	FRotator test2 = FRotator(1.0f, 0.0f, 0.0f);
	FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion());

	FVector vec2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation();
	FVector vec = GetActorLocation();
	float distance = FVector::Dist(actor, actor2);

	//finalrot.Pitch -= 10 - distance / 10000 * 10;
	//SetActorRotation(finalrot);

	TArray<UStaticMeshComponent*> comps;
	GetComponents(comps);
	/*
	for (auto StaticMeshComponent : comps)
	{
	StaticMeshComponent->SetVisibility(true);
	StaticMeshComponent->SetWorldRotation(finalrot);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, StaticMeshComponent->GetComponentRotation().ToString());
	}*/
	if (UGameplayStatics::GetPlayerController(GetWorld(), 0)->WasInputKeyJustPressed(EKeys::I))
	{

	}
	if (shootTimer <= 0.f)
	{


		Shoot(distance);
		shootTimer = 2.f;
	}
	else
		shootTimer -= DeltaSeconds;
	//GetAttachParentActor()->GetRootPrimitiveComponent()->AddImpulse(UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorForwardVector());
	//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(testNumber));
	//GetAttachParentActor()->SetActorRotation()
}
开发者ID:SlooBo,项目名称:RalliaPerkele,代码行数:60,代码来源:DuckTower.cpp

示例5: Shoot

void ADuckTower::Shoot(float distance)
{
	/*
	const FName filename = FName(TEXT("Blueprint'/Game/Blueprints/PickUp.PickUp'"));
	FVector loc = GetAttachParentActor()->GetActorLocation();
	FRotator rot = GetAttachParentActor()->GetActorRotation();
	SpawnBP(GetWorld(), (UClass*)LoadObjFromPath<UBlueprint>(&filename), loc, rot);
	*/
	APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 1)->GetControlledPawn();
	int randomValue = distance / 10000;
	FVector vec = player->GetActorLocation() + FVector(FMath::RandRange(-randomValue, randomValue), FMath::RandRange(-randomValue, randomValue), 0.0f); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10;
	FVector vec2 = GetActorLocation();
	FVector Direction = vec - vec2;
	FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
	FRotator test2 = FRotator(1.0f, 0.0f, 0.0f);
	FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion());


	FVector forward = GetActorForwardVector();
	finalrot.Roll = -finalrot.Roll;
	finalrot.Yaw = -finalrot.Yaw;
	finalrot.Pitch = -finalrot.Pitch;
	FVector loc = GetActorLocation() + forward * 500.0f;
	FRotator rot = GetActorRotation();
	AActor* actor = GetWorld()->SpawnActor<AActor>(BulletBlueprint, loc, GetActorRotation());
	actor->SetActorScale3D(FVector(3.0f, 3.0f, 3.0f));
	//actor->GetRootPrimitiveComponent()->AddImpulse(actor->GetActorForwardVector()* 5000.0f);

	//actor->GetRootPrimitiveComponent()->SetPhysicsLinearVelocity(actor->GetActorForwardVector()*10000.0f); //* (distance/10000 * 1.0f));
}
开发者ID:SlooBo,项目名称:RalliaPerkele,代码行数:30,代码来源:DuckTower.cpp

示例6: 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() );
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:31,代码来源:ActorEditor.cpp

示例7: NotifyHit

void ATP_FlyingPawn::NotifyHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{
	Super::NotifyHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);

	// Deflect along the surface when we collide.
	FRotator CurrentRotation = GetActorRotation(RootComponent);
	SetActorRotation(FQuat::Slerp(CurrentRotation.Quaternion(), HitNormal.ToOrientationQuat(), 0.025f));
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:8,代码来源:TP_FlyingPawn.cpp

示例8: DebugOrientation

void UDebugHandUtility::DebugOrientation(FRotator Orientation, FVector At, float Scale)
{
	FRotator rotation = UKismetMathLibrary::ComposeRotators(Orientation, GetComponentRotation());
	FVector EndArrow = (UKismetMathLibrary::GetForwardVector(rotation)*Scale) + At; 
	DrawDebugDirectionalArrow(GetWorld(), At, EndArrow, 5, FColor::Black); 

	FVector Extent = Scale * FVector(0.2, 0.2, 0.2);
	DrawDebugBox(GetWorld(), EndArrow, Extent, rotation.Quaternion(), FColor::Black);
}
开发者ID:Deams51,项目名称:leap-ue4,代码行数:9,代码来源:DebugHandUtility.cpp

示例9: CalculateStereoViewOffset

void FSimpleHMD::CalculateStereoViewOffset(const enum EStereoscopicPass StereoPassType, const FRotator& ViewRotation, const float WorldToMeters, FVector& ViewLocation)
{
	if( StereoPassType != eSSP_FULL)
	{
		float EyeOffset = 3.20000005f;
		const float PassOffset = (StereoPassType == eSSP_LEFT_EYE) ? EyeOffset : -EyeOffset;
		ViewLocation += ViewRotation.Quaternion().RotateVector(FVector(0,PassOffset,0));
	}
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:9,代码来源:SimpleHMD.cpp

示例10: GenerateSphylAsSimpleCollision

int32 GenerateSphylAsSimpleCollision(UStaticMesh* StaticMesh)
{
	if (!PromptToRemoveExistingCollision(StaticMesh))
	{
		return INDEX_NONE;
	}

	UBodySetup* bs = StaticMesh->BodySetup;

	// Calculate bounding box.
	FRawMesh RawMesh;
	FStaticMeshSourceModel& SrcModel = StaticMesh->SourceModels[0];
	SrcModel.RawMeshBulkData->LoadRawMesh(RawMesh);

	FSphere sphere;
	float length;
	FRotator rotation;
	FVector unitVec = bs->BuildScale3D;
	CalcBoundingSphyl(RawMesh, sphere, length, rotation, unitVec);

	// Dont use if radius is zero.
	if (sphere.W <= 0.f)
	{
		FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "Prompt_10", "Could not create geometry."));
		return INDEX_NONE;
	}

	// If height is zero, then a sphere would be better (should we just create one instead?)
	if (length <= 0.f)
	{
		length = SMALL_NUMBER;
	}

	bs->Modify();

	// Create new GUID
	bs->InvalidatePhysicsData();

	FKSphylElem SphylElem;
	SphylElem.Center = sphere.Center;
	SphylElem.Orientation = rotation.Quaternion();
	SphylElem.Radius = sphere.W;
	SphylElem.Length = length;
	bs->AggGeom.SphylElems.Add(SphylElem);

	// refresh collision change back to staticmesh components
	RefreshCollisionChange(StaticMesh);

	// Mark staticmesh as dirty, to help make sure it gets saved.
	StaticMesh->MarkPackageDirty();

	StaticMesh->bCustomizedCollision = true;	//mark the static mesh for collision customization

	return bs->AggGeom.SphylElems.Num() - 1;
}
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:55,代码来源:GeomFitUtils.cpp

示例11: turnShip

void AShip::turnShip(float delta){
	if (turnDirection == 0)
		return;

	FRotator rot = FRotator(turnDirection * engines->getTurnSpeed() * delta, 0.f, 0.f);
	FTransform transform = GetTransform();
	transform.ConcatenateRotation(rot.Quaternion());
	transform.NormalizeRotation();
	SetActorTransform(transform);

}
开发者ID:Zecknaal,项目名称:Jettisoned,代码行数:11,代码来源:Ship.cpp

示例12: CalculateStereoViewOffset

void FOSVRHMD::CalculateStereoViewOffset(const EStereoscopicPass StereoPassType, const FRotator& ViewRotation, const float WorldToMeters, FVector& ViewLocation)
{
    if (StereoPassType != eSSP_FULL)
    {
        float EyeOffset = (GetInterpupillaryDistance() * WorldToMeters) / 2.0f;
        const float PassOffset = (StereoPassType == eSSP_LEFT_EYE) ? -EyeOffset : EyeOffset;
        ViewLocation += ViewRotation.Quaternion().RotateVector(FVector(0, PassOffset, 0));

        const FVector vHMDPosition = DeltaControlOrientation.RotateVector(CurHmdPosition);
        ViewLocation += vHMDPosition;
    }
}
开发者ID:Stormwind99,项目名称:OSVR-Unreal,代码行数:12,代码来源:OSVRHMD.cpp

示例13: RelativeTick

void ACinemotusPlayerController::RelativeTick(float DeltaTime)
{

	UPrimitiveComponent* prim = GetPawn()->GetMovementComponent()->UpdatedComponent;
	bool SetPrimDirectly = true;
	FQuat finalQuat;
	if ((currentCaptureState & ECinemotusCaptureState::ERelativeRotation) == ECinemotusCaptureState::ERelativeRotation)
	{
		FRotator rot = HydraLatestData->controllers[CAM_HAND].angular_velocity;
		const FQuat OldRotation = prim->GetComponentQuat();//GetControlRotation().Quaternion(); //TODO: hold onto a quaternion potentially
		const FRotator OldRotationRotator = OldRotation.Rotator();
		FRotator worldRotator = FRotator(0, DeadZone(rot.Yaw*DeltaTime, 0.0) + addYaw, 0);
		FRotator worldRotator1 = FRotator(DeadZone(rot.Pitch*DeltaTime, 0.0), 0, 0);
		FRotator localRotator = FRotator(0, 0, DeadZone(rot.Roll*DeltaTime, 0.0));
		const FQuat WorldRot = worldRotator.Quaternion();
		const FQuat pitchRot = worldRotator1.Quaternion();
		const FQuat LocalRot = localRotator.Quaternion();

		////This one does roll around local forward, pitch around world right flattened and yaw around world up
		////			FQuat finalQuat = pitchRot*WorldRot*((OldRotation*LocalRot));

		finalQuat = WorldRot*((OldRotation*LocalRot)*pitchRot);
	}
	else
	{
		finalQuat = FRotator(0, addYaw, 0).Quaternion()*prim->GetComponentQuat();
	}

	SetControlRotation(finalQuat.Rotator());
	if (SetPrimDirectly && prim)
	{
		prim->SetWorldLocationAndRotation(prim->GetComponentLocation(), finalQuat);// not sure need
	}



	HandleMovementAbs(DeltaTime, (currentCaptureState & ECinemotusCaptureState::ERelativeTranslation) == ECinemotusCaptureState::ERelativeTranslation);

}
开发者ID:erinmichno,项目名称:CinemotusUE4,代码行数:39,代码来源:CinemotusPlayerController.cpp

示例14: UpdateBones

void ALeapMotionHandActor::UpdateBones(float DeltaSeconds)
{
	if (BoneActors.Num() == 0) { return; }

	float CombinedScale = GetCombinedScale();

	FLeapMotionDevice* Device = FLeapMotionControllerPlugin::GetLeapDeviceSafe();
	if (Device && Device->IsConnected())
	{
		int BoneArrayIndex = 0;
		for (ELeapBone LeapBone = bShowArm ? ELeapBone::Forearm : ELeapBone::Palm; LeapBone <= ELeapBone::Finger4Tip; ((int8&)LeapBone)++)
		{
			FVector TargetPosition;
			FRotator TargetOrientation;

			bool Success = Device->GetBonePostionAndOrientation(HandId, LeapBone, TargetPosition, TargetOrientation);

			if (Success)
			{
				// Offset target position & rotation by the SpawnReference actor's transform
				FQuat RefQuat = GetRootComponent()->GetComponentRotation().Quaternion();
				TargetPosition = RefQuat * TargetPosition * CombinedScale + GetRootComponent()->GetComponentLocation();
				TargetOrientation = (RefQuat * TargetOrientation.Quaternion()).Rotator();

				// Get current position & rotation
				ALeapMotionBoneActor* BoneActor = BoneActors[BoneArrayIndex++];

				UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(BoneActor->GetRootComponent());
				if (PrimitiveComponent && PrimitiveComponent->IsSimulatingPhysics())
				{
					FVector CurrentPositon = PrimitiveComponent->GetComponentLocation();
					FRotator CurrentRotation = PrimitiveComponent->GetComponentRotation();

					// Compute linear velocity
					FVector LinearVelocity = (TargetPosition - CurrentPositon) / DeltaSeconds;

					// Compute angular velocity
					FVector Axis;
					float Angle;
					ConvertDeltaRotationsToAxisAngle(CurrentRotation, TargetOrientation, Axis, Angle);
					if (Angle > PI) { Angle -= 2 * PI; }
					FVector AngularVelcity = Axis * (Angle / DeltaSeconds);

					// Apply velocities
					PrimitiveComponent->SetPhysicsLinearVelocity(LinearVelocity);
					PrimitiveComponent->SetAllPhysicsAngularVelocity(AngularVelcity * 180.0f / PI);
				}
			}
		}
	}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:51,代码来源:LeapMotionHandActor.cpp

示例15: Tick

// Called every frame
void ACPP_VRPawn::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	FRotator FinalRotation; //final rotation for object
	FRotator LHandRotation;	//left hand rotation
	FRotator RHandRotation;	//right hand rotation
	FQuat DiffQuat;	//difference in rotation between initial and current

	//set left item rotation if grabbing
	if (bLIsGrabbing)
	{
		LHandRotation = LeftHand->GetComponentRotation();

		//calculate difference in rotation
		DiffQuat = LHandRotation.Quaternion() * LInitialHandRotation.GetInverse().Quaternion();

		//rotate initial rotation by our difference
		FinalRotation = (DiffQuat * LInitialItemRotation.Quaternion()).Rotator();

		LPhysHandle->SetTargetLocationAndRotation(LeftHand->GetComponentLocation(), FinalRotation);
	}

	//set right item rotation if grabbing something
	if (bRIsGrabbing)
	{
		RHandRotation = RightHand->GetComponentRotation();

		DiffQuat = RHandRotation.Quaternion() * RInitialHandRotation.GetInverse().Quaternion();

		FinalRotation = (DiffQuat * RInitialItemRotation.Quaternion()).Rotator();

		RPhysHandle->SetTargetLocationAndRotation(RightHand->GetComponentLocation(), FinalRotation);
	}

}
开发者ID:Znny,项目名称:VRTemplate,代码行数:37,代码来源:CPP_VRPawn.cpp


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