Hole in Mesh Runtime

Hello guys,

I am trying to get a hole (square) into a pre meshed object “wall” using the Blueprint System so I can see and go through.

So far I was able to remove the collision box at a specific area I am looking at. The Problem is that you can’t see through. The mesh is still the same only the collision box will be removed.
I also took a look into Location Based Opacity but I simply can’t connect it with the problem I have. Despite that fact that I am new to the Unreal Engine I would like to ask for help.

https://my-run.de/downloads/s/crannk_09-08-16_r7ya1.png

Best Regards

Let me clarify what you are asking for assistance with, you need help adjusting the material to show a hole?

This is what we are aiming to accomplish. You have an Object in front of you (most likely a Wall) with a mouse click create a hole in this wall. This removes the collider in this area as well as the object itself, so basically you can go or shoot through.

https://my-run.de/downloads/s/20160809141438_1.jpg

https://my-run.de/downloads/s/20160809141445_1.jpg

Ok, that will be kind of tricky as you have the interior walls of the hole to deal with… Will you only be able to do this on specific surfaces? Will all surfaces be same depth? How complex will these surfaces be?

If it is going to be simple surfaces you may want to look into the procedural mesh component to replace the wall and update the actual mesh at runtime to create the hole. Or create a wall with hole mesh to replace what is there. I can help you out if you need some assistance with these options if any of them sound like they may be useful to you, might just take some time to get you a proper response

You might be best served by using the procedural mesh component to update the flat wall surfaces. It will allow you to manipulate geometry and UVs so that you can litterally have the player cut a hole in your walls to any size or shape you want (depending on how much work you want to invest). Again I am unsure if the player can place these holes on any surface or just perfectly flat surfaces. I am going to assume it has to be on a flat surface with enough space for the hole.

If you want I can do a quick writeup tonight after work to show you how you could implement this.

Well, the point is that the object which needs to get the hole is shortly defined like the image above.
I know about the BSP Methode and using pre mesh is not an option because the hole needs to be specified placed by the user it self and not pre-defined by the game itself.

You are assuming right, it will be only on flat surfaces with enough space. According to what you say this seems to be exactly what we are looking for. I would very much appreciated if you give me a kick-start with a quick writeup.
Thanks in advance.

No problem, one of my first forays into procedural mesh generation was exactly this. I will try to get you something by tomorrow morning.

Alright, I made a quick example which hopefully you can deduce a little bit more. If you have any questions feel free to ask.

So basically, in order to use the Procedural Mesh Generator you need to understand how a mesh works. It takes an array of points for the verts, then an array of integers that are the indexes of the vert array to form triangles, then an array of vector2’s which are the UV coordinates of each vert.

So Verticies and UVs need to be of the same length, where verticies are the location in local space and UVs are their relative location to the texture square with (0,0) in the bottom left and (1,1) in the upper right. Generally I find that on a flat plane the UVs should be 1/100 of the vert positions but you will figure things out as you go and depending on your needs.

The Tris are referencing the Index of the vert array, so the first tri in the example I made will reference verts 0,1,5

The order is important as that determines the normal of the face. Note all of my tris are counter clockwise. If you were to make them clockwise they would face the other direction.

I know this is a quick and simple example, but hopefully it will make sense how it works and how to draw a hole inside a square.

You will need to build the opposite side and then figure out the tri orders to bridge them. I would suggest diagramming out the vert order like I did with reroute nodes in my blueprint to help you figure it out.

Hi I am working with together and also took a look into this.
First of all we appreciate your help a lot.
It looks like everytime we call that BP it creates a complete new Mesh with the defined hole in it.
So the Mesh is static as well as the hole. I can’t connect your example with our Idea to spawn a hole in an existing wall.
The image below shows exactly what we are trying to acomplish in runtime. A Brsuh (subtractive) which can be spawned in any given Brush.

Am I missing something?

https://my-run.de/downloads/s/schlumpf_08_11_16_8byyl.png

Ok, so the example I gave will give you a static wall and a static hole. You will need to modify it, likely by defining the plain wall as it’s own array of verts, then defining the hole as a separate array then appending them together.

So you could modify the code to utilize the following parameters:
WallLength (float defining the length of your wall segment)
WallHeight (float defining the height of your wall segment)
WallThickness (float defining the thickness of your wall segment)
WallTris (Array of integers defining the tris of the wall)

HoleLength (float defining the length of your hole)
HoleHeight (float defining the height of your hole)
HoleCenter (This would be the center point of your hole)
HoleTris (Array of integers defining the tris of the hole)

WallVerts (Automatically computed from the WallLength, WallHeight and WallThickness. Verts 0-7)
WallUVs (Array of UV coordinates for the wall, match the indices of WallVerts)
HoleVerts (Automatically computed from the HoleLength HoleHeight HoleCenter and WallThickness. Verts 8-15)
HoleUVs (Array of UV coordinates for the wall, match the indices of HoleVerts)

You would compute the 8 verts for HoleVerts then append it to WallVerts. The order of the tris should always be consistent so that should never change. You will also need to update the UVs.

The basic idea is to either swap out the meshes, or just use a procedural mesh without the hole, then add a hole into it when you want to (another reason to keep the items separate)

I hope this makes more sense.

Alright, although this seems pretty hard to do we will try to use as much as possible from your example. Thanks a lot!
I think we might come back to ask some specific questions later on.

Best regards

It’s intimidating at first, but once you get your head around it it is actually pretty simple. Feel free to hit me up with any questions. Best of luck!

Just wanted to check in and see if you got this working. Would love to see some screenshots of it in action, sounds pretty cool.