• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ UGameViewportClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetWorld

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: OnSlateWindowRenderedDuringBroadcasting

void FGameLiveStreaming::OnSlateWindowRenderedDuringBroadcasting( SWindow& SlateWindow, void* ViewportRHIPtr )
{
	// If we're streaming live video/audio, we'll go ahead and push new video frames here
	UGameViewportClient* GameViewportClient = GEngine->GameViewport;
	if( IsBroadcastingGame() && GameViewportClient != nullptr )
	{
		// We only care about our own Slate window
		if( GameViewportClient->GetWindow() == SlateWindow.AsShared() )
		{
			// Check to see if we're streaming live video.  If so, we'll want to push new frames to be broadcast.
			if( LiveStreamer->IsReadyForVideoFrames() )
			{
				// Check to see if there are any video frames ready to push
				BroadcastGameVideoFrame();

				// Start copying next game video frame
				const FViewportRHIRef* ViewportRHI = ( const FViewportRHIRef* )ViewportRHIPtr;
				StartCopyingNextGameVideoFrame( *ViewportRHI );
			}
		}
	}
	else
	{
		// No longer broadcasting.  The live streaming service may have been interrupted.
		StopBroadcastingGame();
	}
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:27,代码来源:GameLiveStreaming.cpp


示例3: GetWorld

/*
* 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: GetWorld

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


示例5: PostInitializeComponents

void ATutorialGameHUD::PostInitializeComponents()
{
    Super::PostInitializeComponents();

    if (GEngine && GEngine->GameViewport)
    {
        UGameViewportClient* Viewport = GEngine->GameViewport;

        SAssignNew(GameHUD, STutorialGameHUDUI)
        .OwnerHUD(TWeakObjectPtr<ATutorialGameHUD>(this));

        Viewport->AddViewportWidgetContent(
            SNew(SWeakWidget).PossiblyNullContent(GameHUD.ToSharedRef())
        );
    }
}
开发者ID:henrya2,项目名称:SlateTutorials,代码行数:16,代码来源:TutorialGameHUD.cpp


示例6: SetMouseLockedToViewport

void ULucyFunctions::SetMouseLockedToViewport(const bool Locked)
{
	if (GEngine == nullptr)
	{
		return;
	}

	UGameViewportClient* ViewportClient = GEngine->GameViewport;
	if (ViewportClient == nullptr)
	{
		return;
	}

	TSharedPtr<SViewport> ViewportWidget = ViewportClient->GetGameViewportWidget();
	if (!ViewportWidget.IsValid())
	{
		return;
	}

	TArray<APlayerController*> LocalPlayerControllers;
	GEngine->GetAllLocalPlayerControllers(LocalPlayerControllers);

	for (APlayerController* LocalPlayerController : LocalPlayerControllers)
	{
		if (LocalPlayerController == nullptr)
		{
			continue;
		}

		ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(LocalPlayerController->Player);
		if (LocalPlayer == nullptr)
		{
			continue;
		}

		if (Locked)
		{
			LocalPlayer->GetSlateOperations().LockMouseToWidget(ViewportWidget.ToSharedRef());
		}
		else
		{
			LocalPlayer->GetSlateOperations().ReleaseMouseLock();
		}
	}
}
开发者ID:kjustynski,项目名称:Lucy,代码行数:45,代码来源:LucyFunctions.cpp


示例7: 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


示例8: OnSlateWindowRenderedDuringCapture

void FWebMRecord::OnSlateWindowRenderedDuringCapture(SWindow& SlateWindow, void* ViewportRHIPtr)
{
	// Probably need to verify that this is the window we want, but not sure yet

	UGameViewportClient* GameViewportClient = GEngine->GameViewport;
	if (bRecording && GameViewportClient != nullptr)
	{
		if (GameViewportClient->GetWindow() == SlateWindow.AsShared())
		{
			if (VideoDeltaTimeAccum >= VideoFrameDelay)
			{
				//UE_LOG(LogUTWebM, Log, TEXT("Saving video frame %f"), VideoDeltaTimeAccum);

				SaveCurrentFrameToDisk();

				const FViewportRHIRef* ViewportRHI = (const FViewportRHIRef*)ViewportRHIPtr;
				StartCopyingNextGameFrame(*ViewportRHI);
			}
		}
	}
}
开发者ID:knepleyp,项目名称:UTWebMRecord,代码行数:21,代码来源:WebMRecord.cpp


示例9: 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


示例10: UE_LOG

int32 UUnitTestCommandlet::Main(const FString& Params)
{
	// @todo #JohnBLowPri: Fix StandaloneRenderer support for static builds
#if IS_MONOLITHIC
	UE_LOG(LogUnitTest, Log, TEXT("NetcodeUnitTest commandlet not currently supported in static/monolithic builds"));

#else
	GIsRequestingExit = false;

	// @todo #JohnBLowPri: Steam detection doesn't seem to work this early on, but does work further down the line;
	//				try to find a way, to detect it as early as possible

	// NetcodeUnitTest is not compatible with Steam; if Steam is running/detected, abort immediately
	// @todo #JohnBLowPri: Add support for Steam
	if (NUTNet::IsSteamNetDriverAvailable())
	{
		UE_LOG(LogUnitTest, Log, TEXT("NetcodeUnitTest does not currently support Steam. Close Steam before running."));
		GIsRequestingExit = true;
	}

	if (!GIsRequestingExit)
	{
		GIsRunning = true;

		// Hack-set the engine GameViewport, so that setting GIsClient, doesn't cause an auto-exit
		// @todo JohnB: If you later remove the GIsClient setting code below, remove this as well
		if (GEngine->GameViewport == NULL)
		{
			UGameEngine* GameEngine = Cast<UGameEngine>(GEngine);

			// GameInstace = GameEngine->GameInstance;
			UGameInstance* GameInstance = GET_PRIVATE(UGameEngine, GameEngine, GameInstance);

			if (GameEngine != NULL)
			{
				UGameViewportClient* NewViewport = NewObject<UGameViewportClient>(GameEngine);
				FWorldContext* CurContext = GameInstance->GetWorldContext();

				GameEngine->GameViewport = NewViewport;
				NewViewport->Init(*CurContext, GameInstance);

				// Set the internal FViewport, for the new game viewport, to avoid another bit of auto-exit code
				NewViewport->Viewport = new FDummyViewport(NewViewport);

				// Set the main engine world context game viewport, to match the newly created viewport, in order to prevent crashes
				CurContext->GameViewport = NewViewport;
			}
		}


		// Now, after init stages are done, enable GIsClient for netcode and such
		GIsClient = true;


		// Before running any unit tests, create a world object, which will contain the unit tests manager etc.
		//	(otherwise, when the last unit test world is cleaned up, the unit test manager stops functioning)
		UWorld* UnitTestWorld = NUTNet::CreateUnitTestWorld(false);


		const TCHAR* ParamsRef = *Params;
		FString UnitTestParam = TEXT("");
		FString UnitCmd = TEXT("UnitTest ");


		if (FParse::Value(ParamsRef, TEXT("UnitTest="), UnitTestParam))
		{
			UnitCmd += UnitTestParam;
		}
		else
		{
			UnitCmd += TEXT("all");
		}

		GEngine->Exec(UnitTestWorld, *UnitCmd);


		// NOTE: This main loop is partly based off of FileServerCommandlet
		while (GIsRunning && !GIsRequestingExit)
		{
			GEngine->UpdateTimeAndHandleMaxTickRate();
			GEngine->Tick(FApp::GetDeltaTime(), false);

			if (FSlateApplication::IsInitialized())
			{
				FSlateApplication::Get().PumpMessages();
				FSlateApplication::Get().Tick();
			}


			// Execute deferred commands
			for (int32 DeferredCommandsIndex=0; DeferredCommandsIndex<GEngine->DeferredCommands.Num(); DeferredCommandsIndex++)
			{
				GEngine->Exec(UnitTestWorld, *GEngine->DeferredCommands[DeferredCommandsIndex], *GLog);
			}

			GEngine->DeferredCommands.Empty();


			FPlatformProcess::Sleep(0);

//.........这里部分代码省略.........
开发者ID:frobro98,项目名称:UnrealSource,代码行数:101,代码来源:UnitTestCommandlet.cpp


示例11: DECLARE_SCOPE_CYCLE_COUNTER

void UGameEngine::Init(IEngineLoop* InEngineLoop)
{
	DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime);

	// Call base.
	UEngine::Init(InEngineLoop);

#if USE_NETWORK_PROFILER
	FString NetworkProfilerTag;
	if( FParse::Value(FCommandLine::Get(), TEXT("NETWORKPROFILER="), NetworkProfilerTag ) )
	{
		GNetworkProfiler.EnableTracking(true);
	}
#endif

	// Load all of the engine modules that we need at startup that are not editor-related
	UGameEngine::LoadRuntimeEngineStartupModules();

	// Load and apply user game settings
	GetGameUserSettings()->LoadSettings();
	GetGameUserSettings()->ApplyNonResolutionSettings();

	// Create game instance.  For GameEngine, this should be the only GameInstance that ever gets created.
	{
		FStringClassReference GameInstanceClassName = GetDefault<UGameMapsSettings>()->GameInstanceClass;
		UClass* GameInstanceClass = (GameInstanceClassName.IsValid() ? LoadObject<UClass>(NULL, *GameInstanceClassName.ToString()) : UGameInstance::StaticClass());
		
		GameInstance = NewObject<UGameInstance>(this, GameInstanceClass);

		GameInstance->InitializeStandalone();
	}
 
//  	// Creates the initial world context. For GameEngine, this should be the only WorldContext that ever gets created.
//  	FWorldContext& InitialWorldContext = CreateNewWorldContext(EWorldType::Game);

	// Initialize the viewport client.
	UGameViewportClient* ViewportClient = NULL;
	if(GIsClient)
	{
		ViewportClient = NewObject<UGameViewportClient>(this, GameViewportClientClass);
		ViewportClient->Init(*GameInstance->GetWorldContext(), GameInstance);
		GameViewport = ViewportClient;
		GameInstance->GetWorldContext()->GameViewport = ViewportClient;
	}

	bCheckForMovieCapture = true;

	// Attach the viewport client to a new viewport.
	if(ViewportClient)
	{
		// This must be created before any gameplay code adds widgets
		bool bWindowAlreadyExists = GameViewportWindow.IsValid();
		if (!bWindowAlreadyExists)
		{
			GameViewportWindow = CreateGameWindow();
		}

		CreateGameViewport( ViewportClient );

		if( !bWindowAlreadyExists )
		{
			SwitchGameWindowToUseGameViewport();
		}

		FString Error;
		if(ViewportClient->SetupInitialLocalPlayer(Error) == NULL)
		{
			UE_LOG(LogEngine, Fatal,TEXT("%s"),*Error);
		}

		UGameViewportClient::OnViewportCreated().Broadcast();
	}

	GameInstance->StartGameInstance();


	UE_LOG(LogInit, Display, TEXT("Game Engine Initialized.") );

	// for IsInitialized()
	bIsInitialized = true;
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:81,代码来源:GameEngine.cpp


示例12: DECLARE_SCOPE_CYCLE_COUNTER

void UGameEngine::Init(IEngineLoop* InEngineLoop)
{
	DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime);

	// Call base.
	UEngine::Init(InEngineLoop);

#if USE_NETWORK_PROFILER
	FString NetworkProfilerTag;
	if( FParse::Value(FCommandLine::Get(), TEXT("NETWORKPROFILER="), NetworkProfilerTag ) )
	{
		GNetworkProfiler.EnableTracking(true);
	}
#endif

	// Load and apply user game settings
	GetGameUserSettings()->LoadSettings();
	GetGameUserSettings()->ApplySettings();

	// Creates the initial world context. For GameEngine, this should be the only WorldContext that ever gets created.
	FWorldContext &InitialWorldContext = CreateNewWorldContext(EWorldType::Game);

	// Initialize the viewport client.
	UGameViewportClient* ViewportClient = NULL;
	if(GIsClient)
	{
		ViewportClient = ConstructObject<UGameViewportClient>(GameViewportClientClass,this);
		ViewportClient->SetReferenceToWorldContext(InitialWorldContext);
		GameViewport = ViewportClient;
		InitialWorldContext.GameViewport = ViewportClient;
	}

	bCheckForMovieCapture = true;

	// Attach the viewport client to a new viewport.
	if(ViewportClient)
	{
		// This must be created before any gameplay code adds widgets
		bool bWindowAlreadyExists = GameViewportWindow.IsValid();
		if (!bWindowAlreadyExists)
		{
			GameViewportWindow = CreateGameWindow();
		}

		CreateGameViewport( ViewportClient );

		if( !bWindowAlreadyExists )
		{
			SwitchGameWindowToUseGameViewport();
		}
		FString Error;
		if(!ViewportClient->Init(Error))
		{
			UE_LOG(LogEngine, Fatal,TEXT("%s"),*Error);
		}
	}

	// Create default URL.
	// @note:  if we change how we determine the valid start up map update LaunchEngineLoop's GetStartupMap()
	FURL DefaultURL;
	DefaultURL.LoadURLConfig( TEXT("DefaultPlayer"), GGameIni );

	// Enter initial world.
	EBrowseReturnVal::Type BrowseRet = EBrowseReturnVal::Failure;
	FString Error;
	TCHAR Parm[4096]=TEXT("");
	const TCHAR* Tmp = FCommandLine::Get();

#if UE_BUILD_SHIPPING
	// In shipping don't allow an override
	Tmp = TEXT("");
#endif // UE_BUILD_SHIPPING

	const UGameMapsSettings* GameMapsSettings = GetDefault<UGameMapsSettings>();
	const FString& DefaultMap = GameMapsSettings->GetGameDefaultMap();
	if (!FParse::Token(Tmp, Parm, ARRAY_COUNT(Parm), 0) || Parm[0] == '-')
	{
		FCString::Strcpy(Parm, *(DefaultMap + GameMapsSettings->LocalMapOptions));
	}
	FURL URL( &DefaultURL, Parm, TRAVEL_Partial );
	if( URL.Valid )
	{
		BrowseRet = Browse(InitialWorldContext, URL, Error );
	}

	// If waiting for a network connection, go into the starting level.
	if (BrowseRet != EBrowseReturnVal::Success && FCString::Stricmp(Parm, *DefaultMap) != 0)
	{
		const FText Message = FText::Format( NSLOCTEXT("Engine", "MapNotFound", "The map specified on the commandline '{0}' could not be found. Would you like to load the default map instead?"), FText::FromString( URL.Map ) );

		// the map specified on the command-line couldn't be loaded.  ask the user if we should load the default map instead
		if ( FCString::Stricmp(*URL.Map, *DefaultMap) != 0 &&
			FMessageDialog::Open( EAppMsgType::OkCancel, Message ) != EAppReturnType::Ok)
		{
			// user canceled (maybe a typo while attempting to run a commandlet)
			FPlatformMisc::RequestExit( false );
			return;
		}
		else
		{
//.........这里部分代码省略.........
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:101,代码来源:GameEngine.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UGen类代码示例发布时间:2022-05-31
下一篇:
C++ UFunction类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap