BRL-CAD
sh_grass.c File Reference
#include "common.h"
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "bu/parallel.h"
#include "vmath.h"
#include "plot3.h"
#include "raytrace.h"
#include "optical.h"
Include dependency graph for sh_grass.c:

Go to the source code of this file.

Data Structures

struct  leaf_segment
 
struct  blade
 
struct  plant
 
struct  grass_ray
 
struct  grass_specific
 

Macros

#define SHADE_CONT   0
 
#define SHADE_ABORT_GRASS   1 /* bit_flag */
 
#define SHADE_ABORT_STACK   2 /* bit_flag */
 
#define grass_MAGIC   0x1834 /* make this a unique number for each shader */
 
#define CK_grass_SP(_p)   BU_CKMAG(_p, grass_MAGIC, "grass_specific")
 
#define CELL_POS(cell_pos, grass_sp, cell_num)
 
#define BLADE_SEGS_MAX   4
 
#define LEAF_MAGIC   1024
 
#define BLADE_MAGIC   1023
 
#define PLANT_MAGIC   1022
 
#define BLADE_MAX   6
 
#define BLADE_LAST   (BLADE_MAX-1)
 
#define GRASSRAY_MAGIC   2048
 
#define grass_ray_MAGIC   0x2461
 
#define CK_grass_r(_p)   BU_CKMAG(_p, grass_ray_MAGIC, "grass_ray")
 
#define SHDR_NULL   ((struct grass_specific *)0)
 
#define SHDR_O(m)   bu_offsetof(struct grass_specific, m)
 
#define FLAG(x, y)   ((1 << ((y+1)*3)) << (x+1))
 
#define ISDONE(x, y, flags)   (! (FLAG(x, y) & flags))
 

Functions

HIDDEN int grass_setup (register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
 
HIDDEN int grass_render (struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
 
HIDDEN void grass_print (register struct region *rp, void *dp)
 
HIDDEN void grass_free (void *cp)
 

Variables

struct bu_structparse grass_print_tab []
 
struct bu_structparse grass_parse_tab []
 
struct mfuncs grass_mfuncs []
 

Detailed Description

A procedural shader to produce grass

Definition in file sh_grass.c.

Macro Definition Documentation

#define SHADE_CONT   0

Definition at line 40 of file sh_grass.c.

#define SHADE_ABORT_GRASS   1 /* bit_flag */

Definition at line 41 of file sh_grass.c.

#define SHADE_ABORT_STACK   2 /* bit_flag */

Definition at line 42 of file sh_grass.c.

#define grass_MAGIC   0x1834 /* make this a unique number for each shader */

Definition at line 45 of file sh_grass.c.

#define CK_grass_SP (   _p)    BU_CKMAG(_p, grass_MAGIC, "grass_specific")

Definition at line 46 of file sh_grass.c.

Referenced by grass_render().

#define CELL_POS (   cell_pos,
  grass_sp,
  cell_num 
)
Value:
{ \
cell_pos[X] = cell_num[X] * grass_sp->cell[X]; \
cell_pos[Y] = cell_num[Y] * grass_sp->cell[Y]; \
}
Definition: color.c:49
Definition: color.c:50

Definition at line 49 of file sh_grass.c.

Referenced by grass_render().

#define BLADE_SEGS_MAX   4

Definition at line 55 of file sh_grass.c.

#define LEAF_MAGIC   1024

Definition at line 57 of file sh_grass.c.

#define BLADE_MAGIC   1023

Definition at line 58 of file sh_grass.c.

#define PLANT_MAGIC   1022

Definition at line 59 of file sh_grass.c.

Referenced by grass_setup().

#define BLADE_MAX   6

Definition at line 80 of file sh_grass.c.

#define BLADE_LAST   (BLADE_MAX-1)

Definition at line 81 of file sh_grass.c.

#define GRASSRAY_MAGIC   2048

Definition at line 92 of file sh_grass.c.

Referenced by grass_render().

#define grass_ray_MAGIC   0x2461

Definition at line 106 of file sh_grass.c.

#define CK_grass_r (   _p)    BU_CKMAG(_p, grass_ray_MAGIC, "grass_ray")

Definition at line 107 of file sh_grass.c.

#define SHDR_NULL   ((struct grass_specific *)0)

Definition at line 182 of file sh_grass.c.

#define SHDR_O (   m)    bu_offsetof(struct grass_specific, m)

Definition at line 183 of file sh_grass.c.

#define FLAG (   x,
 
)    ((1 << ((y+1)*3)) << (x+1))
#define ISDONE (   x,
  y,
  flags 
)    (! (FLAG(x, y) & flags))

Function Documentation

HIDDEN int grass_setup ( register struct region rp,
struct bu_vls matparm,
void **  dpp,
const struct mfuncs *  mfp,
struct rt_i rtip 
)

Definition at line 487 of file sh_grass.c.

References bn_mat_inv(), bn_mat_print(), bu_bomb(), BU_CK_VLS, BU_GET, bu_log(), bu_struct_parse(), bu_struct_print(), db_region_mat(), grass_specific::m_to_sh, plant::magic, PLANT_MAGIC, grass_specific::proto, rdebug, RDEBUG_SHADE, region::reg_aircode, region::reg_name, RT_CHECK_RTI, RT_CK_REGION, rt_uniresource, rt_i::rti_dbip, and grass_specific::sh_to_m.

Here is the call graph for this function:

HIDDEN void grass_print ( register struct region rp,
void *  dp 
)

Definition at line 548 of file sh_grass.c.

References bu_struct_print(), and region::reg_name.

Here is the call graph for this function:

HIDDEN void grass_free ( void *  cp)

Definition at line 555 of file sh_grass.c.

References BU_PUT.

Variable Documentation

struct bu_structparse grass_print_tab[]
Initial value:
= {
{"%g", 2, "cell", SHDR_O(cell), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "ppc", SHDR_O(ppc), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "ppcd", SHDR_O(ppcd), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "t", SHDR_O(t), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "width", SHDR_O(blade_width), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "lacunarity", SHDR_O(lacunarity), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "H", SHDR_O(h_val), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "octaves", SHDR_O(octaves), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "size", SHDR_O(size), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%d", 1, "nsegs", SHDR_O(nsegs), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "seg_ratio", SHDR_O(seg_ratio), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
#define SHDR_O(m)
Definition: sh_grass.c:183

Definition at line 189 of file sh_grass.c.

struct bu_structparse grass_parse_tab[]
Initial value:
= {
{"%p", 1, "grass_print_tab", bu_byteoffset(grass_print_tab[0]), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 2, "c", SHDR_O(cell), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "p", SHDR_O(ppc), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "pd", SHDR_O(ppcd), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "l", SHDR_O(lacunarity), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "o", SHDR_O(octaves), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "s", SHDR_O(size), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "w", SHDR_O(blade_width), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%d", 1, "n", SHDR_O(nsegs), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "r", SHDR_O(seg_ratio), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%d", 1, "d", SHDR_O(debug), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
#define bu_byteoffset(_i)
Definition: parse.h:81
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
struct bu_structparse grass_print_tab[]
Definition: sh_grass.c:189
#define SHDR_O(m)
Definition: sh_grass.c:183

Definition at line 203 of file sh_grass.c.

struct mfuncs grass_mfuncs[]
Initial value:
= {
{MF_MAGIC, "grass", 0, MFI_NORMAL|MFI_HIT|MFI_UV, MFF_PROC, grass_setup, grass_render, grass_print, grass_free },
{0, (char *)0, 0, 0, 0, 0, 0, 0, 0 }
}
#define MF_MAGIC
Definition: magic.h:205
HIDDEN int grass_render(struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
Definition: sh_grass.c:1104
HIDDEN void grass_print(register struct region *rp, void *dp)
Definition: sh_grass.c:548
HIDDEN int grass_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Definition: sh_grass.c:487
HIDDEN void grass_free(void *cp)
Definition: sh_grass.c:555

Definition at line 232 of file sh_grass.c.

Referenced by optical_shader_init().