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.4 by greg, Thu May 30 11:56:43 1996 UTC vs.
Revision 1.10 by greg, Mon Nov 10 19:08:18 2008 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 458 | Line 457 | void process_args (int argc, char *argv[])
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");
462 < #ifdef __GNUC__
463 <    printf ("32 bit version. DOS extender Copyright (c) 1991 DJ Delorie\n");
464 < #endif
460 >    printf("Version 2.0 by Steve Anger and Jeff Bowermaster 1996\n");
461      printf ("\n");
462  
463      if (argc < 2) {
# Line 927 | 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 1601 | Line 1600 | void write_mgf_material (FILE *f, MatProp *m)
1600   /* Write a mesh file */
1601   void write_mesh (FILE *f, Mesh *mesh)
1602   {
1604    FILE *fi;
1603      int i;
1604      char curmat[80];
1605      Vector va, vb, vc;
# Line 2952 | Line 2950 | dword read_dword()
2950  
2951   float read_float()
2952   {
2953 +    union { dword i; char c[8]; } u;
2954      dword data;
2955  
2956      data = read_dword();
2957  
2958 <    return *(float *)&data;
2958 >    if (sizeof(dword) == sizeof(float))
2959 >        return *(float *)&data;
2960 >
2961 >    u.i = 1;
2962 >    if (u.c[0] == 0)
2963 >        return *(float *)&data; /* assume big-endian */
2964 >
2965 >    if (sizeof(dword) != 2*sizeof(float)) {
2966 >        fputs("Unsupported word length\n", stderr);
2967 >        exit(1);
2968 >    }
2969 >    u.i = data;
2970 >    return *(float *)&u.c[4];
2971   }
2972  
2973  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines