home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / 3d_light.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-28  |  2KB  |  74 lines

  1. Uses Crt,ModeXLib,Gif,var_3d;
  2.  
  3. Const
  4.     worldlen=8*3;               {Point-Array}
  5.     Worldconst:Array[0..worldlen-1] of Integer =
  6.     (-200,-200,-200,
  7.     -200,-200,200,
  8.     -200,200,-200,
  9.     -200,200,200,
  10.     200,-200,-200,
  11.     200,-200,200,
  12.     200,200,-200,
  13.     200,200,200);
  14.     surfclen=38;                {Surface-Array}
  15.     surfcconst:Array[0..surfclen-1] of Word=
  16.     ($fee0,4, 0,2,6,4,
  17.      $fec0,4, 0,1,3,2,
  18.      $fec0,4, 4,6,7,5,
  19.      $fee0,4, 1,5,7,3,
  20.      $fec0,4, 2,3,7,6,
  21.      $fec0,4, 0,4,5,1,0,0);
  22.     { $fe = use light source, primary color in the low-byte}
  23.  
  24. Var
  25.     i,j:Word;
  26.  
  27. Procedure Shad_Pal;             {prepare palette for shading}
  28. Begin
  29.   For j:=192 to 223 do Begin    {prepare colors 192 - 223 and 224 - 255}
  30.     i:=trunc((j/32)*43);        {determine brightness}
  31.     Fillchar(Palette[j*3],3,i+20);  {colors 192-223 to gray tones}
  32.  
  33.     Palette[(j+32)*3]:=i+20;    {colors 224-255 to red tones}
  34.     Palette[(j+32)*3+1]:=0;
  35.     Palette[(j+32)*3+2]:=0;
  36.   End;
  37.   Setpal;                       {set this palette}
  38. End;
  39.  
  40. procedure drawworld;external;   {draws the world on current video page}
  41. {$l 3dasm.obj}
  42. {$l poly.obj}
  43. {$l bres.obj}
  44. {$l root.obj}
  45.  
  46. Begin
  47.   vz:=1000;                     {solid is located at 1000 unit depth}
  48.   vpage:=0;                     {start with page 0}
  49.   LoadGif('logor.gif');         {load wallpaper}
  50.   init_modex;                   {enable ModeX}
  51.   Shad_Pal;                     {calculate shading palette}
  52.   rotx:=0;                      {initial values for rotation}
  53.   roty:=0;
  54.   rotz:=0;
  55.   Fill:=true;                   {SurfaceFill on}
  56.   sf_sort:=true;                {SurfaceSort on}
  57.   sf_shift:=true;               {SurfaceShift suppression on}
  58.   Glass:=false;                 {glass surfaces off}
  59.   p13_2_modex(16000*2,16000);   {wallpaper to VGA page 2}
  60.   repeat
  61.     CopyScreen(vpage,16000*2);  {wallpaper to current page}
  62.     DrawWorld;                  {draw world}
  63.     switch;                     {switch to finished picture}
  64.     WaitRetrace;                {wait for next retrace}
  65.     Inc(rotx);                  {continue rotating ... }
  66.     If rotx=120 Then rotx:=0;
  67.     Inc(rotz);
  68.     If rotz=120 Then rotz:=0;
  69.     inc(roty);
  70.     if roty=120 Then roty:=0;
  71.   Until KeyPressed;             { ... until key}
  72.   TextMode(3);
  73. End.
  74.