home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Homebrewer's Handbook / vr.iso / vroom / viewer.pas < prev    next >
Pascal/Delphi Source File  |  1996-03-19  |  2KB  |  96 lines

  1. program viewer;
  2.  
  3. uses vroom,crt,dos,cyberman;
  4.  
  5. var object1 : file_object3d;
  6.     ch : char;
  7.     ok, junk, mouse, cyber : boolean;
  8.     myname : string;
  9.  
  10. procedure directory;
  11. var dirinfo : searchrec;
  12.     count : integer;
  13. begin
  14.      count:=1;
  15.      findfirst('*.3d',anyfile,dirinfo);
  16.      while doserror=0 do
  17.      begin
  18.           write(dirinfo.name : 13);
  19.           inc(count);
  20.           if count=6 then
  21.           begin
  22.                writeln;
  23.                count:=1;
  24.           end;
  25.           findnext(dirinfo);
  26.      end;
  27. end;
  28.  
  29. function file_exists(filename : string) : boolean;
  30. var dirinfo : searchrec;
  31. begin
  32.      findfirst(filename,anyfile,dirinfo);
  33.      file_exists:=(doserror=0);
  34. end;
  35.  
  36.  
  37. {$F+}
  38.  
  39. function MyKeyProc(ch : char) : boolean;
  40. var ok : boolean;
  41. begin
  42.      ok:=true;
  43.      case ch of
  44.                 'o': object1.RotateY(-10);
  45.                 'l': object1.RotateY(10);
  46.                 ',': object1.RotateZ(-10);
  47.                 '.': object1.RotateZ(10);
  48.                 'n': object1.RotateX(10);
  49.                 'm': object1.RotateX(-10);
  50.      else
  51.                ok:=false;
  52.      end;
  53.      MyKeyProc:=ok;
  54. end;
  55.  
  56. {$F-}
  57.  
  58. begin
  59.      directory;
  60.      writeln;
  61.      repeat
  62.            write('Enter the name of your object file : ');
  63.            readln(myname);
  64.            if myname='quit' then halt;
  65.            if not(file_exists(myname)) then writeln('Incorrect filename - please re-enter (''quit'' to quit)');
  66.      until file_exists(myname);
  67.  
  68.  
  69.      mouse:=false;
  70.      cyber:=false;
  71.      if cyberman_available then cyber:=true else if mouse_available then mouse:=true;
  72.  
  73.      Init_System;
  74.  
  75.      Set_Ambient_Intensity(0.5);
  76.      Set_Light(0.75,0,-1,-0.75);
  77.  
  78.      User_KeyCheck_Proc(MyKeyProc);
  79.  
  80.      object1.Init(myname);
  81.      object1.Set_Reference_Point(0,0,0);
  82.  
  83.      Set_View(200,0,0,0,0,0);
  84.      Set_Window(-20,-15,20,15);
  85.      Store_Settings;
  86.  
  87.      Redraw_Scene;
  88.  
  89.      repeat
  90.            junk:=false;
  91.            if cyber then junk:=cyberman_check else if mouse then junk:=mouse_check;
  92.            if keyboard_check or junk then redraw_scene;
  93.      until false;
  94.  
  95.      stop_graphics;
  96. end.