| 10 |
|
* I'm not sure they work correctly. (Taken out -- see TEXMAPS defines.) |
| 11 |
|
*/ |
| 12 |
|
|
| 13 |
< |
#include "standard.h" |
| 13 |
> |
#include <stdlib.h> |
| 14 |
> |
#include <stdio.h> |
| 15 |
> |
#include <ctype.h> |
| 16 |
|
|
| 17 |
+ |
#include "rtmath.h" |
| 18 |
+ |
#include "rtio.h" |
| 19 |
+ |
#include "resolu.h" |
| 20 |
|
#include "trans.h" |
| 16 |
– |
|
| 21 |
|
#include "tmesh.h" |
| 22 |
|
|
| 19 |
– |
#include <ctype.h> |
| 23 |
|
|
| 24 |
|
#define PATNAME "M-pat" /* mesh pattern name (reused) */ |
| 25 |
|
#define TEXNAME "M-nor" /* mesh texture name (reused) */ |
| 68 |
|
|
| 69 |
|
int flatten = 0; /* discard surface normal information */ |
| 70 |
|
|
| 68 |
– |
char *getmtl(), *getonm(); |
| 69 |
– |
|
| 71 |
|
char mapname[128]; /* current picture file */ |
| 72 |
|
char matname[64]; /* current material name */ |
| 73 |
|
char group[16][32]; /* current group names */ |
| 76 |
|
int lineno; /* current line number */ |
| 77 |
|
int faceno; /* current face number */ |
| 78 |
|
|
| 79 |
+ |
static void getnames(FILE *fp); |
| 80 |
+ |
static void convert(FILE *fp); |
| 81 |
+ |
static int getstmt(char *av[MAXARG], FILE *fp); |
| 82 |
+ |
static char * getmtl(void); |
| 83 |
+ |
static char * getonm(void); |
| 84 |
+ |
static int matchrule(RULEHD *rp); |
| 85 |
+ |
static int cvtndx(VNDX vi, char *vs); |
| 86 |
+ |
static int nonplanar(int ac, char **av); |
| 87 |
+ |
static int putface(int ac, char **av); |
| 88 |
+ |
static int puttri(char *v1, char *v2, char *v3); |
| 89 |
+ |
static void freeverts(void); |
| 90 |
+ |
static int newv(double x, double y, double z); |
| 91 |
+ |
static int newvn(double x, double y, double z); |
| 92 |
+ |
static int newvt(double x, double y); |
| 93 |
+ |
static void syntax(char *er); |
| 94 |
|
|
| 95 |
< |
main(argc, argv) /* read in .obj file and convert */ |
| 96 |
< |
int argc; |
| 97 |
< |
char *argv[]; |
| 95 |
> |
|
| 96 |
> |
int |
| 97 |
> |
main( /* read in .obj file and convert */ |
| 98 |
> |
int argc, |
| 99 |
> |
char *argv[] |
| 100 |
> |
) |
| 101 |
|
{ |
| 102 |
|
int donames = 0; |
| 103 |
|
int i; |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
|
| 151 |
< |
getnames(fp) /* get valid qualifier names */ |
| 152 |
< |
FILE *fp; |
| 151 |
> |
void |
| 152 |
> |
getnames( /* get valid qualifier names */ |
| 153 |
> |
FILE *fp |
| 154 |
> |
) |
| 155 |
|
{ |
| 156 |
|
char *argv[MAXARG]; |
| 157 |
|
int argc; |
| 199 |
|
} |
| 200 |
|
|
| 201 |
|
|
| 202 |
< |
convert(fp) /* convert a T-mesh */ |
| 203 |
< |
FILE *fp; |
| 202 |
> |
void |
| 203 |
> |
convert( /* convert a T-mesh */ |
| 204 |
> |
FILE *fp |
| 205 |
> |
) |
| 206 |
|
{ |
| 207 |
|
char *argv[MAXARG]; |
| 208 |
|
int argc; |
| 305 |
|
|
| 306 |
|
|
| 307 |
|
int |
| 308 |
< |
getstmt(av, fp) /* read the next statement from fp */ |
| 309 |
< |
register char *av[MAXARG]; |
| 310 |
< |
FILE *fp; |
| 308 |
> |
getstmt( /* read the next statement from fp */ |
| 309 |
> |
register char *av[MAXARG], |
| 310 |
> |
FILE *fp |
| 311 |
> |
) |
| 312 |
|
{ |
| 313 |
|
extern char *fgetline(); |
| 314 |
|
static char sbuf[MAXARG*10]; |
| 340 |
|
|
| 341 |
|
|
| 342 |
|
char * |
| 343 |
< |
getmtl() /* figure material for this face */ |
| 343 |
> |
getmtl(void) /* figure material for this face */ |
| 344 |
|
{ |
| 345 |
|
register RULEHD *rp = ourmapping; |
| 346 |
|
|
| 366 |
|
|
| 367 |
|
|
| 368 |
|
char * |
| 369 |
< |
getonm() /* invent a good name for object */ |
| 369 |
> |
getonm(void) /* invent a good name for object */ |
| 370 |
|
{ |
| 371 |
|
static char name[64]; |
| 372 |
|
register char *cp1, *cp2; |
| 391 |
|
} |
| 392 |
|
|
| 393 |
|
|
| 394 |
< |
matchrule(rp) /* check for a match on this rule */ |
| 395 |
< |
register RULEHD *rp; |
| 394 |
> |
int |
| 395 |
> |
matchrule( /* check for a match on this rule */ |
| 396 |
> |
register RULEHD *rp |
| 397 |
> |
) |
| 398 |
|
{ |
| 399 |
|
ID tmpid; |
| 400 |
|
int gotmatch; |
| 444 |
|
} |
| 445 |
|
|
| 446 |
|
|
| 447 |
< |
cvtndx(vi, vs) /* convert vertex string to index */ |
| 448 |
< |
register VNDX vi; |
| 449 |
< |
register char *vs; |
| 447 |
> |
int |
| 448 |
> |
cvtndx( /* convert vertex string to index */ |
| 449 |
> |
register VNDX vi, |
| 450 |
> |
register char *vs |
| 451 |
> |
) |
| 452 |
|
{ |
| 453 |
|
/* get point */ |
| 454 |
|
vi[0] = atoi(vs); |
| 493 |
|
} |
| 494 |
|
|
| 495 |
|
|
| 496 |
< |
nonplanar(ac, av) /* are vertices non-planar? */ |
| 497 |
< |
register int ac; |
| 498 |
< |
register char **av; |
| 496 |
> |
int |
| 497 |
> |
nonplanar( /* are vertices non-planar? */ |
| 498 |
> |
register int ac, |
| 499 |
> |
register char **av |
| 500 |
> |
) |
| 501 |
|
{ |
| 502 |
|
VNDX vi; |
| 503 |
|
RREAL *p0, *p1; |
| 546 |
|
} |
| 547 |
|
|
| 548 |
|
|
| 549 |
< |
putface(ac, av) /* put out an N-sided polygon */ |
| 550 |
< |
int ac; |
| 551 |
< |
register char **av; |
| 549 |
> |
int |
| 550 |
> |
putface( /* put out an N-sided polygon */ |
| 551 |
> |
int ac, |
| 552 |
> |
register char **av |
| 553 |
> |
) |
| 554 |
|
{ |
| 555 |
|
VNDX vi; |
| 556 |
|
char *cp; |
| 581 |
|
} |
| 582 |
|
|
| 583 |
|
|
| 584 |
< |
puttri(v1, v2, v3) /* put out a triangle */ |
| 585 |
< |
char *v1, *v2, *v3; |
| 584 |
> |
int |
| 585 |
> |
puttri( /* put out a triangle */ |
| 586 |
> |
char *v1, |
| 587 |
> |
char *v2, |
| 588 |
> |
char *v3 |
| 589 |
> |
) |
| 590 |
|
{ |
| 591 |
|
char *mod; |
| 592 |
|
VNDX v1i, v2i, v3i; |
| 593 |
|
BARYCCM bvecs; |
| 594 |
|
RREAL bcoor[3][3]; |
| 595 |
< |
int texOK, patOK; |
| 595 |
> |
int texOK = 0, patOK; |
| 596 |
|
int flatness; |
| 597 |
|
register int i; |
| 598 |
|
|
| 675 |
|
} |
| 676 |
|
|
| 677 |
|
|
| 678 |
< |
freeverts() /* free all vertices */ |
| 678 |
> |
void |
| 679 |
> |
freeverts(void) /* free all vertices */ |
| 680 |
|
{ |
| 681 |
|
if (nvs) { |
| 682 |
|
free((void *)vlist); |
| 694 |
|
|
| 695 |
|
|
| 696 |
|
int |
| 697 |
< |
newv(x, y, z) /* create a new vertex */ |
| 698 |
< |
double x, y, z; |
| 697 |
> |
newv( /* create a new vertex */ |
| 698 |
> |
double x, |
| 699 |
> |
double y, |
| 700 |
> |
double z |
| 701 |
> |
) |
| 702 |
|
{ |
| 703 |
|
if (!(nvs%CHUNKSIZ)) { /* allocate next block */ |
| 704 |
|
if (nvs == 0) |
| 721 |
|
|
| 722 |
|
|
| 723 |
|
int |
| 724 |
< |
newvn(x, y, z) /* create a new vertex normal */ |
| 725 |
< |
double x, y, z; |
| 724 |
> |
newvn( /* create a new vertex normal */ |
| 725 |
> |
double x, |
| 726 |
> |
double y, |
| 727 |
> |
double z |
| 728 |
> |
) |
| 729 |
|
{ |
| 730 |
|
if (!(nvns%CHUNKSIZ)) { /* allocate next block */ |
| 731 |
|
if (nvns == 0) |
| 750 |
|
|
| 751 |
|
|
| 752 |
|
int |
| 753 |
< |
newvt(x, y) /* create a new texture map vertex */ |
| 754 |
< |
double x, y; |
| 753 |
> |
newvt( /* create a new texture map vertex */ |
| 754 |
> |
double x, |
| 755 |
> |
double y |
| 756 |
> |
) |
| 757 |
|
{ |
| 758 |
|
if (!(nvts%CHUNKSIZ)) { /* allocate next block */ |
| 759 |
|
if (nvts == 0) |
| 775 |
|
} |
| 776 |
|
|
| 777 |
|
|
| 778 |
< |
syntax(er) /* report syntax error and exit */ |
| 779 |
< |
char *er; |
| 778 |
> |
void |
| 779 |
> |
syntax( /* report syntax error and exit */ |
| 780 |
> |
char *er |
| 781 |
> |
) |
| 782 |
|
{ |
| 783 |
|
fprintf(stderr, "%s: Wavefront syntax error near line %d: %s\n", |
| 784 |
|
inpfile, lineno, er); |