How can I do boolean operations on meshes with UE4?

Hello,

I just started playing with UE4 and i am trying to do run-time mesh edition based on boolean operations.
For instance, when the player hit a object with is gun, the object should be replaced by “object-SphereOfImpace”. SphereOfImpace being a spherical mesh. (Exemple of boolean operation on meshes: http://www.flipcode.com/archives/fig4.gif)

I plan on calling a external library to execute the boolean operation.

I don’t think liking to a library should be a issue:

I have already been able to generate run-time meshes using the following wiki entry:

I have identified some library (http://doc.cgal.org, Google Code Archive - Long-term storage for Google Code Project Hosting., GTS - The GNU Triangulated Surface Library, GitHub - gilbo/cork: 3D Boolean / CSG Library), but i don’t know which one to pick.

Does anyone have any experience with boolean operations on meshes with UE4? Which library is the best suited for my needs (fast and easy even if inacurate)? Is calling a external library the way to go?

Thanks,

Edit: I changed the title to emphasize the boolean operation aspect of my question

#Extend Static Mesh Actor

Just extend the static mesh actor class, and use your custom class in your game instead of AStaticMeshActor

#Extending Class

UCLASS()
class AYourSMA : public AStaticMeshActor

Then your own class can handle all the modifications to itself

#Detect Collisions Against Mesh

Use this function to detect projectile and other collisions, within the class, and then set the new meshes

void AVictoryWall::ReceiveHit(
	class UPrimitiveComponent* MyComp, 
	class AActor* Other, 
	class UPrimitiveComponent* OtherComp, 
	bool bSelfMoved, 
	FVector HitLocation, 
	FVector HitNormal, 
	FVector NormalImpulse, 
	const FHitResult& Hit
)
{
	//Hit by Character?
	AVictoryPlayerCharacterBase* IsChar = Cast<AVictoryPlayerCharacterBase>(Other);
	if(!IsChar) return;
	//~~~~~~~~~

}

#Set Mesh

set new mesh this way

StaticMeshComponent->SetMesh(new asset);

Thank you for your input.

My question was more about the boolean operation on the mesh, and which tools was more suited to do that. Do you have any experience with this kind of problem?

By the way, i’m seen you username in many post relevant to my work. :slight_smile:

Hello robi395 !
My idea is the same with you, I Currently studying Procedural_Mesh.
If you have the result, please let me know.Thx!

I’m working on an answer, currently I have similar problem. Probably I’ll use CGAL or some other library. I’ll post you a code when I finish.

Found this two years old thread by looking to do the same.
Did you guys manage to static link some boolean mesh code library to Unreal?
For example Blender is using Carve library and its working pretty well.
Or do you know some similar functionality already imported to UE4?

there is experimental plugin integrated in Unreal engine - Geometry Script

Using this tool you can make different boolean operations on mesh with Blueprints or Python
this is example python script for that - UE5.0 Geometry Script - Mesh Booleans in Python | Tutorial
In Blueprints it look like so:

Go to documentation page and read it.