Where to even start with FDynamicMesh3?

UProceduralMeshComponent has a CreateMeshSection function, but does anyone happen to know what the equivalent would be for a USimpleDynamicMeshComponent or UOctreeDynamicMeshComponent (Not even sure which one to use). Am I supposed to get the FDynamicMesh3 and then use AppendVertices, AppendTriangles individually? Is that correct?

All I want to be able to do is create a simple Triangle :smiley:, trying to understand how it works by looking at ModelingTools implementation is insanity. Thereā€™s FDynamicMesh, FMeshDescription, Operators, Mechanics, Mesh Editors, Mesh Spatials, Compute Meshes?? etcā€¦

If you are looking to create a Component, ie some visible geometry attached to an Actor, then you would use USimpleDynamicMeshComponent (note: in 5.0 USimpleDynamicMeshComponent is renamed UDynamicMeshComponent). And yes you would get the FDynamicMesh3, then call AppendVertex and AppendTriangle, and then call UDynamicMeshComponent::NotifyMeshUpdated().

Alternately you could construct your own FDynamicMesh3 separately and then call UDynamicMeshComponent::SetMesh().

If you have not seen them, it might be helpful to read this article on my website. Itā€™s a bit out-of-date now though:

Basically, FDynamicMesh3 is the data - the actual vertices and triangles - and has nothing to do with Actors/Components/etc. You can use FDynamicMesh3 in pure C++ code to do mesh processing things that are not connected to gameplay. UDynamicMeshComponent is a visible Component where the 3D geometry is defined by a FDynamicMesh3 stored in the Component.

This is similar to UStaticMeshComponent/UStaticMesh, except UStaticMesh doesnā€™t actually contain the 3D geometry either - UStaticMesh stores the 3D geometry in a FMeshDescription. So FMeshDescription is similar to FDynamicMesh3 in that it is the actual mesh data structure, vs a container for it.

Another way to think about it is UStaticMesh is an Asset that allows multiple UStaticMeshComponent to re-use the same FMeshDescription mesh. There is no asset for FDynamicMesh3 - each UDynamicMeshComponent has itā€™s own FDynamicMesh3 (similar to how UProceduralMeshComponent has itā€™s mesh sections).

Operators, Mechanics, Mesh Editors, Compute Meshes - these are all things that are specific to our modeling tools framework and infrastructure. You would not use them to (eg) display a triangle, you would use them if you want to do mesh editing operations (either computationally or interactively).

ā€œMesh Spatialā€ generally means an AABBTree for a FDynamicMesh3, or other Mesh. Spatial == Spatial Data Structure. We use this more generic word because we can technically plug in other BVH hierarchies, octrees, etc.

UOctreeDynamicMeshComponent is a variant of USimpleDynamicMeshComponent, so it works the same way (internal FDynamicMesh3 defines what will be rendered). It supports partial updates based on a 3D Octree, but using it is quite complex and I would not recommend it unless you are trying to implement 3D mesh sculpting with dynamic/adaptive remeshing (which is what we use it for).

2 Likes

I would love if someone could create an example c++ script where I ā†’

  1. Assign a mesh to an actor
  2. select some verts in its vertices index
  3. move those verts around in anyway

If anyone can help I would muchly appreciated it.

When you say ā€œAssign a mesh to an actorā€, what kind of Mesh and what kind of Actor are you referring to (sorry, I know itā€™s complicated)

Sure, i meant assign a dynamic mesh to a static mesh actor i guess. Basically i need to create a dynamic mesh actor with code.

The link @rmsEG msEG pointed to seems pretty good for this.
What part didnā€™t work?