Code archives/3D Graphics - Effects/Crater Code
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
A handy function that easily makes a nice round crater. Assumes terrain sections are 1x1 Blitz units (add Step to change). Also fun to tinker with, and easy to add particles, crater ring, etc. entity=entity crater is created around terrain=terrain in which the crater is formed radius=crater's radius (default is 1) th=maximum height of any terrain section (default is 100) hardness=hardness of the ground, 1 is completely soft, 0 is completely solid (default is 1) | |||||
Function crater(entity,terrain,radius#=1,th#=100,hardness#=1) ex#=EntityX(entity) ez#=EntityZ(entity) For x=-radius To radius For z=-radius To radius If Sqr(x*x+z*z)<=radius And hardness<>0 d#=Sqr(x*x+z*z) h#=TerrainHeight(terrain,ex+x,ez+z) scale#=th/hardness h=h+d/scale-radius/scale If h<0 Then h=0 ModifyTerrain terrain,ex+x,ez+z,h,True EndIf Next Next End Function |
Comments
| ||
Nice man! =) Been lookin for 1 of these forever! =D Thanks man! =) ~DarkShadowWing~ |
Code Archives Forum