本文整理汇总了C++中FVector::HeadingAngle方法的典型用法代码示例。如果您正苦于以下问题:C++ FVector::HeadingAngle方法的具体用法?C++ FVector::HeadingAngle怎么用?C++ FVector::HeadingAngle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FVector
的用法示例。
在下文中一共展示了FVector::HeadingAngle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRadianHeading
float AMinimapActor::GetRadianHeading() const
{
FVector vec;
FRotator rot;
float radians;
//only need a vector with this actor's
rot.Yaw = GetActorRotation().Yaw;
vec = rot.Vector();
radians = vec.HeadingAngle();
radians = FMath::UnwindRadians(radians);
while (radians < 0.f)
radians += PI * 2.0f;
return radians;
}
示例2: GetUnitHeading
float APlayerHUD::GetUnitHeading(AGameCharacter* unit) const
{
if (!IsValid(unit))
return -1.f;
FVector vec;
FRotator rot;
float radians;
//only need a vector with this actor's
rot.Yaw = unit->GetActorRotation().Yaw;
vec = rot.Vector();
radians = vec.HeadingAngle();
radians = FMath::UnwindRadians(radians);
while (radians < 0.f)
radians += PI * 2.0f;
return radians;
}
示例3: GetAvoidanceVelocity_Internal
//.........这里部分代码省略.........
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (DebugMode)
{
// DrawDebugDirectionalArrow(MyWorld, EffectiveVelocityB + PointAWorld, PointPlane[0] + PointAWorld, 50.0f, FColor(64,64,64), true, 0.05f, SDPG_MAX);
// DrawDebugLine(MyWorld, PointAWorld, EffectiveVelocityB + PointAWorld, FColor(64,64,64), true, 0.05f, SDPG_MAX, 5.0f);
}
#endif
//Make the right plane
PointPlane[0] = EffectiveVelocityB + (PointBRelative - (SidewaysFromB * RadiusB));
PointPlane[1].Set(PointPlane[0].X, PointPlane[0].Y, PointPlane[0].Z - 100.0f);
NewCone.ConePlane[1] = FPlane(EffectiveVelocityB, PointPlane[0], PointPlane[1]); //First point is relative to A, which is ZeroVector in this implementation
checkSlow((((PointBRelative+EffectiveVelocityB)|NewCone.ConePlane[1]) - NewCone.ConePlane[1].W) > 0.0f);
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (DebugMode)
{
// DrawDebugDirectionalArrow(MyWorld, EffectiveVelocityB + PointAWorld, PointPlane[0] + PointAWorld, 50.0f, FColor(64,64,64), true, 0.05f, SDPG_MAX);
}
#endif
if ((((ReturnVelocity|NewCone.ConePlane[0]) - NewCone.ConePlane[0].W) > 0.0f)
&& (((ReturnVelocity|NewCone.ConePlane[1]) - NewCone.ConePlane[1].W) > 0.0f))
{
Unobstructed = false;
}
AllCones.Add(NewCone);
}
}
}
if (Unobstructed)
{
//Trivial case, our ideal velocity is available.
return inAvoidanceData.Velocity;
}
TArray<FNavEdgeSegment> NavEdges;
if (EdgeProviderOb.IsValid())
{
DECLARE_SCOPE_CYCLE_COUNTER(TEXT("Avoidance: collect nav edges"), STAT_AIAvoidanceEdgeCollect, STATGROUP_AI);
EdgeProviderInterface->GetEdges(inAvoidanceData.Center, inAvoidanceData.TestRadius2D, NavEdges);
}
//Find a good velocity that isn't inside a cone.
if (AllCones.Num())
{
float AngleCurrent;
float AngleF = ReturnVelocity.HeadingAngle();
float BestScore = 0.0f;
float BestScorePotential;
FVector BestVelocity = FVector::ZeroVector; //Worst case is we just stand completely still. Should we also allow backing up? Should we test standing still?
const int AngleCount = 4; //Every angle will be tested both right and left.
float AngleOffset[AngleCount] = {FMath::DegreesToRadians<float>(23.0f), FMath::DegreesToRadians<float>(40.0f), FMath::DegreesToRadians<float>(55.0f), FMath::DegreesToRadians<float>(85.0f)};
FVector AngleVector[AngleCount<<1];
//Determine check angles
for (int i = 0; i < AngleCount; ++i)
{
AngleCurrent = AngleF - AngleOffset[i];
AngleVector[(i<<1)].Set(FMath::Cos(AngleCurrent), FMath::Sin(AngleCurrent), 0.0f);
AngleCurrent = AngleF + AngleOffset[i];
AngleVector[(i<<1) + 1].Set(FMath::Cos(AngleCurrent), FMath::Sin(AngleCurrent), 0.0f);
}
//Sample velocity-space destination points and drag them back to form lines
for (int AngleToCheck = 0; AngleToCheck < (AngleCount<<1); ++AngleToCheck)
{
FVector VelSpacePoint = AngleVector[AngleToCheck] * MaxSpeed;
//Skip testing if we know we can't possibly get a better score than what we have already.
//Note: This assumes the furthest point is the highest-scoring value (i.e. VelSpacePoint is not moving backward relative to ReturnVelocity)
BestScorePotential = (VelSpacePoint|ReturnVelocity) * (VelSpacePoint|VelSpacePoint);
if (BestScorePotential > BestScore)
{
const bool bAvoidsNavEdges = NavEdges.Num() > 0 ? AvoidsNavEdges(inAvoidanceData.Center, VelSpacePoint, NavEdges, inAvoidanceData.HalfHeight) : true;
if (bAvoidsNavEdges)
{
FVector CandidateVelocity = AvoidCones(AllCones, FVector::ZeroVector, VelSpacePoint, AllCones.Num());
float CandidateScore = (CandidateVelocity|ReturnVelocity) * (CandidateVelocity|CandidateVelocity);
//Vectors are rated by their length and their overall forward movement.
if (CandidateScore > BestScore)
{
BestScore = CandidateScore;
BestVelocity = CandidateVelocity;
}
}
}
}
ReturnVelocity = BestVelocity;
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (DebugMode)
{
DrawDebugDirectionalArrow(MyWorld, inAvoidanceData.Center + inAvoidanceData.Velocity, inAvoidanceData.Center + (ReturnVelocity / DeltaTime), 75.0f, FColor(64,255,64), true, 2.0f, SDPG_MAX);
}
#endif
}
return ReturnVelocity / DeltaTime; //Remove prediction-time scaling
}