x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to use PDI drawing?

I'd like to draw a simple mesh sphere (i.e DrawWireSphere, etc.) while I'm in HUD (I trace the mouse in DrawHUD and want to place a sphere centered on the hit). However, that requires a FPrimitiveDrawInterface pointer. How can I get hold of that pointer?

Product Version: Not Selected
Tags:
more ▼

asked Apr 11 '14 at 11:37 PM in C++ Programming

avatar image

Andargor
132 16 18 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

DrawDebugHelpers.h

If you just want to draw a wire sphere you can do that right now, without direct access to PDI, using the DrawDebug version!

 /** Draw a debug sphere */
 ENGINE_API void DrawDebugSphere(const UWorld* InWorld, FVector const& Center, float Radius, int32 Segments, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);


You just type the function directly, it is ENGINE_API

 // Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
 
 /**
  * DrawDebugHelpers.h
  */
 
 
 #pragma once
 
 /** Flush persistent lines */
 ENGINE_API void FlushPersistentDebugLines(const UWorld* InWorld);
 /** Draw a debug line */
 ENGINE_API void DrawDebugLine(const UWorld* InWorld, FVector const& LineStart, FVector const& LineEnd, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0, float Thickness = 0.f);
 /** Draw a debug point */
 ENGINE_API void DrawDebugPoint(const UWorld* InWorld, FVector const& Position, float Size, FColor const& PointColor, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw directional arrow **/
 ENGINE_API void DrawDebugDirectionalArrow(const UWorld* InWorld, FVector const& LineStart, FVector const& LineEnd, float ArrowSize, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw a debug box */
 ENGINE_API void DrawDebugBox(const UWorld* InWorld, FVector const& Center, FVector const& Extent, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw a debug box with rotation */
 ENGINE_API void DrawDebugBox(const UWorld* InWorld, FVector const& Center, FVector const& Box, const FQuat & Rotation, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw Debug coordinate system */
 ENGINE_API void DrawDebugCoordinateSystem(const UWorld* InWorld, FVector const& AxisLoc, FRotator const& AxisRot, float Scale, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw Debug Circle */
 ENGINE_API void DrawDebugCircle(const UWorld* InWorld, const FMatrix& TransformMatrix, float Radius, int32 Segments, const FColor& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw Debug 2D donut */
 ENGINE_API void DrawDebug2DDonut(const UWorld* InWorld, const FMatrix& TransformMatrix, float InnerRadius, float OuterRadius, int32 Segments, const FColor& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw a debug sphere */
 ENGINE_API void DrawDebugSphere(const UWorld* InWorld, FVector const& Center, float Radius, int32 Segments, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw a debug cylinder */
 ENGINE_API void DrawDebugCylinder(const UWorld* InWorld, FVector const& Start, FVector const& End, float Radius, int32 Segments, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 ENGINE_API void DrawDebugCone(const UWorld* InWorld, FVector const& Origin, FVector const& Direction, float Length, float AngleWidth, float AngleHeight, int32 NumSides, FColor const& Color, bool bPersistentLines=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Used by gameplay when defining a cone by a vertical and horizontal dot products. */
 ENGINE_API void DrawDebugAltCone(const UWorld* InWorld, FVector const& Origin, FRotator const& Rotation, float Length, float AngleWidth, float AngleHeight, FColor const& DrawColor, bool bPersistentLines=false, float LifeTime=-1.f, uint8 DepthPriority=0);
 ENGINE_API void DrawDebugString(const UWorld* InWorld, FVector const& TextLocation, const FString& Text, class AActor* TestBaseActor = NULL, FColor const& TextColor = FColor::White, float Duration = -1.000000);
 ENGINE_API void DrawDebugFrustum(const UWorld* InWorld, const FMatrix& FrustumToWorld, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw a capsule using the LineBatcher */
 ENGINE_API void DrawDebugCapsule(const UWorld* InWorld, FVector const& Center, float HalfHeight, float Radius, const FQuat & Rotation, FColor const& Color, bool bPersistentLines=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 /** Draw a debug camera shape.  FOV is full angle in degrees. */
 ENGINE_API void DrawDebugCamera(const UWorld* InWorld, FVector const& Location, FRotator const& Rotation, float FOVDeg, float Scale=1.f, FColor const& Color=FColor::White, bool bPersistentLines=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 ENGINE_API void FlushDebugStrings(const UWorld* InWorld);
 
 ENGINE_API void DrawDebugSolidBox(const UWorld* InWorld, FVector const& Center, FVector const& Box, FColor const& Color, bool bPersistent=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 ENGINE_API void DrawDebugSolidBox(const UWorld* InWorld, FVector const& Center, FVector const& Extent, FQuat const& Rotation, FColor const& Color, bool bPersistent=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 ENGINE_API void DrawDebugMesh(const UWorld* InWorld, TArray<FVector> const& Verts, TArray<int32> const& Indices, FColor const& Color, bool bPersistent=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
 ENGINE_API void DrawDebugSolidPlane(const UWorld* InWorld, FPlane const& P, FVector const& Loc, float Size, FColor const& Color, bool bPersistent=false, float LifeTime=-1, uint8 DepthPriority = 0);

:)

Drawing to PDI

I explain how I got access to the PDI (After many hours of hunting) here;

https://forums.unrealengine.com/showthread.php?2662-Video-The-Power-amp-Grace-of-UE4-C-Dynamic-Rendering-of-HD-Torus-Knots-(for-fun)[

I am quite curious if there is some easier way, my only solution was to actually make UPrimitiveComponent and draw to its PDI

Rama

more ▼

answered Apr 12 '14 at 02:03 AM

avatar image

Rama
10.6k 446 346 1088

avatar image YuZ Feb 19 '15 at 03:58 PM

I'm not the smartest person and need a hint. Because UPrimitiveComponent does not hold a PDI as variable, I assume you created a SceneProxy and used the function Collector.getPDI(ViewIndex)? But where do you get the parameters (const TArray& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) from?

avatar image kamrann Feb 19 '15 at 07:01 PM

You need to override either FPrimitiveSceneProxy::DrawDynamicElements(), or FPrimitiveSceneProxy::GetDynamicMeshElements(), which provides these parameters. It's not clear to me when one or the other should be used. I'd suggest looking at one of the many examples of this in the engine code, for example here in CapsuleComponent.cpp. Or for an easier but less flexible and less optimal approach, use FDebugRenderSceneProxy, as for example in EQSRenderingComponent.cpp.

avatar image YuZ Feb 20 '15 at 09:25 AM

The link is not available anymore. Could you tell me where the .cpp files are? I can only look into the headers.

avatar image kamrann Feb 20 '15 at 10:22 AM

The link should work, so long as you have linked your UE4 account to their github engine page. Then entering FPrimitiveSceneProxy or FDebugRenderSceneProxy in the github project search box will give you heaps of examples. Here are the paths for the two I mentioned: UnrealEngine/Engine/Source/Runtime/Engine/Private/CapsuleComponent.cpp UnrealEngine/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EQSRenderingComponent.cpp

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question