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


C++ UGameViewportClient::GetViewportSize方法代码示例

本文整理汇总了C++中UGameViewportClient::GetViewportSize方法的典型用法代码示例。如果您正苦于以下问题:C++ UGameViewportClient::GetViewportSize方法的具体用法?C++ UGameViewportClient::GetViewportSize怎么用?C++ UGameViewportClient::GetViewportSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UGameViewportClient的用法示例。


在下文中一共展示了UGameViewportClient::GetViewportSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TouchUpdate

void AMobileOpenCVCharacter::TouchUpdate(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	if ((TouchItem.bIsPressed == true) && ( TouchItem.FingerIndex==FingerIndex))
	{
		if (TouchItem.bIsPressed)
		{
			if (GetWorld() != nullptr)
			{
				UGameViewportClient* ViewportClient = GetWorld()->GetGameViewport();
				if (ViewportClient != nullptr)
				{
					FVector MoveDelta = Location - TouchItem.Location;
					FVector2D ScreenSize;
					ViewportClient->GetViewportSize(ScreenSize);
					FVector2D ScaledDelta = FVector2D( MoveDelta.X, MoveDelta.Y) / ScreenSize;									
					if (ScaledDelta.X != 0.0f)
					{
						TouchItem.bMoved = true;
						float Value = ScaledDelta.X * BaseTurnRate;
						AddControllerYawInput(Value);
					}
					if (ScaledDelta.Y != 0.0f)
					{
						TouchItem.bMoved = true;
						float Value = ScaledDelta.Y* BaseTurnRate;
						AddControllerPitchInput(Value);
					}
					TouchItem.Location = Location;
				}
				TouchItem.Location = Location;
			}
		}
	}
}
开发者ID:brucelane,项目名称:UEMobileOpenCV,代码行数:34,代码来源:MobileOpenCVCharacter.cpp

示例2: TouchUpdate

void AFP_FirstPersonCharacter::TouchUpdate(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	// If we are processing a touch event and this index matches the initial touch event process movement
	if ((TouchItem.bIsPressed == true) && (TouchItem.FingerIndex == FingerIndex))
	{
		if (GetWorld() != nullptr)
		{
			UGameViewportClient* ViewportClient = GetWorld()->GetGameViewport();
			if (ViewportClient != nullptr)
			{
				FVector MoveDelta = Location - TouchItem.Location;
				FVector2D ScreenSize;
				ViewportClient->GetViewportSize(ScreenSize);
				FVector2D ScaledDelta = FVector2D(MoveDelta.X, MoveDelta.Y) / ScreenSize;
				if (ScaledDelta.X != 0.0f)
				{
					TouchItem.bMoved = true;
					float Value = ScaledDelta.X * BaseTurnRate;
					AddControllerYawInput(Value);
				}
				if (ScaledDelta.Y != 0.0f)
				{
					TouchItem.bMoved = true;
					float Value = ScaledDelta.Y* BaseTurnRate;
					AddControllerPitchInput(Value);
				}
				TouchItem.Location = Location;
			}
			TouchItem.Location = Location;
		}
	}
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:32,代码来源:FP_FirstPersonCharacter.cpp

示例3: TouchUpdate

/*
* Putting my own functionality in the TouchUpdate; this way we can swipe up/down/left/right from the center
* of the screen and move the character in that direction.
*/
void ASterlingResortsCharacter::TouchUpdate(const ETouchIndex::Type FingerIndex, const FVector Location)
{
    if ((TouchItem.bIsPressed == true) && (TouchItem.FingerIndex == FingerIndex))
    {
        if (TouchItem.bIsPressed)
        {
            if (GetWorld() != nullptr)
            {
                UGameViewportClient* ViewportClient = GetWorld()->GetGameViewport();
                if (ViewportClient != nullptr)
                {
                    FVector2D ScreenSize;
                    ViewportClient->GetViewportSize(ScreenSize);
                    FVector2D ScreenCenter = ScreenSize / 2.0f;

                    FVector MoveDelta = Location - TouchItem.Location;
                    FVector2D ScaledDelta = FVector2D(MoveDelta.X, MoveDelta.Y) / ScreenSize;
                    //FVector2D ScaledDelta = FVector2D(MoveDelta.X - ScreenCenter.X, MoveDelta.Y - ScreenCenter.Y) / ScreenCenter;
                    if (ScaledDelta.X != 0.0f)
                    {
                        TouchItem.bMoved = true;
                        MoveRight(ScaledDelta.X * BaseTurnRate * -1.0f);
                    }
                    if (ScaledDelta.Y != 0.0f)
                    {
                        TouchItem.bMoved = true;
                        MoveForward(ScaledDelta.Y * BaseTurnRate * -1.0f);
                    }
                }
            }
        }
    }
}
开发者ID:mukund-dh,项目名称:SterlingResorts,代码行数:37,代码来源:SterlingResortsCharacter.cpp

示例4: Tick

void AECommanderPawn::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	// Get the game viewport and make sure it exists as there is no
	// guarantee that it does.
	UGameViewportClient* GameViewport = GEngine->GameViewport;
	if (!GameViewport)
	{
		return;
	}

	// Get the position of the mouse on the screen.
	FVector2D MousePosition;
	GameViewport->GetMousePosition(MousePosition);

	// Get the size of the screen.
	FVector2D ViewportSize;
	GameViewport->GetViewportSize(ViewportSize);

	// Make sure the game view port has focus (contains the mouse).
	if (!GameViewport->IsFocused(GameViewport->Viewport))
	{
		return;
	}

	// Check if the mouse is at the left or right side of the
	// screen and move accordingly.
	if (MousePosition.X < CameraScrollBoundary)
	{
	}
	else if ((ViewportSize.X - MousePosition.X) < CameraScrollBoundary)
	{
	}

	// Check if the mouse is at the top or bottom of the screen
	// and move accordingly.
	if (MousePosition.Y < CameraScrollBoundary)
	{
	}
	else if ((ViewportSize.Y - MousePosition.Y) < CameraScrollBoundary)
	{
	}
}
开发者ID:TheCreeper,项目名称:Empires2,代码行数:44,代码来源:ECommanderPawn.cpp

示例5: Tick

void AMainCameraSpecPawn::Tick(float DeltaSeconds) {
	Super::Tick(DeltaSeconds);

	FVector2D MousePosition;
	FVector2D ViewportSize;

	UGameViewportClient* GameViewport = GEngine->GameViewport;

	check(GameViewport);
	GameViewport->GetViewportSize(ViewportSize);

	// Check if input is detectable
	if (GameViewport->IsFocused(GameViewport->Viewport) &&
		GameViewport->GetMousePosition(MousePosition) &&
		bCanMoveCamera) {

		// Edge of screen movement
		if (MousePosition.X < CameraScrollBounds) {
			YMovement = -1.0f;
		} else if (ViewportSize.X - MousePosition.X < CameraScrollBounds) {
			YMovement = 1.0f;
		}

		if (MousePosition.Y < CameraScrollBounds) {
			XMovement = 1.0f;
		}
		else if (ViewportSize.Y - MousePosition.Y < CameraScrollBounds) {
			XMovement = -1.0f;
		}

		// movement
		MoveCameraForward(XMovement * FastMoveMultiplier * DeltaSeconds);
		MoveCameraRight(YMovement * FastMoveMultiplier * DeltaSeconds);

	}
	
}
开发者ID:TravisTheProgrammer,项目名称:MetalHeads,代码行数:37,代码来源:MainCameraSpecPawn.cpp


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