ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgflib/3ds2mgf.c
(Generate patch)

Comparing ray/src/cv/mgflib/3ds2mgf.c (file contents):
Revision 1.2 by greg, Thu Feb 8 13:29:33 1996 UTC vs.
Revision 1.9 by greg, Wed Sep 5 02:41:19 2007 UTC

# Line 1 | Line 1
1 + #ifndef lint
2 + static const char       RCSid[] = "$Id$";
3 + #endif
4   /*
5 <      3DS2POV.C  Copyright (c) 1996 Steve Anger and Jeff Bowermaster
5 >      3DS2POV.C  by Steve Anger and Jeff Bowermaster
6                          MGF output added by Greg Ward
7  
8        Reads a 3D Studio .3DS file and writes a POV-Ray, Vivid,
# Line 10 | Line 13
13        Compiled with MSDOS GNU C++ 2.4.1 or generic ANSI-C compiler
14   */
15  
13 #ifndef lint
14 static char SCCSid[] = "$SunId$ LBL";
15 #endif
16
16   #include <stdio.h>
17   #include <stdlib.h>
18   #include <math.h>
# Line 47 | Line 46 | extern unsigned _stklen = 16384;
46   #define MGF      4
47   #define RAW      99
48  
49 < #define DEG(x) ((180.0/M_PI)*(x))
50 < #define RAD(x) ((M_PI/180.0)*(x))
49 > #define DEG(x) ((double)(180.0/M_PI)*(x))
50 > #define RAD(x) ((double)(M_PI/180.0)*(x))
51  
52   #ifndef M_PI
53   #define M_PI (3.14159265358979323846)
# Line 351 | Line 350 | char *read_string (void);
350   float findfov (float lens);
351   int read_mgfmatname (char *s, int n, FILE *f);
352  
353 + char *progname;
354  
355 +
356   int main (int argc, char *argv[])
357   {
358      char meshfname[128];
# Line 453 | Line 454 | int main (int argc, char *argv[])
454   void process_args (int argc, char *argv[])
455   {
456      int i;
456    char *progname;
457      char *env_opt, *option;
458  
459      printf("\n\nAutodesk 3D Studio to Raytracer file Translator. Feb/96\n");
460 <    printf("Version 2.0 Copyright (c) 1996 Steve Anger and Jeff Bowermaster\n");
461 < #ifdef __GNUC__
462 <    printf ("32 bit version. DOS extender Copyright (c) 1991 DJ Delorie\n");
463 < #endif
460 >    printf("Version 2.0 by Steve Anger and Jeff Bowermaster 1996\n");
461      printf ("\n");
462  
463      if (argc < 2) {
# Line 473 | Line 470 | void process_args (int argc, char *argv[])
470          printf ("         -b<object>   - Convert this object as a box\n");
471          printf ("         +i, -i       - Turn internal bounding on or off\n");
472          printf ("         +v, -v       - Turn verbose status messages on or off\n");
473 <        printf ("         -op          - Output to POV-Ray 2.0 format (default)\n");
473 >        printf ("         -op          - Output to POV-Ray 2.0 format\n");
474          printf ("         -op1         - Output to POV-Ray 1.0 format\n");
475          printf ("         -ov          - Output to Vivid format\n");
476          printf ("         -ol          - Output to poLyray format\n");
# Line 497 | Line 494 | void process_args (int argc, char *argv[])
494      else if (!strcmp(progname, "3ds2raw"))
495          format = RAW;
496      else
497 <        format = MGF;           /* default if program name strange */
497 >        format = POV20;         /* default if program name strange */
498  
499      strcpy (inname, "");
500      strcpy (outname, "");
# Line 926 | Line 923 | void write_summary (FILE *f)
923          case MGF:
924              comstr = "# ";
925              break;
926 +        default:
927 +                printf ("Illegal format in write_summary() '%c'\n", format);
928 +                exit(1);
929      }
930      fprintf (f, "%s   Object    CenterX    CenterY    CenterZ    LengthX    LengthY    LengthZ\n", comstr);
931      fprintf (f, "%s ---------- ---------- ---------- ---------- ---------- ---------- ----------\n", comstr);
# Line 1011 | Line 1011 | void write_light (FILE *f, char *name, Vector pos, Col
1011              if (name[0]) fprintf (f, "o %s\n", name);
1012              fprintf (f, "m\n\tsides 1\n\tc\n\t\t\tcmix %.3f R %.3f G %.3f B\n\ted %e\n",
1013                      CIE_Y_r*col.red, CIE_Y_g*col.green, CIE_Y_b*col.blue,
1014 <            10000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue));
1014 >            100000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue));
1015              fprintf (f, "v c =\n\tp %.4f %.4f %.4f\nsph c .01\n",
1016                      pos[X], pos[Y], pos[Z]);
1017              if (name[0]) fprintf (f, "o\n");
# Line 1086 | Line 1086 | void write_spot (FILE *f, char *name, Vector pos, Vect
1086              fprintf (f, "# hotspot: %.2f\n# falloff: %.2f\n", hotspot, falloff);
1087              fprintf (f, "m\n\tsides 1\n\tc\n\t\t\tcmix %.3f R %.3f G %.3f B\n\ted %e\n",
1088                      CIE_Y_r*col.red, CIE_Y_g*col.green, CIE_Y_b*col.blue,
1089 <            10000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue));
1089 >            100000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue));
1090              fprintf (f, "v c =\n\tp %.4f %.4f %.4f\n\tn %.4f %.4f %.4f\n",
1091                      pos[X], pos[Y], pos[Z],
1092                      target[X]-pos[X], target[Y]-pos[Y], target[Z]-pos[Z]);
# Line 1600 | Line 1600 | void write_mgf_material (FILE *f, MatProp *m)
1600   /* Write a mesh file */
1601   void write_mesh (FILE *f, Mesh *mesh)
1602   {
1603    FILE *fi;
1603      int i;
1604      char curmat[80];
1605      Vector va, vb, vc;
# Line 2376 | Line 2375 | void parse_3ds (Chunk *mainchunk)
2375  
2376      do  {
2377          start_chunk (&chunk);
2378 <
2378 >        if (feof(in)) {
2379 >                fprintf(stderr, "%s: unexpected EOF\n", progname);
2380 >                break;
2381 >        }
2382          if (chunk.end <= mainchunk->end) {
2383              switch (chunk.tag) {
2384                  case 0x3D3D: parse_mdata (&chunk);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines