1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
|
/* |
5 |
|
3DS2POV.C Copyright (c) 1996 Steve Anger and Jeff Bowermaster |
6 |
|
MGF output added by Greg Ward |
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> |
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) |
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]; |
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"); |
473 |
|
printf (" -b<object> - Convert this object as a box\n"); |
474 |
|
printf (" +i, -i - Turn internal bounding on or off\n"); |
475 |
|
printf (" +v, -v - Turn verbose status messages on or off\n"); |
476 |
< |
printf (" -op - Output to POV-Ray 2.0 format (default)\n"); |
476 |
> |
printf (" -op - Output to POV-Ray 2.0 format\n"); |
477 |
|
printf (" -op1 - Output to POV-Ray 1.0 format\n"); |
478 |
|
printf (" -ov - Output to Vivid format\n"); |
479 |
|
printf (" -ol - Output to poLyray format\n"); |
497 |
|
else if (!strcmp(progname, "3ds2raw")) |
498 |
|
format = RAW; |
499 |
|
else |
500 |
< |
format = MGF; /* default if program name strange */ |
500 |
> |
format = POV20; /* default if program name strange */ |
501 |
|
|
502 |
|
strcpy (inname, ""); |
503 |
|
strcpy (outname, ""); |
926 |
|
case MGF: |
927 |
|
comstr = "# "; |
928 |
|
break; |
929 |
+ |
default: |
930 |
+ |
printf ("Illegal format in write_summary() '%c'\n", format); |
931 |
+ |
exit(1); |
932 |
|
} |
933 |
|
fprintf (f, "%s Object CenterX CenterY CenterZ LengthX LengthY LengthZ\n", comstr); |
934 |
|
fprintf (f, "%s ---------- ---------- ---------- ---------- ---------- ---------- ----------\n", comstr); |
1014 |
|
if (name[0]) fprintf (f, "o %s\n", name); |
1015 |
|
fprintf (f, "m\n\tsides 1\n\tc\n\t\t\tcmix %.3f R %.3f G %.3f B\n\ted %e\n", |
1016 |
|
CIE_Y_r*col.red, CIE_Y_g*col.green, CIE_Y_b*col.blue, |
1017 |
< |
10000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue)); |
1017 |
> |
100000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue)); |
1018 |
|
fprintf (f, "v c =\n\tp %.4f %.4f %.4f\nsph c .01\n", |
1019 |
|
pos[X], pos[Y], pos[Z]); |
1020 |
|
if (name[0]) fprintf (f, "o\n"); |
1089 |
|
fprintf (f, "# hotspot: %.2f\n# falloff: %.2f\n", hotspot, falloff); |
1090 |
|
fprintf (f, "m\n\tsides 1\n\tc\n\t\t\tcmix %.3f R %.3f G %.3f B\n\ted %e\n", |
1091 |
|
CIE_Y_r*col.red, CIE_Y_g*col.green, CIE_Y_b*col.blue, |
1092 |
< |
10000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue)); |
1092 |
> |
100000.0*(CIE_Y_r*col.red + CIE_Y_g*col.green + CIE_Y_b*col.blue)); |
1093 |
|
fprintf (f, "v c =\n\tp %.4f %.4f %.4f\n\tn %.4f %.4f %.4f\n", |
1094 |
|
pos[X], pos[Y], pos[Z], |
1095 |
|
target[X]-pos[X], target[Y]-pos[Y], target[Z]-pos[Z]); |
1603 |
|
/* Write a mesh file */ |
1604 |
|
void write_mesh (FILE *f, Mesh *mesh) |
1605 |
|
{ |
1603 |
– |
FILE *fi; |
1606 |
|
int i; |
1607 |
|
char curmat[80]; |
1608 |
|
Vector va, vb, vc; |
2378 |
|
|
2379 |
|
do { |
2380 |
|
start_chunk (&chunk); |
2381 |
< |
|
2381 |
> |
if (feof(in)) { |
2382 |
> |
fprintf(stderr, "%s: unexpected EOF\n", progname); |
2383 |
> |
break; |
2384 |
> |
} |
2385 |
|
if (chunk.end <= mainchunk->end) { |
2386 |
|
switch (chunk.tag) { |
2387 |
|
case 0x3D3D: parse_mdata (&chunk); |