首页 > 其他 > 详细

一些投影和鼠标位置(未整理)

时间:2017-03-31 16:26:23      阅读:504      评论:0      收藏:0      [点我收藏+]

一、得到当前运行的屏幕分辨率:

		FVector2D ScreenPos = GEngine->GameViewport->Viewport->GetSizeXY();

二、使用DeprojectScreenPositionToWorld运算:

PlayerController->DeprojectScreenPositionToWorld(ScreenPos.X / 2.0f, ScreenPos.Y / 2.0f, MousePos, MouseDir);

  其中,PlayerController为对应的控制器。

	/** The view port representing the current game instance. Can be 0 so don‘t use without checking. */
	UPROPERTY()
	class UGameViewportClient* GameViewport;

UGameViewportClient的说明:

/**
 * A game viewport (FViewport) is a high-level abstract interface for the
 * platform specific rendering, audio, and input subsystems.
 * GameViewportClient is the engine‘s interface to a game viewport.
 * Exactly one GameViewportClient is created for each instance of the game.  The
 * only case (so far) where you might have a single instance of Engine, but
 * multiple instances of the game (and thus multiple GameViewportClients) is when
 * you have more than one PIE window running.
 *
 * Responsibilities:
 * propagating input events to the global interactions list
 *
 * @see UGameViewportClient
 */
UCLASS(Within=Engine, transient, config=Engine)
class ENGINE_API UGameViewportClient : public UScriptViewportClient, public FExec
{

解(反)投影?不确切这个词怎么译,反正就是投影的逆运算

	/** Convert current mouse 2D position to World Space 3D position and direction. Returns false if unable to determine value. **/
	UFUNCTION(BlueprintCallable, Category = "Game|Player", meta = (DisplayName = "ConvertScreenLocationToWorldSpace", Keywords = "deproject"))
	bool DeprojectScreenPositionToWorld(float ScreenX, float ScreenY, FVector& WorldLocation, FVector& WorldDirection) const;

  

一些投影和鼠标位置(未整理)

原文:http://www.cnblogs.com/redeyerabbit/p/6652004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!