home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / MISC / VCAD2P.ZIP / VCAD2PV.MAC < prev    next >
Encoding:
Text File  |  1991-09-09  |  7.4 KB  |  218 lines

  1. /*-------------------------------------------------------------------*/
  2. /* VCAD2PV.MAC - VersaCAD Applications Program                       */
  3. /*                                                                   */
  4. /*         Create Complex Polygon file (or simple coordinate file    */
  5. /*         for Z axis extrusion) from Digitized Points for           */
  6. /*         triangulation and translation (3 sided rectangles) to     */
  7. /*         a Ray Trace scene description file.                       */
  8. /*                                                                   */
  9. /*         Robert Cleere (CIS 72050,3677)           08/13/91         */
  10. /*-------------------------------------------------------------------*/
  11.  
  12. clr (2);                              /* Erase Message Area          */
  13. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  14.  
  15. print ("Create Complex Polygon File");
  16. beep(2);
  17.  
  18. print ("\nEnter Filename ? ");        /* Get Filename                */
  19. input (File$);
  20.  
  21. clr (2);                              /* Erase Message Area          */
  22. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  23.  
  24. print ("Create Complex Polygon File");
  25. print ("\nEnter Constant Z Coordinate ? ");
  26. beep(2);
  27. input(z);
  28.  
  29. clr (2);                              /* Erase Message Area          */
  30. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  31.  
  32. print ("Create 3D Polygon File");
  33. print ("\nEnter Polygon Description ? ");
  34. beep(2);
  35. input(Desc$);
  36.  
  37. handle = open (3,File$);              /* Try to Open File            */
  38.  
  39. if handle == -1 then                  /* If New File then Create     */
  40.  
  41.   {
  42.  
  43.     create (File$);                   /* Create File                 */
  44.  
  45.     handle = open (3,File$);          /* Open File                   */
  46.  
  47.    }
  48.  
  49. fkey(1,2);                            /* Snap to Object Routine      */
  50. clr(2);
  51. cmd("O");
  52.  
  53. clr (2);                              /* Erase Message Area          */
  54. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  55.  
  56. print ("Select Snap Object for Common Polygon Node");
  57.  
  58. button = 0;                           /* Hold for Tablet Button      */
  59.  
  60. while button == 0 do tablet(1,x,y,button);
  61.  
  62. coord(x,y,button);                    /* Send x,y to Snap/Object     */
  63.  
  64. clr (2);                              /* Erase Message Area          */
  65. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  66.  
  67. print ("Select Common Polygon Node");
  68.  
  69. button = 0;                           /* Hold for Tablet Button      */
  70.  
  71. while button == 0 do tablet(1,x,y,button);
  72.  
  73. xend = x;                             /* Swap Coord for Line Draw    */
  74. yend = y;
  75.  
  76. /*               Add Common Node to 3D Polygon File                  */
  77.  
  78. a$ = str(x);                          /* Set x to 10 char string     */
  79. len = 10 - strlen (a$);
  80. strset (x$,' ',len);
  81. strcat (x$,a$);
  82.  
  83. a$ = str(y);                          /* Set y to 10 char string     */
  84. len = 10 - strlen (a$);
  85. strset (y$,' ',len);
  86. strcat (y$,a$);
  87.  
  88. a$ = str(z);                          /* Set z to 10 char string     */
  89. len = 10 - strlen (a$);
  90. strset (z$,' ',len);
  91. strcat (z$,a$);
  92.  
  93. write (handle,"/*--------------------------------------------*/");
  94. write (handle,"/*   VersaCad 3D Complex Polygon File         */");
  95. write (handle,"/*                                            */");
  96. write (handle,"/*   Created by VCAD2PV - Robert Cleere  1991 */");
  97. write (handle,"/*                                            */");
  98. write (handle,"/*   ",Desc$,"    */");
  99. write (handle,"/*--------------------------------------------*/");
  100. write (handle,"/* X Coord   Y Coord   Z Coord                */");
  101. write (handle,"/*--------------------------------------------*/");
  102.  
  103. write (handle,x$,y$,z$);
  104.  
  105. NumNode = 1;                          /* Set Polygon Node Count      */
  106.  
  107.   while inp() <> 113 do               /* Add Nodes until "q" pressed */
  108.  
  109.   {
  110.  
  111.     NumNode = Numnode+1;              /* Inc Surface Node Counter    */
  112.  
  113.     fkey(1,2);                        /* Snap to Object Routine      */
  114.     clr(2);
  115.     cmd("O");
  116.  
  117.     clr (2);                          /* Erase Message Area          */
  118.     gotorc (messline,0);              /* Set Cursor to Msg Line      */
  119.     
  120.     print ("Current Polygon Node Count = ",NumNode);
  121.     print ("\nSelect Snap Object for Next Polygon Point");
  122.  
  123.     button = 0;                       /* Hold for Tablet Button      */
  124.  
  125.     while button == 0 do tablet(1,x,y,button);
  126.  
  127.     coord(x,y,button);                /* Send x,y to Snap/Object     */
  128.  
  129.     clr (2);                          /* Erase Message Area          */
  130.     gotorc (messline,0);              /* Set Cursor to Msg Line      */
  131.  
  132.     print ("Select point to Add to Polygon");
  133.     print ("\n(Hold 'q' while picking for Last Polygon Point)");
  134.  
  135.     button = 0;                       /* Hold for Tablet Button      */
  136.  
  137.     while button == 0 do tablet(1,x,y,button);
  138.  
  139.     addobj (10,x,y,xend,yend,0,0);    /* Draw Lint to x,y            */
  140.  
  141.     xend = x;                         /* Swap Coord for Line Draw    */
  142.     yend = y;
  143.  
  144.     /*            Add mid - Node to 3D Polygon File                  */
  145.  
  146.     a$ = str(x);                      /* Set x to 10 char string     */
  147.     len = 10 - strlen (a$);
  148.     strset (x$,' ',len);
  149.     strcat (x$,a$);
  150.  
  151.     a$ = str(y);                      /* Set y to 10 char string     */
  152.     len = 10 - strlen (a$);
  153.     strset (y$,' ',len);
  154.     strcat (y$,a$);
  155.  
  156.     a$ = str(z);                      /* Set z to 10 char string     */
  157.     len = 10 - strlen (a$);
  158.     strset (z$,' ',len);
  159.     strcat (z$,a$);
  160.  
  161.     write (handle,x$,y$,z$);
  162.  
  163.    }
  164.  
  165. fkey(1,2);                            /* Snap to Object Routine      */
  166. clr(2);
  167. cmd("O");
  168.  
  169. clr (2);                              /* Erase Message Area          */
  170. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  171.  
  172. print ("Select Snap Object for Last Polygon Node");
  173.  
  174. button = 0;                           /* Hold for Tablet Button      */
  175.  
  176. while button == 0 do tablet(1,x,y,button);
  177.  
  178. coord(x,y,button);                    /* Send x,y to Snap/Object     */
  179.  
  180. clr (2);                              /* Erase Message Area          */
  181. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  182.  
  183. print ("Select Last Polygon Node");
  184.  
  185. button = 0;                           /* Hold for Tablet Button      */
  186.  
  187. while button == 0 do tablet(1,x,y,button);
  188.  
  189. addobj (10,x,y,xend,yend,0,0);        /* Draw Line to x,y            */
  190.  
  191. /*               Add Last Node to 3D Polygon File                    */
  192.  
  193. a$ = str(x);                          /* Set x to 10 char string     */
  194. len = 10 - strlen (a$);
  195. strset (x$,' ',len);
  196. strcat (x$,a$);
  197.  
  198. a$ = str(y);                          /* Set y to 10 char string     */
  199. len = 10 - strlen (a$);
  200. strset (y$,' ',len);
  201. strcat (y$,a$);
  202.  
  203. a$ = str(z);                          /* Set z to 10 char string     */
  204. len = 10 - strlen (a$);
  205. strset (z$,' ',len);
  206. strcat (z$,a$);
  207.  
  208. write (handle,x$,y$,z$);
  209.  
  210. write (handle,"/*----------------------------------------*/");
  211. write (handle,"/* Total Nodes In Polygon = ",NumNode,"   */");
  212. write (handle,"/*----------------------------------------*/");
  213.  
  214. clr(2);
  215.  
  216. gotorc (messline,0);                  /* Set Cursor to Msg Line      */
  217.  
  218. close (handle);                       /* Close 3d Polygon File */