home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 116 / 3DEMO.ZIP / CNVT.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-17  |  4KB  |  159 lines

  1. {                        
  2. ************************************************************************
  3.                          C N V T   v1.0
  4.  
  5.   This program was created by me, Ives, in order to find a way
  6.   to create data files for art.pas (from art.zip).  ART.PAS was
  7.   written by someone else, I give the author most of the credit
  8.   for the functions and code used for the calculations and stuff.
  9.   If you want the original program files, download ART.ZIP.
  10.   
  11.   --------------------------------------------------------------
  12.  
  13. To use this program...
  14.  
  15.      CNVT infile outfile [BIN/int]  where [..] is the infile type
  16.  
  17.    EXAMPLE: "CNVT cube.3dd cube.3di" or "CNVT cube.3dd cube.3di BIN"
  18.  
  19.     result: This would give you a text file with integer values of
  20.             the object file's points and lines.
  21.  
  22.   EXAMPLE2: "CNVT letter.3di letter.3dd INT"
  23.  
  24.     result: The text file that you create will be converted into
  25.             the binary format used by 3DEMO.EXE.
  26.   
  27.   --------------------------------------------------------------
  28.  
  29. note: If you would like more information on the file format, see
  30.       the file FORMAT.TXT
  31.  
  32. ************************************************************************
  33. }
  34. program CNVT;
  35. {$I-}
  36. uses crt,Dos;
  37. const
  38.   Bins=True;
  39.   Ints=False;
  40. var
  41.   cnt : integer;
  42.   Direction:boolean;
  43.   FileIn,FileOut:string;
  44. type
  45.   Point = record
  46.     x,y,z : real;
  47.   end;
  48.   Line  = record
  49.     FP,TP : real;
  50.   end;
  51.   f_real= file of real;
  52.  
  53. procedure error(j:integer);
  54. var
  55.   C: Char;
  56. begin
  57.   writeln;
  58.   case j of
  59.     1:writeln('Open File Error / Input File Not Found');
  60.     2:writeln('Error Creating Output File');
  61.     3:begin
  62.         writeln('Output File Exists, replace it? (Y/n)');
  63.         C:=Readkey; if C='n' then begin
  64.           writeln;halt(1);end else exit;
  65.       end;
  66.     4:begin
  67.        writeln('  Syntax:  CNVT infile outfile [BIN/int]');writeln;
  68.        writeln('           (default = Binary to Int)');writeln;writeln;
  69.        writeln('    EXAMPLE:  CNVT box.3db box.3di BIN');
  70.      end;
  71.  end;
  72.  halt(1);
  73. end;
  74.  
  75. procedure ReadBin;
  76. var
  77.   fyle1       :f_real;
  78.   fyle2       :text;
  79.   t1,t2,t3    :real;
  80.   i,j         :byte;
  81.   numOfPoints :integer;
  82.   numOfLines  :integer;
  83.   Sfile       :string[79];
  84. begin
  85.   assign(fyle1,FileIn);
  86.   reset(fyle1);
  87.   if ioResult <>0 then error(1);
  88.   Sfile:=FSearch(FileOut,'');if Sfile=FileOut then error(3);
  89.   assign(fyle2,FileOut);rewrite(fyle2);
  90.   if ioResult <>0 then error(2);
  91.   begin
  92.     read(fyle1,t1);
  93.     numOfPoints:=trunc(t1);
  94.     writeln(fyle2,numOfPoints);
  95.     for j:=1 to numOfPoints do begin
  96.       read(fyle1,t1,t2,t3);
  97.       writeln(fyle2,trunc(t1),' ',trunc(t2),' ',trunc(t3));
  98.     end;
  99.     writeln(fyle2);
  100.     read(fyle1,t1);
  101.     numOfLines:=trunc(t1);
  102.     writeln(fyle2,numOfLines);
  103.     for j:=1 to numOfLines do begin
  104.       read(fyle1,t1,t2);
  105.       writeln(fyle2,trunc(t1),' ',trunc(t2));
  106.     end;
  107.   end;
  108.   close(fyle1);close(fyle2);
  109. end;
  110.  
  111. procedure ReadInt;
  112. var
  113.   fyle1       :text;
  114.   fyle2       :f_real;
  115.   t1,t2,t3    :real;
  116.   i,j         :byte;
  117.   numOfPoints :integer;
  118.   numOfLines  :integer;
  119.   Sfile       :string[79];
  120. begin
  121.   assign(fyle1,FileIn);
  122.   reset(fyle1);
  123.   if ioResult <>0 then error(ioresult);
  124.   Sfile:=FSearch(FileOut,'');if Sfile=FileOut then error(3);
  125.   assign(fyle2,FileOut);rewrite(fyle2);
  126.   if ioResult <>0 then error(2);
  127.   begin
  128.     read(fyle1,t1);
  129.     numOfPoints:=trunc(t1);
  130.     write(fyle2,t1);
  131.     for j:=1 to numOfPoints do begin
  132.       read(fyle1,t1,t2,t3);
  133.       write(fyle2,t1,t2,t3);
  134.     end;
  135.     read(fyle1,t1);
  136.     numOfLines:=trunc(t1);
  137.     write(fyle2,t1);
  138.     for j:=1 to numOfLines do begin
  139.       read(fyle1,t1,t2);
  140.       write(fyle2,t1,t2);
  141.     end;
  142.   end;
  143.   close(fyle1);close(fyle2);
  144. end;
  145.  
  146. function FindDir : boolean;
  147. begin
  148.   FileIn:=ParamStr(1);FileOut:=ParamStr(2);
  149.   if ParamCount < 2 then error(4);
  150.   if ParamCount = 3 then begin
  151.     if 'int'=ParamStr(3) then FindDir:=ints;
  152.     if 'INT'=ParamStr(3) then FindDir:=ints;end
  153.   else FindDir:=bins;
  154. end;
  155.  
  156. begin;
  157.   if FindDir then ReadBIN else ReadInt;
  158. end.
  159.