home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol069 / files.pas < prev    next >
Pascal/Delphi Source File  |  1984-04-29  |  2KB  |  82 lines

  1. External GRAPHICS::FILES(1);
  2. (*$E+ *)
  3.  
  4. Procedure DefineObject;
  5. var
  6.   Pts,PtsObj,PolsObj,PtsPol,I,J : counter;
  7.   X,Y,Z,Xpos,Ypos,Zpos : real;
  8.   ObjFile : file of char;
  9. begin
  10.   write('Name of file: ');readln(Filename);    {get file name}
  11.   rewrite(Filename,Objfile);            {open object file}
  12.   write('Number of points: '); readln(PtsObj);
  13.   write('Number of polygons: '); readln(PolsObj);
  14.   writeln(ObjFile,PtsObj,PolsObj);
  15.   writeln('Pnt    X,Y,Z');
  16.   for I := 1 to PtsObj do
  17.     begin
  18.       write(I:2);write('    ');readln(X,Y,Z);
  19.       writeln(ObjFile,X,Y,Z);
  20.     end;
  21.   for I := 1 to PolsObj do
  22.     begin
  23.       write('# of pnts in ',I:2,' polygon: ');readln(PtsPol);
  24.       write(ObjFile,PtsPol);   { write polygon vertex pointers }
  25.       for J := 1 to PtsPol do
  26.         begin
  27.       read(Pts);
  28.           write(ObjFile,Pts)
  29.         end;
  30.       writeln(ObjFile)  { read past end of line }
  31.     end
  32.   end;  { DefineObject }
  33.  
  34. (*$L+ *)
  35. procedure ReadObject(FileName : $string255);
  36.   { read in object from disk }
  37. var
  38.   PtsObj,PolsObj,PtsPol,I,J : counter;
  39.   Xpos,Ypos,Zpos : real;
  40.   ObjFile : file of char;
  41. begin
  42.   write('Position for ',Filename,' X Y Z : ');
  43.   readln(Xpos,Ypos,Zpos);
  44.   reset(Filename,Objfile);   {open object file }
  45.   readln(ObjFile,PtsObj,PolsObj);
  46.   write('Number of points: '); writeln(PtsObj:4);
  47.   write('Number of polygons: '); writeln(PolsObj:4);
  48.   for I := 1 to PtsObj do
  49.     with Points[I+NumPts] do
  50.       begin
  51.         readln(ObjFile,X,Y,Z);
  52.         X := X+Xpos;
  53.         Y := Y+Ypos;
  54.         Z := Z+Zpos;
  55.         writeln('Point: ',I,'    ',X:6:1,Y:6:1,Z:6:1)
  56.       end;
  57.   for I := 1 to PolsObj do
  58.      begin
  59.        read(ObjFile,PtsPol);   { read polygon vertex pointers }
  60.        writeln('Polygon ',I:2,' has ',PtsPol:4,' vertices');
  61.        write('They are: ');
  62.        for J := 1 to PtsPol do
  63.          begin
  64.            read(ObjFile,Vertices[J+NumVtces]);
  65.            Vertices[J+NumVtces] := Vertices[J+NumVtces]+NumPts;
  66.        write(Vertices[J+NumVtces]:3)
  67.          end;
  68.        readln(ObjFile);  { read past end of line }
  69.        writeln;
  70.        with Polygons[I+NumPols] do
  71.          begin
  72.            Start := NumVtces;
  73.            NumVtx := PtsPol;
  74.          end;
  75.        NumVtces := NumVtces + PtsPol;
  76.     end;
  77.   NumPts := NumPts + PtsObj;
  78.   NumPols := NumPols + PolsObj;
  79.   readln(CmdChar)    { leave display until cr }
  80. end;  { ReadObject }
  81. .
  82.