本文整理汇总了C++中FVector::InitFromString方法的典型用法代码示例。如果您正苦于以下问题:C++ FVector::InitFromString方法的具体用法?C++ FVector::InitFromString怎么用?C++ FVector::InitFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FVector
的用法示例。
在下文中一共展示了FVector::InitFromString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseConfig
bool VRPNTrackerInputDevice::ParseConfig(FConfigSection *InConfigSection) {
const FString* RotationOffsetString = InConfigSection->Find(FName(TEXT("RotationOffset")));
FVector RotationOffsetVector;
float RotationOffsetAngleDegrees;
if(RotationOffsetString == nullptr || !RotationOffsetVector.InitFromString(*RotationOffsetString) || !FParse::Value(*(*RotationOffsetString), TEXT("Angle="), RotationOffsetAngleDegrees))
{
UE_LOG(LogVRPNInputDevice, Log, TEXT("Expected RotationOffsetAxis of type FVector and RotationOffsetAnlge of type Float when parsing tracker device. Rotation offset will be the indenty transform."));
RotationOffset = FQuat::Identity;
} else
{
RotationOffsetVector.Normalize();
RotationOffset = FQuat(RotationOffsetVector, FMath::DegreesToRadians(RotationOffsetAngleDegrees));
RotationOffset.Normalize();
}
const FString* PositioOffsetString = InConfigSection->Find(FName(TEXT("PositionOffset")));
if(PositioOffsetString == nullptr || !TranslationOffset.InitFromString(*PositioOffsetString))
{
UE_LOG(LogVRPNInputDevice, Log, TEXT("Expected PositionOffset of type FVector (in device coordinates). Will use default of (0,0,0)."));
TranslationOffset.Set(0, 0, 0);
}
FString *TrackerUnitsToUE4UnitsText = InConfigSection->Find(FName(TEXT("TrackerUnitsToUE4Units")));
if(TrackerUnitsToUE4UnitsText == nullptr)
{
UE_LOG(LogVRPNInputDevice, Warning, TEXT("Expected to find TrackerUnitsToUE4UnitsText of type Float. Using default of 1.0f"));
TrackerUnitsToUE4Units = 1.0f;
} else
{
TrackerUnitsToUE4Units = FCString::Atof(*(*TrackerUnitsToUE4UnitsText));
}
FString *FlipZAxisText = InConfigSection->Find(FName(TEXT("FlipZAxis")));
if(FlipZAxisText == nullptr)
{
UE_LOG(LogVRPNInputDevice, Warning, TEXT("Expected to find FlipZAxis of type Boolean. Using default of false."));
FlipZAxis = false;
} else
{
FlipZAxis = FCString::ToBool(*(*FlipZAxisText));
}
TArray<const FString*> Trackers;
InConfigSection->MultiFindPointer(FName(TEXT("Tracker")), Trackers);
if(Trackers.Num() == 0)
{
UE_LOG(LogVRPNInputDevice, Warning, TEXT("Config file for tracker device has no tracker mappings specified. Expeted field Tracker."));
return false;
}
bool bHasMotionControllers = false;
for(const FString* TrackerString: Trackers)
{
int32 TrackerId;
FString TrackerName;
FString TrackerDescription;
if(!FParse::Value(*(*TrackerString), TEXT("Id="), TrackerId) ||
!FParse::Value(*(*TrackerString), TEXT("Name="), TrackerName) ||
!FParse::Value(*(*TrackerString), TEXT("Description="), TrackerDescription))
{
UE_LOG(LogVRPNInputDevice, Warning, TEXT("Config not parse tracker. Expected: Tracker = (Id=#,Name=String,Description=String)."));
continue;
}
// see if this is a motion controller
int PlayerId = -1;
FParse::Value(*(*TrackerString), TEXT("PlayerId="), PlayerId);
EControllerHand Hand = EControllerHand::Left;
if(PlayerId >= 0)
{
UE_LOG(LogVRPNInputDevice, Log, TEXT("Found motion controller."));
bHasMotionControllers = true;
FString HandString;
if(FParse::Value(*(*TrackerString), TEXT("Hand="), HandString))
{
if(HandString.Equals("Right"))
{
Hand = EControllerHand::Right;
}
}
}
UE_LOG(LogVRPNInputDevice, Log, TEXT("Adding new tracker: [%i,%s,%s,%i]."), TrackerId, *TrackerName, *TrackerDescription, PlayerId);
const TrackerInput &Input = TrackerMap.Add(TrackerId, {FKey(*(TrackerName + "MotionX")), FKey(*(TrackerName + "MotionY")), FKey(*(TrackerName + "MotionZ")),
FKey(*(TrackerName + "RotationYaw")), FKey(*(TrackerName + "RotationPitch")), FKey(*(TrackerName + "RotationRoll")),
FVector(0), FQuat(EForceInit::ForceInit), PlayerId, Hand,false});
// Translation
EKeys::AddKey(FKeyDetails(Input.MotionXKey, FText::FromString(TrackerName + " X position"), FKeyDetails::FloatAxis));
EKeys::AddKey(FKeyDetails(Input.MotionYKey, FText::FromString(TrackerName + " Y position"), FKeyDetails::FloatAxis));
EKeys::AddKey(FKeyDetails(Input.MotionZKey, FText::FromString(TrackerName + " Z position"), FKeyDetails::FloatAxis));
// Rotation
EKeys::AddKey(FKeyDetails(Input.RotationYawKey, FText::FromString(TrackerName + " Yaw"), FKeyDetails::FloatAxis));
EKeys::AddKey(FKeyDetails(Input.RotationPitchKey, FText::FromString(TrackerName + " Pitch"), FKeyDetails::FloatAxis));
EKeys::AddKey(FKeyDetails(Input.RotationRollKey, FText::FromString(TrackerName + " Roll"), FKeyDetails::FloatAxis));
//.........这里部分代码省略.........