HIDDEN int envmap_setup(register struct region *rp, struct bu_vls *matparm, void **UNUSED(dpp), const struct mfuncs *UNUSED(mfp), struct rt_i *rtip) { struct mfuncs *shaders = MF_NULL; BU_CK_VLS(matparm); RT_CK_RTI(rtip); if (env_region.reg_mfuncs) { bu_log("envmap_setup: second environment map ignored\n"); return 0; /* drop region */ } env_region = *rp; /* struct copy */ /* Get copies of, or eliminate, references to dynamic structures */ env_region.reg_name = bu_strdup(rp->reg_name); env_region.reg_treetop = TREE_NULL; env_region.l.forw = BU_LIST_NULL; env_region.l.back = BU_LIST_NULL; env_region.reg_mfuncs = (char *)0; env_region.reg_mater.ma_shader = bu_vls_strdup(matparm); /* get list of available shaders */ if (!shaders) { optical_shader_init(&shaders); } if (mlib_setup(&shaders, &env_region, rtip) < 0) bu_log("envmap_setup() material '%s' failed\n", env_region.reg_mater.ma_shader); return 0; /* This region should be dropped */ }
/* * Go poke the rgb values of a region, on the fly. * This does not update the inmemory database, * so any changes will vanish on next re-prep unless other measures * are taken. */ int sh_directchange_shader(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const char *argv[]) { long int rtip_val; struct rt_i *rtip; struct region *regp; struct directory *dp; struct bu_vls shader = BU_VLS_INIT_ZERO; if ( argc < 4 ) { Tcl_AppendResult(interp, "Usage: sh_directchange_shader $rtip comb shader_arg(s)\n", NULL); return TCL_ERROR; } rtip_val = atol(argv[1]); rtip = (struct rt_i *)rtip_val; RT_CK_RTI(rtip); if ( rtip->needprep ) { Tcl_AppendResult(interp, "rt_prep() hasn't been called yet, error.\n", NULL); return TCL_ERROR; } if ( (dp = db_lookup( rtip->rti_dbip, argv[2], LOOKUP_NOISY)) == RT_DIR_NULL ) { Tcl_AppendResult(interp, argv[2], ": not found\n", NULL); return TCL_ERROR; } bu_vls_from_argv(&shader, argc-3, argv+3); bu_vls_trimspace(&shader); /* Find all region names which match /comb/ pattern */ for ( BU_LIST_FOR( regp, region, &rtip->HeadRegion ) ) { /* if ( dp->d_flags & RT_DIR_REGION ) { */ /* name will occur at end of region string w/leading slash */ /* } else { */ /* name will occur anywhere, bracketed by slashes */ /* } */ /* XXX quick hack */ if ( strstr( regp->reg_name, argv[2] ) == NULL ) continue; /* Modify the region's shader string */ bu_log("sh_directchange_shader() changing %s\n", regp->reg_name); if ( regp->reg_mater.ma_shader ) bu_free( (void *)regp->reg_mater.ma_shader, "reg_mater.ma_shader"); regp->reg_mater.ma_shader = bu_vls_strdup(&shader); /* Update the shader */ mlib_free(regp); if ( mlib_setup( &mfHead, regp, rtip ) != 1 ) { Tcl_AppendResult(interp, regp->reg_name, ": mlib_setup() failure\n", NULL); } } bu_vls_free(&shader); return TCL_OK; }
/* * Go poke the rgb values of a region, on the fly. * This does not update the inmemory database, * so any changes will vanish on next re-prep unless other measures * are taken. */ int sh_directchange_rgb(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const char *argv[]) { long int rtip_val; struct rt_i *rtip; struct region *regp; struct directory *dp; float r, g, b; if ( argc != 6 ) { Tcl_AppendResult(interp, "Usage: sh_directchange_rgb $rtip comb r g b\n", NULL); return TCL_ERROR; } r = atoi(argv[3+0]) / 255.0; g = atoi(argv[3+1]) / 255.0; b = atoi(argv[3+2]) / 255.0; rtip_val = atol(argv[1]); rtip = (struct rt_i *)rtip_val; RT_CK_RTI(rtip); if ( rtip->needprep ) { Tcl_AppendResult(interp, "rt_prep() hasn't been called yet, error.\n", NULL); return TCL_ERROR; } if ( (dp = db_lookup( rtip->rti_dbip, argv[2], LOOKUP_NOISY)) == RT_DIR_NULL ) { Tcl_AppendResult(interp, argv[2], ": not found\n", NULL); return TCL_ERROR; } /* Find all region names which match /comb/ pattern */ for ( BU_LIST_FOR( regp, region, &rtip->HeadRegion ) ) { /* if ( dp->d_flags & RT_DIR_REGION ) { */ /* name will occur at end of region string w/leading slash */ /* } else { */ /* name will occur anywhere, bracketed by slashes */ /* } */ /* XXX quick hack */ if ( strstr( regp->reg_name, argv[2] ) == NULL ) continue; /* Modify the region's color */ bu_log("sh_directchange_rgb() changing %s\n", regp->reg_name); VSET( regp->reg_mater.ma_color, r, g, b ); /* Update the shader */ mlib_free(regp); if ( mlib_setup( &mfHead, regp, rtip ) != 1 ) { Tcl_AppendResult(interp, regp->reg_name, ": mlib_setup() failure\n", NULL); } } return TCL_OK; }