Tachyon (current)  Current Main Branch
main.c
Go to the documentation of this file.
1 /*
2  * main.c - This file contains the Tachyon main program.
3  *
4  * (C) Copyright 1994-2022 John E. Stone
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * $Id: main.c,v 1.120 2022/03/07 20:01:26 johns Exp $
8  *
9  */
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <ctype.h>
14 #include <string.h>
15 
16 #include "tachyon.h" /* The Tachyon ray tracing library API */
17 #include "getargs.h" /* command line argument/option parsing */
18 #include "parse.h" /* Support for my own scene file format */
19 #include "nffparse.h" /* Support for NFF files, as in SPD */
20 #include "ac3dparse.h" /* Support for AC3D files */
21 #include "mgfparse.h" /* Support for MGF files */
22 
23 #ifdef USEOPENGL
24 #include "glwin.h" /* OpenGL run-time display code */
25 
26 #if defined(_MSC_VER)
27 #include <windows.h>
28 #else
29 #include <X11/Xlib.h>
30 #endif
31 #include <GL/gl.h>
32 #endif
33 
34 #include "spaceball.h" /* Spaceball fly-through code */
35 
36 typedef struct {
37  float x;
38  float y;
39  float z;
40 } floatvec;
41 
42 
43 typedef struct {
44  int oxsize, oysize;
45  int xsize, ysize, fson;
46 #if defined(USEOPENGL)
47  unsigned char * img;
48  void * glwin;
49 #endif
50 } dispHandle;
51 
52 
53 #if defined(ANDROID)
54 
55 int ray(int argc, char **argv); /* provide a prototype... */
56 
57 /*
58  * Tachyon is wrapped in a JNI shared object and called by Java...
59  */
60 #include <jni.h>
61 
62 #if !defined(TACHYON_JNI_CLASSNAME)
63 #define TACHYON_JNI_CLASSNAME "com/photonlimited/Tachyon/Tachyon"
64 #endif
65 #if !defined(TACHYON_JNI_WRAPFUNC)
66 #define TACHYON_JNI_WRAPFUNC Java_com_photonlimited_Tachyon_Tachyon_nativeMain
67 #endif
68 
69 void logtojava(JNIEnv *env, jobject thiz, const char *logstring) {
70 #if 1
71  // c version JNI interface:
72  jclass clazz = (*env)->FindClass(env, TACHYON_JNI_CLASSNAME);
73 
74  jmethodID logOutput = (*env)->GetMethodID(env, clazz, "logOutput",
75  "(Ljava/lang/String;)V");
76 
77  /* this actually logs a char*, logstring */
78  (*env)->CallVoidMethod(env, thiz, logOutput, (*env)->NewStringUTF(env, logstring));
79 #else
80  // c++ version JNI interface:
81  jclass clazz = (env)->FindClass(TACHYON_JNI_CLASSNAME);
82  jmethodID logOutput = (env)->GetMethodID(clazz, "logOutput",
83  "(Ljava/lang/String;)V");
84 
85  /* this actually logs a char*, logstring */
86  (env)->CallVoidMethod(thiz, logOutput, (env)->NewStringUTF(logstring));
87 #endif
88 }
89 
90 /* XXX gross disgusting hack!!!! */
91 JNIEnv *global_jnienv; /* XXX hack! */
92 jobject global_thiz; /* XXX hack! */
93 
94 /*
95  * This is the main JNI wrapper function.
96  * Contains startup code, neverending loop, shutdown code, etc...
97  */
98 void TACHYON_JNI_WRAPFUNC(JNIEnv* env, jobject thiz ) {
99  char* rargv[10];
100 
101  global_jnienv = env; /* XXX this is a hack! */
102  global_thiz = thiz; /* XXX this is a hack! */
103 
104  fprintf(stderr, "--stderr fprintf---------------------------------\n");
105  printf("---regular printf----------------------------\n");
106  fflush(stdout);
107  logtojava(global_jnienv, global_thiz, "--Log event ---------------------\n");
108 
109 #if 0
110  printf("Android platform info:\n");
111  printf(" sizeof(char): %d\n", sizeof(char));
112  printf(" sizeof(int): %d\n", sizeof(int));
113  printf(" sizeof(long): %d\n", sizeof(long));
114  printf(" sizeof(void*): %d\n", sizeof(void*));
115  fflush(stdout);
116 #endif
117 
118  rargv[0] = "tachyon.so";
119  rargv[1] = "/sdcard/balls.dat";
120  rargv[2] = "-o";
121  rargv[3] = "/sdcard/outfile.tga";
122  rargv[4] = "+V";
123  rargv[5] = NULL;
124 
125  ray(5, rargv); /* launch Tachyon... */
126 
127  logtojava(global_jnienv, global_thiz, "--Log event ---------------------\n");
128  fprintf(stderr, "--stderr fprintf---------------------------------\n");
129  printf("---regular printf----------------------------\n");
130  fflush(stdout);
131 }
132 
133 static void my_ui_message(int a, char * msg) {
134  char logstring[256];
135  strncpy(logstring, msg, sizeof(logstring)-2);
136  strcat(logstring, "\n");
137 
138  logtojava(global_jnienv, global_thiz, logstring);
139 }
140 
141 static void my_ui_progress(int percent) {
142  logtojava(global_jnienv, global_thiz, ".");
143 #if 0
144  printf("\rRendering Progress: %3d%% complete \r", percent);
145  fflush(stdout);
146 #endif
147 }
148 
149 #else /* not ANDROID */
150 
151 /*
152  * Normal Tachyon build...
153  */
154 static void my_ui_message(int a, char * msg) {
155  printf("%s\n", msg);
156 }
157 
158 static void my_ui_progress(int percent) {
159  printf("\rRendering Progress: %3d%% complete \r", percent);
160  fflush(stdout);
161 }
162 
163 #endif
164 
165 
166 
167 #if defined(USEOPENGL)
168 /*
169  * routines for managing runtime display of ray traced scene
170  */
171 static int tachyon_display_reshape(dispHandle *dh) {
172  float wscalex, wscaley, wminscale;
173  float wxoffset, wyoffset;
174  int wsx, wsy, instereo, maxx, maxy;
175 
176  glwin_get_wininfo(dh->glwin, &instereo, NULL);
177  glwin_get_winsize(dh->glwin, &wsx, &wsy);
178  maxx=dh->xsize;
179  maxy=dh->ysize;
180  wscalex = wsx / (float) maxx;
181  wscaley = wsy / (float) maxy;
182  wminscale = (wscalex < wscaley) ? wscalex : wscaley;
183  wxoffset = ((wminscale * maxx) - wsx) / 2.0f;
184  wyoffset = ((wminscale * maxy) - wsy) / 2.0f;
185 
186  glDrawBuffer(GL_BACK);
187  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
188  glClearColor(0.0, 0.0, 0.0, 1.0); /* black */
189  glViewport(0, 0, wsx, wsy);
190  glClear(GL_COLOR_BUFFER_BIT);
191 
192  glShadeModel(GL_FLAT);
193  glViewport((int) -wxoffset, (int) -wyoffset, wsx, wsy);
194  glMatrixMode(GL_PROJECTION);
195  glLoadIdentity();
196  glOrtho(0.0, wsx, 0.0, wsy, -1.0, 1.0); /* flip upside-down Tachyon image */
197 
198  glMatrixMode(GL_MODELVIEW);
199  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
200  glPixelZoom(wminscale, wminscale); /* flip upside-down Tachyon image */
201 
202  return 0;
203 }
204 #endif
205 
206 
208  dispHandle * dh = (dispHandle *) malloc(sizeof(dispHandle));
209  if (dh != NULL) {
210  memset(dh, 0, sizeof(dispHandle));
211  /* record original image resolution for restoration if needed */
212  rt_get_resolution(scene, &dh->oxsize, &dh->oysize);
213  /* record current image resolution */
214  dh->xsize=dh->oxsize;
215  dh->ysize=dh->oysize;
216  dh->fson=0;
217 
218 #if defined(USEOPENGL)
219  dh->img = (unsigned char *) malloc((dh->xsize)*(dh->ysize)*3);
220  if (dh->img != NULL) {
221  rt_rawimage_rgb24(scene, dh->img);
222 
223  dh->glwin = glwin_create("Tachyon Parallel/Multiprocessor Ray Tracer", dh->xsize, dh->ysize);
224  tachyon_display_reshape(dh);
225  } else {
226  printf("Couldn't allocate image buffer for framebuffer display!!\n");
227  free(dh);
228  return NULL;
229  }
230 #endif
231  }
232 
233  return dh;
234 }
235 
236 
238 #if defined(USEOPENGL)
239  if (dh->img != NULL) {
240  /* handle redraw events */
241  while (glwin_handle_events(dh->glwin, GLWIN_EV_POLL_NONBLOCK)) {
242  int evdev, evval;
243  char evkey;
244  int wsx, wsy, instereo;
245  glwin_get_lastevent(dh->glwin, &evdev, &evval, &evkey);
246  glwin_get_wininfo(dh->glwin, &instereo, NULL);
247  glwin_get_winsize(dh->glwin, &wsx, &wsy);
248 
249  if (evdev == GLWIN_EV_KBD) {
250  switch (evkey) {
251  case 'q':
252  case 'Q':
253  case 0x1b: /* ESC key */
254  return 1; /* exit from program */
255  break;
256 
257  case 'f':
258  case 'F':
259  /* toggle fullscreen state */
260  dh->fson = (!dh->fson);
261  if (glwin_fullscreen(dh->glwin, dh->fson, 0) == 0) {
262  printf("Toggling fullscreen mode %s...\n",
263  (dh->fson) ? "on" : "off");
264  } else {
265  printf("Fullscreen mode not available...\n");
266  }
267  break;
268 
269 #if 0
270  default:
271  printf("ignored keypress %0x: '%c'\n",
272  evkey, (isalnum(evkey)) ? evkey : '\0');
273  break;
274 #endif
275  }
276  }
277 
278  tachyon_display_reshape(dh);
279  glwin_draw_image(dh->glwin, dh->xsize, dh->ysize, dh->img);
280 
281  if (evdev == GLWIN_EV_KBD) {
282  switch (evkey) {
283  case 'n':
284  case 'N':
285  dh->xsize = dh->oxsize;
286  dh->ysize = dh->oysize;
287  free(dh->img);
288  dh->img = (unsigned char *) calloc(1, dh->xsize*dh->ysize*3);
289  rt_rawimage_rgb24(scene, dh->img);
290  rt_resolution(scene, dh->xsize, dh->ysize);
291  glwin_resize(dh->glwin, dh->xsize, dh->ysize);
292  tachyon_display_reshape(dh);
293  break;
294 
295  case 'r':
296  case 'R':
297  free(dh->img);
298  dh->img = (unsigned char *) calloc(1, wsx*wsy*3);
299  rt_rawimage_rgb24(scene, dh->img);
300  rt_resolution(scene, wsx, wsy);
301  dh->xsize = wsx;
302  dh->ysize = wsy;
303  tachyon_display_reshape(dh);
304  break;
305 
306  case ']':
307  dh->xsize *= 2;
308  dh->ysize *= 2;
309  free(dh->img);
310  dh->img = (unsigned char *) calloc(1, dh->xsize*dh->ysize*3);
311  rt_rawimage_rgb24(scene, dh->img);
312  rt_resolution(scene, dh->xsize, dh->ysize);
313  glwin_resize(dh->glwin, dh->xsize, dh->ysize);
314  tachyon_display_reshape(dh);
315  break;
316 
317  case '>':
318  dh->xsize *= 1.5;
319  dh->ysize *= 1.5;
320  free(dh->img);
321  dh->img = (unsigned char *) calloc(1, dh->xsize*dh->ysize*3);
322  rt_rawimage_rgb24(scene, dh->img);
323  rt_resolution(scene, dh->xsize, dh->ysize);
324  glwin_resize(dh->glwin, dh->xsize, dh->ysize);
325  tachyon_display_reshape(dh);
326  break;
327 
328  case '[':
329  dh->xsize /= 2;
330  dh->ysize /= 2;
331  free(dh->img);
332  dh->img = (unsigned char *) calloc(1, dh->xsize*dh->ysize*3);
333  rt_rawimage_rgb24(scene, dh->img);
334  rt_resolution(scene, dh->xsize, dh->ysize);
335  glwin_resize(dh->glwin, dh->xsize, dh->ysize);
336  tachyon_display_reshape(dh);
337  break;
338 
339  case '<':
340  dh->xsize /= 1.5;
341  dh->ysize /= 1.5;
342  free(dh->img);
343  dh->img = (unsigned char *) calloc(1, dh->xsize*dh->ysize*3);
344  rt_rawimage_rgb24(scene, dh->img);
345  rt_resolution(scene, dh->xsize, dh->ysize);
346  glwin_resize(dh->glwin, dh->xsize, dh->ysize);
347  tachyon_display_reshape(dh);
348  break;
349  }
350  }
351  }
352 
353  glwin_draw_image(dh->glwin, dh->xsize, dh->ysize, dh->img);
354  }
355 
356 #endif
357 
358  return 0;
359 }
360 
362 #if defined(USEOPENGL)
363  if (dh->img != NULL) {
364  glwin_destroy(dh->glwin);
365  free(dh->img);
366  }
367 #endif
368 }
369 
370 
371 /*
372  * main loop for creating animations by flying using a spaceball
373  * or other 3-D input mechanism.
374  */
375 static int fly_scene(argoptions opt, SceneHandle scene, int node) {
376  dispHandle * dh = NULL;
377  int done = 0;
378  int frameno = 0;
379  float fps = 0.0f;
380  float fpsexpave = 0.0f;
381  rt_timerhandle fpstimer;
382  rt_timerhandle animationtimer;
383  char outfilename[1];
384 #if defined(USEOPENGL)
385  sbHandle * bh = NULL;
386 #endif
387 
388  if (node == 0)
389  dh = tachyon_display_create(scene);
390 #if defined(USEOPENGL)
391  else
392  rt_rawimage_rgb24(scene, NULL); /* must match node 0 image depth */
393 #endif
394 
395  rt_set_ui_message(NULL);
396  rt_set_ui_progress(NULL);
397 
398  if (node == 0)
399  printf("Interactive Camera Flight\n");
400 
401  outfilename[0] = '\0';
402  rt_outputfile(scene, outfilename);
403 
404  fpstimer=rt_timer_create();
405  animationtimer=rt_timer_create();
406 
407 #if defined(USEOPENGL)
408  if (node == 0) {
409 #if 1
410  bh = tachyon_init_spaceball(scene, dh->glwin, opt.spaceballport);
411 #else
412  if (rt_numnodes() < 2) {
413  bh = tachyon_init_spaceball(scene, dh->glwin, opt.spaceballport);
414  } else {
415  printf("WARNING: Spaceball mode disabled when running with distributed memory");
416  }
417 #endif
418  }
419 #endif
420 
421 #if defined(RT_ACCUMULATE_ON)
423 #endif
424 
425  rt_timer_start(animationtimer);
426  while (!done) {
427  if (frameno != 0) {
428  rt_timer_stop(fpstimer);
429  fps = 1.0f / (float) (rt_timer_time(fpstimer) + 0.00001f);
430  } else {
431  fps = 0.0f;
432  }
433 
434  /* compute exponential moving average for exp(-1/10) */
435  fpsexpave = (fpsexpave * 0.90f) + (fps * 0.10f);
436 
437  rt_timer_start(fpstimer);
438  if (node == 0) {
439  printf("\rRendering Frame: %9d %.1f FPS ", frameno, fpsexpave);
440  fflush(stdout);
441  }
442 
443 #if defined(USEOPENGL)
444  if (bh != NULL)
445  done = tachyon_spaceball_update(bh, scene);
446 #endif
447 
448  rt_renderscene(scene);
449 
450  if (dh != NULL) {
451  int rc = tachyon_display_draw(scene, dh);
452  if (rc != 0)
453  done=1;
454  }
455  frameno++;
456  }
457 
458  rt_timer_stop(animationtimer);
459  fps = frameno / (float) rt_timer_time(animationtimer);
460 
461  if (node == 0) {
462  printf("\rCompleted animation of %d frames \n", frameno);
463  printf("Animation Time: %10.4f seconds (Averaged %.1f FPS)\n",
464  rt_timer_time(animationtimer), fps);
465  }
466  rt_timer_destroy(fpstimer);
467 
468  if (node == 0) {
469  printf("\nFinished Running Camera.\n");
470 
471  if (dh !=NULL)
473  }
474 
475  rt_deletescene(scene); /* free the scene */
476  rt_finalize(); /* close down the rendering library and MPI */
477 
478  return 0;
479 }
480 
481 
482 
483 /*
484  * main loop for creating animations by playing recorded camera fly-throughs
485  */
486 static int animate_scene(argoptions opt, SceneHandle scene, int node) {
487  char outfilename[1000];
488  FILE * camfp;
489  dispHandle * dh = NULL;
490 
491  if (node == 0)
492  dh = tachyon_display_create(scene);
493 #if defined(USEOPENGL)
494  else
495  rt_rawimage_rgb24(scene, NULL); /* must match node 0 image depth */
496 #endif
497 
498  /* if we have a camera file, then animate.. */
499  if ((camfp = fopen(opt.camfilename, "r")) != NULL) {
500  floatvec cv, cu, cc;
501  apivector cmv, cmu, cmc;
502  int frameno=0;
503  int done=0;
504  float fps;
505  rt_timerhandle fpstimer;
506  rt_timerhandle animationtimer;
507 
508  rt_set_ui_message(NULL);
509  rt_set_ui_progress(NULL);
510 
511  if (node == 0)
512  printf("Running Camera File: %s\n", opt.camfilename);
513 
514  fpstimer=rt_timer_create();
515  animationtimer=rt_timer_create();
516 
517  rt_timer_start(animationtimer);
518 
519  while (!feof(camfp) && !done) {
520  fscanf(camfp, "%f %f %f %f %f %f %f %f %f",
521  &cv.x, &cv.y, &cv.z, &cu.x, &cu.y, &cu.z, &cc.x, &cc.y, &cc.z);
522 
523  cmv.x = cv.x; cmv.y = cv.y; cmv.z = cv.z;
524  cmu.x = cu.x; cmu.y = cu.y; cmu.z = cu.z;
525  cmc.x = cc.x; cmc.y = cc.y; cmc.z = cc.z;
526 
527  if (frameno != 0) {
528  rt_timer_stop(fpstimer);
529  fps = 1.0f / (float) rt_timer_time(fpstimer);
530  } else {
531  fps = 0.0f;
532  }
533 
534  rt_timer_start(fpstimer);
535  outfilename[0] = '\0';
536  if (opt.nosave == 1) {
537  if (node == 0) {
538  printf("\rRendering Frame: %9d %.1f FPS ", frameno, fps);
539  fflush(stdout);
540  }
541  } else {
542  sprintf(outfilename, opt.outfilename, frameno);
543  if (node == 0) {
544  printf("\rRendering Frame to %s (%.1f FPS) ", outfilename, fps);
545  fflush(stdout);
546  }
547  }
548 
549  rt_outputfile(scene, outfilename);
550  rt_camera_position(scene, cmc, cmv, cmu);
551 
552  rt_renderscene(scene);
553 
554  if (dh != NULL) {
555  int rc = tachyon_display_draw(scene, dh);
556  if (rc != 0)
557  done=1;
558  }
559 
560  frameno++;
561  }
562  rt_timer_stop(animationtimer);
563  fps = frameno / (float) rt_timer_time(animationtimer);
564  if (node == 0) {
565  printf("\rCompleted animation of %d frames \n", frameno);
566  printf("Animation Time: %10.4f seconds (Averaged %.1f FPS)\n",
567  rt_timer_time(animationtimer), fps);
568  }
569  rt_timer_destroy(fpstimer);
570  fclose(camfp);
571  } else {
572  if (node == 0) {
573  printf("Couldn't open camera file: %s\n", opt.camfilename);
574  printf("Aborting render.\n");
575  }
576  rt_deletescene(scene); /* free the scene */
577  rt_finalize(); /* close down the rendering library and MPI */
578  return -1;
579  }
580 
581  if (node == 0) {
582  printf("\nFinished Running Camera.\n");
583 
584  if (dh !=NULL)
586  }
587 
588  rt_deletescene(scene); /* free the scene */
589  rt_finalize(); /* close down the rendering library and MPI */
590 
591  return 0;
592 }
593 
594 
595 
596 
597 #if defined(ANDROID) || defined(VXWORKS)
598 int ray(int argc, char **argv) {
599 #else
600 int main(int argc, char **argv) {
601 #endif
602  SceneHandle scene;
603  unsigned int rc;
604  argoptions opt;
605  char * filename;
606  int node, fileindex;
607  rt_timerhandle parsetimer;
608  size_t len;
609 
610  node = rt_initialize(&argc, &argv);
611 
614 
615  if (node == 0) {
616  char strbuf[1024];
617  sprintf(strbuf, "Tachyon Parallel/Multiprocessor Ray Tracer Version %s ",
619  my_ui_message(0, strbuf);
620  sprintf(strbuf, "Copyright 1994-2022, John E. Stone <john.stone@gmail.com> ");
621  my_ui_message(0, strbuf);
622  sprintf(strbuf, "------------------------------------------------------------ ");
623  my_ui_message(0, strbuf);
624  }
625 
626  if ((rc = getargs(argc, argv, &opt, node)) != 0) {
627  rt_finalize();
628 #if defined(ANDROID)
629  return rc;
630 #else
631  exit(rc);
632 #endif
633  }
634 
635  if (opt.numfiles > 1) {
636  if (node == 0)
637  printf("Rendering %d scene files.\n", opt.numfiles);
638  }
639 
640  for (fileindex=0; fileindex<opt.numfiles; fileindex++) {
641  scene = rt_newscene();
642 
643  /* process command line overrides */
644  presceneoptions(&opt, scene);
645 
646  filename = opt.filenames[fileindex];
647 
648  if (opt.numfiles > 1) {
649  if (node == 0)
650  printf("\nRendering scene file %d of %d, %s\n", fileindex+1, opt.numfiles, filename);
651  }
652 
653  parsetimer=rt_timer_create();
654  rt_timer_start(parsetimer);
655 
656  len = strlen(filename);
657 
658  if (len > 4 && (!strcmp(filename+len-4, ".nff") ||
659  !strcmp(filename+len-4, ".NFF"))) {
660  rc = ParseNFF(filename, scene); /* must be an NFF file */
661  }
662  else if (len > 3 && (!strcmp(filename+len-3, ".ac") ||
663  !strcmp(filename+len-3, ".AC"))) {
664  rc = ParseAC3D(filename, scene); /* Must be an AC3D file */
665  }
666 #ifdef USELIBMGF
667  else if (len > 4 && (!strcmp(filename+len-4, ".mgf") ||
668  !strcmp(filename+len-4, ".MGF"))) {
669  rc = ParseMGF(filename, scene, 1); /* Must be an MGF file */
670  }
671 #endif
672  else {
673  rc = readmodel(filename, scene); /* Assume its a Tachyon scene file */
674  }
675 
676  rt_timer_stop(parsetimer);
677  if (rc == PARSENOERR && node == 0)
678  printf("Scene Parsing Time: %10.4f seconds\n", rt_timer_time(parsetimer));
679  rt_timer_destroy(parsetimer);
680 
681  if (rc != PARSENOERR && node == 0) {
682  switch(rc) {
683  case PARSEBADFILE:
684  printf("Parser failed due to nonexistent input file: %s\n", filename);
685  break;
686  case PARSEBADSUBFILE:
687  printf("Parser failed due to nonexistent included file.\n");
688  break;
689  case PARSEBADSYNTAX:
690  printf("Parser failed due to an input file syntax error.\n");
691  break;
692  case PARSEEOF:
693  printf("Parser unexpectedly hit an end of file.\n");
694  break;
695  case PARSEALLOCERR:
696  printf("Parser ran out of memory.\n");
697  break;
698  }
699  if (fileindex+1 < opt.numfiles)
700  printf("Aborting render, continuing with next scene file...\n");
701  else
702  printf("Aborting render.\n");
703 
704  rt_deletescene(scene); /* free the scene */
705  continue; /* process the next scene */
706  }
707 
708  /* process command line overrides */
709  postsceneoptions(&opt, scene);
710 
711  /* choose which rendering mode to use */
712  if (opt.usecamfile == 1) {
713  return animate_scene(opt, scene, node); /* fly using prerecorded data */
714  } else if (opt.spaceballon) {
715  return fly_scene(opt, scene, node); /* fly Spaceball/SpaceNavigator */
716  } else {
717  if (opt.numfiles > 1 && opt.nosave != 1) {
718  char multioutfilename[FILENAME_MAX];
719  sprintf(multioutfilename, opt.outfilename, fileindex);
720  rt_outputfile(scene, multioutfilename);
721  }
722 
723  rt_renderscene(scene); /* Render a single frame */
724  }
725 
726  rt_deletescene(scene); /* free the scene, get ready for next one */
727  }
728 
729  rt_finalize(); /* close down the rendering library and MPI */
730  freeoptions(&opt); /* free parsed command line option data */
731 
732  return 0;
733 }
734 
735 
unsigned int ParseAC3D(char *modelfile, SceneHandle scene)
Definition: ac3dparse.c:98
#define PARSEALLOCERR
Definition: ac3dparse.h:16
int glwin_get_lastevent(void *voidhandle, int *evdev, int *evval, char *evkey)
Definition: glwin.c:3347
void * glwin_create(const char *wintitle, int width, int height)
Definition: glwin.c:3315
double rt_timer_time(rt_timerhandle v)
Definition: util.c:186
static int animate_scene(argoptions opt, SceneHandle scene, int node)
Definition: main.c:486
void rt_timer_destroy(rt_timerhandle v)
Definition: util.c:233
Definition: main.c:36
void rt_resolution(SceneHandle voidscene, int hres, int vres)
Set the horizontal and vertical resolution (in pixels) for the specified scene.
Definition: api.c:372
void glwin_destroy(void *voidhandle)
Definition: glwin.c:3319
#define PARSENOERR
Definition: ac3dparse.h:11
int oxsize
Definition: main.c:44
float y
Definition: main.c:38
void * rt_timerhandle
Definition: util.h:63
int tachyon_spaceball_update(sbHandle *bh, SceneHandle scene)
Definition: spaceball.c:60
int glwin_handle_events(void *voidhandle, int evblockmode)
Definition: glwin.c:3327
void rt_accumulation_mode(SceneHandle voidscene, int mode)
Request Tachyon to use (or disuse) an internal floating point accumulation buffer, combining the newest frame with previously accumulated frames, normalizing the pixel values using an internal subframe counter.
Definition: api.c:457
void rt_timer_start(rt_timerhandle v)
Definition: util.c:168
char camfilename[FILENAME_MAX]
camera filename
Definition: getargs.h:23
void glwin_draw_image(void *voidhandle, int xsize, int ysize, unsigned char *img)
Definition: glwin.c:3359
char ** filenames
list of model files to render
Definition: getargs.h:12
int xsize
Definition: main.c:45
void freeoptions(argoptions *opt)
Definition: getargs.c:643
unsigned int ParseMGF(char *mgfname, SceneHandle scene, int defaultflag)
char spaceballport[FILENAME_MAX]
spaceball serial port device
Definition: getargs.h:43
int fson
Definition: main.c:45
void rt_timer_stop(rt_timerhandle v)
Definition: util.c:177
void rt_renderscene(SceneHandle voidscene)
Render the current scene.
Definition: api.c:180
#define RT_ACCUMULATE_ON
accum.
Definition: tachyon.h:349
void * tachyon_init_spaceball(SceneHandle scene, void *glwin, char *serialport)
Definition: spaceball.c:28
unsigned int readmodel(const char *modelfile, SceneHandle scene)
Definition: parse.c:225
int nosave
don&#39;t write output image to disk
Definition: getargs.h:31
#define GLWIN_EV_POLL_NONBLOCK
Definition: glwin.h:28
int glwin_get_winsize(void *voidhandle, int *xsize, int *ysize)
Definition: glwin.c:3335
static dispHandle * tachyon_display_create(SceneHandle scene)
Definition: main.c:207
int rt_initialize(int *argc, char ***argv)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:70
flt x
X coordinate or direction component.
Definition: tachyon.h:54
#define TACHYON_VERSION_STRING
string version info
Definition: tachyon.h:34
static void tachyon_display_delete(dispHandle *dh)
Definition: main.c:361
int oysize
Definition: main.c:44
int glwin_fullscreen(void *voidhandle, int fson, int xinescreen)
Definition: glwin.c:3400
int numfiles
number of files to render
Definition: getargs.h:13
flt y
Y coordinate or direction component.
Definition: tachyon.h:55
#define PARSEBADSUBFILE
Definition: ac3dparse.h:13
#define PARSEBADSYNTAX
Definition: ac3dparse.h:14
int rt_numnodes(void)
distributed memory parallel node count
Definition: api.c:53
SceneHandle rt_newscene(void)
Allocate, initialize, and return a handle for a new scene.
Definition: api.c:698
char outfilename[FILENAME_MAX]
name of output image file
Definition: getargs.h:15
void rt_rawimage_rgb24(SceneHandle voidscene, unsigned char *img)
Have Tachyon save the output image in the specified memory area, in raw 24-bit, packed, pixel interleaved, unsigned RGB bytes.
Definition: api.c:419
void rt_outputfile(SceneHandle voidscene, const char *outname)
Set the filename for the output image for the specified scene.
Definition: api.c:350
void rt_set_ui_message(void(*func)(int, char *))
Set function pointer for user interface output callbacks.
Definition: ui.c:23
static int tachyon_display_draw(SceneHandle scene, dispHandle *dh)
Definition: main.c:237
void rt_set_ui_progress(void(*func)(int))
Set function pointer for user interface progress callbacks.
Definition: ui.c:27
static void my_ui_message(int a, char *msg)
Definition: main.c:154
#define GLWIN_EV_KBD
all non-special chars
Definition: glwin.h:33
void rt_deletescene(SceneHandle voidscene)
Destroy and deallocate the specified scene.
Definition: api.c:784
#define PARSEEOF
Definition: ac3dparse.h:15
int postsceneoptions(argoptions *opt, SceneHandle scene)
Definition: getargs.c:189
int ysize
Definition: main.c:45
static void my_ui_progress(int percent)
Definition: main.c:158
float x
Definition: main.c:37
void * SceneHandle
Definition: tachyon.h:51
int presceneoptions(argoptions *opt, SceneHandle scene)
Definition: getargs.c:180
static int fly_scene(argoptions opt, SceneHandle scene, int node)
Definition: main.c:375
void rt_finalize(void)
Shut down Tachyon library for good, at final use before program termination.
Definition: api.c:153
int glwin_resize(void *voidhandle, int width, int height)
Definition: glwin.c:3392
int usecamfile
use camera file
Definition: getargs.h:22
int spaceballon
spaceball input enabled
Definition: getargs.h:42
unsigned int ParseNFF(char *nffname, SceneHandle scene)
Definition: nffparse.c:71
rt_timerhandle rt_timer_create(void)
Definition: util.c:226
void rt_get_resolution(SceneHandle voidscene, int *hres, int *vres)
Get the horizontal and vertical resolution (in pixels) for the specified scene.
Definition: api.c:379
void rt_camera_position(SceneHandle voidscene, apivector camcent, apivector viewvec, apivector upvec)
Set camera position and orientation.
Definition: api.c:256
Tachyon public API function prototypes and declarations used to drive the ray tracing engine...
int getargs(int argc, char **argv, argoptions *opt, int node)
Definition: getargs.c:585
int glwin_get_wininfo(void *voidhandle, int *instereo, int *havestencil)
Definition: glwin.c:3331
flt z
Z coordinate or direction component.
Definition: tachyon.h:56
int main(int argc, char **argv)
Definition: main.c:600
float z
Definition: main.c:39
#define PARSEBADFILE
Definition: ac3dparse.h:12