本文整理汇总了C++中UPrimitiveComponent::SetAllPhysicsAngularVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ UPrimitiveComponent::SetAllPhysicsAngularVelocity方法的具体用法?C++ UPrimitiveComponent::SetAllPhysicsAngularVelocity怎么用?C++ UPrimitiveComponent::SetAllPhysicsAngularVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UPrimitiveComponent
的用法示例。
在下文中一共展示了UPrimitiveComponent::SetAllPhysicsAngularVelocity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
}
}