home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Encyclopedia of Graphics File Formats Companion
/
GFF_CD.ISO
/
formats
/
ttddd
/
code
/
mbb.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-20
|
1KB
|
58 lines
/* mbb.c - simple little program to read in an Imagine object, and output
* - a few useful statistics
* - written by Glenn M. Lewis - 8/6/92
*/
static char rcs_id[] = "$Id: mbb.c,v 1.5 1993/01/31 19:26:31 glewis Exp $";
#include <stdio.h>
#include "t3dlib.h"
#ifdef __STDC__
#include <stdlib.h>
#include <strings.h>
#include "mbb_protos.h"
#endif
main(argc, argv)
int argc;
char *argv[];
{
int i;
FILE *inp, *fopen();
WORLD *world;
MBB *mbb;
for (i=1; i<argc; i++)
if (argv[i][0]=='-' && argv[i][1]=='h') goto USAGE;
if (argc>2) {
USAGE:
fprintf(stderr, "Usage: %s [file.iob]\n", argv[0]);
exit(-1);
}
if (argc==2) {
if (!(inp = fopen(argv[1], "r"))) {
fprintf(stderr, "Can't open '%s' for input.\n", argv[1]);
exit(-1);
}
} else inp = stdin;
world = read_World(inp);
calculate_MBB_world(world);
mbb = (MBB *)world->user;
fprintf(stdout, "MBB of object: (%.12g,%.12g,%.12g)-(%.12g,%.12g,%.12g)\n",
mbb->minx, mbb->miny, mbb->minz,
mbb->maxx, mbb->maxy, mbb->maxz);
fprintf(stdout, "Center of object: %.12g %.12g %.12g\n",
(mbb->minx+mbb->maxx)/2.0,
(mbb->miny+mbb->maxx)/2.0,
(mbb->minz+mbb->maxx)/2.0);
fprintf(stdout, "Size of object: %.12g %.12g %.12g\n",
mbb->maxx-mbb->minx,
mbb->maxy-mbb->minx,
mbb->maxz-mbb->minx);
exit(0);
}