本文整理汇总了C++中UPrimitiveComponent::GetComponentTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ UPrimitiveComponent::GetComponentTransform方法的具体用法?C++ UPrimitiveComponent::GetComponentTransform怎么用?C++ UPrimitiveComponent::GetComponentTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UPrimitiveComponent
的用法示例。
在下文中一共展示了UPrimitiveComponent::GetComponentTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TickComponent
//.........这里部分代码省略.........
//BasePrimComp->AddForceAtLocation(FVector(DampingForce.X, DampingForce.Y, DampingForce.Z + BuoyancyForceZ), worldBoneLoc, BoneNames[Itr]);
}
//Apply fluid damping & clamp velocity
if (isUnderwater)
{
BI->SetLinearVelocity(-BI->GetUnrealWorldVelocity() * (FluidLinearDamping / 10), true);
BI->SetAngularVelocity(-BI->GetUnrealWorldAngularVelocity() * (FluidAngularDamping / 10), true);
//Clamp the velocity to MaxUnderwaterVelocity
if (ClampMaxVelocity && BI->GetUnrealWorldVelocity().Size() > MaxUnderwaterVelocity)
{
FVector Velocity = BI->GetUnrealWorldVelocity().GetSafeNormal() * MaxUnderwaterVelocity;
BI->SetLinearVelocity(Velocity, false);
}
}
if (DrawDebugPoints)
{
FColor DebugColor = FLinearColor(0.8, 0.7, 0.2, 0.8).ToRGBE();
if (isUnderwater) { DebugColor = FLinearColor(0, 0.2, 0.7, 0.8).ToRGBE(); } //Blue color underwater, yellow out of watter
DrawDebugSphere(World, worldBoneLoc, BoneTestRadius, 8, DebugColor);
}
}
}
return;
}
//--------------------------------------------------------
float TotalPoints = TestPoints.Num();
if (TotalPoints < 1) return;
int PointsUnderWater = 0;
for (int pointIndex = 0; pointIndex < TotalPoints; pointIndex++)
{
if (!TestPoints.IsValidIndex(pointIndex)) return; //Array size changed during runtime
bool isUnderwater = false;
FVector testPoint = TestPoints[pointIndex];
FVector worldTestPoint = BasePrimComp->GetComponentTransform().TransformPosition(testPoint);
FVector waveHeight = OceanManager->GetWaveHeightValue(worldTestPoint, World, !EnableWaveForces, TwoGerstnerIterations);
//Direction of radius (test radius is actually a Z offset, should probably rename it!). Just in case we need an upside down world.
float SignedRadius = FMath::Sign(BasePrimComp->GetPhysicsVolume()->GetGravityZ()) * TestPointRadius;
//If test point radius is below water surface, add buoyancy force.
if (waveHeight.Z > (worldTestPoint.Z + SignedRadius)
&& BasePrimComp->IsGravityEnabled()) //Buoyancy doesn't exist without gravity
{
PointsUnderWater++;
isUnderwater = true;
float DepthMultiplier = (waveHeight.Z - (worldTestPoint.Z + SignedRadius)) / (TestPointRadius * 2);
DepthMultiplier = FMath::Clamp(DepthMultiplier, 0.f, 1.f);
//If we have a point density override, use the overridden value instead of MeshDensity
float PointDensity = PointDensityOverride.IsValidIndex(pointIndex) ? PointDensityOverride[pointIndex] : MeshDensity;
/**
* --------
* Buoyancy force formula: (Volume(Mass / Density) * Fluid Density * -Gravity) / Total Points * Depth Multiplier
* --------
*/
float BuoyancyForceZ = BasePrimComp->GetMass() / PointDensity * FluidDensity * -Gravity / TotalPoints * DepthMultiplier;
//Experimental velocity damping using VelocityAtPoint.
FVector DampingForce = -GetUnrealVelocityAtPoint(BasePrimComp, worldTestPoint) * VelocityDamper * BasePrimComp->GetMass() * DepthMultiplier;
//Experimental xy wave force
if (EnableWaveForces)
{
DampingForce += BasePrimComp->GetMass() * FVector2D(waveHeight.X, waveHeight.Y).Size() * FVector(OceanManager->GlobalWaveDirection.X, OceanManager->GlobalWaveDirection.Y, 0) * WaveForceMultiplier / TotalPoints;
//float waveVelocity = FMath::Clamp(GetUnrealVelocityAtPoint(BasePrimComp, worldTestPoint).Z, -20.f, 150.f) * (1 - DepthMultiplier);
//DampingForce += OceanManager->GlobalWaveDirection * BasePrimComp->GetMass() * waveVelocity * WaveForceMultiplier / TotalPoints;
}
//Add force for this test point
BasePrimComp->AddForceAtLocation(FVector(DampingForce.X, DampingForce.Y, DampingForce.Z + BuoyancyForceZ), worldTestPoint);
}
if (DrawDebugPoints)
{
FColor DebugColor = FLinearColor(0.8, 0.7, 0.2, 0.8).ToRGBE();
if (isUnderwater) { DebugColor = FLinearColor(0, 0.2, 0.7, 0.8).ToRGBE(); } //Blue color underwater, yellow out of watter
DrawDebugSphere(World, worldTestPoint, TestPointRadius, 8, DebugColor);
}
}
//Clamp the velocity to MaxUnderwaterVelocity if there is any point underwater
if (ClampMaxVelocity && PointsUnderWater > 0
&& BasePrimComp->GetPhysicsLinearVelocity().Size() > MaxUnderwaterVelocity)
{
FVector Velocity = BasePrimComp->GetPhysicsLinearVelocity().GetSafeNormal() * MaxUnderwaterVelocity;
BasePrimComp->SetPhysicsLinearVelocity(Velocity);
}
//Update damping based on number of underwater test points
BasePrimComp->SetLinearDamping(_baseLinearDamping + FluidLinearDamping / TotalPoints * PointsUnderWater);
BasePrimComp->SetAngularDamping(_baseAngularDamping + FluidAngularDamping / TotalPoints * PointsUnderWater);
}