# Terrain deformation via mouse in real time using OpenGL

The main problem I’m facing is how I can, given a spot on a terrain mesh (x and z coordinates) change the mesh so that the surrounding points also change height but will be less affected. What’s confusing me is how I could change the mesh when that spot is not a vertex within the mesh so that the mesh will accurately represent the given point changing height. Would I need to change the mesh entirely, changing the vertex points completely to accommodate for the new shape (so possibly making that point a new vertex in the mesh and thus changing the mesh entirely) or is there some other way to do it without having to restructure the mesh so that the vertices that are affected by the height change move which will then change the faces to be in accordance with the change in height

• What is the goal of this? Is this purely graphical? Will you link this to an actual physics mesh so that players or object can move on it? – Vaillancourt Mar 12 at 0:48
• For now it’s mostly graphical I just want to be able to manipulate it yes. In the future it may be that players can move around on it but for now that’s not my main goal – Elijah Villarmia Mar 12 at 7:20
• A triangle mesh seems like a bad representation for mouse editing. For example, Minecraft does not store the world as a triangle mesh, it just converts it to one for display. Here is how they edited terrain in The Witness. – user253751 Mar 12 at 10:52
• Interesting, I’ll have a look at that, that looks like a reasonable solution to my problem. I’ll just need to see if I can reasonably implement that. Thanks! – Elijah Villarmia Mar 13 at 14:56
• Assuming you have a mesh, if you need it e.g. for collision things you'd have to change it. If you only extrude it for visuals like in a heightmap you'd simply pass in the mouse position into the pipeline and calculate the offsets depending on distance of the current vertex, e.g. via cubic interpolation in the vertexshader or whatever function you'd like. I am sure there a ton of other possibilities to do it. – user136710 Mar 15 at 22:08