mah@hpuviea.UUCP (Michael Haberler) (03/03/89)
The QRT posting made it! At least I've got everything. Re: Viewing QRT output - I managed to change QRT so it generates the format used by the MTV raytracer, for which a couple of viewing programs recently were posted to this group. I tried drawpic which generates X11 output, and it works fine; a little dark still, though. - michael -- Michael Haberler mah@hpuviea.uucp Hewlett-Packard Austria GmbH, ...mcvax!tuvie!hpuviea!mah Lieblgasse 1 ...hplabs!hpfcla!hpbbn!hpuviea!mah A-1220 Vienna, Austria Tel: (0043) (222) 2500 x412 (9-18 CET)
ronbo@vixen.uucp (Ron Hitchens) (03/12/89)
In article <861@hpuviea.UUCP> mah@hpuviea.UUCP (Michael Haberler) writes: > Re: Viewing QRT output - I managed to change QRT so it generates the > format used by the MTV raytracer, for which a couple of viewing programs > recently were posted to this group. I tried drawpic which generates X11 > output, and it works fine; a little dark still, though. > > Michael Haberler mah@hpuviea.uucp > Hewlett-Packard Austria GmbH, ...mcvax!tuvie!hpuviea!mah > Lieblgasse 1 ...hplabs!hpfcla!hpbbn!hpuviea!mah > A-1220 Vienna, Austria Tel: (0043) (222) 2500 x412 (9-18 CET) Rather than hacking QRT to produce a different file format, it's better to use a post-processor to convert the output to the form you want. Below is a simple little filter to convert a QRT output file to the MTV format. It deals properly with subranges of scanlines. The QRT code as posted is configured for an Amiga, and somewhat strangely at that, so it will yield rather yucky results if you just compile and run it on something like a Sun where you want generic 24-bit color. Change these two constants in qrt.h: from: #define ASPECT 0.56 /* aspect ratio */ #define CNUM 100 /* this many shades/color */ to: #define ASPECT 1.00 /* aspect ratio */ #define CNUM 255 /* this many shades/color */ and at least these default settings in qrt.c (you may want to tweak some of the others as well): from: def.cinfo.amb.r = /* default ambiant light */ def.cinfo.amb.g = def.cinfo.amb.b = 25; def.threshold = .1; /* threshold at 10 percent */ to: def.cinfo.amb.r = /* default ambiant light */ def.cinfo.amb.g = def.cinfo.amb.b = CNUM / 4; def.threshold = CNUM / 10.0; /* threshold at 10 percent */ This will give you images that are well lit and which have the proper aspect ratio. Ron Hitchens ronbo@vixen.uucp hitchens@cs.utexas.edu ---- /* * Filter to convert the output of the QRT raytracer to the file * type produced by the MTV raytracer. The file format of QRT files is: * * <width> (two bytes, binary, Intel format (low-byte, high-byte)) * <height> (two bytes, same format) * (for each scanline) * <scanline#> (two bytes, same format as above) * <width> bytes of red data * <width> bytes of green data * <width> bytes of blue data * * Note: There may not be width*height*3 bytes of data in the file. * The scanline numbers can be a subrange of 0 to <height-1> * * The format of the file produced by the MTV raytracer is: * * width height\n (ascii strings in decimal, suitable for fscanf) * (for each scanline) * <width> triplets of red, green and blue bytes * * There will be width*height*3 bytes of image data following the \n * * This filter is a quick hack, it doesn't check memory allocations * for failure etc. It also takes the easy way out by sucking in the * entire file to deal with scanline subranges. A lot of memory could * be saved by peeking at the first scanline number, writing out the * initial missing scanlines, then processing each scanline from stdin * to stdout, then writing any missing trailing scanlines. But, since * *my* PC is a Sun 3/60C, I did it the easy way. * * Ron Hitchens, March 1989 ronbo@vixen.uucp, hitchens@cs.utexas.edu */ #include <stdio.h> extern char *malloc (); main (argc, argv) int argc; char **argv; { int width, height; char *image_24; char *r, *g, *b; int i; width = getchar(); /* Intel format, gag, puke */ width += getchar() << 8; height = getchar(); height += getchar() << 8; fprintf (stderr, "%dx%d\n", width, height); r = malloc (width); /* scanline buffers */ g = malloc (width); b = malloc (width); image_24 = malloc (width * height * 3); /* may not have data for every scanline, make everything black */ bzero (image_24, width * height * 3); fprintf (stderr, "loading QRT rgb data\n"); for (i = 0; i < height; i++) { register int j; int scan_line; register char *p; scan_line = getchar(); if (scan_line == EOF) { /* early EOF, that's ok */ break; } scan_line += getchar() << 8; fread (r, 1, width, stdin); fread (g, 1, width, stdin); fread (b, 1, width, stdin); p = &image_24 [scan_line * width * 3]; for (j = 0; j < width; j++) { *p++ = r [j]; *p++ = g [j]; *p++ = b [j]; } } free (r); free (g); free (b); fprintf (stderr, "dumping MTV rgb data\n"); fprintf (stdout, "%d %d\n", width, height); fwrite (image_24, 3, width * height, stdout); free (image_24); exit (0); }