Code archives/3D Graphics - Misc/resizeterrain
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
resizes a terrain to an absolute size. If you tell it to go to 500 units wide it will be 500 units wide, not anything else. terrain is the terrain you want to scale. x,y,z are the sizes you want the terrain to be. | |||||
Function resizeTerrain(terrain,x,y,z) BaseSize = terrainsize(terrain) sx# = (EntityScale(terrain,0)/BaseSize)*x sy# = EntityScale(terrain,1)*y ;starts at 1, no point in dividing by 1 sz# = (EntityScale(terrain,2)/BaseSize)*z ScaleEntity terrain,sx,sy,sz End Function Function EntityScale#(entity,axis) x#=GetMatElement(entity,axis,0) y#=GetMatElement(entity,axis,1) z#=GetMatElement(entity,axis,2) Return Sqr(x*x+y*y+z*z) End Function ;example terrain = loadterrain("myterrain.bmp") resizeterrain(terrain,500,300,500) |
Comments
| ||
http://www.blitzbasic.com/b3ddocs/command.php?name=TerrainSize&ref=3d_a-z may come in handy here too :) |
| ||
well, that's useful...now you do not have to load the image or pass in base size. (updated above) Thanks cygnus for the pointer. |
| ||
my first double post... |
Code Archives Forum