本文整理汇总了C++中FSceneView::ScreenToWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ FSceneView::ScreenToWorld方法的具体用法?C++ FSceneView::ScreenToWorld怎么用?C++ FSceneView::ScreenToWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSceneView
的用法示例。
在下文中一共展示了FSceneView::ScreenToWorld方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimMouseMove
void FPhATEdPreviewViewportClient::SimMouseMove(float DeltaX, float DeltaY)
{
DragX = Viewport->GetMouseX() - SharedData->LastClickPos.X;
DragY = Viewport->GetMouseY() - SharedData->LastClickPos.Y;
if (!SharedData->MouseHandle->GrabbedComponent)
{
return;
}
//We need to convert Pixel Delta into Screen position (deal with different viewport sizes)
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues( Viewport, GetScene(), EngineShowFlags ));
FSceneView* View = CalcSceneView(&ViewFamily);
FVector4 ScreenOldPos = View->PixelToScreen(SharedData->LastClickPos.X, SharedData->LastClickPos.Y, 1.f);
FVector4 ScreenNewPos = View->PixelToScreen(DragX + SharedData->LastClickPos.X, DragY + SharedData->LastClickPos.Y, 1.f);
FVector4 ScreenDelta = ScreenNewPos - ScreenOldPos;
FVector4 ProjectedDelta = View->ScreenToWorld(ScreenDelta);
FVector4 WorldDelta;
//Now we project new ScreenPos to xy-plane of SimGrabLocation
FVector LocalOffset = View->ViewMatrices.ViewMatrix.TransformPosition(SimGrabLocation + SimGrabZ * SimGrabPush);
float ZDistance = GetViewportType() == ELevelViewportType::LVT_Perspective ? fabs(LocalOffset.Z) : 1.f; //in the ortho case we don't need to do any fixup because there is no perspective
WorldDelta = ProjectedDelta * ZDistance;
//Now we convert back into WorldPos
FVector WorldPos = SimGrabLocation + WorldDelta + SimGrabZ * SimGrabPush;
FVector NewLocation = WorldPos;
float QuickRadius = 5 - SimGrabPush / SimHoldDistanceChangeDelta;
QuickRadius = QuickRadius < 2 ? 2 : QuickRadius;
DrawDebugPoint(GetWorld(), NewLocation, QuickRadius, FColorList::Red, false, 0.3);
SharedData->MouseHandle->SetTargetLocation(NewLocation);
SharedData->MouseHandle->GrabbedComponent->WakeRigidBody(SharedData->MouseHandle->GrabbedBoneName);
}