BRL-CAD
sh_billboard.c
Go to the documentation of this file.
1 /* S H _ B I L L B O A R D . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file liboptical/sh_billboard.c
21  *
22  * A billboard shader for use with RCC geometry
23  *
24  * 6) Edit shaders.tcl and comb.tcl in the ../tclscripts/mged directory to
25  * add a new gui for this shader.
26  */
27 
28 #include "common.h"
29 
30 #include <stdlib.h>
31 #include <stddef.h>
32 #include <stdio.h>
33 #include <string.h>
34 #include <math.h>
35 
36 #include "bu/sort.h"
37 #include "vmath.h"
38 #include "raytrace.h"
39 #include "rtgeom.h"
40 #include "optical.h"
41 #include "plot3.h"
42 
43 
44 #define bbd_MAGIC 0x62626400 /* "bbd" */
45 #define CK_bbd_SP(_p) BU_CKMAG(_p, bbd_MAGIC, "bbd_specific")
46 
47 struct bbd_img {
48  struct bu_list l; /* must be first */
49  plane_t img_plane; /* plane eqn for image plane */
50  point_t img_origin; /* image origin in XYZ */
51  vect_t img_x; /* u direction in image plane */
52  double img_xlen; /* length of image in u direction */
53  vect_t img_y; /* v direction in image plane */
54  double img_ylen; /* length of image in v direction */
55  size_t img_width; /* dimension of image */
56  size_t img_height;
57  struct bu_mapped_file *img_mf; /* image data */
58 };
59 
60 
61 /*
62  * the shader specific structure contains all variables which are unique
63  * to any particular use of the shader.
64  */
65 struct bbd_specific {
66  uint32_t magic; /* magic # for memory validity check, must come 1st */
68  size_t img_width;
69  size_t img_height;
70  double img_scale;
72 
73  /* these are not initialized by the user */
74  size_t img_count;
75  struct bu_list imgs;
76 
77  struct rt_i *rtip; /* this is needed by structparse */
78  plane_t p_A;
79  plane_t p_B;
80 
81 };
82 #define MAX_IMAGES 64
83 /* The default values for the variables in the shader specific structure */
84 static const
85 struct bbd_specific bbd_defaults = {
86  bbd_MAGIC,
87  10, /* img_threshold */
88  512, /* img_width */
89  512, /* img_height */
90  100.0, /* img_scale */
92  0,
94  NULL,
95  HINIT_ZERO,
96  HINIT_ZERO
97 };
98 
99 
100 #define SHDR_NULL ((struct bbd_specific *)0)
101 #define SHDR_O(m) bu_offsetof(struct bbd_specific, m)
102 
103 /* local sp_hook function */
104 void new_image(const struct bu_structparse *, const char *, void *, const char *, void *);
105 
106 
107 /* description of how to parse/print the arguments to the shader
108  * There is at least one line here for each variable in the shader specific
109  * structure above
110  */
112  {"%ld", 1, "w", SHDR_O(img_width), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
113  {"%ld", 1, "n", SHDR_O(img_height), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
114  {"%d", 1, "t", SHDR_O(img_threshold), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
115  {"%g", 1, "h", SHDR_O(img_scale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
116  {"%V", 1, "f", SHDR_O(img_filename), new_image, NULL, NULL },
117  {"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
118 };
120  {"%p", 1, "bbd_print_tab", bu_byteoffset(bbd_print_tab[0]), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
121  {"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
122 };
123 
124 
125 void
126 new_image(const struct bu_structparse *UNUSED(sdp),
127  const char *UNUSED(name),
128  void *base,
129  const char *UNUSED(value),
130  void *UNUSED(data))
131 {
132  struct bbd_specific *bbd_sp = (struct bbd_specific *)base;
133  struct bbd_img *bbdi;
134 
135  /* XXX - looks like we don't release this memory */
136  BU_ALLOC(bbdi, struct bbd_img);
137 
139  bbd_sp->rtip->rti_dbip->dbi_filepath,
140  bu_vls_addr(&bbd_sp->img_filename),
141  NULL);
142 
143  if (!bbdi->img_mf) {
144  bu_log("error opening image %s\n", bu_vls_addr(&bbd_sp->img_filename));
145  bu_bomb("");
146  }
147  BU_CK_MAPPED_FILE(bbdi->img_mf);
148 
149  bbdi->img_width = bbd_sp->img_width;
150  bbdi->img_width = bbd_sp->img_height;
151 
152  BU_LIST_APPEND(&bbd_sp->imgs, &(bbdi->l));
153  bbd_sp->img_count++;
154 
155 }
156 
157 
158 /*
159  * This routine is called (at prep time)
160  * once for each region which uses this shader.
161  * Any shader-specific initialization should be done here.
162  *
163  * Returns:
164  * 1 success
165  * 0 success, but delete region
166  * -1 failure
167  */
168 HIDDEN int
169 bbd_setup(struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
170 {
171  register struct bbd_specific *bbd_sp;
172  struct rt_db_internal intern;
173  struct rt_tgc_internal *tgc;
174  int s;
175  mat_t mat;
176  struct bbd_img *bi;
177  double angle;
178  vect_t vtmp;
179  int img_num;
180  vect_t vv;
181 
182  /* check the arguments */
183  RT_CHECK_RTI(rtip);
184  BU_CK_VLS(matparm);
185  RT_CK_REGION(rp);
186 
187 
188  if (rdebug&RDEBUG_SHADE) bu_log("bbd_setup(%s)\n", rp->reg_name);
189 
190  RT_CK_TREE(rp->reg_treetop);
191 
192  if (rp->reg_treetop->tr_a.tu_op != OP_SOLID) {
193  bu_log("--- Warning: Region %s shader %s", rp->reg_name, mfp->mf_name);
194  bu_bomb("Shader should be used on region of single (rec/rcc) primitive\n");
195  }
196 
198  if (rp->reg_treetop->tr_a.tu_stp->st_id != ID_REC) {
199  bu_log("--- Warning: Region %s shader %s", rp->reg_name, mfp->mf_name);
200  bu_log("Shader should be used on region of single REC/RCC primitive %d\n",
201  rp->reg_treetop->tr_a.tu_stp->st_id);
202  bu_bomb("oops\n");
203  }
204 
205 
206  /* Get memory for the shader parameters and shader-specific data */
207  BU_GET(bbd_sp, struct bbd_specific);
208  *dpp = bbd_sp;
209 
210  /* initialize the default values for the shader */
211  memcpy(bbd_sp, &bbd_defaults, sizeof(struct bbd_specific));
212  bu_vls_init(&bbd_sp->img_filename);
213  BU_LIST_INIT(&bbd_sp->imgs);
214  bbd_sp->rtip = rtip; /* because new_image() needs this */
215  bbd_sp->img_count = 0;
216 
217  /* parse the user's arguments for this use of the shader. */
218  if (bu_struct_parse(matparm, bbd_parse_tab, (char *)bbd_sp, NULL) < 0)
219  return -1;
220 
221  if (bbd_sp->img_count > MAX_IMAGES) {
222  bu_log("too many images (%zu) in shader for %s sb < %d\n",
223  bbd_sp->img_count, rp->reg_name, MAX_IMAGES);
224  bu_bomb("excessive image count\n");
225  }
226 
227 
228  MAT_IDN(mat);
229  RT_DB_INTERNAL_INIT(&intern);
230  s = rt_db_get_internal(&intern, rp->reg_treetop->tr_a.tu_stp->st_dp, rtip->rti_dbip,
231  mat, &rt_uniresource);
232 
233  if (intern.idb_minor_type != ID_TGC &&
234  intern.idb_minor_type != ID_REC) {
235  bu_log("What did I get? %d\n", intern.idb_minor_type);
236  }
237 
238  if (s < 0) {
239  bu_log("%s:%d didn't get internal", __FILE__, __LINE__);
240  bu_bomb("");
241  }
242  tgc = (struct rt_tgc_internal *)intern.idb_ptr;
243  RT_TGC_CK_MAGIC(tgc);
244 
245  angle = M_PI / (double)bbd_sp->img_count;
246  img_num = 0;
247  VMOVE(vv, tgc->h);
248  VUNITIZE(vv);
249  for (BU_LIST_FOR(bi, bbd_img, &bbd_sp->imgs)) {
250  static const point_t o = VINIT_ZERO;
251  bn_mat_arb_rot(mat, o, vv, angle*img_num);
252 
253  /* compute plane equation */
254  MAT4X3VEC(bi->img_plane, mat, tgc->a);
255  VUNITIZE(bi->img_plane);
256  bi->img_plane[H] = VDOT(tgc->v, bi->img_plane);
257 
258  MAT4X3VEC(vtmp, mat, tgc->b);
259  VADD2(bi->img_origin, tgc->v, vtmp); /* image origin in 3d space */
260  /* calculate image u vector */
261  VREVERSE(bi->img_x, vtmp);
262  VUNITIZE(bi->img_x);
263  bi->img_xlen = MAGNITUDE(vtmp) * 2;
264 
265  /* calculate image v vector */
266  VMOVE(bi->img_y, tgc->h);
267  VUNITIZE(bi->img_y);
268  bi->img_ylen = MAGNITUDE(tgc->h);
269 
270  if (rdebug&RDEBUG_SHADE) {
271  HPRINT("\nimg_plane", bi->img_plane);
272  VPRINT("vtmp", vtmp);
273  VPRINT("img_origin", bi->img_origin);
274  bu_log("img_xlen:%g ", bi->img_xlen);
275  VPRINT("img_x", bi->img_x);
276  bu_log("img_ylen:%g ", bi->img_ylen);
277  VPRINT("img_y", bi->img_y);
278  }
279 
280  img_num++;
281  }
282 
283  rt_db_free_internal(&intern);
284 
285  if (rdebug&RDEBUG_SHADE) {
286  bu_struct_print(" Parameters:", bbd_print_tab, (char *)bbd_sp);
287  }
288 
289  return 1;
290 }
291 
292 
293 HIDDEN void
294 bbd_print(struct region *rp, void *dp)
295 {
296  bu_struct_print(rp->reg_name, bbd_print_tab, (char *)dp);
297 }
298 
299 
300 HIDDEN void
301 bbd_free(void *cp)
302 {
303  BU_PUT(cp, struct bbd_specific);
304 }
305 
306 
307 static void
308 plot_ray_img(struct application *ap,
309  const struct partition *pp,
310  double dist,
311  struct bbd_img *bi)
312 {
313  static int plot_num;
314  FILE *pfd;
315  char name[256];
316  point_t pt;
317 
318  sprintf(name, "bbd_%d.plot3", plot_num++);
319  bu_log("plotting %s\n", name);
320  if ((pfd = fopen(name, "wb")) == (FILE *)NULL) {
321  bu_bomb("can't open plot3 file\n");
322  }
323 
324  /* red line from ray origin to hit point */
325  VJOIN1(pp->pt_inhit->hit_point, ap->a_ray.r_pt, pp->pt_inhit->hit_dist,
326  ap->a_ray.r_dir);
327  if (VNEAR_EQUAL(ap->a_ray.r_pt, pp->pt_inhit->hit_point, 0.125)) {
328  /* start and hit point identical, make special allowance */
329  vect_t vtmp;
330 
331  pl_color(pfd, 255, 0, 128);
332  VREVERSE(vtmp, ap->a_ray.r_dir);
333  VJOIN1(vtmp, ap->a_ray.r_pt, 5.0, vtmp);
334  pdv_3line(pfd, vtmp, pp->pt_inhit->hit_point);
335  } else {
336  pl_color(pfd, 255, 0, 0);
337  pdv_3line(pfd, ap->a_ray.r_pt, pp->pt_inhit->hit_point);
338  }
339 
340  /* yellow line from hit point to plane point */
341  VJOIN1(pt, ap->a_ray.r_pt, dist, ap->a_ray.r_dir); /* point on plane */
342  pl_color(pfd, 255, 255, 0);
343  pdv_3line(pfd, pp->pt_inhit->hit_point, pt);
344 
345  /* green line from image origin to plane point */
346  pl_color(pfd, 0, 255, 0);
347  pdv_3line(pfd, pt, bi->img_origin);
348 
349  fclose(pfd);
350 
351 
352 }
353 
354 
355 /*
356  * Handle ray interaction with 1 image
357  */
358 static void
359 do_ray_image(struct application *ap,
360  const struct partition *pp,
361  struct shadework *swp, /* defined in ../h/shadework.h */
362  struct bbd_specific *bbd_sp,
363  struct bbd_img *bi,
364  double dist)
365 {
366  double x, y, dx, dy, xlo, xhi, ylo, yhi;
367  int u, v, ulo, uhi, vlo, vhi;
368  unsigned char *pixels, *color;
369  int val;
370  static const double rgb255 = 1.0 / 256.0;
371  vect_t cum_color;
372  point_t pt;
373  vect_t vpt;
374  double radius;
375  int tot;
376  int color_count;
377  double t, opacity;
378 
379  if (rdebug&RDEBUG_SHADE) {
380  bu_log("do_ray_image\n");
381  plot_ray_img(ap, pp, dist, bi);
382  }
383 
384  VJOIN1(pt, ap->a_ray.r_pt, dist, ap->a_ray.r_dir); /* point on plane */
385  VSUB2(vpt, pt, bi->img_origin); /* vect: origin to pt */
386  x = VDOT(vpt, bi->img_x);
387  y = VDOT(vpt, bi->img_y);
388 
389  if (x < 0.0 || x > bi->img_xlen ||
390  y < 0.0 || y > bi->img_ylen) {
391  if (rdebug&RDEBUG_SHADE) {
392  bu_log("hit outside bounds, leaving color %g %g %g\n",
393  V3ARGS(swp->sw_color));
394  }
395  return;
396  }
397 
398 
399  /* get the radius of the beam at the image plane */
400  radius = ap->a_rbeam + dist * ap->a_diverge;
401 
402  /*
403  dx = radius * VDOT(ap->a_ray.r_dir, bi->img_x);
404  dy = radius * VDOT(ap->a_ray.r_dir, bi->img_y);
405  */
406  dx = radius;
407  dy = radius;
408 
409 
410  xlo = x - dx;
411  xhi = x + dx;
412 
413  ylo = y - dy;
414  yhi = y + dy;
415 
416  CLAMP(xlo, 0.0, bi->img_xlen);
417  CLAMP(xhi, 0.0, bi->img_xlen);
418 
419  CLAMP(ylo, 0.0, bi->img_ylen);
420  CLAMP(yhi, 0.0, bi->img_ylen);
421 
422  vlo = (ylo / bi->img_ylen) * (bi->img_height -1);
423  vhi = (yhi / bi->img_ylen) * (bi->img_height -1);
424 
425  ulo = (xlo / bi->img_xlen) * (bi->img_width -1);
426  uhi = (xhi / bi->img_xlen) * (bi->img_width -1);
427 
428  if (ulo > uhi) { int i = ulo; ulo = uhi; uhi = i; }
429  if (vlo > vhi) { int i = vlo; vlo = vhi; vhi = i; }
430 
431  pixels = (unsigned char*)bi->img_mf->buf;
432 
433  if (rdebug&RDEBUG_SHADE) {
434  bu_log("u:%d..%d v:%d..%d\n", ulo, uhi, vlo, vhi);
435  }
436 
437  tot = (uhi - ulo + 1) * (vhi - vlo + 1); /* total # of pixels */
438  color_count = 0; /* */
439  VSETALL(cum_color, 0.0);
440  for (v = vlo; v <= vhi; v++) {
441  for (u = ulo; u <= uhi; u++) {
442  color = &pixels[v*bi->img_width*3 + u*3];
443  val = color[0]+color[1]+color[2];
444  if (val > bbd_sp->img_threshold) {
445  color_count++;
446  VJOIN1(cum_color, cum_color, rgb255, color);
447  if (rdebug&RDEBUG_SHADE) {
448  bu_log("%d %d %d\n", V3ARGS(color));
449  VPRINT("cum_color", cum_color);
450  }
451  }
452  }
453  }
454  if (rdebug&RDEBUG_SHADE)
455  bu_log("tot:%d color_count: %d\n", tot, color_count);
456 
457  if (color_count == 0) {
458  if (rdebug&RDEBUG_SHADE)
459  bu_log("no color contribution, leaving color as %g %g %g\n",
460  V3ARGS(swp->sw_color));
461  return;
462  }
463  /* get average color: scale color by the # of contributions */
464  t = 1.0 / (double)color_count;
465  VSCALE(cum_color, cum_color, t);
466  if (rdebug&RDEBUG_SHADE) {
467  int c[3];
468 
469  VSCALE(c, cum_color, 256);
470  bu_log("average color: %d %d %d\n", V3ARGS(c));
471  }
472 
473  /* compute residual transmission */
474  opacity = ((double)color_count / tot); /* opacity */
475 
476  t = swp->sw_transmit*opacity;
477  VJOIN1(swp->sw_color, swp->sw_color, t, cum_color);
478 
479  swp->sw_transmit -= opacity;
480  if (swp->sw_transmit < 0.0) swp->sw_transmit = 0.0;
481 
482 
483 }
484 
485 
486 struct imgdist {
487  int status;
489  struct bbd_img *bi;
490  int index;
491 };
492 
493 
494 int
495 imgdist_compare(const void *a, const void *b, void *UNUSED(arg))
496 {
497  return (int)(((struct imgdist *)a)->dist - ((struct imgdist *)b)->dist);
498 }
499 
500 
501 /*
502  * This is called (from viewshade() in shade.c) once for each hit point
503  * to be shaded. The purpose here is to fill in values in the shadework
504  * structure.
505  *
506  * dp is a pointer to the shader-specific struct
507  */
508 int
509 bbd_render(struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
510 {
511  register struct bbd_specific *bbd_sp = (struct bbd_specific *)dp;
512  union tree *tp;
513  struct bbd_img *bi;
514  struct imgdist id[MAX_IMAGES];
515  size_t i;
516 
517  /* check the validity of the arguments we got */
518  RT_AP_CHECK(ap);
519  RT_CHECK_PT(pp);
520  CK_bbd_SP(bbd_sp);
521 
522  if (rdebug&RDEBUG_SHADE) {
523  bu_struct_print("bbd_render Parameters:",
524  bbd_print_tab, (char *)bbd_sp);
525  bu_log("pixel %d %d\n", ap->a_x, ap->a_y);
526  bu_log("bbd region: %s\n", pp->pt_regionp->reg_name);
527  }
528  tp = pp->pt_regionp->reg_treetop;
529  if (tp->tr_a.tu_op != OP_SOLID) {
530  bu_log("%s:%d region %s rendering bbd should have found OP_SOLID, not %d\n",
531  __FILE__, __LINE__, pp->pt_regionp->reg_name, tp->tr_a.tu_op);
532  bu_bomb("\n");
533  }
534 
535 
536  swp->sw_transmit = 1.0;
537  VSETALL(swp->sw_color, 0.0);
538  VSETALL(swp->sw_basecolor, 1.0);
539 
540  i = 0;
541  for (BU_LIST_FOR(bi, bbd_img, &bbd_sp->imgs)) {
542  /* find out if the ray hits the plane */
543  id[i].index = i;
544  id[i].bi = bi;
545  id[i].status = bn_isect_line3_plane(&id[i].dist,
546  ap->a_ray.r_pt, ap->a_ray.r_dir,
547  bi->img_plane, &ap->a_rt_i->rti_tol);
548  i++;
549  }
550 
551  bu_sort(id, bbd_sp->img_count, sizeof(id[0]), &imgdist_compare, NULL);
552 
553  for (i = 0; i < bbd_sp->img_count && swp->sw_transmit > 0.0; i++) {
554  if (id[i].status > 0) do_ray_image(ap, pp, swp, bbd_sp, id[i].bi, id[i].dist);
555  }
556  if (rdebug&RDEBUG_SHADE) {
557  bu_log("color %g %g %g\n", V3ARGS(swp->sw_color));
558  }
559  /* shader must perform transmission/reflection calculations
560  *
561  * 0 < swp->sw_transmit <= 1 causes transmission computations
562  * 0 < swp->sw_reflect <= 1 causes reflection computations
563  */
564  if (swp->sw_reflect > 0 || swp->sw_transmit > 0) {
565  int level = ap->a_level;
566  ap->a_level = 0; /* Bogus hack to keep rr_render from giving up */
567  (void)rr_render(ap, pp, swp);
568  ap->a_level = level;
569  }
570  if (rdebug&RDEBUG_SHADE) {
571  bu_log("color %g %g %g\n", V3ARGS(swp->sw_color));
572  }
573  return 1;
574 }
575 
576 
577 /* The "mfuncs" structure defines the external interface to the shader.
578  * Note that more than one shader "name" can be associated with a given
579  * shader by defining more than one mfuncs struct in this array.
580  * See sh_phong.c for an example of building more than one shader "name"
581  * from a set of source functions. There you will find that "glass" "mirror"
582  * and "plastic" are all names for the same shader with different default
583  * values for the parameters.
584  */
585 struct mfuncs bbd_mfuncs[] = {
586  {MF_MAGIC, "bbd", 0, MFI_NORMAL|MFI_HIT|MFI_UV, 0,
588 
589  {0, (char *)0, 0, 0, 0,
590  0, 0, 0, 0 }
591 };
592 
593 
594 /*
595  * Local Variables:
596  * mode: C
597  * tab-width: 8
598  * indent-tabs-mode: t
599  * c-file-style: "stroustrup"
600  * End:
601  * ex: shiftwidth=4 tabstop=8
602  */
Definition: db_flip.c:35
void bu_vls_init(struct bu_vls *vp)
Definition: vls.c:56
size_t img_width
Definition: sh_billboard.c:55
struct xray a_ray
Actual ray to be shot.
Definition: raytrace.h:1583
#define BU_LIST_FOR(p, structure, hp)
Definition: list.h:365
struct bu_structparse bbd_print_tab[]
Definition: sh_billboard.c:111
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
int rt_db_get_internal(struct rt_db_internal *ip, const struct directory *dp, const struct db_i *dbip, const mat_t mat, struct resource *resp)
Definition: dir.c:76
struct region * pt_regionp
ptr to containing region
Definition: raytrace.h:580
#define bu_byteoffset(_i)
Definition: parse.h:81
int bn_isect_line3_plane(fastf_t *dist, const point_t pt, const vect_t dir, const plane_t plane, const struct bn_tol *tol)
#define bbd_MAGIC
Definition: sh_billboard.c:44
size_t img_count
Definition: sh_billboard.c:74
Definition: list.h:118
const struct directory * st_dp
Directory entry of solid.
Definition: raytrace.h:436
int status
Definition: sh_billboard.c:487
#define MF_MAGIC
Definition: magic.h:205
#define MAX_IMAGES
Definition: sh_billboard.c:82
if lu s
Definition: nmg_mod.c:3860
Definition: clone.c:90
fastf_t dist
Definition: sh_billboard.c:488
#define VSETALL(a, s)
Definition: color.c:54
#define M_PI
Definition: fft.h:35
#define BU_LIST_INIT_ZERO
Definition: list.h:167
int tu_op
leaf, OP_SOLID
Definition: raytrace.h:1154
char ** dbi_filepath
search path for aux file opens (convenience var)
Definition: raytrace.h:810
HIDDEN void bbd_free(void *cp)
Definition: sh_billboard.c:301
Header file for the BRL-CAD common definitions.
vect_t img_x
Definition: sh_billboard.c:51
const char * reg_name
Identifying string.
Definition: raytrace.h:539
#define BU_LIST_APPEND(old, new)
Definition: list.h:197
struct rt_i * rtip
Definition: sh_billboard.c:77
#define RT_CK_REGION(_p)
Definition: raytrace.h:559
struct hit * pt_inhit
IN hit pointer.
Definition: raytrace.h:577
#define HIDDEN
Definition: common.h:86
size_t img_height
Definition: sh_billboard.c:69
struct bu_mapped_file * img_mf
Definition: sh_billboard.c:57
struct soltab * tu_stp
Definition: raytrace.h:1156
void bu_struct_print(const char *title, const struct bu_structparse *parsetab, const char *base)
Definition: parse.c:1221
HIDDEN int bbd_setup(struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Definition: sh_billboard.c:169
#define CK_bbd_SP(_p)
Definition: sh_billboard.c:45
if(share_geom)
Definition: nmg_mod.c:3829
#define RT_AP_CHECK(_ap)
Definition: raytrace.h:1685
point_t img_origin
Definition: sh_billboard.c:50
COMPLEX data[64]
Definition: fftest.c:34
struct rt_i * a_rt_i
this librt instance
Definition: raytrace.h:1588
#define BU_CK_VLS(_vp)
Definition: vls.h:69
struct resource rt_uniresource
default. Defined in librt/globals.c
Definition: globals.c:41
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
#define RT_CHECK_RTI(_p)
Definition: raytrace.h:1832
#define RT_DB_INTERNAL_INIT(_p)
Definition: raytrace.h:199
fastf_t a_diverge
slope of beam divergence/mm
Definition: raytrace.h:1600
#define V3ARGS(a)
Definition: color.c:56
int a_x
Screen X of ray, if applicable.
Definition: raytrace.h:1596
#define BU_GET(_ptr, _type)
Definition: malloc.h:201
point_t hit_point
DEPRECATED: Intersection point, use VJOIN1 hit_dist.
Definition: raytrace.h:251
uint32_t magic
Definition: sh_billboard.c:66
#define BU_CK_MAPPED_FILE(_mf)
Definition: mapped_file.h:101
void bu_sort(void *array, size_t nummemb, size_t sizememb, int(*compare)(const void *, const void *, void *), void *context)
Definition: sort.c:110
plane_t p_A
Definition: sh_billboard.c:78
int a_level
recursion level (for printing)
Definition: raytrace.h:1595
double img_scale
Definition: sh_billboard.c:70
#define UNUSED(parameter)
Definition: common.h:239
#define HPRINT(a, b)
Definition: raytrace.h:1882
int bbd_render(struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
Definition: sh_billboard.c:509
#define BU_PUT(_ptr, _type)
Definition: malloc.h:215
double img_ylen
Definition: sh_billboard.c:54
char * bu_vls_addr(const struct bu_vls *vp)
Definition: vls.c:111
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
void pl_color(register FILE *plotfp, int r, int g, int b)
Definition: plot3.c:325
vect_t r_dir
Direction of ray (UNIT Length)
Definition: raytrace.h:219
void pdv_3line(register FILE *plotfp, const fastf_t *a, const fastf_t *b)
Definition: plot3.c:642
#define ID_REC
Right Elliptical Cylinder [TGC special].
Definition: raytrace.h:465
vect_t img_y
Definition: sh_billboard.c:53
struct bn_tol rti_tol
Math tolerances for this model.
Definition: raytrace.h:1765
struct mfuncs bbd_mfuncs[]
Definition: sh_billboard.c:585
size_t img_height
Definition: sh_billboard.c:56
#define BU_LIST_INIT(_hp)
Definition: list.h:148
void * idb_ptr
Definition: raytrace.h:195
struct bu_structparse bbd_parse_tab[]
Definition: sh_billboard.c:119
double img_xlen
Definition: sh_billboard.c:52
point_t r_pt
Point at which ray starts.
Definition: raytrace.h:218
#define SHDR_O(m)
Definition: sh_billboard.c:101
size_t img_width
Definition: sh_billboard.c:68
#define RDEBUG_SHADE
Definition: optical.h:130
struct db_i * rti_dbip
prt to Database instance struct
Definition: raytrace.h:1774
int bu_struct_parse(const struct bu_vls *in_vls, const struct bu_structparse *desc, const char *base, void *data)
Definition: parse.c:878
int a_y
Screen Y of ray, if applicable.
Definition: raytrace.h:1597
#define RT_CK_SOLTAB(_p)
Definition: raytrace.h:453
union tree * reg_treetop
Pointer to boolean tree.
Definition: raytrace.h:540
plane_t p_B
Definition: sh_billboard.c:79
int idb_minor_type
ID_xxx.
Definition: raytrace.h:193
fastf_t a_rbeam
initial beam radius (mm)
Definition: raytrace.h:1599
struct bu_vls img_filename
Definition: sh_billboard.c:71
#define RT_CK_TREE(_p)
Definition: raytrace.h:1182
int rr_render(struct application *app, const struct partition *pp, struct shadework *swp)
#define OP_SOLID
Leaf: tr_stp -> solid.
Definition: raytrace.h:1126
HIDDEN void bbd_print(struct region *rp, void *dp)
Definition: sh_billboard.c:294
#define BU_VLS_INIT_ZERO
Definition: vls.h:84
int st_id
Solid ident.
Definition: raytrace.h:431
#define RT_CHECK_PT(_p)
compat
Definition: raytrace.h:588
fastf_t hit_dist
dist from r_pt to hit_point
Definition: raytrace.h:250
#define ID_TGC
Generalized Truncated General Cone.
Definition: raytrace.h:460
void new_image(const struct bu_structparse *, const char *, void *, const char *, void *)
Definition: sh_billboard.c:126
struct bu_list l
Definition: sh_billboard.c:48
Definition: vls.h:56
struct bu_list imgs
Definition: sh_billboard.c:75
void bu_bomb(const char *str) _BU_ATTR_NORETURN
Definition: bomb.c:91
double fastf_t
Definition: defines.h:300
#define VPRINT(a, b)
Definition: raytrace.h:1881
Header file for the BRL-CAD Optical Library, LIBOPTICAL.
struct bbd_img * bi
Definition: sh_billboard.c:489
struct tree::tree_leaf tr_a
int rdebug
Definition: init.c:39
int imgdist_compare(const void *a, const void *b, void *arg)
Definition: sh_billboard.c:495
struct bu_mapped_file * bu_open_mapped_file_with_path(char *const *path, const char *name, const char *appl)
Definition: mappedfile.c:430
void rt_db_free_internal(struct rt_db_internal *ip)
Definition: dir.c:216
void bn_mat_arb_rot(mat_t m, const point_t pt, const vect_t dir, const fastf_t ang)
Definition: mat.c:987
plane_t img_plane
Definition: sh_billboard.c:49