| 31 |
|
static int lineno; /* current line number */ |
| 32 |
|
static int faceno; /* current face number */ |
| 33 |
|
|
| 34 |
< |
static int getstmt(); |
| 35 |
< |
static int cvtndx(); |
| 36 |
< |
static OBJECT getmod(); |
| 37 |
< |
static int putface(); |
| 38 |
< |
static int puttri(); |
| 39 |
< |
static void freeverts(); |
| 40 |
< |
static int newv(); |
| 41 |
< |
static int newvn(); |
| 42 |
< |
static int newvt(); |
| 43 |
< |
static void syntax(); |
| 34 |
> |
static int getstmt(char *av[MAXARG], FILE *fp); |
| 35 |
> |
static int cvtndx(VNDX vi, char *vs); |
| 36 |
> |
static int putface(int ac, char **av); |
| 37 |
> |
static OBJECT getmod(void); |
| 38 |
> |
static int puttri(char *v1, char *v2, char *v3); |
| 39 |
> |
static void freeverts(void); |
| 40 |
> |
static int newv(double x, double y, double z); |
| 41 |
> |
static int newvn(double x, double y, double z); |
| 42 |
> |
static int newvt(double x, double y); |
| 43 |
> |
static void syntax(char *er); |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
void |
| 47 |
< |
wfreadobj(objfn) /* read in .OBJ file and convert */ |
| 48 |
< |
char *objfn; |
| 47 |
> |
wfreadobj( /* read in .OBJ file and convert */ |
| 48 |
> |
char *objfn |
| 49 |
> |
) |
| 50 |
|
{ |
| 51 |
|
FILE *fp; |
| 52 |
|
char *argv[MAXARG]; |
| 53 |
|
int argc; |
| 54 |
|
int nstats, nunknown; |
| 54 |
– |
int i; |
| 55 |
|
|
| 56 |
|
if (objfn == NULL) { |
| 57 |
|
inpfile = "<stdin>"; |
| 157 |
|
|
| 158 |
|
|
| 159 |
|
static int |
| 160 |
< |
getstmt(av, fp) /* read the next statement from fp */ |
| 161 |
< |
register char *av[MAXARG]; |
| 162 |
< |
FILE *fp; |
| 160 |
> |
getstmt( /* read the next statement from fp */ |
| 161 |
> |
register char *av[MAXARG], |
| 162 |
> |
FILE *fp |
| 163 |
> |
) |
| 164 |
|
{ |
| 165 |
|
static char sbuf[MAXARG*16]; |
| 166 |
|
register char *cp; |
| 191 |
|
|
| 192 |
|
|
| 193 |
|
static int |
| 194 |
< |
cvtndx(vi, vs) /* convert vertex string to index */ |
| 195 |
< |
register VNDX vi; |
| 196 |
< |
register char *vs; |
| 194 |
> |
cvtndx( /* convert vertex string to index */ |
| 195 |
> |
register VNDX vi, |
| 196 |
> |
register char *vs |
| 197 |
> |
) |
| 198 |
|
{ |
| 199 |
|
/* get point */ |
| 200 |
|
vi[0] = atoi(vs); |
| 240 |
|
|
| 241 |
|
|
| 242 |
|
static int |
| 243 |
< |
putface(ac, av) /* put out an N-sided polygon */ |
| 244 |
< |
int ac; |
| 245 |
< |
register char **av; |
| 243 |
> |
putface( /* put out an N-sided polygon */ |
| 244 |
> |
int ac, |
| 245 |
> |
register char **av |
| 246 |
> |
) |
| 247 |
|
{ |
| 248 |
|
char *cp; |
| 249 |
|
register int i; |
| 262 |
|
|
| 263 |
|
|
| 264 |
|
static OBJECT |
| 265 |
< |
getmod() /* get current modifier ID */ |
| 265 |
> |
getmod(void) /* get current modifier ID */ |
| 266 |
|
{ |
| 267 |
|
char *mnam; |
| 268 |
|
OBJECT mod; |
| 288 |
|
|
| 289 |
|
|
| 290 |
|
static int |
| 291 |
< |
puttri(v1, v2, v3) /* convert a triangle */ |
| 292 |
< |
char *v1, *v2, *v3; |
| 291 |
> |
puttri( /* convert a triangle */ |
| 292 |
> |
char *v1, |
| 293 |
> |
char *v2, |
| 294 |
> |
char *v3 |
| 295 |
> |
) |
| 296 |
|
{ |
| 297 |
|
VNDX v1i, v2i, v3i; |
| 298 |
|
RREAL *v1c, *v2c, *v3c; |
| 299 |
|
RREAL *v1n, *v2n, *v3n; |
| 300 |
|
|
| 301 |
< |
if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3)) |
| 301 |
> |
if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3)) { |
| 302 |
> |
error(WARNING, "bad vertex reference"); |
| 303 |
|
return(0); |
| 304 |
< |
|
| 304 |
> |
} |
| 305 |
|
if (v1i[1]>=0 && v2i[1]>=0 && v3i[1]>=0) { |
| 306 |
|
v1c = vtlist[v1i[1]]; |
| 307 |
|
v2c = vtlist[v2i[1]]; |
| 322 |
|
|
| 323 |
|
|
| 324 |
|
static void |
| 325 |
< |
freeverts() /* free all vertices */ |
| 325 |
> |
freeverts(void) /* free all vertices */ |
| 326 |
|
{ |
| 327 |
|
if (nvs) { |
| 328 |
|
free((void *)vlist); |
| 340 |
|
|
| 341 |
|
|
| 342 |
|
static int |
| 343 |
< |
newv(x, y, z) /* create a new vertex */ |
| 344 |
< |
double x, y, z; |
| 343 |
> |
newv( /* create a new vertex */ |
| 344 |
> |
double x, |
| 345 |
> |
double y, |
| 346 |
> |
double z |
| 347 |
> |
) |
| 348 |
|
{ |
| 349 |
|
if (!(nvs%CHUNKSIZ)) { /* allocate next block */ |
| 350 |
|
if (nvs == 0) |
| 364 |
|
|
| 365 |
|
|
| 366 |
|
static int |
| 367 |
< |
newvn(x, y, z) /* create a new vertex normal */ |
| 368 |
< |
double x, y, z; |
| 367 |
> |
newvn( /* create a new vertex normal */ |
| 368 |
> |
double x, |
| 369 |
> |
double y, |
| 370 |
> |
double z |
| 371 |
> |
) |
| 372 |
|
{ |
| 373 |
|
if (!(nvns%CHUNKSIZ)) { /* allocate next block */ |
| 374 |
|
if (nvns == 0) |
| 390 |
|
|
| 391 |
|
|
| 392 |
|
static int |
| 393 |
< |
newvt(x, y) /* create a new texture map vertex */ |
| 394 |
< |
double x, y; |
| 393 |
> |
newvt( /* create a new texture map vertex */ |
| 394 |
> |
double x, |
| 395 |
> |
double y |
| 396 |
> |
) |
| 397 |
|
{ |
| 398 |
|
if (!(nvts%CHUNKSIZ)) { /* allocate next block */ |
| 399 |
|
if (nvts == 0) |
| 412 |
|
|
| 413 |
|
|
| 414 |
|
static void |
| 415 |
< |
syntax(er) /* report syntax error and exit */ |
| 416 |
< |
char *er; |
| 415 |
> |
syntax( /* report syntax error and exit */ |
| 416 |
> |
char *er |
| 417 |
> |
) |
| 418 |
|
{ |
| 419 |
|
sprintf(errmsg, "%s: Wavefront syntax error near line %d: %s\n", |
| 420 |
|
inpfile, lineno, er); |