Commit d6c20c52 authored by Tim Abbott's avatar Tim Abbott

Imported Upstream version 0.98~beta.dfsg

parents
This diff is collapsed.
/*
* Copyright (c) 1994-2007 John E. Stone
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by John E. Stone
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
README for Tachyon(tm) Parallel/Multiprocessor Ray Tracing Software
-------------------------------------------------------------------
Tachyon - 1967, from Greek "tachys", meaning "swift" or "speedy",
A hypothetical particle held to travel only faster than light.
Author: John E. Stone - johns@megapixel.com (preferred email address)
j.stone@acm.org (preferred email address)
johns@ks.uiuc.edu (work email address)
What is Tachyon??
-----------------
Tachyon is a result of my curiosities in computer graphics. Some of
it was written as part of my M.S. degree in Computer Science, other
parts of it were done purely for their entertainment value.
In this collection of software, you will find:
- A portable, high performance parallel ray tracing system supporting
MPI and multithreaded implementations. Tachyon is built as a
C callable library, which can be used with the included demo
programs or within your own application. The distribution
also includes a simple scene file parser front-end which reads
a few different formats.
- Tachyon implements all of the basic geometric primitives such as
triangles, planes, spheres, cylinders, etc. Some of the goals in
developing Tachyon were to make it fast and for it to parallelize
well. These are what set it apart from more full-featured programs
like POV-Ray, Rayshade, and others. Tachyon supports enough features
to be an excellent alternative to slower programs for demanding animation
and scientific visualization tasks. As time goes on, Tachyon will
indeed incorporate more features, but with a continued emphasis on
rendering performance.
- Example scenes for use with the ray tracer and previewer.
Note: some scenes require texture maps and/or volume data sets
which are distributed seperately due to their large size.
How do I compile and run Tachyon?
---------------------------------
The build process is quite simple. On Unix, just cd into the
unix directory and type "make", you'll see a long list of configurations
that can be built. This will work fine for almost all Unix systems.
If you wish to customize your build to enable optional features,
you'll need to edit Make-config. These are discussed in more
detail in the README file included in the unix directory.
On Windows, the process is as simple as loading up the project files
in the msvc subdirectory and building them.
All of the documentation, research papers, and seperately distributed
components related to this project can be retrieved from:
http://jedi.ks.uiuc.edu/~johns/raytracer/
In addition to the existing documentation, feel free to send me email
with questions on how things work, or for help getting things compiled
on platforms that aren't built into the makefiles that come with the
distribution.
How can I contribute to further development?
--------------------------------------------
I continue to work on this software in my free time. I depend
on other individuals or institutions to provide me access to
the various kinds of parallel computers Tachyon supports in
order to continue maintaining it on those platforms. If you
would like to see the software ported to a new parallel platform,
send me a note, and I'll work with you on it.
I would be happy to collaborate with others on extending
Tachyon for a wide variety of uses.
Copyrights etc.
---------------
All work included in this distribution is copyrighted by John E. Stone,
except where noted within specific source files. You may use this code
for any purpose you wish, as long as credit is given to its source(s).
Last updated January 20, 2007
John E. Stone
johns@megapixel.com
johns@ks.uiuc.edu
john.stone@gmail.com
/glwin.c/1.12/Fri Aug 10 05:53:08 2001//
/glwin.h/1.3/Mon Mar 5 06:42:58 2001//
/jsinterp.h/1.1/Sun Feb 23 06:06:59 1997//
/mainanim.c/1.14/Wed Dec 20 00:09:36 2000//
/mgfparse.h/1.2/Thu Dec 11 17:07:02 1997//
/nffparse.h/1.3/Sat Nov 1 13:45:53 1997//
/spaceball.c/1.2/Sun Aug 19 06:57:06 2001//
/spaceball.h/1.2/Sun Aug 19 06:57:06 2001//
/tgatoyuv.c/1.3/Fri May 1 01:14:50 1998//
/trackball.c/1.1/Sun Aug 19 05:57:17 2001//
/trackball.h/1.1/Sun Aug 19 05:57:17 2001//
/animskull.c/1.11/Wed Jul 3 21:20:08 2002//
/animspheres.c/1.13/Wed Jul 3 21:20:08 2002//
/animspheres2.c/1.11/Wed Jul 3 21:20:08 2002//
/hypertex.c/1.13/Wed Jul 3 21:20:09 2002//
/nffparse.c/1.12/Wed Jul 3 21:20:09 2002//
/ac3dparse.c/1.18/Mon Jul 29 04:31:27 2002//
/ac3dparse.h/1.7/Mon Jul 29 04:31:27 2002//
/mgfparse.c/1.13/Mon Jul 29 04:31:27 2002//
/parse.h/1.28/Mon Feb 5 03:36:35 2007//
/fire.c/1.22/Tue Feb 13 09:00:35 2007//
/getargs.c/1.42/Tue Feb 13 09:00:35 2007//
/getargs.h/1.19/Tue Feb 13 09:00:35 2007//
/main.c/1.72/Tue Feb 13 09:00:35 2007//
/parse.c/1.73/Fri Mar 9 21:10:33 2007//
D
johns@74.134.246.53:/home/johns/cvsroot
This diff is collapsed.
/*
* definitions for parsing ac3d modeler files
*
*/
#define PARSENOERR 0
#define PARSEBADFILE 1
#define PARSEBADSUBFILE 2
#define PARSEBADSYNTAX 4
#define PARSEEOF 8
#define PARSEALLOCERR 16
unsigned int ParseAC3D(char *, SceneHandle);
#ifdef PARSE_INTERNAL
#define NUMTEXS 8192
#define TEXNAMELEN 24
typedef float RotMat[3][3];
typedef float TransMat[3];
typedef struct {
char name[TEXNAMELEN];
void * tex;
} texentry;
typedef struct tri_list_t {
int v0; /* index of vertex 0 */
int v1; /* index of vertex 1 */
int v2; /* index of vertex 2 */
int smooth; /* smoothed or flat shaded flag */
int texnum; /* index of texture to use */
struct tri_list_t * next; /* pointer to next triangle */
} tri_list;
typedef unsigned int errcode;
static errcode add_texture(void * tex, char name[TEXNAMELEN]);
static void tlist_add_tri(tri_list ** tlist, int v0, int v1, int v2,
int smooth, int texnum);
static void tlist_delete(tri_list ** tlist);
static void clear_normals(apivector * normals, int numverts);
static void normalize(apivector * vec);
static void renormalize_normals(apivector * normals, int numverts);
static apivector tri_normal(apivector * v0, apivector * v1, apivector * v2);
static void gen_triangles(SceneHandle, tri_list * tlist, apivector * vertex,
apivector * normal);
static errcode GetMaterial(FILE *, SceneHandle);
static errcode GetString(FILE *, char *);
static errcode GetScenedefs(FILE *, SceneHandle);
static errcode GetScene(FILE *, SceneHandle);
static errcode GetObject(FILE *, SceneHandle);
#endif
/* main.c
* This file contains the main program and driver for the raytracer.
*
* $Id: animskull.c,v 1.11 2002/07/03 04:59:28 johns Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "tachyon.h"
int rt_mynode(void); /* proto */
typedef struct { /* Scalar Volume Visualization Data */
int loaded; /* Volume data memory residence flag */
int xres; /* volume X axis size */
int yres; /* volume Y axis size */
int zres; /* volume Z axis size */
apiflt opacity; /* opacity per unit length */
char name[80]; /* Volume data filename */
unsigned char * data; /* pointer to raw byte volume data */
} scalarvol;
#define MAXFRAMES 100
#define RAD 6.28
#ifdef cube
#define RFILE "/cfs/johns/anim/frame"
#endif
#ifndef cube
#define RFILE "outfile"
#endif
int main(int argc, char **argv) {
SceneHandle scene;
int i;
int xres, yres, raydepth, antialiasing, verbosemode;
apiflt zoom, aspectratio;
apivector Ccenter, Cview, Cup;
apivector ctr1;
apitexture tex1, tex2;
apivector min3, max3;
scalarvol vol;
apiflt xc,yc;
char fname[1000];
char fname2[2000];
rt_initialize(&argc, &argv);
scene = rt_newscene();
xres=256; yres=256;
aspectratio=1.0; raydepth=18;
antialiasing=1; verbosemode=0; zoom=1.0;
Ccenter.x=0.0; Ccenter.y=0.0; Ccenter.z=-8.0;
Cview.x=0.0; Cview.y=0.0; Cview.z=1.0;
Cup.x=0.0; Cup.y=-1.0; Cup.z=0.0;
ctr1.x=20.0; ctr1.y=20.0; ctr1.z=-40.0;
tex1.col.r=1.0; tex1.col.g=1.0; tex1.col.b=1.0;
tex1.ambient=1.0;
tex1.diffuse=0.0;
tex1.specular=0.0;
tex1.opacity=8.0;
tex1.texturefunc=0;
tex2=tex1;
min3.x=-1.0; min3.y=-1.0; min3.z=-0.40;
max3.x=1.0; max3.y=1.0; max3.z=0.40;
vol.loaded=0;
for (i=0; i<MAXFRAMES; i++) {
sprintf(fname,".%4.4d.tga",i);
strcpy(fname2,RFILE);
strcat(fname2, fname);
rt_initialize(&argc, &argv);
if (rt_mynode()==0) printf("Rendering: %s \n",fname2);
xc=cos(6.28 * i / (1.0 * MAXFRAMES));
yc=sin(6.28 * i / (1.0 * MAXFRAMES));
Ccenter.x = xc*3.0;
Ccenter.z = yc*3.0;
Cview.x = -xc;
Cview.z = -yc;
rt_outputfile(scene, fname2);
rt_resolution(scene, xres, yres);
rt_verbose(scene, verbosemode);
rt_camera_setup(scene, zoom, aspectratio, antialiasing,
raydepth, Ccenter, Cview, Cup);
rt_light(scene, rt_texture(scene, &tex1), ctr1, 1.0);
rt_scalarvol(scene, rt_texture(scene, &tex2), min3, max3, 256, 256, 100,
"/disk7/cube/vol/head.256x256x109", &vol);
rt_renderscene(scene);
}
rt_finalize();
return 0;
}
/* main.c
* This file contains the main program and driver for the raytracer.
*
* $Id: animspheres.c,v 1.13 2002/07/03 04:59:28 johns Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tachyon.h"
int rt_mynode(void); /* proto */
/* Number of frames to render */
#define MAXFRAMES 400
/* Number of bouncing spheres */
#define NUMSP 16
/* NTSC Resolution */
/* #define XRES 640
#define YRES 480
*/
/* MPEG-1 Resolution */
#define XRES 352
#define YRES 240
#define MAXX 1.0
#define MAXY 1.0
#define MAXZ 1.0
#define MINX -1.0
#define MINY -1.0
#define MINZ -1.0
#define LOOP 200.0
#define LOOP2 100.0
#define RAD 6.28
typedef struct {
apitexture tex;
apivector ctr;
apiflt rad;
apivector dir;
void * voidtex;
} asphere;
asphere sp[NUMSP];
apiflt randflt(void) {
long a;
apiflt f;
a=rand() % 1000;
f=(a*1.0) / 1000.0;
return f;
}
void initspheres(void) {
int i;
apiflt t1;
for (i=0; i<NUMSP; i++) {
sp[i].tex.col.r=randflt() / 3.0 + 0.66;
sp[i].tex.col.g=randflt() / 3.0 + 0.66;
sp[i].tex.col.b=randflt() / 3.0 + 0.66;
t1=randflt()*0.9;
sp[i].tex.ambient=0.1;
sp[i].tex.diffuse=t1;
sp[i].tex.specular=0.9 - t1;
sp[i].tex.opacity=1.0;
sp[i].tex.scale.x=1.0;
sp[i].tex.scale.y=1.0;
sp[i].tex.scale.z=1.0;
sp[i].tex.rot.x=0.0;
sp[i].tex.rot.y=0.0;
sp[i].tex.rot.z=0.0;
sp[i].tex.texturefunc=rand() % 7;
sp[i].ctr.x=randflt() * 2.0 - 1.0;
sp[i].ctr.y=randflt() * 2.0 - 1.0;
sp[i].ctr.z=randflt() * 2.0 - 1.0;
sp[i].rad=randflt()*0.5 + 0.05;
sp[i].dir.x=randflt() * 0.05 - 0.02;
sp[i].dir.y=randflt() * 0.05 - 0.02;
sp[i].dir.z=randflt() * 0.05 - 0.02;
}
}
void movesp(void) {
int i;
for (i=0; i<NUMSP; i++) {
sp[i].ctr.x += sp[i].dir.x;
sp[i].ctr.y += sp[i].dir.y;
sp[i].ctr.z += sp[i].dir.z;
if (sp[i].ctr.x > MAXX) {
sp[i].ctr.x = MAXX;
sp[i].dir.x = -sp[i].dir.x;
}
if (sp[i].ctr.x < MINX) {
sp[i].ctr.x = MINX;
sp[i].dir.x = -sp[i].dir.x;
}
if (sp[i].ctr.y > MAXY) {
sp[i].ctr.y = MAXY;
sp[i].dir.y = -sp[i].dir.y;
}
if (sp[i].ctr.y < MINY) {
sp[i].ctr.y = MINY;
sp[i].dir.y = -sp[i].dir.y;
}
if (sp[i].ctr.z > MAXZ) {
sp[i].ctr.z = MAXZ;
sp[i].dir.z = -sp[i].dir.z;
}
if (sp[i].ctr.z < MINZ) {
sp[i].ctr.z = MINZ;
sp[i].dir.z = -sp[i].dir.z;
}
sp[i].tex.ctr.x = sp[i].dir.x;
sp[i].tex.ctr.y = sp[i].dir.y;
sp[i].tex.ctr.z = sp[i].dir.z;
}
}
void drawsp(SceneHandle scene) {
int i;
apitexture p1;
apivector ct1, n1;
for (i=0; i<NUMSP; i++) {
sp[i].voidtex = rt_texture(scene, &sp[i].tex);
rt_sphere(scene, sp[i].voidtex, sp[i].ctr, sp[i].rad);
}
p1.col.r=1.0;
p1.col.g=1.0;
p1.col.b=1.0;
p1.ambient=0.1;
p1.diffuse=0.5;
p1.specular=0.4;
p1.opacity=1.0;
ct1.x=0.0;
ct1.y=-1.10;
ct1.z=0.0;
n1.x=0.0;
n1.y=1.0;
n1.z=0.0;
rt_plane(scene, rt_texture(scene, &p1), ct1, n1);
}
int main(int argc, char **argv) {
SceneHandle scene;
int i, j;
apivector Ccenter, Cview, Cup;
apivector ctr1, ctr2;
apitexture tex1, tex2;
void * vtx1, * vtx2;
char fname[100];
rt_initialize(&argc, &argv);
Ccenter.x=0.0; Ccenter.y=0.0; Ccenter.z=-3.0;
Cview.x=0.0; Cview.y=0.0; Cview.z=1.0;
Cup.x=0.0; Cup.y=1.0; Cup.z=0.0;
ctr1.x=20.0; ctr1.y=20.0; ctr1.z=-40.0;
ctr2.x=-20.0; ctr2.y=20.0; ctr2.z=-40.0;
tex1.col.r=1.0;
tex1.col.g=0.5;
tex1.col.b=0.0;
tex1.ambient=1.0;
tex1.opacity=1.0;
tex2=tex1;
tex2.col.r=0.0;
tex2.col.b=1.0;
initspheres();
for (i=0; i<MAXFRAMES; i++) {
scene = rt_newscene();
vtx1=rt_texture(scene, &tex1);
vtx2=rt_texture(scene, &tex2);
sprintf(fname,"outfile.%4.4d.tga",i);
if (rt_mynode()==0) printf("Rendering: %s\n", fname);
rt_outputfile(scene, fname);
rt_resolution(scene, XRES, YRES);
rt_verbose(scene, 0);
rt_camera_setup(scene, 1.0, 1.0, 0, 5, Ccenter, Cview, Cup);
movesp();
drawsp(scene);
rt_light(scene, vtx1, ctr1, 1.0);
rt_light(scene, vtx2, ctr2, 1.0);
rt_renderscene(scene);
rt_deletescene(scene);
for (j=0; j<NUMSP; j++)
free(sp[i].voidtex);
}
rt_finalize();
return 0;
}
/*
* This file contains the main program and driver for the raytracer.
*
* $Id: animspheres2.c,v 1.11 2002/07/03 04:59:29 johns Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "tachyon.h"
#define XRES 352
#define YRES 240
#define NUMSP 12
#define MYPI 3.1415926
#define MYTPI 6.282
int rt_mynode(void);
#define MAXFRAMES 400
#define MAXX 1.0
#define MAXY 1.0
#define MAXZ 1.0
#define MINX -1.0
#define MINY -1.0
#define MINZ -1.0
#define LOOP 200.0
#define LOOP2 100.0
#define RAD 6.28
#ifdef cube
#define RFILE "/cfs/johns/anim/frame"
#endif
#ifndef cube
#define RFILE "outfile"
#endif
typedef struct {
apitexture tex;
apivector ctr;
apiflt rad;
apivector dir;
} asphere;
asphere sp[NUMSP];
apiflt randflt(void) {
long a;
apiflt f;
a=rand() % 1000;
f=(a*1.0) / 1000.0;
return f;
}
void initspheres(void) {
int i;
apiflt t1;
for (i=0; i<NUMSP; i++) {
sp[i].tex.col.r=randflt() / 3.0 + 0.66;
sp[i].tex.col.g=randflt() / 3.0 + 0.66;
sp[i].tex.col.b=randflt() / 3.0 + 0.66;
t1=randflt()*0.9;
sp[i].tex.ambient=0.1;
sp[i].tex.diffuse=t1;
sp[i].tex.specular=0.9 - t1;
sp[i].tex.opacity=1.0;
sp[i].tex.scale.x=1.0;
sp[i].tex.scale.y=1.0;
sp[i].tex.scale.z=1.0;
sp[i].tex.rot.x=0.0;
sp[i].tex.rot.y=