| 1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* Generate renderable grids from a holodeck file |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include <stdio.h> |
| 9 |
+ |
|
| 10 |
+ |
#include "platform.h" |
| 11 |
+ |
#include "resolu.h" |
| 12 |
|
#include "holo.h" |
| 13 |
|
|
| 14 |
|
char *progname; /* global argv[0] */ |
| 16 |
|
char *mat, *name; /* material and object id */ |
| 17 |
|
double rad; /* grid line radius */ |
| 18 |
|
|
| 19 |
+ |
static void gridsect(char *fname, int sect); |
| 20 |
+ |
static void putgrid(HOLO *hp); |
| 21 |
+ |
static void putline(FVECT wp[2]); |
| 22 |
|
|
| 23 |
< |
main(argc, argv) |
| 24 |
< |
int argc; |
| 25 |
< |
char *argv[]; |
| 23 |
> |
|
| 24 |
> |
int |
| 25 |
> |
main( |
| 26 |
> |
int argc, |
| 27 |
> |
char *argv[] |
| 28 |
> |
) |
| 29 |
|
{ |
| 30 |
|
int sect; |
| 31 |
|
|
| 32 |
|
progname = argv[0]; |
| 33 |
< |
if (argc < 5 | argc > 6) |
| 33 |
> |
if ((argc < 5) | (argc > 6)) |
| 34 |
|
goto userr; |
| 35 |
|
mat = argv[1]; |
| 36 |
|
name = argv[2]; |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
|
| 50 |
< |
gridsect(fname, sect) /* get specified section(s) and print grids */ |
| 51 |
< |
char *fname; |
| 52 |
< |
int sect; |
| 50 |
> |
void |
| 51 |
> |
gridsect( /* get specified section(s) and print grids */ |
| 52 |
> |
char *fname, |
| 53 |
> |
int sect |
| 54 |
> |
) |
| 55 |
|
{ |
| 47 |
– |
extern long ftell(); |
| 56 |
|
FILE *fp; |
| 57 |
|
HOLO hdsect; |
| 58 |
|
int fd; |
| 59 |
< |
int4 nextloc; |
| 59 |
> |
int32 nextloc; |
| 60 |
|
int n; |
| 61 |
|
/* open holodeck file */ |
| 62 |
< |
if ((fp = fopen(fname, "r")) == NULL) { |
| 62 |
> |
if ((fp = fopen(fname, "rb")) == NULL) { |
| 63 |
|
sprintf(errmsg, "cannot open \"%s\"", fname); |
| 64 |
|
error(SYSTEM, errmsg); |
| 65 |
|
} |
| 72 |
|
nextloc = ftell(fp); /* get stdio position */ |
| 73 |
|
fclose(fp); /* done with stdio */ |
| 74 |
|
for (n = 0; nextloc > 0L; n++) { /* get the section(s) */ |
| 75 |
< |
lseek(fd, (long)nextloc, 0); |
| 75 |
> |
lseek(fd, (off_t)nextloc, SEEK_SET); |
| 76 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
| 77 |
< |
if (sect < 0 | n == sect) { |
| 77 |
> |
if ((sect < 0) | (n == sect)) { |
| 78 |
|
read(fd, (char *)&hdsect, sizeof(HDGRID)); |
| 79 |
|
hdcompgrid(&hdsect); |
| 80 |
|
putgrid(&hdsect); /* print grid */ |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
|
| 86 |
< |
putgrid(hp) /* run through holodeck section grid lines */ |
| 87 |
< |
register HOLO *hp; |
| 86 |
> |
void |
| 87 |
> |
putgrid( /* run through holodeck section grid lines */ |
| 88 |
> |
HOLO *hp |
| 89 |
> |
) |
| 90 |
|
{ |
| 91 |
< |
register int w, i; |
| 91 |
> |
int w, i; |
| 92 |
|
int g0, g1; |
| 93 |
|
FVECT wp[2], mov; |
| 94 |
|
double d; |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
< |
putline(wp) /* put out a line */ |
| 137 |
< |
register FVECT wp[2]; |
| 136 |
> |
void |
| 137 |
> |
putline( /* put out a line */ |
| 138 |
> |
FVECT wp[2] |
| 139 |
> |
) |
| 140 |
|
{ |
| 141 |
|
static int cnt = 0; |
| 142 |
|
|