本文整理汇总了C++中FSceneView类的典型用法代码示例。如果您正苦于以下问题:C++ FSceneView类的具体用法?C++ FSceneView怎么用?C++ FSceneView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FSceneView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FVector2D
/* After release of left mouse button, check if this unit is within selection box. */
void ARTSUnit::CheckForSelection()
{
/* Find screen coordinates of the unit. */
FVector2D MyResult = FVector2D(0, 0);
ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(PC->Player);
if (LocalPlayer != NULL && LocalPlayer->ViewportClient != NULL && LocalPlayer->ViewportClient->Viewport != NULL)
{
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
LocalPlayer->ViewportClient->Viewport,
GetWorld()->Scene,
LocalPlayer->ViewportClient->EngineShowFlags)
.SetRealtimeUpdate(true));
FVector ViewLocation;
FRotator ViewRotation;
FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);
if (SceneView)
{
auto MyWorldPosition = GetActorLocation();
MyResult;
SceneView->WorldToPixel(MyWorldPosition, MyResult);
}
}
/* If the selection box contains the screen postion: */
if (ARTSHUD::SelectionContainsPoint(MyResult)){
// Select this unit, and leave possibility to select others.
Select();
}
}
示例2: check
bool FSpriteEditorViewportClient::ConvertMarqueeToSourceTextureSpace(/*out*/ FIntPoint& OutStartPos, /*out*/ FIntPoint& OutDimension)
{
FSpriteGeometryEditMode* GeometryEditMode = ModeTools->GetActiveModeTyped<FSpriteGeometryEditMode>(FSpriteGeometryEditMode::EM_SpriteGeometry);
check(GeometryEditMode);
const FVector2D MarqueeStartPos = GeometryEditMode->GetMarqueeStartPos();
const FVector2D MarqueeEndPos = GeometryEditMode->GetMarqueeEndPos();
bool bSuccessful = false;
UPaperSprite* Sprite = SourceTextureViewComponent->GetSprite();
UTexture2D* SpriteSourceTexture = Sprite->GetSourceTexture();
if (SpriteSourceTexture != nullptr)
{
// Calculate world space positions
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(Viewport, GetScene(), EngineShowFlags));
FSceneView* View = CalcSceneView(&ViewFamily);
const FVector StartPos = View->PixelToWorld(MarqueeStartPos.X, MarqueeStartPos.Y, 0);
const FVector EndPos = View->PixelToWorld(MarqueeEndPos.X, MarqueeEndPos.Y, 0);
// Convert to source texture space to work out the pixels dragged
FVector2D TextureSpaceStartPos = Sprite->ConvertWorldSpaceToTextureSpace(StartPos);
FVector2D TextureSpaceEndPos = Sprite->ConvertWorldSpaceToTextureSpace(EndPos);
if (TextureSpaceStartPos.X > TextureSpaceEndPos.X)
{
Swap(TextureSpaceStartPos.X, TextureSpaceEndPos.X);
}
if (TextureSpaceStartPos.Y > TextureSpaceEndPos.Y)
{
Swap(TextureSpaceStartPos.Y, TextureSpaceEndPos.Y);
}
const FIntPoint SourceTextureSize(SpriteSourceTexture->GetImportedSize());
const int32 SourceTextureWidth = SourceTextureSize.X;
const int32 SourceTextureHeight = SourceTextureSize.Y;
FIntPoint TSStartPos;
TSStartPos.X = FMath::Clamp<int32>((int32)TextureSpaceStartPos.X, 0, SourceTextureWidth - 1);
TSStartPos.Y = FMath::Clamp<int32>((int32)TextureSpaceStartPos.Y, 0, SourceTextureHeight - 1);
FIntPoint TSEndPos;
TSEndPos.X = FMath::Clamp<int32>((int32)TextureSpaceEndPos.X, 0, SourceTextureWidth - 1);
TSEndPos.Y = FMath::Clamp<int32>((int32)TextureSpaceEndPos.Y, 0, SourceTextureHeight - 1);
const FIntPoint TextureSpaceDimensions = TSEndPos - TSStartPos;
if ((TextureSpaceDimensions.X > 0) || (TextureSpaceDimensions.Y > 0))
{
OutStartPos = TSStartPos;
OutDimension = TextureSpaceDimensions;
bSuccessful = true;
}
}
return bSuccessful;
}
示例3: InputState
bool FSpriteGeometryEditMode::InputKey(FEditorViewportClient* ViewportClient, FViewport* Viewport, FKey Key, EInputEvent Event)
{
bool bHandled = false;
FInputEventState InputState(Viewport, Key, Event);
// Handle marquee tracking in source region edit mode
if (IsEditingGeometry())
{
if (SpriteGeometryHelper.IsAddingPolygon())
{
if (Key == EKeys::LeftMouseButton)
{
const int32 HitX = Viewport->GetMouseX();
const int32 HitY = Viewport->GetMouseY();
// Calculate the texture space position of the mouse click
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(Viewport, ViewportClient->GetScene(), ViewportClient->EngineShowFlags));
FSceneView* View = ViewportClient->CalcSceneView(&ViewFamily);
const FVector WorldPoint = View->PixelToWorld(HitX, HitY, 0);
const FVector2D TexturePoint = SpriteGeometryHelper.GetEditorContext()->WorldSpaceToTextureSpace(WorldPoint);
// Add or close the polygon (depending on where the click happened and how)
const bool bMakeSubtractiveIfAllowed = Viewport->KeyState(EKeys::LeftControl) || Viewport->KeyState(EKeys::RightControl);
SpriteGeometryHelper.HandleAddPolygonClick(TexturePoint, bMakeSubtractiveIfAllowed, *View, Event);
}
else if ((Key == EKeys::BackSpace) && (Event == IE_Pressed))
{
SpriteGeometryHelper.DeleteLastVertexFromAddPolygonMode();
}
else if (Key == EKeys::Enter)
{
SpriteGeometryHelper.ResetAddPolygonMode();
}
else if (Key == EKeys::Escape)
{
SpriteGeometryHelper.AbandonAddPolygonMode();
}
}
else
{
if (ProcessMarquee(Viewport, Key, Event, true))
{
const bool bAddingToSelection = InputState.IsShiftButtonPressed(); //@TODO: control button moves widget? Hopefully make this more consistent when that is changed
SelectVerticesInMarquee(ViewportClient, Viewport, bAddingToSelection);
}
}
}
//@TODO: Support select-and-drag in a single operation (may involve InputAxis and StartTracking)
// Pass keys to standard controls, if we didn't consume input
return bHandled ? true : FEdMode::InputKey(ViewportClient, Viewport, Key, Event);
}
示例4: GetViewLocation
FSceneView* FJavascriptUMGViewportClient::CalcSceneView(FSceneViewFamily* ViewFamily)
{
FSceneViewInitOptions ViewInitOptions;
const FVector& ViewLocation = GetViewLocation();
const FRotator& ViewRotation = GetViewRotation();
const FIntPoint ViewportSizeXY = Viewport->GetSizeXY();
FIntRect ViewRect = FIntRect(0, 0, ViewportSizeXY.X, ViewportSizeXY.Y);
ViewInitOptions.SetViewRectangle(ViewRect);
ViewInitOptions.ViewOrigin = ViewLocation;
ViewInitOptions.ViewRotationMatrix = FInverseRotationMatrix(ViewRotation);
ViewInitOptions.ViewRotationMatrix = ViewInitOptions.ViewRotationMatrix * FMatrix(
FPlane(0, 0, 1, 0),
FPlane(1, 0, 0, 0),
FPlane(0, 1, 0, 0),
FPlane(0, 0, 0, 1));
//@TODO: Should probably be locally configurable (or just made into a FMinimalViewInfo property)
const EAspectRatioAxisConstraint AspectRatioAxisConstraint = GetDefault<ULocalPlayer>()->AspectRatioAxisConstraint;
FMinimalViewInfo::CalculateProjectionMatrixGivenView(ViewInfo, AspectRatioAxisConstraint, Viewport, /*inout*/ ViewInitOptions);
ViewInitOptions.ViewFamily = ViewFamily;
ViewInitOptions.SceneViewStateInterface = ViewState.GetReference();
ViewInitOptions.ViewElementDrawer = this;
ViewInitOptions.BackgroundColor = GetBackgroundColor();
//ViewInitOptions.EditorViewBitflag = 0, // send the bit for this view - each actor will check it's visibility bits against this
// for ortho views to steal perspective view origin
//ViewInitOptions.OverrideLODViewOrigin = FVector::ZeroVector;
//ViewInitOptions.bUseFauxOrthoViewPos = true;
//ViewInitOptions.CursorPos = CurrentMousePos;
FSceneView* View = new FSceneView(ViewInitOptions);
ViewFamily->Views.Add(View);
View->StartFinalPostprocessSettings(ViewLocation);
//OverridePostProcessSettings(*View);
View->EndFinalPostprocessSettings(ViewInitOptions);
return View;
}
示例5: DrawCanvas
void FSCSEditorViewportClient::DrawCanvas( FViewport& InViewport, FSceneView& View, FCanvas& Canvas )
{
AActor* PreviewActor = GetPreviewActor();
if(PreviewActor)
{
TGuardValue<bool> AutoRestore(GAllowActorScriptExecutionInEditor, true);
const int32 HalfX = 0.5f * Viewport->GetSizeXY().X;
const int32 HalfY = 0.5f * Viewport->GetSizeXY().Y;
auto SelectedNodes = BlueprintEditorPtr.Pin()->GetSelectedSCSEditorTreeNodes();
if(bIsManipulating && SelectedNodes.Num() > 0)
{
USceneComponent* SceneComp = Cast<USceneComponent>(SelectedNodes[0]->FindComponentInstanceInActor(PreviewActor, true));
if(SceneComp)
{
const FVector WidgetLocation = GetWidgetLocation();
const FPlane Proj = View.Project(WidgetLocation);
if(Proj.W > 0.0f)
{
const int32 XPos = HalfX + (HalfX * Proj.X);
const int32 YPos = HalfY + (HalfY * (Proj.Y * -1));
DrawAngles(&Canvas, XPos, YPos, GetCurrentWidgetAxis(), GetWidgetMode(), GetWidgetCoordSystem().Rotator(), WidgetLocation);
}
}
}
}
}
示例6: SetMesh
virtual void SetMesh(FRHICommandList& RHICmdList, FShader* Shader,const FVertexFactory* VertexFactory,const FSceneView& View,const FMeshBatchElement& BatchElement,uint32 DataFlags) const override
{
const bool bInstanced = View.GetFeatureLevel() >= ERHIFeatureLevel::SM4;
FMeshParticleVertexFactory* MeshParticleVF = (FMeshParticleVertexFactory*)VertexFactory;
FVertexShaderRHIParamRef VertexShaderRHI = Shader->GetVertexShader();
SetUniformBufferParameter(RHICmdList, VertexShaderRHI, Shader->GetUniformBufferParameter<FMeshParticleUniformParameters>(), MeshParticleVF->GetUniformBuffer() );
if (!bInstanced)
{
const FMeshParticleVertexFactory::FBatchParametersCPU* BatchParameters = (const FMeshParticleVertexFactory::FBatchParametersCPU*)BatchElement.UserData;
const FMeshParticleInstanceVertex* Vertex = BatchParameters->InstanceBuffer + BatchElement.UserIndex;
const FMeshParticleInstanceVertexDynamicParameter* DynamicVertex = BatchParameters->DynamicParameterBuffer + BatchElement.UserIndex;
SetShaderValue(RHICmdList, VertexShaderRHI, Transform1, Vertex->Transform[0]);
SetShaderValue(RHICmdList, VertexShaderRHI, Transform2, Vertex->Transform[1]);
SetShaderValue(RHICmdList, VertexShaderRHI, Transform3, Vertex->Transform[2]);
SetShaderValue(RHICmdList, VertexShaderRHI, SubUVParams, FVector4((float)Vertex->SubUVParams[0], (float)Vertex->SubUVParams[1], (float)Vertex->SubUVParams[2], (float)Vertex->SubUVParams[3]));
SetShaderValue(RHICmdList, VertexShaderRHI, SubUVLerp, Vertex->SubUVLerp);
SetShaderValue(RHICmdList, VertexShaderRHI, ParticleDirection, Vertex->Velocity);
SetShaderValue(RHICmdList, VertexShaderRHI, RelativeTime, Vertex->RelativeTime);
if (BatchParameters->DynamicParameterBuffer)
{
SetShaderValue(RHICmdList, VertexShaderRHI, DynamicParameter, FVector4(DynamicVertex->DynamicValue[0], DynamicVertex->DynamicValue[1], DynamicVertex->DynamicValue[2], DynamicVertex->DynamicValue[3]));
}
SetShaderValue(RHICmdList, VertexShaderRHI, ParticleColor, FVector4(Vertex->Color.Component(0), Vertex->Color.Component(1), Vertex->Color.Component(2), Vertex->Color.Component(3)));
}
}
示例7: TextureSpaceToScreenSpace
FVector2D FSpriteGeometryEditingHelper::TextureSpaceToScreenSpace(const FSceneView& View, const FVector2D& SourcePoint) const
{
const FVector WorldSpacePoint = EditorContext->TextureSpaceToWorldSpace(SourcePoint);
FVector2D PixelLocation;
View.WorldToPixel(WorldSpacePoint, /*out*/ PixelLocation);
return PixelLocation;
}
示例8: SourceTextureSpaceToScreenSpace
FVector2D FSpriteEditorViewportClient::SourceTextureSpaceToScreenSpace(const FSceneView& View, const FVector2D& SourcePoint) const
{
const FVector WorldSpacePoint = SourceTextureSpaceToWorldSpace(SourcePoint);
FVector2D PixelLocation;
View.WorldToPixel(WorldSpacePoint, /*out*/ PixelLocation);
return PixelLocation;
}
示例9: PreRenderView_RenderThread
void FSteamVRHMD::PreRenderView_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneView& View)
{
check(IsInRenderingThread());
// The last view location used to set the view will be in BaseHmdOrientation. We need to calculate the delta from that, so that
// cameras that rely on game objects (e.g. other components) for their positions don't need to be updated on the render thread.
const FQuat DeltaOrient = View.BaseHmdOrientation.Inverse() * TrackingFrame.DeviceOrientation[vr::k_unTrackedDeviceIndex_Hmd];
View.ViewRotation = FRotator(View.ViewRotation.Quaternion() * DeltaOrient);
View.UpdateViewMatrix();
}
示例10: DrawBatchedElements
void FSimpleElementCollector::DrawBatchedElements(FRHICommandList& RHICmdList, const FSceneView& View, FTexture2DRHIRef DepthTexture, EBlendModeFilter::Type Filter) const
{
// Mobile HDR does not execute post process, so does not need to render flipped
const bool bNeedToSwitchVerticalAxis = RHINeedsToSwitchVerticalAxis(View.GetShaderPlatform()) && !bIsMobileHDR;
// Draw the batched elements.
BatchedElements.Draw(
RHICmdList,
View.GetFeatureLevel(),
bNeedToSwitchVerticalAxis,
View.ViewProjectionMatrix,
View.ViewRect.Width(),
View.ViewRect.Height(),
View.Family->EngineShowFlags.HitProxies,
1.0f,
&View,
DepthTexture,
Filter
);
}
示例11: DrawingPolicy
bool TDistortionMeshDrawingPolicyFactory<DistortMeshPolicy>::DrawDynamicMesh(
FRHICommandList& RHICmdList,
const FSceneView& View,
ContextType bInitializeOffsets,
const FMeshBatch& Mesh,
bool bBackFace,
bool bPreFog,
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
FHitProxyId HitProxyId
)
{
const auto FeatureLevel = View.GetFeatureLevel();
bool bDistorted = Mesh.MaterialRenderProxy && Mesh.MaterialRenderProxy->GetMaterial(FeatureLevel)->IsDistorted();
if(bDistorted && !bBackFace)
{
// draw dynamic mesh element using distortion mesh policy
TDistortionMeshDrawingPolicy<DistortMeshPolicy> DrawingPolicy(
Mesh.VertexFactory,
Mesh.MaterialRenderProxy,
*Mesh.MaterialRenderProxy->GetMaterial(FeatureLevel),
bInitializeOffsets,
View.Family->EngineShowFlags.ShaderComplexity,
FeatureLevel
);
RHICmdList.BuildAndSetLocalBoundShaderState(DrawingPolicy.GetBoundShaderStateInput(View.GetFeatureLevel()));
DrawingPolicy.SetSharedState(RHICmdList, &View, typename TDistortionMeshDrawingPolicy<DistortMeshPolicy>::ContextDataType());
for (int32 BatchElementIndex = 0; BatchElementIndex < Mesh.Elements.Num(); BatchElementIndex++)
{
DrawingPolicy.SetMeshRenderState(RHICmdList, View,PrimitiveSceneProxy,Mesh,BatchElementIndex,bBackFace,typename TDistortionMeshDrawingPolicy<DistortMeshPolicy>::ElementDataType(), typename TDistortionMeshDrawingPolicy<DistortMeshPolicy>::ContextDataType());
DrawingPolicy.DrawMesh(RHICmdList, Mesh,BatchElementIndex);
}
return true;
}
else
{
return false;
}
}
示例12: ViewFamily
void AMouseController::GetCameraRay(FVector& WorldOrigin, FVector& WorldDirection)
{
ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player);
FVector2D MousePosition;
if (LocalPlayer)
{
if (!LocalPlayer->ViewportClient->GetMousePosition(MousePosition))
{
return;
}
}
// Early out if we clicked on a HUD hitbox
if (GetHUD() != NULL && GetHUD()->GetHitBoxAtCoordinates(MousePosition, true))
{
return;
}
if (LocalPlayer != NULL && LocalPlayer->ViewportClient != NULL && LocalPlayer->ViewportClient->Viewport != NULL)
{
// Create a view family for the game viewport
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
LocalPlayer->ViewportClient->Viewport,
GetWorld()->Scene,
LocalPlayer->ViewportClient->EngineShowFlags)
.SetRealtimeUpdate(true));
// Calculate a view where the player is to update the streaming from the players start location
FVector ViewLocation;
FRotator ViewRotation;
FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);
if (SceneView)
{
SceneView->DeprojectFVector2D(MousePosition, WorldOrigin, WorldDirection);
}
}
}
示例13: RunBenchmarkShader
void RunBenchmarkShader(FRHICommandList& RHICmdList, const FSceneView& View, TRefCountPtr<IPooledRenderTarget>& Src, float WorkScale)
{
auto ShaderMap = GetGlobalShaderMap(View.GetFeatureLevel());
TShaderMapRef<FPostProcessBenchmarkVS> VertexShader(ShaderMap);
TShaderMapRef<FPostProcessBenchmarkPS<Method> > PixelShader(ShaderMap);
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(RHICmdList, View.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(RHICmdList, View, Src);
VertexShader->SetParameters(RHICmdList, View);
// single pass was not fine grained enough so we reduce the pass size based on the fractional part of WorkScale
float TotalHeight = GBenchmarkResolution * WorkScale;
// rounds up
uint32 PassCount = (uint32)FMath::CeilToFloat(TotalHeight / GBenchmarkResolution);
for(uint32 i = 0; i < PassCount; ++i)
{
float Top = i * GBenchmarkResolution;
float Bottom = FMath::Min(Top + GBenchmarkResolution, TotalHeight);
float LocalHeight = Bottom - Top;
DrawRectangle(
RHICmdList,
0, 0,
GBenchmarkResolution, LocalHeight,
0, 0,
GBenchmarkResolution, LocalHeight,
FIntPoint(GBenchmarkResolution, GBenchmarkResolution),
FIntPoint(GBenchmarkResolution, GBenchmarkResolution),
*VertexShader,
EDRF_Default);
}
}
示例14: ComputeTemporalLODBoundsScreenSize
float ComputeTemporalLODBoundsScreenSize( const FVector& Origin, const float SphereRadius, const FSceneView& View, int32 SampleIndex )
{
// This is radial LOD, not the view parallel computation used in ComputeBoundsScreenSize
const float Divisor = (Origin - View.GetTemporalLODOrigin(SampleIndex)).Size();
// Get projection multiple accounting for view scaling.
const float ScreenMultiple = FMath::Max(View.ViewRect.Width() / 2.0f * View.ViewMatrices.ProjMatrix.M[0][0],
View.ViewRect.Height() / 2.0f * View.ViewMatrices.ProjMatrix.M[1][1]);
const float ScreenRadius = ScreenMultiple * SphereRadius / FMath::Max(Divisor, 1.0f);
const float ScreenArea = PI * ScreenRadius * ScreenRadius;
return FMath::Clamp(ScreenArea / View.ViewRect.Area(), 0.0f, 1.0f);
}
示例15: checkSlow
void FMeshElementCollector::AddMesh(int32 ViewIndex, FMeshBatch& MeshBatch)
{
checkSlow(MeshBatch.GetNumPrimitives() > 0);
checkSlow(MeshBatch.VertexFactory && MeshBatch.MaterialRenderProxy);
checkSlow(PrimitiveSceneProxy);
if (MeshBatch.bCanApplyViewModeOverrides)
{
FSceneView* View = Views[ViewIndex];
ApplyViewModeOverrides(
ViewIndex,
View->Family->EngineShowFlags,
View->GetFeatureLevel(),
PrimitiveSceneProxy,
MeshBatch.bUseWireframeSelectionColoring,
MeshBatch,
*this);
}
TArray<FMeshBatchAndRelevance,SceneRenderingAllocator>& ViewMeshBatches = *MeshBatches[ViewIndex];
new (ViewMeshBatches) FMeshBatchAndRelevance(MeshBatch, PrimitiveSceneProxy, FeatureLevel);
}