   Spherical Terrain Deformation.
  Hey all,Just for shits and giggles, I'm adding some terrain deformation to my engine in process (and very young, I might add).After some help in #math on a couple of IRC channels, I've come up with this:  for(int iLoop = 0; iLoop < 4; iLoop++){int x = (m_Vertices[iLoop].x - iX) * (m_Vertices[iLoop].x - iX);int y = (m_Vertices[iLoop].y - iY) * (m_Vertices[iLoop].y - iY);int z = (m_Vertices[iLoop].z - iZ) * (m_Vertices[iLoop].z - iZ);double dAnswer = sqrt(x + y + z);double dRadius = iRadius * iRadius;if(dAnswer <= dRadius)m_Vertices[iLoop].y -= iRadius;}Where iX, iY and iZ is the centre of the sphere and iRadius is the distance from the middle to the edge.And that creates a pretty nice round hole, like so:As you can see, the hole clearly forms a circle, but it doesn't form a nice rounded crater.Right now I've got a golf hole.  Round but 'straight' down.  I'm looking for a ball cut in half.Any ideas how I can expand on the code above to create a sphere-half in the ground?[edited by - GroZZleR on February 10, 2004 5:32:37 PM][edited by - GroZZleR on February 10, 2004 5:44:56 PM]
  go to this websitehttp://www.robot-frog.com/3d/hills/hill.htmlnow that example actual creates a hill out of the flat surface of the ground.all you really need to do me thinks is invert the height to make it dip below the ground to make a hole   "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA ;  Here's the basic idea.  Optimize to taste... //For sphere of radius R centered at (a, b)for(double x=-R; x<=R; x++){    for(double y=-sqrt(R*R-x*x); y<=sqrt(R*R-x*x); y++)    {    z[a + x][b + y] -= sqrt(R*R - x*x - y*y);    }} [edited by - TerranFury on February 10, 2004 9:42:21 PM];  iRadius is a costant...that''s why 