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


C++ FVector::InitFromString方法代码示例

本文整理汇总了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));
//.........这里部分代码省略.........
开发者ID:flair2005,项目名称:VRPNInput,代码行数:101,代码来源:VRPNInputDevice.cpp


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