1 /*
2 * mainanim.c - This file contains an animation driver for the raytracer.
3 *
4 * $Id: mainanim.c,v 1.14 2000/12/20 00:09:36 johns Exp $
5 */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <math.h>
11 #include "tachyon.h"
12
13 int rt_mynode(void); /* proto */
14
15 #define MAXFRAMES 100
16 #define LOOP 100.0
17 #define LOOP2 50.0
18 #define RAD 6.28
19
20 #ifdef cube
21 #define RFILE "/cfs/johns/anim/frame"
22 #else
23 #define RFILE "outfile"
24 #endif
25
main(int argc,char ** argv)26 int main(int argc, char **argv) {
27 SceneHandle scene;
28 int i,j;
29 apivector ctr, ctr1, vect2;
30 apitexture tex1, tex2;
31 apiflt f1, f2;
32 char fname[200];
33 char fname2[200];
34
35 rt_initialize(&argc, &argv);
36
37 tex1.col.r=1.0;
38 tex1.col.g=1.0;
39 tex1.col.b=1.0;
40 ctr1.x=5.0;
41 ctr1.y=5.0;
42 ctr1.z=1.0;
43 f1=0.5;
44
45 tex2.col.r=1.0;
46 tex2.col.g=1.0;
47 tex2.col.b=1.0;
48 tex2.ambient=0.1;
49 tex2.diffuse=0.7;
50 tex2.specular=0.2;
51 tex2.opacity=1.0;
52 tex2.texturefunc=0;
53 f2=1.5;
54
55 vect2.x=0.0;
56 vect2.y=1.0;
57 vect2.z=0.0;
58
59 for (i=0; i<MAXFRAMES; i++) {
60 void * txarray[20];
61
62 scene = rt_newscene();
63 rt_resolution(scene, 320, 240);
64
65 #ifdef cube
66 if (rt_mynode()==0) printf("Rendering frame %d \n",i);
67 #endif
68 #ifndef cube
69 printf("Rendering frame %d \n",i);
70 #endif
71 ctr1.x= i / 20.0 - 5.0;
72 ctr1.y=5.0;
73 ctr1.z= i / 20.0 + 5.0;
74 tex1.col.r=1.0;
75 tex1.col.g=1.0;
76 tex1.col.b=1.0;
77 txarray[0] = rt_texture(scene, &tex1);
78 rt_light(scene, txarray[0], ctr1, f1);
79
80 ctr1.x= i / 15.0 - 5.0;
81 ctr1.y=0.0;
82 ctr1.z=15.0;
83 tex1.col.r=0.0;
84 tex1.col.g=0.0;
85 tex1.col.b=1.0;
86 txarray[1] = rt_texture(scene, &tex1);
87 rt_light(scene, txarray[1], ctr1, f1 / 3.0 );
88
89 j=i;
90 tex2.col.r=1.0;
91 tex2.texturefunc=0;
92 ctr.x=2.0*sin((j*RAD) / LOOP);
93 ctr.z=10.0 + 2.0*cos((j*RAD) / LOOP);
94 ctr.y=-2.0;
95
96 txarray[2] = rt_texture(scene, &tex2);
97 rt_sphere(scene, txarray[2], ctr, f2);
98
99 tex2.texturefunc=0;
100 j=i+(MAXFRAMES/3);
101 tex2.col.r=0.5 + 0.5*sin((j*RAD)/ LOOP2);
102 ctr.x=2.0*sin((j*RAD) / LOOP);
103 ctr.z=10.0 + 2.0*cos((j*RAD) / LOOP);
104 ctr.y=-2.0;
105
106 txarray[3] = rt_texture(scene, &tex2);
107 rt_sphere(scene, txarray[3], ctr, f2);
108
109 j=i+((MAXFRAMES * 2)/3);
110 tex2.col.r=1.0;
111 tex2.col.b=0.5 + 0.5*sin((j*RAD)/ LOOP2);
112 ctr.x=2.0*sin((j*RAD) / LOOP);
113 ctr.z=10.0 + 2.0*cos((j*RAD) / LOOP);
114 ctr.y=-2.0;
115
116 txarray[4] = rt_texture(scene, &tex2);
117 rt_sphere(scene, txarray[4], ctr, f2);
118
119 tex2.col.r=0.0;
120 tex2.col.b=1.0;
121 tex2.ambient=0.0;
122 tex2.diffuse=0.0;
123 tex2.specular=0.99;
124
125 ctr.x=0.0;
126 ctr.y=-2.0;
127 ctr.z=10.0;
128
129 txarray[5] = rt_texture(scene, &tex2);
130 rt_sphere(scene, txarray[5], ctr, f2);
131
132
133 tex2.diffuse=0.8;
134 tex2.ambient=0.1;
135 tex2.specular=0.2;
136 tex2.col.r=1.0;
137 ctr.y=-7.0;
138
139 txarray[6] = rt_texture(scene, &tex2);
140 rt_plane(scene, txarray[6], ctr, vect2);
141
142
143 sprintf(fname,".%4.4d.tga",i);
144 strcpy(fname2, RFILE);
145 strcat(fname2, fname);
146
147 rt_outputfile(scene, fname2);
148
149 rt_renderscene(scene);
150
151 rt_deletescene(scene);
152
153 for (j=0; j<7; j++)
154 free(txarray[j]);
155 }
156
157 rt_finalize();
158
159 return 0;
160 }
161
162