How to make Player Mesh Preview in UI

Hi,

I’m wondering how we can handle to preview a mesh in UI. This is used when selecting a character for example, you can see it mesh & description.

I have in mind to set a kind of camera with a render to target and draw the texture on the UI, but I suspect I will have lighting issue & I must reserve a part of my “level” to do this trick.
I saw also in UT code that they are using a WorldPreview to make this happenned, but I can’t find any documentation on this.

Can anyone leads me on documentation or on steps to make this happen?

Thanks,

Bump.

I hope someone will know how to do this…

Aside from placing things in an pocket world, UT4 doing the usual - place stuff somewhere, take the result and rendering it.
If you choose to place it in the existing world, just place it way off somewhere and shove it inside a box that contains its own lighting, background colour etc.

You can see the result of such a thing in the following screenshot:

Doing it this way require no C++ and provided you setup your background and material correctly, you can render your mesh without a background.

Hi,

Thanks for the answers.
Your UI is exactly the type of things I want to do.

I added my previewer component inside my world as it will be easier to customize the background than the “preview world” approach.

I have made a quick start on this, and I have 2 issues as the moment:
1 - I have difficulties to understand how to setup the SceneCaptureComponent correctly. I don’t understand how it works: where the “camera look” and what will be capture (with the FoV angle). Is there any docs / way to see the “camera view” inside the BP?
2 - When I’m rendering the SceneComponent in the RenderTarget. I’m using a Material to map it to a SlateBrushMaterial. When I’m in PIE, everything is fine, when I lauch the game out of the editor, it renders correctly but after 30 sec, SlateBrushMaterial becomes null and the game crash. Have you experienced something similar? How are you rendering the RenderTarget inside your UI?

Thanks,

Most games I’ve seen build a little area under the map for this kind of thing. Or inside a room that’s locked as an alternative.

  1. Setting up the location of the scene capture component is up to you.
    One simple way a bit of trial and error - place it at X distance from the thing you want to view until it fills the desired amount of the view.
    The other is a math - place everything at the same location and your camera automatically adjust its position, FOV etc to make the target fill the desired amount of the view.

  2. I use a dynamically created render target that is added to root.
    Rama has included the code in his collection.
    Its called CreateTextureRenderTarget2D().

This is assigned to my scene capture component, passes the result to a material which is then assigned to my slate brush.

Gonna look into creating some C++ to handle this for me, as I’m a bit over the BP version I created.
If I get anywhere with that, I’ll most likely add that to Rama’s collection :slight_smile:

1 - Understand. I thought there will might be like an helper in the editor showing a wireframe mesh of the “view volume”. just to be sure I understand the way to set up it, the capture direction is from the position (dot of the Gizmo) to the opposite of the gizmo combine vector. I mean that the X, Y, Z gizmo vector create a vector and you need to take the opposite one to have the “view direction”.

2 - Ok so we have nearly the same approach. In fact, I created the Rendertarget asset in the editor, I have it assigned to my SceneCapturecomponent and I created a material that use the RT to output it without any changes. The material is then assigned to the Brush and used as is.
I will try to track down the root cause of this. I bet the brush material is taken by mistake in the Gaarbage collector, but it won’t be easy to track that ^^

What’s tricky is that in PIE, it’s absolutly working as expected, it’s just in standalone game that the problem appears.