home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / graphic / csg_rt / globe.rt < prev    next >
Text File  |  1993-02-11  |  2KB  |  48 lines

  1. ;
  2. ; Draw a globe, ie: a sphere with a world map texture mapped around it.
  3. ;
  4. ; map.bmp is a bitmap of size 360x180 where each pixel corresponds to a
  5. ; degree of longitude and latitude. 0 deg lon., 0 deg lat. is at pixel (180,90).
  6. ;
  7. ; Since we may be rendering a big picture, one pixel in the map may expand to
  8. ; cover several pixels in the final picture. To reduce the visibility of this,
  9. ; we use linear interpolation over the map bitmap.
  10. ;
  11. ; We use col_remap to ensure that when a ray strikes the globe the intersection
  12. ; coordinates are computed relative to the centre of the colour =(0,0,0).
  13. ; This corresponds to the centre of the globe and if the globe is translated
  14. ; or rotated, the colour mapping will move with it.
  15. ;
  16.  
  17. set_col col_white col(rgb(1,1,1))
  18.  
  19. set_col col_globe col_remap(xyz(0,0,0),xyz(0,0,1),xyz(1,0,0),xyz(0,1,0),
  20.                     col_sph(rad(1),rad(1),1,
  21.                       col_interp0(
  22.                         col_interp1(
  23.                           col_field2d(180,90,"map.bmp")))))
  24.  
  25. set_surf surf_globe surf(0.4,0.9,0.1,0,col_globe,col_white,200,1)
  26.  
  27. set_shape shape_globe sphere(1,surf_globe)
  28.  
  29. set_attenuation 1 0.98
  30. set_ambient rgb(0.2,0.2,0.2)
  31. add_light xyz(25,10,25) rgb(2,2,2)
  32.  
  33. set_shape r shape_globe
  34. set_xyz e xyz( 0, 0, 3)
  35. set_xyz f xyz( 0, 0,-1)
  36. set_xyz u xyz( 0, 1, 0)
  37. set_value ax rad(20)
  38. set_value ay rad(20)
  39. set_value cx 200
  40. set_value cy 200
  41.  
  42. render rot_y(r,rad(  0)) e f u ax ay cx cy 0 "globe000.bmp"
  43. ;
  44. ; Note: clearly we can add extra render statements for other rotation values.
  45. ; If we do this we can trace an entire animation of the earth spinning.
  46. ; Just step the rad(0) to rad(350) in steps of 10 for example.
  47. ;
  48.