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

Go to the source code of this file.

Data Structures

struct  fire_specific
 

Macros

#define fire_MAGIC   0x46697265 /* ``Fire'' */
 
#define CK_fire_SP(_p)   BU_CKMAG(_p, fire_MAGIC, "fire_specific")
 
#define SHDR_NULL   ((struct fire_specific *)0)
 
#define SHDR_O(m)   bu_offsetof(struct fire_specific, m)
 
#define DEBUG_SPACE_PRINT(str, i_pt, o_pt)
 
#define SHADER_TO_NOISE(n_pt, sh_pt, fire_sp, zdelta)
 

Functions

HIDDEN int fire_setup (register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
 
HIDDEN int fire_render (struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
 
HIDDEN void fire_print (register struct region *rp, void *dp)
 
HIDDEN void fire_free (void *cp)
 

Variables

struct bu_structparse fire_print_tab []
 
struct bu_structparse fire_parse_tab []
 
struct mfuncs fire_mfuncs []
 
const double flame_colors [18][3]
 

Detailed Description

Fire shader

Parameters:

flicker=rate Specifies rate of translation through noise space for animation. swp->frametime * flicker gives a delta in Z of noise space for animation. Useful values probably in range 0 > flicker > 10

stretch=dist Specifies a scaling of the exponential stretch of the flames. flame stretch = e^(pos[Z] * -stretch)

Standard fbm parameters:

lacunarity Scale between different levels of noise detail

octaves Number of different levels of noise to add to get structure of the flames.

h_val power for frequency (usually 1)

scale 3-tuple which scales noise WRT shader space: "how big is the largest noise frequency on object"

delta 3-tuple specifying origin delta in noise space: "what piece of noise space maps to shader origin"

Usage: mged> shader flame.r {fire {st 1.25}}

Note: The fire shader provides its own color. It does not read any color information from the region definition.

Definition in file sh_fire.c.

Macro Definition Documentation

#define fire_MAGIC   0x46697265 /* ``Fire'' */

Definition at line 71 of file sh_fire.c.

#define CK_fire_SP (   _p)    BU_CKMAG(_p, fire_MAGIC, "fire_specific")

Definition at line 72 of file sh_fire.c.

Referenced by fire_render().

#define SHDR_NULL   ((struct fire_specific *)0)

Definition at line 119 of file sh_fire.c.

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

Definition at line 120 of file sh_fire.c.

#define DEBUG_SPACE_PRINT (   str,
  i_pt,
  o_pt 
)
Value:
if (rdebug&RDEBUG_SHADE || fire_sp->fire_debug) { \
bu_log("fire_render() %s space \n", str); \
bu_log("fire_render() i_pt(%g %g %g)\n", V3ARGS(i_pt)); \
bu_log("fire_render() o_pt(%g %g %g)\n", V3ARGS(o_pt)); \
}
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
#define V3ARGS(a)
Definition: color.c:56
#define RDEBUG_SHADE
Definition: optical.h:130
int rdebug
Definition: init.c:39

Referenced by fire_render().

#define SHADER_TO_NOISE (   n_pt,
  sh_pt,
  fire_sp,
  zdelta 
)
Value:
{ \
point_t tmp_pt; \
tmp_pt[X] = sh_pt[X]; \
tmp_pt[Y] = sh_pt[Y]; \
if (! NEAR_ZERO(fire_sp->fire_stretch, SQRT_SMALL_FASTF)) \
tmp_pt[Z] = exp((sh_pt[Z]+0.125) * -fire_sp->fire_stretch); \
else \
tmp_pt[Z] = sh_pt[Z]; \
MAT4X3PNT(n_pt, fire_sp->fire_sh_to_noise, tmp_pt); \
n_pt[Z] += zdelta; \
}
if(share_geom)
Definition: nmg_mod.c:3829
Definition: color.c:49
#define NEAR_ZERO(val, epsilon)
Definition: color.c:55
#define SQRT_SMALL_FASTF
Definition: defines.h:346
Definition: color.c:51
Definition: color.c:50

Referenced by fire_render().

Function Documentation

HIDDEN int fire_setup ( register struct region rp,
struct bu_vls matparm,
void **  dpp,
const struct mfuncs *  mfp,
struct rt_i rtip 
)
int fire_render ( struct application ap,
const struct partition pp,
struct shadework *  swp,
void *  dp 
)
HIDDEN void fire_print ( register struct region rp,
void *  dp 
)

Definition at line 271 of file sh_fire.c.

References bu_struct_print(), and region::reg_name.

Here is the call graph for this function:

HIDDEN void fire_free ( void *  cp)

Definition at line 278 of file sh_fire.c.

References BU_PUT.

Variable Documentation

struct bu_structparse fire_print_tab[]
Initial value:
= {
{"%d", 1, "debug", SHDR_O(fire_debug), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 1, "flicker", SHDR_O(fire_flicker), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 1, "stretch", SHDR_O(fire_stretch), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "lacunarity", SHDR_O(noise_lacunarity), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "H", SHDR_O(noise_h_val), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "octaves", SHDR_O(noise_octaves), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 3, "scale", SHDR_O(noise_size), bu_mm_cvt, NULL, NULL },
{"%f", 3, "vscale", SHDR_O(noise_vscale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "delta", SHDR_O(noise_delta), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "max", SHDR_O(fire_max), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "min", SHDR_O(fire_min), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
void bu_mm_cvt(const struct bu_structparse *sdp, const char *name, void *base, const char *value, void *data)
Definition: units.c:386
#define SHDR_O(m)
Definition: sh_fire.c:120
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153

Definition at line 127 of file sh_fire.c.

struct bu_structparse fire_parse_tab[]
Initial value:
= {
{"%p", 1, "fire_print_tab", bu_byteoffset(fire_print_tab[0]), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 1, "f", SHDR_O(fire_flicker), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 1, "st", SHDR_O(fire_stretch), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "l", SHDR_O(noise_lacunarity), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "H", SHDR_O(noise_h_val), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "o", SHDR_O(noise_octaves), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "s", SHDR_O(noise_size), bu_mm_cvt, NULL, NULL },
{"%f", 3, "v", SHDR_O(noise_vscale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "vs", SHDR_O(noise_vscale), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "d", SHDR_O(noise_delta), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
#define bu_byteoffset(_i)
Definition: parse.h:81
struct bu_structparse fire_print_tab[]
Definition: sh_fire.c:127
void bu_mm_cvt(const struct bu_structparse *sdp, const char *name, void *base, const char *value, void *data)
Definition: units.c:386
#define SHDR_O(m)
Definition: sh_fire.c:120
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153

Definition at line 142 of file sh_fire.c.

struct mfuncs fire_mfuncs[]
Initial value:
= {
{MF_MAGIC, "fire", 0, MFI_HIT, 0,
{0, (char *)0, 0, 0, 0,
0, 0, 0, 0 }
}
HIDDEN void fire_free(void *cp)
Definition: sh_fire.c:278
HIDDEN int fire_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Definition: sh_fire.c:207
#define MF_MAGIC
Definition: magic.h:205
HIDDEN int fire_render(struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
Definition: sh_fire.c:290
HIDDEN void fire_print(register struct region *rp, void *dp)
Definition: sh_fire.c:271

Definition at line 170 of file sh_fire.c.

Referenced by optical_shader_init().

const double flame_colors[18][3]
Initial value:
= {
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0},
{0.106, 0.0, 0.0},
{0.212, 0.0, 0.0},
{0.318, 0.0, 0.0},
{0.427, 0.0, 0.0},
{0.533, 0.0, 0.0},
{0.651, 0.02, 0.0},
{0.741, 0.118, 0.0},
{0.827, 0.235, 0.0},
{0.906, 0.353, 0.0},
{0.933, 0.500, 0.0},
{0.957, 0.635, 0.047},
{0.973, 0.733, 0.227},
{0.984, 0.820, 0.451},
{0.990, 0.925, 0.824},
{1.0, 0.945, 0.902},
{1.0, 0.945, 0.902}
}

Definition at line 179 of file sh_fire.c.