Editing a mesh in-game

Hey, all! RiokuTheSlayer here, with a bit of a hard one.

I have a game I’m working on, and I want to be able to edit the tiles in the game whenever you like, and be able to save them for use in a level builder.

That’s all fine, but the hardest part about this for me is the logic behind making the mesh editable.

Mostly, the feature I want is to be able to select a section of a face on a model, and then extrude that face inward or outward. Basically give me the ability to click any given pixel on a model, and then drag that pixel out or into the model.

I’ve never done any kind of procedural meshes like this, only voxel-based ones. I know that I basically need to add 8 more vertices (4 for the place the selected “pixel” was before, and 4 for the new faces you make.) and then the new triangles and uvs for the new stuff.

I was just wondering if anyone knew a page I could read up on, or know the exact logic off the top of their head.

A few pictures of how it looks in blender

Any help would be much appreciated!

Check out the Mesh documentation. It goes over creating and modifying meshes during runtime.

1 Like

Thanks, but I understand that. I’ve done things using that in the past, what I actually need is some explanation in the logic behind actively creating and removing faces from a mesh, moving them, ect. I don’t think I’ve explained this well enough really.

I think what I’m trying to do is actually overcomplicated. I’ll probably switch back to my old method of editing the models, which is just having them all be little voxel arrays and build a mesh off of that.

This is a deep foray into the field of graph theory and applied geometry. Open source projects like Blender3D do it all the time in their Boolean operators, so if you want to see some code, take a look there. It’s not a trivial thing.

If you want to see what I mean, make a cube in Blender, and make a Boolean Modifier (for your example, use Union) against another shape, and then move them relative to each other in real time. The geometry created is pretty insane.