Tachyon (current)  Current Main Branch
api.c
Go to the documentation of this file.
1 /*
2  * api.c - This file contains all of the API calls that are defined for
3  * external driver code to use.
4  *
5  * (C) Copyright 1994-2022 John E. Stone
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * $Id: api.c,v 1.210 2022/03/13 23:30:01 johns Exp $
9  *
10  */
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <math.h>
16 
17 #define TACHYON_INTERNAL 1
18 #include "tachyon.h"
19 #include "macros.h"
20 
21 #include "parallel.h"
22 #include "threads.h"
23 
24 #include "box.h"
25 #include "cylinder.h"
26 #include "plane.h"
27 #include "quadric.h"
28 #include "ring.h"
29 #include "sphere.h"
30 #include "triangle.h"
31 #include "vol.h"
32 #include "extvol.h"
33 
34 #include "texture.h"
35 #include "light.h"
36 #include "render.h"
37 #include "trace.h"
38 #include "camera.h"
39 #include "vector.h"
40 #include "intersect.h"
41 #include "shade.h"
42 #include "util.h"
43 #include "imap.h"
44 #include "global.h"
45 #include "ui.h"
46 #include "shade.h"
47 
48 
49 int rt_mynode(void) {
50  return rt_par_rank(global_parhnd);
51 }
52 
53 int rt_numnodes(void) {
54  return rt_par_size(global_parhnd);
55 }
56 
57 
59  InitTextures();
60 
61  if (global_parhnd == NULL) {
63  if (global_parhnd == NULL)
64  return -1;
65  }
66 
67  return rt_mynode(); /* return our node id */
68 }
69 
70 int rt_initialize(int * argc, char ***argv) {
71  InitTextures();
72 
73  if (global_parhnd == NULL) {
74  global_parhnd = rt_par_init(argc, argv);
75  if (global_parhnd == NULL)
76  return -1;
77  }
78 
79  return rt_mynode(); /* return our node id */
80 }
81 
82 int rt_initialize_mpi_comm(void *mpicomm) {
83  InitTextures();
84 
85  if (global_parhnd == NULL) {
87  if (global_parhnd == NULL)
88  return -1;
89  }
90 
91  return rt_mynode(); /* return our node id */
92 }
93 
95  InitTextures();
96 
97  if (global_parhnd == NULL) {
99  if (global_parhnd == NULL)
100  return -1;
101  }
102 
103  return rt_mynode(); /* return our node id */
104 }
105 
106 int rt_initialize_mpi_comm_split(void *mpicomm, int color, int key) {
107  InitTextures();
108 
109  if (global_parhnd == NULL) {
110  global_parhnd = rt_par_init_mpi_comm_split(mpicomm, color, key);
111  if (global_parhnd == NULL)
112  return -1;
113  }
114 
115  return rt_mynode(); /* return our node id */
116 }
117 
120  return -1;
121 
122  return rt_par_rank(global_parhnd); /* return our node id */
123 }
124 
125 int rt_set_mpi_comm(void *mpicomm) {
126  if (rt_par_set_mpi_comm(global_parhnd, mpicomm))
127  return -1;
128 
129  return rt_par_rank(global_parhnd); /* return our node id */
130 }
131 
132 int rt_set_mpi_comm_split(void *mpicomm, int color, int key) {
133  if (rt_par_set_mpi_comm_split(global_parhnd, mpicomm, color, key))
134  return -1;
135 
136  return rt_par_rank(global_parhnd); /* return our node id */
137 }
138 
139 int rt_set_mpi_comm_world_split(int color, int key) {
141  return -1;
142 
143  return rt_par_rank(global_parhnd); /* return our node id */
144 }
145 
148  return -1;
149 
150  return rt_par_rank(global_parhnd); /* return our node id */
151 }
152 
153 void rt_finalize(void) {
154  FreeTextures();
156 }
157 
158 
160  apivector v;
161 
162  v.x = x;
163  v.y = y;
164  v.z = z;
165 
166  return v;
167 }
168 
170  apicolor c;
171 
172  c.r = r;
173  c.g = g;
174  c.b = b;
175 
176  return c;
177 }
178 
179 
180 void rt_renderscene(SceneHandle voidscene) {
181  scenedef * scene = (scenedef *) voidscene;
182  renderscene(scene);
183 }
184 
185 void rt_normal_fixup_mode(SceneHandle voidscene, int mode) {
186  scenedef * scene = (scenedef *) voidscene;
187  switch (mode) {
188  /* RT_NORMAL_FIXUP_MODE_GUESS */
189  case 2:
190  scene->normalfixupmode = 2; /* accept any normal/winding order combo */
191  /* and suffer the consequences, since this */
192  /* leaves an unhandled case where surface */
193  /* normals on poorly tessellated objects */
194  /* will cause black edges. */
195  break;
196 
197  /* RT_NORMAL_FIXUP_MODE_FLIP */
198  case 1:
199  scene->normalfixupmode = 1; /* reverse the surface normal */
200  break;
201 
202  /* RT_NORMAL_FIXUP_MODE_OFF */
203  case 0:
204  default:
205  scene->normalfixupmode = 0; /* use strict winding order rules */
206  break;
207  }
208 }
209 
210 void rt_aa_maxsamples(SceneHandle voidscene, int maxsamples) {
211  scenedef * scene = (scenedef *) voidscene;
212 
213  if (maxsamples >= 0)
214  scene->antialiasing=maxsamples;
215  else
216  scene->antialiasing=0;
217 }
218 
219 void rt_shadow_filtering(SceneHandle voidscene, int onoff) {
220  scenedef * scene = (scenedef *) voidscene;
221  scene->shadowfilter = onoff;
222 }
223 
224 void rt_trans_max_surfaces(SceneHandle voidscene, int count) {
225  scenedef * scene = (scenedef *) voidscene;
226  scene->transcount= count;
227 }
228 
229 void rt_camera_setup(SceneHandle voidscene, flt zoom, flt aspectratio,
230  int antialiasing, int raydepth,
231  apivector camcent, apivector viewvec, apivector upvec) {
232 #if 0
233  /* this blows away internal state, not a good idea */
234  scenedef * scene = (scenedef *) voidscene;
235  cameradefault(&scene->camera);
236 #endif
237 
238  rt_camera_eye_separation(voidscene, 0.0);
239 
240  rt_camera_zoom(voidscene, zoom);
241 
242  rt_camera_position(voidscene, camcent, viewvec, upvec);
243 
244  rt_aspectratio(voidscene, aspectratio);
245 
246  rt_aa_maxsamples(voidscene, antialiasing);
247 
248  rt_camera_raydepth(voidscene, raydepth);
249 }
250 
251 void rt_camera_projection(SceneHandle voidscene, int mode) {
252  scenedef * scene = (scenedef *) voidscene;
253  cameraprojection(&scene->camera, mode);
254 }
255 
256 void rt_camera_position(SceneHandle voidscene, apivector camcent,
257  apivector viewvec, apivector upvec) {
258  scenedef * scene = (scenedef *) voidscene;
259  cameraposition(&scene->camera, camcent, viewvec, upvec);
260 }
261 
262 void rt_camera_position3fv(SceneHandle voidscene, const float *camcent,
263  const float *viewvec, const float *upvec) {
264  scenedef * scene = (scenedef *) voidscene;
265  vector vctr, vview, vup;
266  vctr.x = camcent[0]; vctr.y = camcent[1]; vctr.z = camcent[2];
267  vview.x = viewvec[0]; vview.y = viewvec[1]; vview.z = viewvec[2];
268  vup.x = upvec[0]; vup.y = upvec[1]; vup.z = upvec[2];
269  cameraposition(&scene->camera, vctr, vview, vup);
270 }
271 
272 
273 void rt_get_camera_position(SceneHandle voidscene, apivector * camcent,
274  apivector * viewvec, apivector * upvec,
275  apivector * rightvec) {
276  scenedef * scene = (scenedef *) voidscene;
277  getcameraposition(&scene->camera, camcent, viewvec, upvec, rightvec);
278 }
279 
280 void rt_get_camera_position3fv(SceneHandle voidscene, float *camcent,
281  float *viewvec, float *upvec, float *rightvec) {
282  scenedef * scene = (scenedef *) voidscene;
283  vector ctr, view, up, right;
284  getcameraposition(&scene->camera, &ctr, &view, &up, &right);
285  camcent[0] = ctr.x; camcent[1] = ctr.y; camcent[2] = ctr.z;
286  viewvec[0] = view.x; viewvec[1] = view.y; viewvec[2] = view.z;
287  upvec[0] = up.x; upvec[1] = up.y; upvec[2] = up.z;
288  rightvec[0] = right.x; rightvec[1] = right.y; rightvec[2] = right.z;
289 }
290 
291 
292 void rt_camera_raydepth(SceneHandle voidscene, int maxdepth) {
293  scenedef * scene = (scenedef *) voidscene;
294  scene->raydepth=maxdepth;
295 }
296 
297 void rt_camera_zoom(SceneHandle voidscene, flt zoom) {
298  scenedef * scene = (scenedef *) voidscene;
299  camerazoom(&scene->camera, zoom);
300 }
301 
303  scenedef * scene = (scenedef *) voidscene;
304  return scene->camera.camzoom;
305 }
306 
307 void rt_camera_eye_separation(SceneHandle voidscene, flt eyesep) {
308  scenedef * scene = (scenedef *) voidscene;
309  scene->camera.eyeshift=eyesep * 0.5;
310 }
311 
313  scenedef * scene = (scenedef *) voidscene;
314  return scene->camera.eyeshift * 2.0;
315 }
316 
318  scenedef * scene = (scenedef *) voidscene;
319  if (cospow != 0) {
320  scene->camera.modulate_eyeshift = 1;
321  }
322  scene->camera.modulate_eyeshift_pow = cospow;
323 }
324 
326  scenedef * scene = (scenedef *) voidscene;
327  if (scene->camera.modulate_eyeshift) {
328  return scene->camera.modulate_eyeshift_pow;
329  }
330  return 0;
331 }
332 
333 void rt_camera_vfov(SceneHandle voidscene, flt vfov) {
334  flt zoom = 1.0 / tan((vfov/360.0)*TWOPI/2.0);
335  rt_camera_zoom(voidscene, zoom);
336 }
337 
339  scenedef * scene = (scenedef *) voidscene;
340  flt vfov = 90.0 * 2.0 * (atan(1.0 / scene->camera.camzoom) / (TWOPI/4.0));
341  return vfov;
342 }
343 
344 
345 void rt_camera_frustum(SceneHandle voidscene, flt left, flt right, flt bottom, flt top) {
346  scenedef * scene = (scenedef *) voidscene;
347  camerafrustum(&scene->camera, left, right, bottom, top);
348 }
349 
350 void rt_outputfile(SceneHandle voidscene, const char * outname) {
351  scenedef * scene = (scenedef *) voidscene;
352  if (strlen(outname) > 0) {
353  strcpy((char *) &scene->outfilename, outname);
354  scene->writeimagefile = 1;
355  }
356  else {
357  scene->writeimagefile = 0;
358  }
359 }
360 
361 void rt_camera_dof(SceneHandle voidscene, flt focaldist, flt aperture) {
362  scenedef * scene = (scenedef *) voidscene;
363  cameradof(&scene->camera, focaldist, aperture);
364 }
365 
366 
367 void rt_outputformat(SceneHandle voidscene, int format) {
368  scenedef * scene = (scenedef *) voidscene;
369  scene->imgfileformat = format;
370 }
371 
372 void rt_resolution(SceneHandle voidscene, int hres, int vres) {
373  scenedef * scene = (scenedef *) voidscene;
374  scene->hres=hres;
375  scene->vres=vres;
376  scene->scenecheck = 1;
377 }
378 
379 void rt_get_resolution(SceneHandle voidscene, int *hres, int *vres) {
380  scenedef * scene = (scenedef *) voidscene;
381  *hres = scene->hres;
382  *vres = scene->vres;
383 }
384 
385 void rt_aspectratio(SceneHandle voidscene, float aspectratio) {
386  scenedef * scene = (scenedef *) voidscene;
387  scene->aspectratio=aspectratio;
388  scene->scenecheck = 1;
389 }
390 
391 void rt_get_aspectratio(SceneHandle voidscene, float *aspectratio) {
392  scenedef * scene = (scenedef *) voidscene;
393  *aspectratio = scene->aspectratio;
394 }
395 
396 void rt_crop_disable(SceneHandle voidscene) {
397  scenedef * scene = (scenedef *) voidscene;
398  scene->imgcrop.cropmode = RT_CROP_DISABLED;
399  scene->imgcrop.xres = 0;
400  scene->imgcrop.yres = 0;
401  scene->imgcrop.xstart = 0;
402  scene->imgcrop.ystart = 0;
403 }
404 
405 void rt_crop_output(SceneHandle voidscene, int hres, int vres, int sx, int sy) {
406  scenedef * scene = (scenedef *) voidscene;
407  scene->imgcrop.cropmode = RT_CROP_ENABLED;
408  scene->imgcrop.xres = hres;
409  scene->imgcrop.yres = vres;
410  scene->imgcrop.xstart = sx;
411  scene->imgcrop.ystart = sy;
412 }
413 
414 void rt_verbose(SceneHandle voidscene, int v) {
415  scenedef * scene = (scenedef *) voidscene;
416  scene->verbosemode = v;
417 }
418 
419 void rt_rawimage_rgb24(SceneHandle voidscene, unsigned char *img) {
420  scenedef * scene = (scenedef *) voidscene;
421  scene->img = (void *) img;
422  scene->imginternal = 0; /* image was allocated by the caller */
423  scene->imgbufformat = RT_IMAGE_BUFFER_RGB24;
424  scene->scenecheck = 1;
425 }
426 
427 
428 void rt_rawimage_rgb96f(SceneHandle voidscene, float *img) {
429  scenedef * scene = (scenedef *) voidscene;
430  scene->img = (void *) img;
431  scene->imginternal = 0; /* image was allocated by the caller */
432  scene->imgbufformat = RT_IMAGE_BUFFER_RGB96F;
433  scene->scenecheck = 1;
434 }
435 
436 
437 void rt_image_clamp(SceneHandle voidscene) {
438  scenedef * scene = (scenedef *) voidscene;
439  scene->imgprocess = RT_IMAGE_CLAMP;
440 }
441 
442 
444  scenedef * scene = (scenedef *) voidscene;
445  scene->imgprocess = RT_IMAGE_NORMALIZE;
446 }
447 
448 
449 void rt_image_gamma(SceneHandle voidscene, float gamma) {
450  scenedef * scene = (scenedef *) voidscene;
451  scene->imggamma = gamma;
452  scene->imgprocess = RT_IMAGE_NORMALIZE | RT_IMAGE_GAMMA;
453 }
454 
455 
456 #if defined(RT_ACCUMULATE_ON)
457 void rt_accumulation_mode(SceneHandle voidscene, int mode) {
458  scenedef * scene = (scenedef *) voidscene;
459  scene->accum_mode = mode;
460  if (mode == RT_ACCUMULATE_OFF) {
461  if (scene->accum_buf != NULL) {
462  free(scene->accum_buf);
463  scene->accum_buf = NULL;
464  }
465  scene->accum_count = 0;
466  }
467 }
468 #endif
469 
470 
471 void rt_set_numthreads(SceneHandle voidscene, int numthreads) {
472  scenedef * scene = (scenedef *) voidscene;
473 #ifdef THR
474  if (numthreads > 0) {
475  scene->numthreads = numthreads;
476  }
477  else {
478  scene->numthreads = rt_thread_numprocessors();
479  }
480 
481  /* force set of # kernel threads */
482  rt_thread_setconcurrency(scene->numthreads);
483 
484 #else
485  scene->numthreads = 1;
486 #endif
487  scene->scenecheck = 1;
488 }
489 
490 void rt_background(SceneHandle voidscene, apicolor col) {
491  scenedef * scene = (scenedef *) voidscene;
492  scene->bgtex.bg_color.r = col.r;
493  scene->bgtex.bg_color.g = col.g;
494  scene->bgtex.bg_color.b = col.b;
495 }
496 
498  flt topval, flt botval,
499  apicolor topcol, apicolor botcol) {
500  apicolor delta;
501  flt maxcoldelta;
502  scenedef * scene = (scenedef *) voidscene;
503 
504  scene->bgtex.bg_grad_top.r = topcol.r;
505  scene->bgtex.bg_grad_top.g = topcol.g;
506  scene->bgtex.bg_grad_top.b = topcol.b;
507 
508  scene->bgtex.bg_grad_bot.r = botcol.r;
509  scene->bgtex.bg_grad_bot.g = botcol.g;
510  scene->bgtex.bg_grad_bot.b = botcol.b;
511 
512  scene->bgtex.bg_grad_updir = up;
513  scene->bgtex.bg_grad_topval = topval;
514  scene->bgtex.bg_grad_botval = botval;
515  scene->bgtex.bg_grad_invrange = 1.0 / (topval - botval);
516 
517  /*
518  * Add noise to gradient backgrounds to prevent Mach banding effects,
519  * particularly noticable in video streams or movie renderings.
520  * Compute the delta between the top and bottom gradient colors and
521  * calculate the noise magnitude required, such that by adding it to the
522  * scalar interpolation parameter we get more than +/-1ulp in the
523  * resulting interpolated color, as represented in an 8bpp framebuffer.
524  */
525  delta.r = fabs(topcol.r - botcol.r);
526  delta.g = fabs(topcol.g - botcol.g);
527  delta.b = fabs(topcol.b - botcol.b);
528  maxcoldelta = (delta.r > delta.g) ?
529  ((delta.r > delta.b) ? delta.r : delta.b) :
530  ((delta.g > delta.b) ? delta.g : delta.b);
531 
532  /*
533  * Ideally the noise mag calc would take into account both max color delta
534  * and image dimensions to avoid banding even with very subtle gradients.
535  */
536  scene->bgtex.bg_grad_noisemag = (3.0f/256.0f) / (maxcoldelta + 0.0005);
537 }
538 
539 void rt_background_sky_sphere(SceneHandle voidscene, apivector up, flt topval,
540  flt botval, apicolor topcol, apicolor botcol) {
541  rt_background_gradient(voidscene, up, topval, botval, topcol, botcol);
542 }
543 
544 void rt_background_mode(SceneHandle voidscene, int mode) {
545  scenedef * scene = (scenedef *) voidscene;
546  switch (mode) {
548  scene->bgtexfunc=sky_sphere_background_texture;
549  break;
550 
552  scene->bgtexfunc=sky_plane_background_texture;
553  break;
554 
556  default:
557  scene->bgtexfunc=solid_background_texture;
558  break;
559  }
560 }
561 
562 
563 void rt_ambient_occlusion(SceneHandle voidscene, int numsamples,
564  apiflt maxdist, apicolor col) {
565  scenedef * scene = (scenedef *) voidscene;
566  scene->ambocc.numsamples = numsamples;
567  scene->ambocc.ao_maxdist = maxdist;
568  scene->ambocc.col.r = col.r;
569  scene->ambocc.col.g = col.g;
570  scene->ambocc.col.b = col.b;
571 }
572 
573 void rt_fog_parms(SceneHandle voidscene, apicolor col, flt start, flt end, flt density) {
574  scenedef * scene = (scenedef *) voidscene;
575  scene->fog.col = col;
576  scene->fog.start = start;
577  scene->fog.end = end;
578  scene->fog.density = density;
579 }
580 
581 void rt_fog_rendering_mode(SceneHandle voidscene, int mode) {
582  scenedef * scene = (scenedef *) voidscene;
583  switch (mode) {
584  /* RT_FOG_VMD is currently a synonym for RT_FOG_OPENGL */
585  case RT_FOG_OPENGL:
586  scene->fog.type = RT_FOG_OPENGL;
587  break;
588 
589  case RT_FOG_NORMAL:
590  default:
591  scene->fog.type = RT_FOG_NORMAL;
592  break;
593  }
594 }
595 
596 void rt_fog_mode(SceneHandle voidscene, int mode) {
597  scenedef * scene = (scenedef *) voidscene;
598 
599  switch (mode) {
600  case RT_FOG_LINEAR:
601  scene->fog.fog_fctn = fog_color_linear;
602  break;
603 
604  case RT_FOG_EXP:
605  scene->fog.fog_fctn = fog_color_exp;
606  break;
607 
608  case RT_FOG_EXP2:
609  scene->fog.fog_fctn = fog_color_exp2;
610  break;
611 
612  case RT_FOG_NONE:
613  default:
614  scene->fog.fog_fctn = NULL;
615  break;
616  }
617 }
618 
619 void rt_trans_mode(SceneHandle voidscene, int mode) {
620  scenedef * scene = (scenedef *) voidscene;
621  scene->transmode = mode;
622 }
623 
624 void rt_boundmode(SceneHandle voidscene, int mode) {
625  scenedef * scene = (scenedef *) voidscene;
626  scene->boundmode = mode;
627  scene->scenecheck = 1;
628 }
629 
630 void rt_boundthresh(SceneHandle voidscene, int threshold) {
631  scenedef * scene = (scenedef *) voidscene;
632 
633  if (threshold > 1) {
634  scene->boundthresh = threshold;
635  }
636  else {
637  if (rt_mynode() == 0) {
638  rt_ui_message(MSG_0, "Out-of-range automatic bounding threshold.\n");
639  rt_ui_message(MSG_0, "Automatic bounding threshold reset to default.\n");
640  }
641  scene->boundthresh = BOUNDTHRESH;
642  }
643  scene->scenecheck = 1;
644 }
645 
646 void rt_shadermode(SceneHandle voidscene, int mode) {
647  scenedef * scene = (scenedef *) voidscene;
648 
649  /* Main shader used for whole scene */
650  switch (mode) {
651  case RT_SHADER_LOWEST:
652  scene->shader = (color (*)(void *)) lowest_shader;
653  break;
654  case RT_SHADER_LOW:
655  scene->shader = (color (*)(void *)) low_shader;
656  break;
657  case RT_SHADER_MEDIUM:
658  scene->shader = (color (*)(void *)) medium_shader;
659  break;
660  case RT_SHADER_HIGH:
661  scene->shader = (color (*)(void *)) full_shader;
662  break;
663  case RT_SHADER_FULL:
664  scene->shader = (color (*)(void *)) full_shader;
665  break;
666  case RT_SHADER_AUTO:
667  default:
668  scene->shader = NULL;
669  break;
670  }
671 }
672 
673 void rt_rescale_lights(SceneHandle voidscene, flt lightscale) {
674  scenedef * scene = (scenedef *) voidscene;
675  scene->light_scale = lightscale;
676 }
677 
678 void rt_phong_shader(SceneHandle voidscene, int mode) {
679  scenedef * scene = (scenedef *) voidscene;
680  switch (mode) {
682  scene->phongfunc = shade_nullphong;
683  break;
685  scene->phongfunc = shade_blinn_fast;
686  break;
687  case RT_SHADER_BLINN:
688  scene->phongfunc = shade_blinn;
689  break;
690  default:
691  case RT_SHADER_PHONG:
692  scene->phongfunc = shade_phong;
693  break;
694  }
695 }
696 
697 /* allocate and initialize a scene with default parameters */
699  scenedef * scene;
700  SceneHandle voidscene;
701  apicolor bgcolor = rt_color(0.0, 0.0, 0.0);
702  apicolor ambcolor = rt_color(1.0, 1.0, 1.0);
703 
704  scene = (scenedef *) malloc(sizeof(scenedef));
705  memset(scene, 0, sizeof(scenedef)); /* clear all valuas to 0 */
706 
707  voidscene = (SceneHandle) scene;
708 
709  rt_outputfile(voidscene, "/tmp/outfile.tga"); /* default output file */
710  rt_crop_disable(voidscene); /* disable cropping */
711  rt_outputformat(voidscene, RT_FORMAT_TARGA); /* default iamge format */
712  rt_resolution(voidscene, 512, 512); /* 512x512 resolution */
713  rt_verbose(voidscene, 0); /* verbose messages off */
714 
715  rt_image_gamma(voidscene, 2.2f); /* set default gamma */
716  rt_image_clamp(voidscene); /* clamp image colors */
717 
718 #if 1
719  rt_rawimage_rgb96f(voidscene, NULL); /* raw image output off */
720 #else
721  rt_rawimage_rgb24(voidscene, NULL); /* raw image output off */
722 #endif
723 
724 #if defined(RT_ACCUMULATE_ON)
725  rt_accumulation_mode(voidscene, RT_ACCUMULATE_OFF); /* no accum default */
726 #endif
727 
728  rt_boundmode(voidscene, RT_BOUNDING_ENABLED); /* spatial subdivision on */
729  rt_boundthresh(voidscene, BOUNDTHRESH); /* default threshold */
730  rt_camera_setup(voidscene, 1.0, 1.0, 0, 6,
731  rt_vector(0.0, 0.0, 0.0),
732  rt_vector(0.0, 0.0, 1.0),
733  rt_vector(0.0, 1.0, 0.0));
734  rt_camera_dof(voidscene, 1.0, 2.8);
735  rt_shadermode(voidscene, RT_SHADER_AUTO);
736  rt_rescale_lights(voidscene, 1.0);
737  rt_phong_shader(voidscene, RT_SHADER_BLINN);
738 
739  rt_background(voidscene, bgcolor);
740  rt_background_sky_sphere(voidscene, rt_vector(0.0, 1.0, 0.0), 0.3, 0,
741  rt_color(0.0, 0.0, 0.0), rt_color(0.0, 0.0, 0.5));
743 
744  /* disable AO by default */
745  rt_ambient_occlusion(voidscene, 0, RT_AO_MAXDIST_UNLIMITED, ambcolor);
746 
747  rt_fog_rendering_mode(voidscene, RT_FOG_NORMAL); /* radial fog by default */
748  rt_fog_mode(voidscene, RT_FOG_NONE); /* disable fog by default */
749  rt_fog_parms(voidscene, bgcolor, 0.0, 1.0, 1.0);
750 
751  /* use max positive integer for max transparent surface limit by default */
752  rt_trans_max_surfaces(voidscene,((((int)1) << ((sizeof(int) * 8) - 2))-1)*2);
753 
754  rt_trans_mode(voidscene, RT_TRANS_ORIG); /* set transparency mode */
755  rt_normal_fixup_mode(voidscene, 0); /* disable normal fixup */
756  rt_shadow_filtering(voidscene, 1); /* shadow filtering on */
757 
758  scene->objgroup.boundedobj = NULL;
759  scene->objgroup.unboundedobj = NULL;
760  scene->objgroup.numobjects = 0;
761 
762  scene->texlist = NULL;
763  scene->lightlist = NULL;
764  scene->cliplist = NULL;
765  scene->numlights = 0;
766  scene->scenecheck = 1;
767  scene->parhnd = global_parhnd; /* XXX this needs to be fixed! */
768  scene->parbuf = NULL;
769  scene->threads = NULL;
770  scene->threadparms = NULL;
771  scene->flags = RT_SHADE_NOFLAGS;
772 
773  rt_set_numthreads(voidscene, -1); /* auto determine num threads */
774 
775  /* number of distributed memory nodes, fills in array of node/cpu info */
776  scene->nodes = rt_par_getcpuinfo(scene->parhnd, &scene->cpuinfo);
777  scene->mynode = rt_mynode();
778 
779  return scene;
780 }
781 
782 
783 
784 void rt_deletescene(SceneHandle voidscene) {
785  scenedef * scene = (scenedef *) voidscene;
786  list * cur, * next;
787 
788  if (scene != NULL) {
789  if (scene->imginternal) {
790  free(scene->img);
791  }
792 
793 #if defined(RT_ACCUMULATE_ON)
794  if (scene->accum_buf) {
795  free(scene->accum_buf);
796  }
797 #endif
798 
799  /* tear down and deallocate persistent rendering threads */
800  destroy_render_threads(scene);
801 
802  /* tear down and deallocate persistent scanline receives */
803  if (scene->parbuf != NULL)
804  rt_par_delete_scanlinereceives(scene->parhnd, scene->parbuf);
805 
806  /* free all lights */
807  cur = scene->lightlist;
808  while (cur != NULL) {
809  next = cur->next;
810 
811  /* free lights that have special data, or aren't freed */
812  /* as part of the object list deallocation loop. */
813  free_light_special(cur->item);
814  free(cur);
815  cur = next;
816  }
817 
818  /* free all textures */
819  cur = scene->texlist;
820  while (cur != NULL) {
821  next = cur->next;
822  ((texture *) cur->item)->methods->freetex(cur->item); /* free texture */
823  free(cur); /* free list entry */
824  cur = next;
825  }
826 
827  /* free all clipping planes */
828  cur = scene->cliplist;
829  while (cur != NULL) {
830  next = cur->next;
831  free(((clip_group *) cur->item)->planes); /* free array of clip planes */
832  free(cur->item); /* free clip group struct */
833  free(cur); /* free list entry */
834  cur = next;
835  }
836 
837  /* free all other textures, MIP Maps, and images */
838  FreeTextures();
839 
840  free(scene->cpuinfo);
841  free_objects(scene->objgroup.boundedobj);
842  free_objects(scene->objgroup.unboundedobj);
843 
844  free(scene);
845  }
846 }
847 
848 void apitextotex(apitexture * apitex, texture * tx) {
849  standard_texture * tex = (standard_texture *) tx;
850  tex->img = NULL;
851 
852  switch(apitex->texturefunc) {
853  case RT_TEXTURE_3D_CHECKER:
854  tex->texfunc=(color(*)(const void *, const void *, void *))(checker_texture);
855  break;
856 
857  case RT_TEXTURE_GRIT:
858  tex->texfunc=(color(*)(const void *, const void *, void *))(grit_texture);
859  break;
860 
861  case RT_TEXTURE_MARBLE:
862  tex->texfunc=(color(*)(const void *, const void *, void *))(marble_texture);
863  break;
864 
865  case RT_TEXTURE_WOOD:
866  tex->texfunc=(color(*)(const void *, const void *, void *))(wood_texture);
867  break;
868 
869  case RT_TEXTURE_GRADIENT:
870  tex->texfunc=(color(*)(const void *, const void *, void *))(gnoise_texture);
871  break;
872 
874  tex->texfunc=(color(*)(const void *, const void *, void *))(cyl_checker_texture);
875  break;
876 
878  tex->texfunc=(color(*)(const void *, const void *, void *))(image_cyl_texture);
879  tex->img=LoadMIPMap(apitex->imap, 0);
880  break;
881 
883  tex->texfunc=(color(*)(const void *, const void *, void *))(image_sphere_texture);
884  tex->img=LoadMIPMap(apitex->imap, 0);
885  break;
886 
888  tex->texfunc=(color(*)(const void *, const void *, void *))(image_plane_texture);
889  tex->img=LoadMIPMap(apitex->imap, 0);
890  break;
891 
893  tex->texfunc=(color(*)(const void *, const void *, void *))(image_volume_texture);
894  tex->img=LoadMIPMap(apitex->imap, 0);
895  break;
896 
897  case RT_TEXTURE_CONSTANT:
898  default:
899  tex->texfunc=(color(*)(const void *, const void *, void *))(constant_texture);
900  break;
901  }
902 
903  tex->ctr = apitex->ctr;
904  tex->rot = apitex->rot;
905  tex->scale = apitex->scale;
906  tex->uaxs = apitex->uaxs;
907  tex->vaxs = apitex->vaxs;
908  tex->waxs = apitex->waxs;
909  tex->ambient = apitex->ambient;
910  tex->diffuse = apitex->diffuse;
911  tex->specular = apitex->specular;
912  tex->opacity = apitex->opacity;
913  tex->col = apitex->col;
914 
915  /* initialize texture flags */
916  tex->flags = RT_TEXTURE_NOFLAGS;
917 
918  /* anything less than an entirely opaque object will modulate */
919  /* the light intensity rather than completly occluding it */
920  if (apitex->opacity >= 0.99999)
921  tex->flags = RT_TEXTURE_SHADOWCAST;
922 
923  tex->phong = 0.0;
924  tex->phongexp = 0.0;
925  tex->phongtype = 0;
926 
927  tex->transmode = RT_TRANS_ORIG;
928 
929  tex->outline = 0.0;
930  tex->outlinewidth = 0.0;
931 }
932 
933 void * rt_texture(SceneHandle sc, apitexture * apitex) {
934  scenedef * scene = (scenedef *) sc;
935  texture * tex;
936  list * lst;
937 
938  tex = new_standard_texture();
939  apitextotex(apitex, tex);
940 
941  /* add texture to the scene texture list */
942  lst = (list *) malloc(sizeof(list));
943  lst->item = (void *) tex;
944  lst->next = scene->texlist;
945  scene->texlist = lst;
946 
947  return(tex);
948 }
949 
950 
951 void rt_define_teximage_rgb24(const char *name, int xs, int ys, int zs, unsigned char *rgb) {
952  AllocateImageRGB24(name, xs, ys, zs, rgb);
953 }
954 
955 /* deprecated version used in old revs of VMD */
956 void rt_define_image(const char *name, int xs, int ys, int zs, unsigned char *rgb) {
957  AllocateImageRGB24(name, xs, ys, zs, rgb);
958 }
959 
960 
961 /* this is a gross hack that needs to be eliminated */
962 /* by writing a new mesh triangle object that doesn't */
963 /* need multiple instantiations of texture objects for */
964 /* correct operation. Ideally we'd store the object */
965 /* pointer in the intersection record so the texture */
966 /* needn't store this itself */
967 void * rt_texture_copy_standard(SceneHandle sc, void *oldtex) {
968  texture *newtex;
969  newtex = new_standard_texture();
970  memcpy(newtex, oldtex, sizeof(standard_texture));
971  return newtex;
972 }
973 void * rt_texture_copy_vcstri(SceneHandle sc, void *oldvoidtex) {
974  texture *oldtex = (texture *) oldvoidtex;
975  texture *newtex = new_vcstri_texture();
976 
977  /* copy in all of the texture components common to both tex types */
978  newtex->flags = oldtex->flags;
979  newtex->ambient = oldtex->ambient;
980  newtex->diffuse = oldtex->diffuse;
981  newtex->phong = oldtex->phong;
982  newtex->phongexp = oldtex->phongexp;
983  newtex->phongtype = oldtex->phongtype;
984  newtex->specular = oldtex->specular;
985  newtex->opacity = oldtex->opacity;
986  newtex->transmode = oldtex->transmode;
987  newtex->outline = oldtex->outline;
988  newtex->outlinewidth = oldtex->outlinewidth;
989 
990  return newtex;
991 }
992 
993 
994 void rt_tex_phong(void * voidtex, flt phong, flt phongexp, int type) {
995  texture * tex = (texture *) voidtex;
996  tex->phong = phong;
997  tex->phongexp = phongexp;
998  tex->phongtype = type;
999 }
1000 
1001 
1002 void rt_tex_transmode(void * voidtex, int transmode) {
1003  texture * tex = (texture *) voidtex;
1004  tex->transmode = transmode;
1005 }
1006 
1007 
1008 void rt_tex_outline(void * voidtex, flt outline, flt outlinewidth) {
1009  texture * tex = (texture *) voidtex;
1010  tex->outline = outline;
1011  tex->outlinewidth = outlinewidth;
1012 }
1013 
1014 
1015 static void add_bounded_object(scenedef * scene, object * obj) {
1016  object * objtemp;
1017 
1018  if (obj == NULL)
1019  return;
1020 
1021  obj->id = new_objectid(scene);
1022  objtemp = scene->objgroup.boundedobj;
1023  scene->objgroup.boundedobj = obj;
1024  obj->nextobj = objtemp;
1025  obj->clip = scene->curclipgroup;
1026 
1027  /* XXX Clipping ought to be applied to objects before they */
1028  /* are even added to the internal data structures, so */
1029  /* they aren't even considered during rendering. */
1030 
1031  scene->scenecheck = 1;
1032 }
1033 
1034 static void add_unbounded_object(scenedef * scene, object * obj) {
1035  object * objtemp;
1036 
1037  if (obj == NULL)
1038  return;
1039 
1040  obj->id = new_objectid(scene);
1041  objtemp = scene->objgroup.unboundedobj;
1042  scene->objgroup.unboundedobj = obj;
1043  obj->nextobj = objtemp;
1044  obj->clip = scene->curclipgroup;
1045  scene->scenecheck = 1;
1046 }
1047 
1048 
1049 void * rt_light(SceneHandle voidscene, void * tex, apivector ctr, flt rad) {
1050  point_light * li;
1051  scenedef * scene = (scenedef *) voidscene;
1052  list * lst;
1053 
1054  li=newpointlight(tex, ctr, rad);
1055 
1056  /* add light to the scene lightlist */
1057  lst = (list *) malloc(sizeof(list));
1058  lst->item = (void *) li;
1059  lst->next = scene->lightlist;
1060  scene->lightlist = lst;
1061  scene->numlights++;
1062 
1063  /* add light as an object as well... */
1064  add_bounded_object((scenedef *) scene, (object *)li);
1065 
1066  return li;
1067 }
1068 
1069 void * rt_light3fv(SceneHandle voidscene, void * tex,
1070  const float *ctr, float rad) {
1071  vector vctr;
1072  vctr.x = ctr[0]; vctr.y = ctr[1]; vctr.z = ctr[2];
1073  return rt_light(voidscene, tex, vctr, rad);
1074 }
1075 
1076 
1077 void * rt_directional_light(SceneHandle voidscene, void * tex, apivector dir) {
1078  directional_light * li;
1079  scenedef * scene = (scenedef *) voidscene;
1080  list * lst;
1081 
1082  VNorm(&dir);
1083  li=newdirectionallight(tex, dir);
1084 
1085  /* add light to the scene lightlist */
1086  lst = (list *) malloc(sizeof(list));
1087  lst->item = (void *) li;
1088  lst->next = scene->lightlist;
1089  scene->lightlist = lst;
1090  scene->numlights++;
1091 
1092  /* don't add to the object list since it's at infinity */
1093  /* XXX must loop over light list and deallocate these */
1094  /* specially since they aren't in the obj list. */
1095 
1096  return li;
1097 }
1098 
1099 void * rt_directional_light3fv(SceneHandle voidscene, void * tex,
1100  const float *dir) {
1101  vector vdir;
1102  vdir.x = dir[0]; vdir.y = dir[1]; vdir.z = dir[2];
1103  return rt_directional_light(voidscene, tex, vdir);
1104 }
1105 
1106 
1107 void * rt_spotlight(SceneHandle voidscene, void * tex, apivector ctr, flt rad,
1108  apivector dir, flt start, flt end) {
1109  flt fallstart, fallend;
1110  point_light * li;
1111  scenedef * scene = (scenedef *) voidscene;
1112  list * lst;
1113 
1114  fallstart = start * 3.1415926 / 180.0;
1115  fallend = end * 3.1415926 / 180.0;
1116  VNorm(&dir);
1117  li = newspotlight(tex, ctr, rad, dir, fallstart, fallend);
1118 
1119  /* add light to the scene lightlist */
1120  lst = (list *) malloc(sizeof(list));
1121  lst->item = (void *) li;
1122  lst->next = scene->lightlist;
1123  scene->lightlist = lst;
1124  scene->numlights++;
1125 
1126  /* add light as an object as well... */
1127  add_bounded_object(scene, (object *) li);
1128 
1129  return li;
1130 }
1131 
1132 void * rt_spotlight3fv(SceneHandle voidscene, void * tex,
1133  const float *ctr, float rad,
1134  const float *dir, float start, float end) {
1135  vector vctr, vdir;
1136  vctr.x = ctr[0]; vctr.y = ctr[1]; vctr.z = ctr[2];
1137  vdir.x = dir[0]; vdir.y = dir[1]; vdir.z = dir[2];
1138  return rt_spotlight(voidscene, tex, vctr, rad, vdir, start, end);
1139 }
1140 
1141 
1142 void rt_light_attenuation(void * vli, flt Kc, flt Kl, flt Kq) {
1143  light_set_attenuation((point_light *) vli, Kc, Kl, Kq);
1144 }
1145 
1146 void rt_scalarvol(SceneHandle scene, void * tex, apivector min, apivector max,
1147  int xs, int ys, int zs, const char * fname, void * voidvol) {
1148  scalarvol * invol = (scalarvol *) voidvol;
1149  add_bounded_object((scenedef *) scene, (object *) newscalarvol(tex, min, max, xs, ys, zs, fname, invol));
1150 }
1151 
1152 void rt_extvol(SceneHandle scene, void * tex, apivector min, apivector max, int samples, flt (* evaluator)(flt, flt, flt)) {
1153  add_bounded_object((scenedef *) scene, (object *) newextvol(tex, min, max, samples, evaluator));
1154 }
1155 
1156 void rt_box(SceneHandle scene, void * tex, apivector min, apivector max) {
1157  add_bounded_object((scenedef *) scene, (object *) newbox(tex, min, max));
1158 }
1159 
1160 void rt_cylinder(SceneHandle scene, void * tex, apivector ctr, apivector axis, flt rad) {
1161  add_unbounded_object((scenedef *) scene, newcylinder(tex, ctr, axis, rad));
1162 }
1163 
1164 void rt_cylinder3fv(SceneHandle scene, void * tex,
1165  const float *ctr, const float *axis, float rad) {
1166  vector vctr, vaxis;
1167  vctr.x = ctr[0]; vctr.y = ctr[1]; vctr.z = ctr[2];
1168  vaxis.x = axis[0]; vaxis.y = axis[1]; vaxis.z = axis[2];
1169  add_bounded_object((scenedef *) scene, newcylinder(tex, vctr, vaxis, rad));
1170 }
1171 
1172 
1173 void rt_fcylinder(SceneHandle scene, void * tex, apivector ctr, apivector axis, flt rad) {
1174  add_bounded_object((scenedef *) scene, newfcylinder(tex, ctr, axis, rad));
1175 }
1176 
1177 void rt_fcylinder3fv(SceneHandle scene, void * tex,
1178  const float *ctr, const float *axis, float rad) {
1179  vector vctr, vaxis;
1180  vctr.x = ctr[0]; vctr.y = ctr[1]; vctr.z = ctr[2];
1181  vaxis.x = axis[0]; vaxis.y = axis[1]; vaxis.z = axis[2];
1182  add_bounded_object((scenedef *) scene, newfcylinder(tex, vctr, vaxis, rad));
1183 }
1184 
1185 
1186 void rt_plane(SceneHandle scene, void * tex, apivector ctr, apivector norm) {
1187  add_unbounded_object((scenedef *) scene, newplane(tex, ctr, norm));
1188 }
1189 
1190 void rt_plane3fv(SceneHandle scene, void * tex,
1191  const float *ctr, const float *norm) {
1192  vector vctr, vnorm;
1193  vctr.x = ctr[0]; vctr.y = ctr[1]; vctr.z = ctr[2];
1194  vnorm.x = norm[0]; vnorm.y = norm[1]; vnorm.z = norm[2];
1195  add_unbounded_object((scenedef *) scene, newplane(tex, vctr, vnorm));
1196 }
1197 
1198 
1199 void rt_ring(SceneHandle scene, void * tex, apivector ctr, apivector norm, flt inner, flt outer) {
1200  add_bounded_object((scenedef *) scene, newring(tex, ctr, norm, inner, outer));
1201 }
1202 
1203 void rt_ring3fv(SceneHandle scene, void * tex,
1204  const float *ctr, const float *norm, float inner, float outer) {
1205  vector vctr, vnorm;
1206  vctr.x = ctr[0]; vctr.y = ctr[1]; vctr.z = ctr[2];
1207  vnorm.x = norm[0]; vnorm.y = norm[1]; vnorm.z = norm[2];
1208  add_bounded_object((scenedef *) scene, newring(tex, vctr, vnorm, inner, outer));
1209 }
1210 
1211 
1212 void rt_sphere(SceneHandle scene, void * tex, apivector ctr, flt rad) {
1213  add_bounded_object((scenedef *) scene, newsphere(tex, ctr, rad));
1214 }
1215 
1216 void rt_sphere3fv(SceneHandle scene, void * tex,
1217  const float *ctr, float rad) {
1218  vector vctr;
1219  vctr.x = ctr[0]; vctr.y = ctr[1]; vctr.z = ctr[2];
1220  add_bounded_object((scenedef *) scene, newsphere(tex, vctr, rad));
1221 }
1222 
1223 
1224 void rt_tri(SceneHandle voidscene, void * tex, apivector v0, apivector v1, apivector v2) {
1225  scenedef * scene = (scenedef *) voidscene;
1226  object * o = newtri(tex, v0, v1, v2);
1227  /* don't add degenerate triangles */
1228  if (o != NULL) {
1229  add_bounded_object(scene, o);
1230  }
1231 }
1232 
1233 
1234 void rt_tri3fv(SceneHandle voidscene, void * tex,
1235  const float *v0, const float *v1, const float *v2) {
1236  scenedef * scene = (scenedef *) voidscene;
1237  vector vv0, vv1, vv2;
1238  object * o;
1239 
1240  vv0.x = v0[0]; vv0.y = v0[1]; vv0.z = v0[2];
1241  vv1.x = v1[0]; vv1.y = v1[1]; vv1.z = v1[2];
1242  vv2.x = v2[0]; vv2.y = v2[1]; vv2.z = v2[2];
1243 
1244  o = newtri(tex, vv0, vv1, vv2);
1245  /* don't add degenerate triangles */
1246  if (o != NULL) {
1247  add_bounded_object(scene, o);
1248  }
1249 }
1250 
1251 
1252 void rt_stri(SceneHandle voidscene, void * tex, apivector v0, apivector v1, apivector v2, apivector n0, apivector n1, apivector n2) {
1253  scenedef * scene = (scenedef *) voidscene;
1254  object * o = newstri(tex, v0, v1, v2, n0, n1, n2);
1255  /* don't add degenerate triangles */
1256  if (o != NULL) {
1257  if (scene->normalfixupmode)
1258  stri_normal_fixup(o, scene->normalfixupmode);
1259  add_bounded_object(scene, o);
1260  }
1261 }
1262 
1263 
1264 void rt_stri3fv(SceneHandle voidscene, void * tex,
1265  const float *v0, const float *v1, const float *v2,
1266  const float *n0, const float *n1, const float *n2) {
1267  scenedef * scene = (scenedef *) voidscene;
1268  vector vv0, vv1, vv2, vn0, vn1, vn2;
1269  object * o;
1270 
1271  vv0.x = v0[0]; vv0.y = v0[1]; vv0.z = v0[2];
1272  vv1.x = v1[0]; vv1.y = v1[1]; vv1.z = v1[2];
1273  vv2.x = v2[0]; vv2.y = v2[1]; vv2.z = v2[2];
1274  vn0.x = n0[0]; vn0.y = n0[1]; vn0.z = n0[2];
1275  vn1.x = n1[0]; vn1.y = n1[1]; vn1.z = n1[2];
1276  vn2.x = n2[0]; vn2.y = n2[1]; vn2.z = n2[2];
1277 
1278  o = newstri(tex, vv0, vv1, vv2, vn0, vn1, vn2);
1279  /* don't add degenerate triangles */
1280  if (o != NULL) {
1281  if (scene->normalfixupmode)
1282  stri_normal_fixup(o, scene->normalfixupmode);
1283  add_bounded_object(scene, o);
1284  }
1285 }
1286 
1287 
1288 void rt_vcstri(SceneHandle voidscene, void * tex,
1289  apivector v0, apivector v1, apivector v2,
1290  apivector n0, apivector n1, apivector n2,
1291  apicolor c0, apicolor c1, apicolor c2) {
1292  scenedef * scene = (scenedef *) voidscene;
1293  object * o = newvcstri(tex, v0, v1, v2, n0, n1, n2, c0, c1, c2);
1294  /* don't add degenerate triangles */
1295  if (o != NULL) {
1296  if (scene->normalfixupmode)
1297  vcstri_normal_fixup(o, scene->normalfixupmode);
1298  add_bounded_object(scene, o);
1299  }
1300 }
1301 
1302 
1303 void rt_vcstri3fv(SceneHandle voidscene, void * tex,
1304  const float *v0, const float *v1, const float *v2,
1305  const float *n0, const float *n1, const float *n2,
1306  const float *c0, const float *c1, const float *c2) {
1307  scenedef * scene = (scenedef *) voidscene;
1308  vector vv0, vv1, vv2, vn0, vn1, vn2;
1309  color cc0, cc1, cc2;
1310  object * o;
1311 
1312  vv0.x = v0[0]; vv0.y = v0[1]; vv0.z = v0[2];
1313  vv1.x = v1[0]; vv1.y = v1[1]; vv1.z = v1[2];
1314  vv2.x = v2[0]; vv2.y = v2[1]; vv2.z = v2[2];
1315  vn0.x = n0[0]; vn0.y = n0[1]; vn0.z = n0[2];
1316  vn1.x = n1[0]; vn1.y = n1[1]; vn1.z = n1[2];
1317  vn2.x = n2[0]; vn2.y = n2[1]; vn2.z = n2[2];
1318  cc0.r = c0[0]; cc0.g = c0[1]; cc0.b = c0[2];
1319  cc1.r = c1[0]; cc1.g = c1[1]; cc1.b = c1[2];
1320  cc2.r = c2[0]; cc2.g = c2[1]; cc2.b = c2[2];
1321 
1322  o = newvcstri(tex, vv0, vv1, vv2, vn0, vn1, vn2, cc0, cc1, cc2);
1323  /* don't add degenerate triangles */
1324  if (o != NULL) {
1325  if (scene->normalfixupmode)
1326  vcstri_normal_fixup(o, scene->normalfixupmode);
1327  add_bounded_object(scene, o);
1328  }
1329 }
1330 
1331 
1332 void rt_tristripscnv3fv(SceneHandle voidscene, void * tex,
1333  int numverts, const float * cnv, int numstrips,
1334  const int *vertsperstrip, const int *facets) {
1335  int strip, t, v;
1336  int stripaddr[2][3] = { {0, 1, 2}, {1, 0, 2} };
1337  scenedef * scene = (scenedef *) voidscene;
1338 
1339  /* render triangle strips one triangle at a time
1340  * triangle winding order is:
1341  * v0, v1, v2, then v2, v1, v3, then v2, v3, v4, etc.
1342  */
1343  /* loop over all of the triangle strips */
1344  for (strip=0, v=0; strip < numstrips; strip++) {
1345  /* loop over all triangles in this triangle strip */
1346  for (t=0; t < (vertsperstrip[strip] - 2); t++) {
1347  apivector v0, v1, v2;
1348  apivector n0, n1, n2;
1349  apicolor c0, c1, c2;
1350  int a0, a1, a2;
1351  list * lst;
1352  object * o;
1353 
1354  /* copy the original input texture to each of the triangles... */
1355  /* converting to a vcstri texture if it isn't already */
1356  vcstri_texture * newtex=rt_texture_copy_vcstri(scene, tex);
1357 
1358  /* add texture to the scene texture list */
1359  lst = (list *) malloc(sizeof(list));
1360  lst->item = (void *) newtex;
1361  lst->next = scene->texlist;
1362  scene->texlist = lst;
1363 
1364  /* render one triangle, using lookup table to fix winding order */
1365  a0 = facets[v + (stripaddr[t & 0x01][0])] * 10;
1366  a1 = facets[v + (stripaddr[t & 0x01][1])] * 10;
1367  a2 = facets[v + (stripaddr[t & 0x01][2])] * 10;
1368 
1369  c0.r = cnv[a0 + 0];
1370  c0.g = cnv[a0 + 1];
1371  c0.b = cnv[a0 + 2];
1372  n0.x = cnv[a0 + 4];
1373  n0.y = cnv[a0 + 5];
1374  n0.z = cnv[a0 + 6];
1375  v0.x = cnv[a0 + 7];
1376  v0.y = cnv[a0 + 8];
1377  v0.z = cnv[a0 + 9];
1378 
1379  c1.r = cnv[a1 + 0];
1380  c1.g = cnv[a1 + 1];
1381  c1.b = cnv[a1 + 2];
1382  n1.x = cnv[a1 + 4];
1383  n1.y = cnv[a1 + 5];
1384  n1.z = cnv[a1 + 6];
1385  v1.x = cnv[a1 + 7];
1386  v1.y = cnv[a1 + 8];
1387  v1.z = cnv[a1 + 9];
1388 
1389  c2.r = cnv[a2 + 0];
1390  c2.g = cnv[a2 + 1];
1391  c2.b = cnv[a2 + 2];
1392  n2.x = cnv[a2 + 4];
1393  n2.y = cnv[a2 + 5];
1394  n2.z = cnv[a2 + 6];
1395  v2.x = cnv[a2 + 7];
1396  v2.y = cnv[a2 + 8];
1397  v2.z = cnv[a2 + 9];
1398 
1399  o = newvcstri(newtex, v0, v1, v2, n0, n1, n2, c0, c1, c2);
1400  if (scene->normalfixupmode)
1401  vcstri_normal_fixup(o, scene->normalfixupmode);
1402  add_bounded_object((scenedef *) scene, o);
1403  v++; /* move on to next vertex */
1404  }
1405  v+=2; /* last two vertices are already used by last triangle */
1406  }
1407 }
1408 
1409 
1410 void rt_quadsphere(SceneHandle scene, void * tex, apivector ctr, flt rad) {
1411  quadric * q;
1412  flt factor;
1413  q=(quadric *) newquadric();
1414  factor= 1.0 / (rad*rad);
1415  q->tex=tex;
1416  q->ctr=ctr;
1417 
1418  q->mat.a=factor;
1419  q->mat.b=0.0;
1420  q->mat.c=0.0;
1421  q->mat.d=0.0;
1422  q->mat.e=factor;
1423  q->mat.f=0.0;
1424  q->mat.g=0.0;
1425  q->mat.h=factor;
1426  q->mat.i=0.0;
1427  q->mat.j=-1.0;
1428 
1429  add_unbounded_object((scenedef *) scene, (object *)q);
1430 }
1431 
1432 
1433 void rt_clip_fv(SceneHandle voidscene, int numplanes, const float *planes) {
1434  list * lst;
1435  clip_group * clip;
1436  int i;
1437  scenedef * scene = (scenedef *) voidscene;
1438 
1439  /* copy clipping info into structure */
1440  clip = (clip_group *) malloc(sizeof(clip_group));
1441  clip->numplanes = numplanes;
1442  clip->planes = (flt *) malloc(numplanes * sizeof(flt) * 4);
1443  for (i=0; i<(numplanes*4); i++) {
1444  clip->planes[i] = planes[i];
1445  }
1446 
1447  /* add clipping info to the scene clip list */
1448  lst = (list *) malloc(sizeof(list));
1449  lst->item = (void *) clip;
1450  lst->next = scene->cliplist;
1451  scene->cliplist = lst;
1452 
1453  /* all objects added from this point on are added with this clip group */
1454  scene->curclipgroup = clip;
1455 }
1456 
1457 
1458 void rt_clip_dv(SceneHandle voidscene, int numplanes, const double *planes) {
1459  list * lst;
1460  clip_group * clip;
1461  int i;
1462  scenedef * scene = (scenedef *) voidscene;
1463 
1464  /* copy clipping info into structure */
1465  clip = (clip_group *) malloc(sizeof(clip_group));
1466  clip->numplanes = numplanes;
1467  clip->planes = (flt *) malloc(numplanes * sizeof(flt) * 4);
1468  for (i=0; i<(numplanes*4); i++) {
1469  clip->planes[i] = planes[i];
1470  }
1471 
1472  /* add clipping info to the scene clip list */
1473  lst = (list *) malloc(sizeof(list));
1474  lst->item = (void *) clip;
1475  lst->next = scene->cliplist;
1476  scene->cliplist = lst;
1477 
1478  /* all objects added from this point on are added with this clip group */
1479  scene->curclipgroup = clip;
1480 }
1481 
1482 
1483 void rt_clip_off(SceneHandle voidscene) {
1484  scenedef * scene = (scenedef *) voidscene;
1485 
1486  /* all objects added from this point on are added without clipping */
1487  scene->curclipgroup = NULL;
1488 }
1489 
1490 
void rt_background_gradient(SceneHandle voidscene, apivector up, flt topval, flt botval, apicolor topcol, apicolor botcol)
Set parameters for gradient (sky plane or sphere) background texturing.
Definition: api.c:497
flt a
Definition: quadric.h:12
#define RT_CROP_DISABLED
Image cropping disabled.
Definition: tachyon.h:277
int rt_set_mpi_comm_split(void *mpicomm, int color, int key)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:132
unsigned int new_objectid(scenedef *scene)
Definition: intersect.c:26
float g
Green color component.
Definition: tachyon.h:61
color sky_plane_background_texture(ray *ry)
Definition: texture.c:116
void rt_camera_setup(SceneHandle voidscene, flt zoom, flt aspectratio, int antialiasing, int raydepth, apivector camcent, apivector viewvec, apivector upvec)
Define a camera for a perspective projection, given the specified zoom factor, aspect ratio...
Definition: api.c:229
color fog_color_exp2(struct fogdata_t *fog, color col, flt r)
OpenGL-like exponential-squared fog.
Definition: shade.c:735
object * newring(void *tex, vector ctr, vector norm, flt inrad, flt outrad)
Definition: ring.c:33
float r
Red color component.
Definition: tachyon.h:60
#define RT_TEXTURE_GRIT
"grit" procedural texture
Definition: tachyon.h:604
void * rt_texture(SceneHandle sc, apitexture *apitex)
Translate a texture definition into the internal format used by Tachyon, and returns an opaque pointe...
Definition: api.c:933
void rt_set_numthreads(SceneHandle voidscene, int numthreads)
Explicitly set the number of worker threads Tachyon will use.
Definition: api.c:471
int rt_par_finish(rt_parhandle voidhandle)
Definition: parallel.c:276
flt h
Definition: quadric.h:14
int rt_set_mpi_comm(void *mpicomm)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:125
void rt_camera_eye_separation(SceneHandle voidscene, flt eyesep)
Set camera stereoscopic eye separation.
Definition: api.c:307
void rt_tristripscnv3fv(SceneHandle voidscene, void *tex, int numverts, const float *cnv, int numstrips, const int *vertsperstrip, const int *facets)
Define smooth-shaded triangle strips using interpolated vertex normals, and per-vertex colors...
Definition: api.c:1332
void rt_ring3fv(SceneHandle scene, void *tex, const float *ctr, const float *norm, float inner, float outer)
Define an annular ring.
Definition: api.c:1203
void InitTextures(void)
Definition: texture.c:535
flt c
Definition: quadric.h:12
void rt_background_sky_sphere(SceneHandle voidscene, apivector up, flt topval, flt botval, apicolor topcol, apicolor botcol)
Set parameters for sky sphere background texturing.
Definition: api.c:539
apicolor col
base object color
Definition: tachyon.h:67
color solid_background_texture(ray *ry)
Definition: texture.c:77
flt b
Definition: quadric.h:12
void rt_shadermode(SceneHandle voidscene, int mode)
Set the shading mode for the specified scene.
Definition: api.c:646
apivector rot
rotation of texture around origin
Definition: tachyon.h:74
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
texture * new_standard_texture(void)
Definition: texture.c:45
void rt_get_camera_position(SceneHandle voidscene, apivector *camcent, apivector *viewvec, apivector *upvec, apivector *rightvec)
Get camera position and orientation.
Definition: api.c:273
#define RT_FOG_LINEAR
linear fog
Definition: tachyon.h:441
void rt_light_attenuation(void *vli, flt Kc, flt Kl, flt Kq)
Set light attenuation parameters for an existing light.
Definition: api.c:1142
quadric * newquadric(void)
Definition: quadric.c:35
void rt_trans_mode(SceneHandle voidscene, int mode)
Set transparency rendering mode.
Definition: api.c:619
flt diffuse
diffuse reflection
Definition: tachyon.h:70
color lowest_shader(ray *incident)
Definition: shade.c:32
flt opacity
how opaque the object is
Definition: tachyon.h:72
#define RT_TEXTURE_3D_CHECKER
checkerboard texture
Definition: tachyon.h:603
color fog_color_exp(struct fogdata_t *fog, color col, flt r)
OpenGL-like exponential fog.
Definition: shade.c:715
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
int rt_initialize_nompi(void)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:58
#define RT_FOG_OPENGL
planar OpenGL-like fog
Definition: tachyon.h:419
void rt_vcstri3fv(SceneHandle voidscene, void *tex, const float *v0, const float *v1, const float *v2, const float *n0, const float *n1, const float *n2, const float *c0, const float *c1, const float *c2)
Define a smooth-shaded triangle using interpolated vertex normals and per-vertex colors.
Definition: api.c:1303
void rt_trans_max_surfaces(SceneHandle voidscene, int count)
Set the maximum number of transparent surfaces that will be rendered.
Definition: api.c:224
#define RT_BACKGROUND_TEXTURE_SOLID
uniform bg color
Definition: tachyon.h:386
color sky_sphere_background_texture(ray *ry)
Definition: texture.c:83
void rt_fog_rendering_mode(SceneHandle voidscene, int mode)
Set fog rendering mode, either radial fog (native Tachyon behavior), or an OpenGL- or VMD-like planar...
Definition: api.c:581
int rt_initialize_mpi_comm(void *mpicomm)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:82
#define RT_TEXTURE_WOOD
"wood" procedural texture
Definition: tachyon.h:606
color marble_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:481
#define RT_SHADER_NULL_PHONG
Disable Phong contributions.
Definition: tachyon.h:673
flt specular
specular reflection
Definition: tachyon.h:71
#define RT_TEXTURE_MARBLE
"marble" procedural texture
Definition: tachyon.h:605
box * newbox(void *tex, vector min, vector max)
Definition: box.c:40
#define RT_SHADER_LOW
low quality shading
Definition: tachyon.h:657
void cameradefault(camdef *camera)
Definition: camera.c:1049
#define RT_TEXTURE_CONSTANT
solid color
Definition: tachyon.h:602
#define RT_TRANS_ORIG
original transparency mode
Definition: tachyon.h:458
rt_parhandle global_parhnd
parallel message passing data structures
Definition: global.c:16
#define RT_TEXTURE_CYLINDRICAL_IMAGE
cylindrical image map
Definition: tachyon.h:609
#define RT_SHADER_BLINN_FAST
Fast version of Blinn&#39;s equation.
Definition: tachyon.h:674
void rt_aa_maxsamples(SceneHandle voidscene, int maxsamples)
Sets the maximum number of supersamples to take for any pixel.
Definition: api.c:210
#define RT_SHADER_FULL
Highest quality shading available.
Definition: tachyon.h:660
int rt_par_set_mpi_comm(rt_parhandle voidhandle, void *mpicomm)
Definition: parallel.c:179
void rt_fog_parms(SceneHandle voidscene, apicolor col, flt start, flt end, flt density)
Set fog rendering parameters.
Definition: api.c:573
void rt_ui_message(int level, char *msg)
Definition: ui.c:31
apicolor rt_color(flt r, flt g, flt b)
Helper function to make colors.
Definition: api.c:169
void rt_extvol(SceneHandle scene, void *tex, apivector min, apivector max, int samples, flt(*evaluator)(flt, flt, flt))
Define an axis-aligned volumetric data set, with a user-defined sample evaluation callback function...
Definition: api.c:1152
void * rt_spotlight(SceneHandle voidscene, void *tex, apivector ctr, flt rad, apivector dir, flt start, flt end)
Define a spotlight with associated texture, position, radius, direction, falloff start, and falloff end parameters.
Definition: api.c:1107
void VNorm(apivector *)
color gnoise_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:516
flt f
Definition: quadric.h:13
void rt_camera_zoom(SceneHandle voidscene, flt zoom)
Set camera "zoom" factor.
Definition: api.c:297
color image_volume_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:252
mipmap * LoadMIPMap(const char *filename, int maxlevels)
Definition: imap.c:155
apivector ctr
origin of texture
Definition: tachyon.h:73
color grit_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:291
flt e
Definition: quadric.h:13
flt i
Definition: quadric.h:14
int rt_initialize_mpi_comm_world(void)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:94
rt_parhandle rt_par_init_nompi(void)
Definition: parallel.c:107
int rt_par_set_mpi_comm_split(rt_parhandle voidhandle, void *mpicomm, int color, int key)
Definition: parallel.c:219
void rt_par_delete_scanlinereceives(rt_parhandle voidparhandle, rt_parbuf voidhandle)
Definition: parallel.c:538
#define RT_TEXTURE_VOLUME_IMAGE
volumetric image map
Definition: tachyon.h:612
char imap[96]
name of image map
Definition: tachyon.h:79
extvol * newextvol(void *voidtex, vector min, vector max, int samples, flt(*evaluator)(flt, flt, flt))
Definition: extvol.c:47
void * rt_light3fv(SceneHandle voidscene, void *tex, const float *ctr, float rad)
Define a point light with associated texture, position, and radius.
Definition: api.c:1069
void rt_fog_mode(SceneHandle voidscene, int mode)
Set fog style (linear, exponential, exponential-squared).
Definition: api.c:596
void rt_renderscene(SceneHandle voidscene)
Render the current scene.
Definition: api.c:180
rt_parhandle rt_par_init_mpi_comm(void *mpicomm)
Definition: parallel.c:132
void rt_define_image(const char *name, int xs, int ys, int zs, unsigned char *rgb)
Defines a named 1-D, 2-D, or 3-D texture image with a 24-bit RGB image buffer, without any file refer...
Definition: api.c:956
void * rt_spotlight3fv(SceneHandle voidscene, void *tex, const float *ctr, float rad, const float *dir, float start, float end)
Define a spotlight with associated texture, position, radius, direction, falloff start, and falloff end parameters.
Definition: api.c:1132
void rt_box(SceneHandle scene, void *tex, apivector min, apivector max)
Define an axis-aligned box.
Definition: api.c:1156
point_light * newpointlight(void *tex, vector ctr, flt rad)
Definition: light.c:63
void rt_sphere(SceneHandle scene, void *tex, apivector ctr, flt rad)
Define a sphere with associated texture, center, and radius.
Definition: api.c:1212
void rt_ambient_occlusion(SceneHandle voidscene, int numsamples, apiflt maxdist, apicolor col)
Ambient occlusion lighting, with monte carlo sampling of omnidirectional "sky" light.
Definition: api.c:563
void rt_sphere3fv(SceneHandle scene, void *tex, const float *ctr, float rad)
Define a sphere with associated texture, center, and radius.
Definition: api.c:1216
void rt_get_aspectratio(SceneHandle voidscene, float *aspectratio)
Get the view frustum aspect ratio (width/height)
Definition: api.c:391
Tachyon cross-platform thread creation and management, atomic operations, and CPU feature query APIs...
static void add_bounded_object(scenedef *scene, object *obj)
Definition: api.c:1015
int rt_thread_setconcurrency(int nthr)
set the concurrency level and scheduling scope for threads
Definition: threads.c:618
void rt_rescale_lights(SceneHandle voidscene, flt lightscale)
Rescale all light sources in the scene by factor lightscale.
Definition: api.c:673
int rt_par_rank(rt_parhandle voidhandle)
Definition: parallel.c:309
color cyl_checker_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:337
object * newstri(void *tex, vector v0, vector v1, vector v2, vector n0, vector n1, vector n2)
Definition: triangle.c:84
#define RT_BACKGROUND_TEXTURE_SKY_SPHERE
gradient bg, persp
Definition: tachyon.h:387
int rt_par_set_mpi_comm_world_split(rt_parhandle voidhandle, int color, int key)
Definition: parallel.c:247
int rt_par_getcpuinfo(rt_parhandle voidhandle, nodeinfo **nodes)
Definition: parallel.c:328
int rt_par_set_mpi_comm_world_split_all(rt_parhandle voidhandle)
Definition: parallel.c:261
void cameraprojection(camdef *camera, int mode)
Definition: camera.c:1003
flt rt_get_camera_vfov(SceneHandle voidscene)
Return vertical field of view (in degrees) for a perspective camera.
Definition: api.c:338
texture * new_vcstri_texture(void)
Definition: texture.c:52
flt rt_camera_get_modulate_eye_separation(SceneHandle voidscene)
Definition: api.c:325
void rt_scalarvol(SceneHandle scene, void *tex, apivector min, apivector max, int xs, int ys, int zs, const char *fname, void *voidvol)
Define an axis-aligned scalar volumetric data set, loaded from a file.
Definition: api.c:1146
double flt
generic floating point number, using double
Definition: tachyon.h:47
void rt_tri(SceneHandle voidscene, void *tex, apivector v0, apivector v1, apivector v2)
Define a flat-shaded triangle.
Definition: api.c:1224
void * rt_texture_copy_standard(SceneHandle sc, void *oldtex)
Do not use this unless you know what you&#39;re doing, this is a short-term workaround until new object t...
Definition: api.c:967
object * newvcstri(void *voidtex, vector v0, vector v1, vector v2, vector n0, vector n1, vector n2, color c0, color c1, color c2)
Definition: triangle.c:141
#define RT_SHADER_LOWEST
lowest quality shading available
Definition: tachyon.h:656
void rt_camera_position3fv(SceneHandle voidscene, const float *camcent, const float *viewvec, const float *upvec)
Set camera position and orientation.
Definition: api.c:262
int rt_mynode(void)
distributed memory parallel node rank
Definition: api.c:49
flt shade_nullphong(const ray *incident, const shadedata *shadevars, flt specpower)
Definition: shade.c:574
void camerazoom(camdef *camera, flt zoom)
Definition: camera.c:1041
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 RT_BOUNDING_ENABLED
Enable spatial subdivision/bounding.
Definition: tachyon.h:475
void * rt_directional_light(SceneHandle voidscene, void *tex, apivector dir)
Define a directional light with associated texture and direction.
Definition: api.c:1077
object * newplane(void *tex, vector ctr, vector norm)
Definition: plane.c:33
void rt_crop_disable(SceneHandle voidscene)
Disable output image cropping.
Definition: api.c:396
flt shade_blinn_fast(const ray *incident, const shadedata *shadevars, flt specpower)
Definition: shade.c:616
void rt_clip_fv(SceneHandle voidscene, int numplanes, const float *planes)
Enable or update a clipping plane group.
Definition: api.c:1433
int rt_thread_numprocessors(void)
number of processors available, subject to user override
Definition: threads.c:202
void rt_camera_projection(SceneHandle voidscene, int mode)
Set camera projection mode.
Definition: api.c:251
void FreeTextures(void)
Definition: texture.c:540
flt apiflt
for backward compatibility
Definition: tachyon.h:49
#define RT_AO_MAXDIST_UNLIMITED
unlimited AO distaned macro
Definition: tachyon.h:737
void rt_image_gamma(SceneHandle voidscene, float gamma)
Apply gamma correction to the pixel values after normalization.
Definition: api.c:449
flt y
Y coordinate or direction component.
Definition: tachyon.h:55
#define RT_TEXTURE_SPHERICAL_IMAGE
spherical image map
Definition: tachyon.h:610
apivector scale
scale of texture in x,y,z
Definition: tachyon.h:75
int rt_numnodes(void)
distributed memory parallel node count
Definition: api.c:53
void rt_quadsphere(SceneHandle scene, void *tex, apivector ctr, flt rad)
Define a quadric sphere, normally used only for testing and benchmarking.
Definition: api.c:1410
color medium_shader(ray *incident)
Definition: shade.c:93
SceneHandle rt_newscene(void)
Allocate, initialize, and return a handle for a new scene.
Definition: api.c:698
void light_set_attenuation(point_light *li, flt Kc, flt Kl, flt Kq)
Definition: light.c:129
color image_sphere_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:187
void rt_tex_transmode(void *voidtex, int transmode)
Set transparent surface shading parameters for an existing texture, enabling or disabling angle-modul...
Definition: api.c:1002
color wood_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:370
void rt_fcylinder(SceneHandle scene, void *tex, apivector ctr, apivector axis, flt rad)
Define a finite-length cylinder.
Definition: api.c:1173
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
static void add_unbounded_object(scenedef *scene, object *obj)
Definition: api.c:1034
void rt_outputfile(SceneHandle voidscene, const char *outname)
Set the filename for the output image for the specified scene.
Definition: api.c:350
apivector uaxs
planar map u axis
Definition: tachyon.h:76
#define RT_FORMAT_TARGA
24-bit Targa file
Definition: tachyon.h:240
void stri_normal_fixup(object *otri, int mode)
Definition: triangle.c:118
void rt_normal_fixup_mode(SceneHandle voidscene, int mode)
Set the surface normal and polygon winding order fixup mode to use when generating triangles with int...
Definition: api.c:185
int rt_set_mpi_comm_world_split(int color, int key)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:139
rt_parhandle rt_par_init_mpi_comm_split(void *mpicomm, int color, int key)
Definition: parallel.c:160
RT_OBJECT_HEAD vector ctr
center of quadric object
Definition: quadric.h:20
Tachyon cross-platform timers, special math function wrappers, and RNGs.
flt g
Definition: quadric.h:14
void cameradof(camdef *camera, flt focaldist, flt aperture)
Definition: camera.c:1024
color full_shader(ray *incident)
Definition: shade.c:233
void rt_phong_shader(SceneHandle voidscene, int mode)
Set the equation used for rendering specular highlights.
Definition: api.c:678
void rt_deletescene(SceneHandle voidscene)
Destroy and deallocate the specified scene.
Definition: api.c:784
flt rt_get_camera_zoom(SceneHandle voidscene)
Return current camera "zoom" factor.
Definition: api.c:302
color image_plane_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:219
color fog_color_linear(struct fogdata_t *fog, color col, flt r)
OpenGL-like linear fog.
Definition: shade.c:696
void rt_tri3fv(SceneHandle voidscene, void *tex, const float *v0, const float *v1, const float *v2)
Define a flat-shaded triangle.
Definition: api.c:1234
flt rt_camera_get_eye_separation(SceneHandle voidscene)
Definition: api.c:312
void * SceneHandle
Definition: tachyon.h:51
void rt_camera_dof(SceneHandle voidscene, flt focaldist, flt aperture)
Set depth-of-field rendering options.
Definition: api.c:361
void * newscalarvol(void *voidtex, vector min, vector max, int xs, int ys, int zs, const char *fname, scalarvol *invol)
Definition: vol.c:48
void rt_image_normalize(SceneHandle voidscene)
Enable renormalization of pixel values to the range [0 1) (rather than clamping) prior to output...
Definition: api.c:443
void rt_stri(SceneHandle voidscene, void *tex, apivector v0, apivector v1, apivector v2, apivector n0, apivector n1, apivector n2)
Define a smooth-shaded triangle using interpolated vertex normals.
Definition: api.c:1252
void rt_get_camera_position3fv(SceneHandle voidscene, float *camcent, float *viewvec, float *upvec, float *rightvec)
Get camera position and orientation.
Definition: api.c:280
void rt_stri3fv(SceneHandle voidscene, void *tex, const float *v0, const float *v1, const float *v2, const float *n0, const float *n1, const float *n2)
Define a smooth-shaded triangle using interpolated vertex normals.
Definition: api.c:1264
point_light * newspotlight(void *tex, vector ctr, flt rad, vector dir, flt fallstart, flt fallend)
Definition: light.c:95
int texturefunc
which texture function to use
Definition: tachyon.h:66
apivector rt_vector(flt x, flt y, flt z)
Helper function to make vectors.
Definition: api.c:159
flt ambient
ambient lighting
Definition: tachyon.h:69
apivector vaxs
planar map v axis
Definition: tachyon.h:77
#define RT_SHADER_BLINN
Blinn&#39;s specular highlights, as in OpenGL.
Definition: tachyon.h:675
void rt_background(SceneHandle voidscene, apicolor col)
Set the background color of the specified scene.
Definition: api.c:490
void rt_clip_off(SceneHandle voidscene)
Disable active clipping plane group.
Definition: api.c:1483
void rt_camera_frustum(SceneHandle voidscene, flt left, flt right, flt bottom, flt top)
Set view frustum for active camera.
Definition: api.c:345
void rt_finalize(void)
Shut down Tachyon library for good, at final use before program termination.
Definition: api.c:153
void * rt_texture_copy_vcstri(SceneHandle sc, void *oldvoidtex)
Do not use this unless you know what you&#39;re doing, this is a short-term workaround until new object t...
Definition: api.c:973
void free_objects(object *start)
Definition: intersect.c:34
#define RT_SHADER_MEDIUM
Medium quality shading.
Definition: tachyon.h:658
#define RT_BACKGROUND_TEXTURE_SKY_ORTHO_PLANE
gradient bg, ortho
Definition: tachyon.h:388
color checker_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:307
quadmatrix mat
quadric function coefficient matrix
Definition: quadric.h:21
object * newsphere(void *tex, vector ctr, flt rad)
Definition: sphere.c:33
void rt_fcylinder3fv(SceneHandle scene, void *tex, const float *ctr, const float *axis, float rad)
Define a finite-length cylinder.
Definition: api.c:1177
object * newcylinder(void *tex, vector ctr, vector axis, flt rad)
Definition: cylinder.c:41
flt d
Definition: quadric.h:13
#define RT_TEXTURE_GRADIENT
gradient noise procedural texture
Definition: tachyon.h:607
#define RT_FOG_EXP2
exponential-squared fog
Definition: tachyon.h:443
void rt_image_clamp(SceneHandle voidscene)
Enable clamping of pixel values to the range [0 1) (rather than renormalizing) prior to output...
Definition: api.c:437
void rt_camera_vfov(SceneHandle voidscene, flt vfov)
Set vertical field of view (in degrees) for a perspective camera.
Definition: api.c:333
float b
Blue color component.
Definition: tachyon.h:62
int rt_initialize_mpi_comm_split(void *mpicomm, int color, int key)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:106
void rt_define_teximage_rgb24(const char *name, int xs, int ys, int zs, unsigned char *rgb)
Define a named 1-D, 2-D, or 3-D texture image with a 24-bit RGB image buffer, without any file refere...
Definition: api.c:951
int rt_par_size(rt_parhandle voidhandle)
Definition: parallel.c:314
int rt_set_mpi_comm_world(void)
Override the previously set MPI communicator with MPI_COMM_WORLD.
Definition: api.c:118
void apitextotex(apitexture *apitex, texture *tx)
Definition: api.c:848
void rt_tex_phong(void *voidtex, flt phong, flt phongexp, int type)
Set Phong shading parameters for an existing texture.
Definition: api.c:994
void renderscene(scenedef *scene)
Definition: render.c:549
#define RT_FOG_NONE
no fog
Definition: tachyon.h:440
void rt_outputformat(SceneHandle voidscene, int format)
Set the format of the output image(s).
Definition: api.c:367
#define RT_ACCUMULATE_OFF
accum.
Definition: tachyon.h:348
void rt_boundthresh(SceneHandle voidscene, int threshold)
Set the threshold to be used when automatic generation of ray tracing acceleration structures is to b...
Definition: api.c:630
#define RT_FOG_EXP
exponential fog
Definition: tachyon.h:442
void rt_camera_raydepth(SceneHandle voidscene, int maxdepth)
Camera maximum ray recursion depth (i.e.
Definition: api.c:292
void rt_boundmode(SceneHandle voidscene, int mode)
Enables or disable automatic generation and use of ray tracing acceleration data structures.
Definition: api.c:624
#define RT_SHADER_PHONG
Phong specular highlights.
Definition: tachyon.h:676
rt_parhandle rt_par_init_mpi_comm_world(void)
Definition: parallel.c:151
void getcameraposition(camdef *camera, vector *center, vector *viewvec, vector *upvec, vector *rightvec)
Definition: camera.c:1079
#define MSG_0
Definition: ui.h:12
#define RT_SHADER_AUTO
Automatically determine shader needed.
Definition: tachyon.h:655
void cameraposition(camdef *camera, vector center, vector viewvec, vector upvec)
Definition: camera.c:1056
void rt_plane(SceneHandle scene, void *tex, apivector ctr, apivector norm)
Define a plane.
Definition: api.c:1186
rt_parhandle rt_par_init(int *argc, char ***argv)
Definition: parallel.c:115
void rt_cylinder3fv(SceneHandle scene, void *tex, const float *ctr, const float *axis, float rad)
Define an infinite cylinder.
Definition: api.c:1164
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_ring(SceneHandle scene, void *tex, apivector ctr, apivector norm, flt inner, flt outer)
Define an annular ring.
Definition: api.c:1199
void rt_plane3fv(SceneHandle scene, void *tex, const float *ctr, const float *norm)
Define a plane.
Definition: api.c:1190
color low_shader(ray *incident)
Definition: shade.c:65
void rt_background_mode(SceneHandle voidscene, int mode)
Set the background texturing mode to use.
Definition: api.c:544
void rt_camera_position(SceneHandle voidscene, apivector camcent, apivector viewvec, apivector upvec)
Set camera position and orientation.
Definition: api.c:256
#define RT_SHADER_HIGH
High quality shading.
Definition: tachyon.h:659
void rt_tex_outline(void *voidtex, flt outline, flt outlinewidth)
Set edge cueing outline shading parameters for an existing texture.
Definition: api.c:1008
Tachyon public API function prototypes and declarations used to drive the ray tracing engine...
apivector waxs
volume map W axis
Definition: tachyon.h:78
directional_light * newdirectionallight(void *tex, vector dir)
Definition: light.c:42
#define RT_CROP_ENABLED
Image cropping enabled.
Definition: tachyon.h:278
void rt_clip_dv(SceneHandle voidscene, int numplanes, const double *planes)
Enable or update a clipping plane group.
Definition: api.c:1458
object * newfcylinder(void *tex, vector ctr, vector axis, flt rad)
Definition: cylinder.c:144
color image_cyl_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:155
void rt_camera_modulate_eye_separation(SceneHandle voidscene, flt cospow)
Set camera stereoscopic eye separation modulation and cosine power.
Definition: api.c:317
#define RT_FOG_NORMAL
radial fog
Definition: tachyon.h:418
void rt_cylinder(SceneHandle scene, void *tex, apivector ctr, apivector axis, flt rad)
Define an infinite cylinder.
Definition: api.c:1160
int rt_set_mpi_comm_world_split_all(void)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:146
void * rt_directional_light3fv(SceneHandle voidscene, void *tex, const float *dir)
Define a directional light with associated texture and direction.
Definition: api.c:1099
void rt_crop_output(SceneHandle voidscene, int hres, int vres, int sx, int sy)
Crop the output image to the specified size, intended only for use in SPECMPI benchmarking.
Definition: api.c:405
void * rt_light(SceneHandle voidscene, void *tex, apivector ctr, flt rad)
Define a point light with associated texture, position, and radius.
Definition: api.c:1049
flt shade_phong(const ray *incident, const shadedata *shadevars, flt specpower)
Definition: shade.c:646
void rt_rawimage_rgb96f(SceneHandle voidscene, float *img)
Request Tachyon to save the output image in the specified memory area, in raw 96-bit, packed, pixel interleaved, 32-bit float RGB bytes.
Definition: api.c:428
flt z
Z coordinate or direction component.
Definition: tachyon.h:56
int rt_par_set_mpi_comm_world(rt_parhandle voidhandle)
Definition: parallel.c:206
#define RT_TEXTURE_PLANAR_IMAGE
planar image map
Definition: tachyon.h:611
void free_light_special(void *voidlight)
Definition: light.c:35
color constant_texture(const vector *hit, const texture *tx, const ray *ry)
Definition: texture.c:149
object * newtri(void *tex, vector v0, vector v1, vector v2)
Definition: triangle.c:54
void rt_verbose(SceneHandle voidscene, int v)
Enables or Disables verbose messages from the Tachyon library during rendering.
Definition: api.c:414
void rt_vcstri(SceneHandle voidscene, void *tex, apivector v0, apivector v1, apivector v2, apivector n0, apivector n1, apivector n2, apicolor c0, apicolor c1, apicolor c2)
Define a smooth-shaded triangle using interpolated vertex normals and per-vertex colors.
Definition: api.c:1288
flt j
Definition: quadric.h:14
void vcstri_normal_fixup(object *otri, int mode)
Definition: triangle.c:183
void rt_aspectratio(SceneHandle voidscene, float aspectratio)
Set the view frustum aspect ratio (width/height)
Definition: api.c:385
flt shade_blinn(const ray *incident, const shadedata *shadevars, flt specpower)
Definition: shade.c:583
rawimage * AllocateImageRGB24(const char *filename, int xs, int ys, int zs, unsigned char *rgb)
Definition: imap.c:48
void camerafrustum(camdef *camera, flt left, flt right, flt bottom, flt top)
When the user directly specifies the world coordinates of the view frustum, it overrides the normal c...
Definition: camera.c:1015
#define RT_TEXTURE_CYLINDRICAL_CHECKER
cylindrical checkerboard
Definition: tachyon.h:608
void destroy_render_threads(scenedef *scene)
Definition: render.c:210
void rt_shadow_filtering(SceneHandle voidscene, int onoff)
Control whether or not transparent surfaces modulate incident light or not.
Definition: api.c:219