Editing meshes (or something similar)

Hello,

TL;DR: How do I create a mesh that I can (quickly) add/remove polygons from on the fly?

I want to render a lot of triangles that I might want to change depending on player input (deformable terrain). I’m experimenting with a few basic approaches using JME, and if I just instantiate a bunch of Geometry’s and add them to my rootNode, it’s pretty slow. If I call GeometryBatchFactory.optimize(rootNode), that speeds it up a bunch, but the problem is that if I call that method every time something alters terrain, it causes a noticeable hop in the framerate (which I expected). So, I’m thinking I need to dynamically generate one mesh and add/subtract from it as things (blocks) are modified. I didn’t see any methods that would do this in the Mesh class (or any of its subclasses) and I was wondering if someone could point me in the right direction. Thanks!

With 2d terrain you can probably figure out the math to do on the fly mesh modifications, but for 3d terrain it’s quicker to just regenerate it.

https://wiki.jmonkeyengine.org/jme3/advanced/custom_meshes.html

also consider the use of “chunks”. that would help by only requiring you to regenerate the mesh of the chunk (or cell) where the change was located, instead of all of your terrain as 1 big mesh.

Thanks for the help here guys. I ended up regenerating meshes and using chunks, which is plenty fast. Chunks had been the plan from the beginning, since I’m taking a lot of ideas from other games (like Minecraft) in terms of how to handle rendering/interacting with a large world.