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

  1. Uses Crt,ModeXLib,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.     (01,4, 0,2,6,4,
  17.      02,4, 0,1,3,2,
  18.      04,4, 4,6,7,5,
  19.      08,4, 1,5,7,3,
  20.      16,4, 2,3,7,6,
  21.      32,4, 0,4,5,1,0,0);
  22.  
  23. Var
  24.     i,j:Word;
  25.  
  26. Procedure Glass_Pal;
  27. {prepares the palette for glass solids}
  28. Begin
  29.   FillChar(Palette[3],765,63);  {first all colors white}
  30.   For i:=1 to 255 do Begin      {define 255 mixed colors}
  31.     If i and 1 = 1 Then Dec(Palette[i*3],16);
  32.     If i and 2 = 2 Then Dec(Palette[i*3+1],16);
  33.     If i and 4 = 4 Then Dec(Palette[i*3+2],16);
  34.     If i and 8 = 8 Then Begin
  35.                           Dec(Palette[i*3],16);
  36.                           Dec(Palette[i*3+1],16);
  37.                         End;
  38.     If i and 16 = 16 Then Begin
  39.                           Dec(Palette[i*3],16);
  40.                           Dec(Palette[i*3+2],16);
  41.                         End;
  42.     If i and 32 = 32 Then Begin
  43.                           Dec(Palette[i*3+1],16);
  44.                           Dec(Palette[i*3+2],16);
  45.                         End;
  46.   End;
  47.   SetPal;
  48. End;
  49.  
  50. procedure drawworld;external;   {draws the world on current video page}
  51. {$l 3dasm.obj}
  52. {$l poly.obj}
  53. {$l bres.obj}
  54. {$l root.obj}
  55.  
  56. Begin
  57.   vz:=1000;                     {solid is located at 1000 units depth}
  58.   vpage:=0;                     {start with page 0}
  59.   init_modex;                   {enable ModeX}
  60.   Glass_Pal;
  61.   rotx:=0;                      {initial values for rotation}
  62.   roty:=0;
  63.   rotz:=0;
  64.   Fill:=true;                   {SurfaceFill on}
  65.   sf_sort:=false;               {SurfaceSort off}
  66.   sf_shift:=false;              {SurfaceShift suppression off}
  67.   Glass:=true;                  {glass surfaces on}
  68.   repeat
  69.     clrx($0f);                  {clear screen}
  70.     DrawWorld;                  {draw world}
  71.     switch;                     {switch to finished picture}
  72.     WaitRetrace;                {wait for next retrace}
  73.     Inc(rotx);                  {continue rotating ... }
  74.     If rotx=120 Then rotx:=0;
  75.     Inc(rotz);
  76.     If rotz=120 Then rotz:=0;
  77.     inc(roty);
  78.     if roty=120 Then roty:=0;
  79.   Until KeyPressed;             { ... until key}
  80.   TextMode(3);
  81. End.
  82.