[Video] The Power & Grace of UE4 C++: Dynamic Rendering of HD Torus Knots (for fun)

Dear Community,

In this video, I am using the awesome power of UE4 C++ to render High Definition Torus Knots…during Gametime!

That’s right, the editor was not open! This video was filmed in an independent game instance!

I adjust the various settings on the torus knot, leading up to HD, using my in-game UI system!

This video is dedicated to Epic’s choice to give us all C++ access!

Thank you Epic!

This video is also sharing with all of you, showing you how truly we can doing anything in UE4 thanks to C++ access :slight_smile:

**HD Torus Knot**

By the end of the video I am rendering torus knots with P 52 and Q 53 with 4096 circle segements!

UE4 C++ is awesome!


My entire UI system is based in the HUD class!

I created my own user input field class / edit box class.

I also setup up the TABing feature for my input fields :slight_smile:


I am using DynamicMeshBuilder to render the torus knot!

For examples of using DynamicMeshBuilder check out PrimitiveDrawingUtils.cpp.

Everything about the Torus Knot is under my control because I am supplying the code for generating the torus knot vertex and triangle render data.

The reason the Torus Knot renders in stages is because I am controlling that myself in the C++, as the calculations are too much to do in a single tick.

I could have calculated everything much faster actually, the speed I chose was for stylistic / artistic reasons :)

I wanted to be able to see the shape building itself!

**Efficiency **

The data is not regenerated every tick, I simply load the cached vertex/triangle data into DynamicMeshBuilder. :slight_smile:


I was originally on a long hunt to figure out how to draw a 3d space triangle!

To do this I knew I needed to access the PDI, the base 3d drawing surface.

I cant disclose the code here due to legal reasons, but to get a sense of how to draw to the PDI of a UPrimitiveComponent,

check out the .cpp for BoxComponent, and especially CreateSceneProxy()


UE4 C++ is awesome!

We can do anything!

Thank you Epic!

I hope everyone enjoys my HD Torus Knot Video!


bump, enjoy the video!

Nice work, Rama!

Hee hee thanks GmPreussner!

Thank you for UE4 C++ !

[FONT=Comic Sans MS]:heart:


This was really helpful, as I was also trying to figure out how to draw 3d world space triangles like this.

Thanks for the pointers in the right direction Rama!

Nice post !

There is some way of getting mouseclick () events or get hit proxies on primitives draw with FDynamicMeshBuilder ?

On docs FDynamicMeshBuilder::GetMesh | Unreal Engine Documentation we have a parameter with HHitProxy* that can we pass when use GetMesh(…)

const FMatrix & LocalToWorld,
const FMaterialRenderProxy * MaterialRenderProxy,
uint8 DepthPriorityGroup,
bool bDisableBackfaceCulling,
bool bReceivesDecals,
bool bUseSelectionOutline,
int32 ViewIndex,
FMeshElementCollector & Collector,
HHitProxy * HitProxy

But how can I get That HitProxy* on other parts of code not only on CustomMeshComponent using a FSceneProxy()