TGC Codebase Backup



Noise Library Part 4: Models.dba by The Sab

31st Oct 2010 10:17
Summary

Plane, Sphere, and Cylinder Noise Map Models, for use with NoiseUtils.dba



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function Cylinder_GetValue(index as integer, angle as float, height as float)
   if module_sets(index).source0 = -1
      ExceptionNoModule(index)
   endif

   result as float
   x as float
   y as float
   z as float
   x = cos(angle)
   y = height
   z = sin(angle)
   result = Module_GetValue(module_sets(index).source0, x, y, z)
endfunction result

function Plane_GetValue(index as integer, x as float, z as float)
   if module_sets(index).source0 = -1
      ExceptionNoModule(index)
   endif

   result as float
   result = Module_GetValue(module_sets(index).source0, x, 0, z)
endfunction result

function Sphere_GetValue(index as integer, lat as float, lon as float)
   if module_sets(index).source0 = -1
      ExceptionNoModule(index)
   endif

   result as float
   x as float
   y as float
   z as float
   x = LatLonToX(lat, lon)
   y = LatLonToY(lat, lon)
   z = LatLonToZ(lat, lon)
   result = Module_GetValue(module_sets(index).source0, x, y, z)
endfunction result