/** * Draws a line with an arrow at the end. * * @param Start Starting point of the line. * @param End Ending point of the line. * @param Color Color of the line. * @param Mag Size of the arrow. */ void FDebugRenderSceneProxy::DrawLineArrow(FPrimitiveDrawInterface* PDI,const FVector &Start,const FVector &End,const FColor &Color,float Mag) const { // draw a pretty arrow FVector Dir = End - Start; const float DirMag = Dir.Size(); Dir /= DirMag; FVector YAxis, ZAxis; Dir.FindBestAxisVectors(YAxis,ZAxis); FMatrix ArrowTM(Dir,YAxis,ZAxis,Start); DrawDirectionalArrow(PDI,ArrowTM,Color,DirMag,Mag,SDPG_World); }
/** * Draw the scene proxy as a dynamic element * * @param PDI - draw interface to render to * @param View - current view */ virtual void DrawDynamicElements(FPrimitiveDrawInterface* PDI,const FSceneView* View) { QUICK_SCOPE_CYCLE_COUNTER( STAT_ArrowSceneProxy_DrawDynamicElements ); FMatrix EffectiveLocalToWorld; #if WITH_EDITOR if (bLightAttachment) { EffectiveLocalToWorld = GetLocalToWorld().GetMatrixWithoutScale(); } else #endif //WITH_EDITOR { EffectiveLocalToWorld = GetLocalToWorld(); } DrawDirectionalArrow(PDI,EffectiveLocalToWorld,ArrowColor,ArrowSize * 3.0f * ARROW_SCALE,ARROW_SCALE,GetDepthPriorityGroup(View)); }
void FUnrealEdUtils::DrawWidget(const FSceneView* View,FPrimitiveDrawInterface* PDI, const FMatrix& WidgetMatrix, int32 InInfo1, int32 InInfo2, EAxisList::Type HighlightAxis, EWidgetMovementMode bInMode, bool bHitTesting) { const FVector WidgetOrigin = WidgetMatrix.GetOrigin(); // Calculate size to draw widget so it takes up the same screen space. const float ZoomFactor = FMath::Min<float>(View->ViewMatrices.ProjMatrix.M[0][0], View->ViewMatrices.ProjMatrix.M[1][1]); const float WidgetRadius = View->Project(WidgetOrigin).W * (UnrealEd_WidgetSize / ZoomFactor); // Choose its color. Highlight manipulated axis in yellow. FColor XColor(255, 0, 0); FColor YColor(0, 255, 0); FColor ZColor(0, 0, 255); if(HighlightAxis == EAxisList::X) XColor = FColor(255, 255, 0); else if(HighlightAxis == EAxisList::Y) YColor = FColor(255, 255, 0); else if(HighlightAxis == EAxisList::Z) ZColor = FColor(255, 255, 0); const FVector XAxis = WidgetMatrix.GetScaledAxis( EAxis::X ); const FVector YAxis = WidgetMatrix.GetScaledAxis( EAxis::Y ); const FVector ZAxis = WidgetMatrix.GetScaledAxis( EAxis::Z ); if(bInMode == WMM_Rotate) { if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::X, WidgetMatrix, bInMode) ); DrawCircle(PDI,WidgetOrigin, YAxis, ZAxis, XColor, WidgetRadius, 24, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Y, WidgetMatrix, bInMode) ); DrawCircle(PDI,WidgetOrigin, XAxis, ZAxis, YColor, WidgetRadius, 24, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Z, WidgetMatrix, bInMode) ); DrawCircle(PDI,WidgetOrigin, XAxis, YAxis, ZColor, WidgetRadius, 24, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); } else { FMatrix WidgetTM; // Draw the widget arrows. if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::X, WidgetMatrix, bInMode) ); WidgetTM = FMatrix(XAxis, YAxis, ZAxis, WidgetOrigin); DrawDirectionalArrow(PDI,WidgetTM, XColor, WidgetRadius, 1.f, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Y, WidgetMatrix, bInMode) ); WidgetTM = FMatrix(YAxis, ZAxis, XAxis, WidgetOrigin); DrawDirectionalArrow(PDI,WidgetTM, YColor, WidgetRadius, 1.f, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Z, WidgetMatrix, bInMode) ); WidgetTM = FMatrix(ZAxis, XAxis, YAxis, WidgetOrigin); DrawDirectionalArrow(PDI,WidgetTM, ZColor, WidgetRadius, 1.f, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bInMode == WMM_Scale) { FVector AlongX = WidgetOrigin + (XAxis * WidgetRadius * 0.3f); FVector AlongY = WidgetOrigin + (YAxis * WidgetRadius * 0.3f); FVector AlongZ = WidgetOrigin + (ZAxis * WidgetRadius * 0.3f); PDI->DrawLine(AlongX, AlongY, FColor(255,255,255), SDPG_Foreground); PDI->DrawLine(AlongY, AlongZ, FColor(255,255,255), SDPG_Foreground); PDI->DrawLine(AlongZ, AlongX, FColor(255,255,255), SDPG_Foreground); } } }