# Deforming surfaces

I'm trying to accomplish a deforming physic behaviour for level surfaces, but don't have any idea how to start with the implemenation so far.

Regardless of the shape of the surface (planes, cubes, spheresâ€¦), I want to have small indentations at the positions from game-entities (players, enemies, objectsâ€¦).

It's kind of complicated to explain, so I illustrated what I'm talking about, here is an example with a sphere:

So, the surfaces should be able to deform themselves a little bit (to appear like a really soft bed or sofa). My surfaces need probably a high vertices count to get a smooth deforming, but my big problem is the math for calculating this deformation.

I'm programming in C/C++ with OpenGL, but any advices in the right direction will be fine.

For a simple deformation, you can pick a point on the surface/object to manipulate, then apply a transformation (e.g. translation) to it. Then, transform all points within a certain distance from that point the same way, but have the transformation loose strength the further away from the chosen point you are.

So, to make stuff indent under a character, choose the point he/she is standing on and displace it downwards.

Depending on what effect you want to archive, you might want to apply the transform globally, locally or towards/away from the object center and/or use different functions to simulate different materials.

A simple example of indenting a plane using sin/cos falloff functions can be found among www.lighthouse3d.com/opengl/terrain/