plug-ins: port lighting to gimp_image_procedure_new2()

...and to GimpProcedureDialog.
As with the last few, improvements could be made to the GUI, mneumonics,
and global variables used.
This commit is contained in:
Alx Sa 2023-10-01 13:43:31 +00:00 committed by Jehan
parent 5765240f6b
commit 5c8aa1f242
7 changed files with 1131 additions and 1128 deletions

View File

@ -151,3 +151,118 @@ compute_image (void)
gimp_displays_flush (); gimp_displays_flush ();
} }
} }
void
copy_from_config (GimpProcedureConfig *config)
{
GimpDrawable *temp_bump_map_drawable = NULL;
GimpDrawable *temp_env_map_drawable = NULL;
GimpRGB *color_1;
GimpRGB *color_2;
GimpRGB *color_3;
GimpRGB *color_4;
GimpRGB *color_5;
GimpRGB *color_6;
g_object_get (config,
"distance", &mapvals.viewpoint.z,
"do-bumpmap", &mapvals.bump_mapped,
"do-envmap", &mapvals.env_mapped,
"antialiasing", &mapvals.antialiasing,
"new-image", &mapvals.create_new_image,
"transparent-background", &mapvals.transparent_background,
"light-color-1", &color_1,
"light-intensity-1", &mapvals.lightsource[0].intensity,
"light-position-x-1", &mapvals.lightsource[0].position.x,
"light-position-y-1", &mapvals.lightsource[0].position.y,
"light-position-z-1", &mapvals.lightsource[0].position.z,
"light-direction-x-1", &mapvals.lightsource[0].direction.x,
"light-direction-y-1", &mapvals.lightsource[0].direction.y,
"light-direction-z-1", &mapvals.lightsource[0].direction.z,
"isolate", &mapvals.light_isolated,
"ambient-intensity", &mapvals.material.ambient_int,
"diffuse-intensity", &mapvals.material.diffuse_int,
"diffuse-reflectivity", &mapvals.material.diffuse_ref,
"specular-reflectivity", &mapvals.material.specular_ref,
"highlight", &mapvals.material.highlight,
"metallic", &mapvals.material.metallic,
"light-color-2", &color_2,
"light-intensity-2", &mapvals.lightsource[1].intensity,
"light-position-x-2", &mapvals.lightsource[1].position.x,
"light-position-y-2", &mapvals.lightsource[1].position.y,
"light-position-z-2", &mapvals.lightsource[1].position.z,
"light-direction-x-2", &mapvals.lightsource[1].direction.x,
"light-direction-y-2", &mapvals.lightsource[1].direction.y,
"light-direction-z-2", &mapvals.lightsource[1].direction.z,
"light-color-3", &color_3,
"light-intensity-3", &mapvals.lightsource[2].intensity,
"light-position-x-3", &mapvals.lightsource[2].position.x,
"light-position-y-3", &mapvals.lightsource[2].position.y,
"light-position-z-3", &mapvals.lightsource[2].position.z,
"light-direction-x-3", &mapvals.lightsource[2].direction.x,
"light-direction-y-3", &mapvals.lightsource[2].direction.y,
"light-direction-z-3", &mapvals.lightsource[2].direction.z,
"light-color-4", &color_4,
"light-intensity-4", &mapvals.lightsource[3].intensity,
"light-position-x-4", &mapvals.lightsource[3].position.x,
"light-position-y-4", &mapvals.lightsource[3].position.y,
"light-position-z-4", &mapvals.lightsource[3].position.z,
"light-direction-x-4", &mapvals.lightsource[3].direction.x,
"light-direction-y-4", &mapvals.lightsource[3].direction.y,
"light-direction-z-4", &mapvals.lightsource[3].direction.z,
"light-color-5", &color_5,
"light-intensity-5", &mapvals.lightsource[4].intensity,
"light-position-x-5", &mapvals.lightsource[4].position.x,
"light-position-y-5", &mapvals.lightsource[4].position.y,
"light-position-z-5", &mapvals.lightsource[4].position.z,
"light-direction-x-5", &mapvals.lightsource[4].direction.x,
"light-direction-y-5", &mapvals.lightsource[4].direction.y,
"light-direction-z-5", &mapvals.lightsource[4].direction.z,
"light-color-6", &color_6,
"light-intensity-6", &mapvals.lightsource[5].intensity,
"light-position-x-6", &mapvals.lightsource[5].position.x,
"light-position-y-6", &mapvals.lightsource[5].position.y,
"light-position-z-6", &mapvals.lightsource[5].position.z,
"light-direction-x-6", &mapvals.lightsource[5].direction.x,
"light-direction-y-6", &mapvals.lightsource[5].direction.y,
"light-direction-z-6", &mapvals.lightsource[5].direction.z,
"bump-drawable", &temp_bump_map_drawable,
"env-drawable", &temp_env_map_drawable,
NULL);
if (color_1)
gimp_rgba_set (&mapvals.lightsource[0].color, color_1->r, color_1->g, color_1->b, 1.0);
if (color_2)
gimp_rgba_set (&mapvals.lightsource[1].color, color_2->r, color_2->g, color_2->b, 1.0);
if (color_3)
gimp_rgba_set (&mapvals.lightsource[2].color, color_3->r, color_3->g, color_3->b, 1.0);
if (color_4)
gimp_rgba_set (&mapvals.lightsource[3].color, color_4->r, color_4->g, color_4->b, 1.0);
if (color_5)
gimp_rgba_set (&mapvals.lightsource[4].color, color_5->r, color_5->g, color_5->b, 1.0);
if (color_6)
gimp_rgba_set (&mapvals.lightsource[5].color, color_6->r, color_6->g, color_6->b, 1.0);
mapvals.bumpmaptype = gimp_procedure_config_get_choice_id (config, "bumpmap-type");
mapvals.light_selected = gimp_procedure_config_get_choice_id (config, "which-light");
mapvals.lightsource[0].type = gimp_procedure_config_get_choice_id (config, "light-type-1");
mapvals.lightsource[1].type = gimp_procedure_config_get_choice_id (config, "light-type-2");
mapvals.lightsource[2].type = gimp_procedure_config_get_choice_id (config, "light-type-3");
mapvals.lightsource[3].type = gimp_procedure_config_get_choice_id (config, "light-type-4");
mapvals.lightsource[4].type = gimp_procedure_config_get_choice_id (config, "light-type-5");
mapvals.lightsource[5].type = gimp_procedure_config_get_choice_id (config, "light-type-6");
if (temp_bump_map_drawable)
mapvals.bumpmap_id = gimp_item_get_id (GIMP_ITEM (temp_bump_map_drawable));
else
mapvals.bumpmap_id = -1;
if (temp_env_map_drawable)
mapvals.envmap_id = gimp_item_get_id (GIMP_ITEM (temp_env_map_drawable));
else
mapvals.envmap_id = -1;
}

View File

@ -1,7 +1,8 @@
#ifndef __LIGHTING_APPLY_H__ #ifndef __LIGHTING_APPLY_H__
#define __LIGHTING_APPLY_H__ #define __LIGHTING_APPLY_H__
void init_compute (void); void init_compute (void);
void compute_image (void); void compute_image (void);
void copy_from_config (GimpProcedureConfig *config);
#endif /* __LIGHTING_APPLY_H__ */ #endif /* __LIGHTING_APPLY_H__ */

View File

@ -66,7 +66,7 @@ static GimpValueArray * lighting_run (GimpProcedure *procedu
GimpImage *image, GimpImage *image,
gint n_drawables, gint n_drawables,
GimpDrawable **drawables, GimpDrawable **drawables,
const GimpValueArray *args, GimpProcedureConfig *config,
gpointer run_data); gpointer run_data);
static void set_default_settings (void); static void set_default_settings (void);
@ -110,9 +110,9 @@ lighting_create_procedure (GimpPlugIn *plug_in,
{ {
GimpRGB white = { 1.0, 1.0, 1.0, 1.0 }; GimpRGB white = { 1.0, 1.0, 1.0, 1.0 };
procedure = gimp_image_procedure_new (plug_in, name, procedure = gimp_image_procedure_new2 (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN, GIMP_PDB_PROC_TYPE_PLUGIN,
lighting_run, NULL, NULL); lighting_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "RGB*"); gimp_procedure_set_image_types (procedure, "RGB*");
gimp_procedure_set_sensitivity_mask (procedure, gimp_procedure_set_sensitivity_mask (procedure,
@ -133,94 +133,137 @@ lighting_create_procedure (GimpPlugIn *plug_in,
"Version 0.2.0, March 15 1998"); "Version 0.2.0, March 15 1998");
GIMP_PROC_ARG_DRAWABLE (procedure, "bump-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "bump-drawable",
"Bump drawable", _("B_ump map image"),
"Bumpmap drawable (set to NULL if disabled)", _("Bumpmap drawable (set to NULL if disabled)"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "env-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "env-drawable",
"Env drawable", _("Enviro_nment map image"),
"Environmentmap drawable (set to NULL if disabled", _("Environmentmap drawable "
"(set to NULL if disabled)"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "do-bumpmap", GIMP_PROC_ARG_BOOLEAN (procedure, "do-bumpmap",
"Do bumpmap", _("Enable bump mappi_ng"),
"Enable bumpmapping", _("Enable bumpmapping"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "do-envmap", GIMP_PROC_ARG_BOOLEAN (procedure, "do-envmap",
"Do envmap", _("Enable en_vironment mapping"),
"Enable envmapping", _("Enable envmapping"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "bumpmap-type", GIMP_PROC_ARG_CHOICE (procedure, "bumpmap-type",
"Bumpmap type", _("Cur_ve"),
"Type of mapping (0=linear, 1=log, 2=sinusoidal, " _("Type of mapping"),
"3=spherical)", gimp_choice_new_with_values ("bumpmap-linear", LINEAR_MAP, _("Linear"), NULL,
0, 2, 0, "bumpmap-log", LOGARITHMIC_MAP, _("Logarithmic"), NULL,
G_PARAM_READWRITE); "bumpmap-sinusoidal", SINUSOIDAL_MAP, _("Sinusoidal"), NULL,
"bumpmap-spherical", SPHERICAL_MAP, _("Spherical"), NULL,
NULL),
"bumpmap-linear",
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "light-type", GIMP_PROC_ARG_DOUBLE (procedure, "bumpmap-max-height",
"Light type", _("Ma_ximum height"),
"Type of lightsource (0=point, 1=directional, " _("The maximum height of the bumpmap"),
"3=spot, 4=none)", 0.0, G_MAXFLOAT, 0.1,
0 ,4, 0, G_PARAM_READWRITE);
G_PARAM_READWRITE);
GIMP_PROC_ARG_RGB (procedure, "light-color", GIMP_PROC_AUX_ARG_CHOICE (procedure, "which-light",
"Light color", _("Active"),
"Light source color", _("Which light is active in the GUI"),
gimp_choice_new_with_values ("light-1", 0, _("Light 1"), NULL,
"light-2", 1, _("Light 2"), NULL,
"light-3", 2, _("Light 3"), NULL,
"light-4", 3, _("Light 4"), NULL,
"light-5", 4, _("Light 5"), NULL,
"light-6", 5, _("Light 6"), NULL,
NULL),
"light-1",
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_BOOLEAN (procedure, "isolate",
_("Isolate"),
_("Only show the active lighting in "
"the preview"),
FALSE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_CHOICE (procedure, "light-type-1",
_("Type"),
_("Type of light source"),
gimp_choice_new_with_values ("light-none", NO_LIGHT, _("None"), NULL,
"light-directional", DIRECTIONAL_LIGHT, _("Directional"), NULL,
"light-point", POINT_LIGHT, _("Point"), NULL,
"light-spot", SPOT_LIGHT, _("Spot"), NULL,
NULL),
"light-point",
G_PARAM_READWRITE);
GIMP_PROC_ARG_RGB (procedure, "light-color-1",
_("Color"),
_("Light source color"),
TRUE, &white, TRUE, &white,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-position-x", GIMP_PROC_ARG_DOUBLE (procedure, "light-intensity-1",
"Light position X", _("Intensity"),
"Light source position (x,y,z)", _("Light source intensity"),
0, 100.0, 1.0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-position-x-1",
_("Light position X"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1, -G_MAXDOUBLE, G_MAXDOUBLE, -1,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-position-y", GIMP_PROC_ARG_DOUBLE (procedure, "light-position-y-1",
"Light position Y", _("Light position Y"),
"Light source position (x,y,z)", _("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1, -G_MAXDOUBLE, G_MAXDOUBLE, -1,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-position-z", GIMP_PROC_ARG_DOUBLE (procedure, "light-position-z-1",
"Light position Z", _("Light position Z"),
"Light source position (x,y,z)", _("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-x-1",
_("Light direction X"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1, -G_MAXDOUBLE, G_MAXDOUBLE, -1,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-x", GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-y-1",
"Light direction X", _("Light direction Y"),
"Light source direction (x,y,z)", _("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1, -G_MAXDOUBLE, G_MAXDOUBLE, -1,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-y", GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-z-1",
"Light direction Y", _("Light direction Z"),
"Light source direction (x,y,z)", _("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-z",
"Light direction Z",
"Light source direction (x,y,z)",
-G_MAXDOUBLE, G_MAXDOUBLE, 1, -G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "ambient-intensity", GIMP_PROC_ARG_DOUBLE (procedure, "ambient-intensity",
"Ambient intensity", _("Ambient intensity"),
"Material ambient intensity", _("Material ambient intensity "
"(Glowing)"),
0, 1, 0.2, 0, 1, 0.2,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "diffuse-intensity", GIMP_PROC_ARG_DOUBLE (procedure, "diffuse-intensity",
"Diffuse intensity", _("Diffuse intensity"),
"Material diffuse intensity", _("Material diffuse intensity "
"(Bright)"),
0, 1, 0.5, 0, 1, 0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
@ -238,27 +281,336 @@ lighting_create_procedure (GimpPlugIn *plug_in,
GIMP_PROC_ARG_DOUBLE (procedure, "highlight", GIMP_PROC_ARG_DOUBLE (procedure, "highlight",
"Highlight", "Highlight",
"Material highlight (note, it's exponential)", "Material highlight (note, it's exponential) "
"(Polished)",
0, G_MAXDOUBLE, 27.0, 0, G_MAXDOUBLE, 27.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "metallic",
_("Metallic"),
_("Enable envmapping"),
FALSE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "antialiasing", GIMP_PROC_ARG_BOOLEAN (procedure, "antialiasing",
"Antialiasing", _("_Antialiasing"),
"Apply antialiasing", _("Apply antialiasing"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "new-image", GIMP_PROC_ARG_BOOLEAN (procedure, "new-image",
"New image", _("Create new ima_ge"),
"Create a new image", _("Create a new image"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "transparent-background", GIMP_PROC_ARG_BOOLEAN (procedure, "transparent-background",
"Transparent background", _("Trans_parent background"),
"Make background transparent", _("Make background transparent"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "distance",
_("_Distance"),
_("Distance of observer from surface"),
0, 2.0, 0.25,
G_PARAM_READWRITE);
/* GUI-only arguments for additional light sources */
GIMP_PROC_AUX_ARG_CHOICE (procedure, "light-type-2",
_("Type"),
_("Type of light source"),
gimp_choice_new_with_values ("light-none", NO_LIGHT, _("None"), NULL,
"light-directional", DIRECTIONAL_LIGHT, _("Directional"), NULL,
"light-point", POINT_LIGHT, _("Point"), NULL,
"light-spot", SPOT_LIGHT, _("Spot"), NULL,
NULL),
"light-point",
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_RGB (procedure, "light-color-2",
_("Color"),
_("Light source color"),
TRUE, &white,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-intensity-2",
_("Intensity"),
_("Light source intensity"),
0, 100.0, 1.0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-x-2",
_("Light position X"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -2,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-y-2",
_("Light position Y"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-z-2",
_("Light position Z"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-x-2",
_("Light direction X"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-y-2",
_("Light direction Y"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-z-2",
_("Light direction Z"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_CHOICE (procedure, "light-type-3",
_("Type"),
_("Type of light source"),
gimp_choice_new_with_values ("light-none", NO_LIGHT, _("None"), NULL,
"light-directional", DIRECTIONAL_LIGHT, _("Directional"), NULL,
"light-point", POINT_LIGHT, _("Point"), NULL,
"light-spot", SPOT_LIGHT, _("Spot"), NULL,
NULL),
"light-point",
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_RGB (procedure, "light-color-3",
_("Color"),
_("Light source color"),
TRUE, &white,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-intensity-3",
_("Intensity"),
_("Light source intensity"),
0, 100.0, 1.0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-x-3",
_("Light position X"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-y-3",
_("Light position Y"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 2,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-z-3",
_("Light position Z"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-x-3",
_("Light direction X"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-y-3",
_("Light direction Y"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-z-3",
_("Light direction Z"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_CHOICE (procedure, "light-type-4",
_("Type"),
_("Type of light source"),
gimp_choice_new_with_values ("light-none", NO_LIGHT, _("None"), NULL,
"light-directional", DIRECTIONAL_LIGHT, _("Directional"), NULL,
"light-point", POINT_LIGHT, _("Point"), NULL,
"light-spot", SPOT_LIGHT, _("Spot"), NULL,
NULL),
"light-point",
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_RGB (procedure, "light-color-4",
_("Color"),
_("Light source color"),
TRUE, &white,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-intensity-4",
_("Intensity"),
_("Light source intensity"),
0, 100.0, 1.0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-x-4",
_("Light position X"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-y-4",
_("Light position Y"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-z-4",
_("Light position Z"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-x-4",
_("Light direction X"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-y-4",
_("Light direction Y"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-z-4",
_("Light direction Z"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_CHOICE (procedure, "light-type-5",
_("Type"),
_("Type of light source"),
gimp_choice_new_with_values ("light-none", NO_LIGHT, _("None"), NULL,
"light-directional", DIRECTIONAL_LIGHT, _("Directional"), NULL,
"light-point", POINT_LIGHT, _("Point"), NULL,
"light-spot", SPOT_LIGHT, _("Spot"), NULL,
NULL),
"light-point",
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_RGB (procedure, "light-color-5",
_("Color"),
_("Light source color"),
TRUE, &white,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-intensity-5",
_("Intensity"),
_("Light source intensity"),
0, 100.0, 1.0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-x-5",
_("Light position X"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-y-5",
_("Light position Y"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-z-5",
_("Light position Z"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-x-5",
_("Light direction X"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-y-5",
_("Light direction Y"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-z-5",
_("Light direction Z"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_CHOICE (procedure, "light-type-6",
_("Type"),
_("Type of light source"),
gimp_choice_new_with_values ("light-none", NO_LIGHT, _("None"), NULL,
"light-directional", DIRECTIONAL_LIGHT, _("Directional"), NULL,
"light-point", POINT_LIGHT, _("Point"), NULL,
"light-spot", SPOT_LIGHT, _("Spot"), NULL,
NULL),
"light-point",
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_RGB (procedure, "light-color-6",
_("Color"),
_("Light source color"),
TRUE, &white,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-intensity-6",
_("Intensity"),
_("Light source intensity"),
0, 100.0, 1.0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-x-6",
_("Light position X"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-y-6",
_("Light position Y"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-position-z-6",
_("Light position Z"),
_("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-x-6",
_("Light direction X"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-y-6",
_("Light direction Y"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_DOUBLE (procedure, "light-direction-z-6",
_("Light direction Z"),
_("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1,
G_PARAM_READWRITE);
} }
return procedure; return procedure;
@ -389,7 +741,7 @@ lighting_run (GimpProcedure *procedure,
GimpImage *image, GimpImage *image,
gint n_drawables, gint n_drawables,
GimpDrawable **drawables, GimpDrawable **drawables,
const GimpValueArray *args, GimpProcedureConfig *config,
gpointer run_data) gpointer run_data)
{ {
GimpDrawable *drawable; GimpDrawable *drawable;
@ -423,10 +775,13 @@ lighting_run (GimpProcedure *procedure,
if (gimp_drawable_is_rgb (drawable)) if (gimp_drawable_is_rgb (drawable))
{ {
mapvals.config = config;
copy_from_config (config);
switch (run_mode) switch (run_mode)
{ {
case GIMP_RUN_INTERACTIVE: case GIMP_RUN_INTERACTIVE:
if (! main_dialog (drawable)) if (! main_dialog (procedure, config, drawable))
{ {
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL, GIMP_PDB_CANCEL,
@ -446,30 +801,6 @@ lighting_run (GimpProcedure *procedure,
break; break;
case GIMP_RUN_NONINTERACTIVE: case GIMP_RUN_NONINTERACTIVE:
mapvals.bumpmap_id = GIMP_VALUES_GET_DRAWABLE_ID (args, 0);
mapvals.envmap_id = GIMP_VALUES_GET_DRAWABLE_ID (args, 1);
mapvals.bump_mapped = GIMP_VALUES_GET_BOOLEAN (args, 2);
mapvals.env_mapped = GIMP_VALUES_GET_BOOLEAN (args, 3);
mapvals.bumpmaptype = GIMP_VALUES_GET_INT (args, 4);
mapvals.lightsource[0].type = GIMP_VALUES_GET_INT (args, 5);
GIMP_VALUES_GET_RGB (args, 6, &mapvals.lightsource[0].color);
mapvals.lightsource[0].position.x = GIMP_VALUES_GET_DOUBLE (args, 7);
mapvals.lightsource[0].position.y = GIMP_VALUES_GET_DOUBLE (args, 8);
mapvals.lightsource[0].position.z = GIMP_VALUES_GET_DOUBLE (args, 9);
mapvals.lightsource[0].direction.x = GIMP_VALUES_GET_DOUBLE (args, 10);
mapvals.lightsource[0].direction.y = GIMP_VALUES_GET_DOUBLE (args, 11);
mapvals.lightsource[0].direction.z = GIMP_VALUES_GET_DOUBLE (args, 12);
mapvals.material.ambient_int = GIMP_VALUES_GET_DOUBLE (args, 13);
mapvals.material.diffuse_int = GIMP_VALUES_GET_DOUBLE (args, 14);
mapvals.material.diffuse_ref = GIMP_VALUES_GET_DOUBLE (args, 15);
mapvals.material.specular_ref = GIMP_VALUES_GET_DOUBLE (args, 16);
mapvals.material.highlight = GIMP_VALUES_GET_DOUBLE (args, 17);
mapvals.antialiasing = GIMP_VALUES_GET_BOOLEAN (args, 18);
mapvals.create_new_image = GIMP_VALUES_GET_BOOLEAN (args, 19);
mapvals.transparent_background = GIMP_VALUES_GET_BOOLEAN (args, 20);
check_drawables (); check_drawables ();
if (image_setup (drawable, FALSE)) if (image_setup (drawable, FALSE))
compute_image (); compute_image ();

View File

@ -63,6 +63,8 @@ typedef struct
gint32 bumpmap_id; gint32 bumpmap_id;
gint32 envmap_id; gint32 envmap_id;
GimpProcedureConfig *config;
/* Render variables */ /* Render variables */
/* ================ */ /* ================ */

View File

@ -377,15 +377,18 @@ preview_compute (void)
compute_preview_rectangle (&startx, &starty, &pw, &ph); compute_preview_rectangle (&startx, &starty, &pw, &ph);
cursor = gdk_cursor_new_for_display (display, GDK_WATCH); if (GDK_IS_WINDOW (gtk_widget_get_window (previewarea)))
gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor); {
g_object_unref (cursor); cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
g_object_unref (cursor);
compute_preview (startx, starty, pw, ph); compute_preview (startx, starty, pw, ph);
cursor = gdk_cursor_new_for_display (display, GDK_HAND2); cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor); gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
g_object_unref (cursor); g_object_unref (cursor);
gdk_display_flush (display); gdk_display_flush (display);
}
} }
@ -458,22 +461,31 @@ interactive_preview_callback (GtkWidget *widget)
static gboolean static gboolean
interactive_preview_timer_callback (gpointer data) interactive_preview_timer_callback (gpointer data)
{ {
gint k = mapvals.light_selected; gint k = mapvals.light_selected;
gchar *pos_x = g_strdup_printf (("light-position-x-%d"), k + 1);
gchar *pos_y = g_strdup_printf (("light-position-y-%d"), k + 1);
gchar *pos_z = g_strdup_printf (("light-position-z-%d"), k + 1);
gchar *dir_x = g_strdup_printf (("light-direction-x-%d"), k + 1);
gchar *dir_y = g_strdup_printf (("light-direction-y-%d"), k + 1);
gchar *dir_z = g_strdup_printf (("light-direction-z-%d"), k + 1);
mapvals.update_enabled = FALSE; /* disable apply_settings() */ mapvals.update_enabled = FALSE; /* disable apply_settings() */
gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin_pos_x), g_object_set (mapvals.config,
mapvals.lightsource[k].position.x); pos_x, mapvals.lightsource[k].position.x,
gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin_pos_y), pos_y, mapvals.lightsource[k].position.y,
mapvals.lightsource[k].position.y); pos_z, mapvals.lightsource[k].position.z,
gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin_pos_z), dir_x, mapvals.lightsource[k].direction.x,
mapvals.lightsource[k].position.z); dir_y, mapvals.lightsource[k].direction.y,
gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin_dir_x), dir_z, mapvals.lightsource[k].direction.z,
mapvals.lightsource[k].direction.x); NULL);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin_dir_y),
mapvals.lightsource[k].direction.y); g_free (pos_x);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin_dir_z), g_free (pos_y);
mapvals.lightsource[k].direction.z); g_free (pos_z);
g_free (dir_x);
g_free (dir_y);
g_free (dir_z);
mapvals.update_enabled = TRUE; mapvals.update_enabled = TRUE;

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,8 @@ extern GtkWidget *spin_dir_z;
/* Externally visible functions */ /* Externally visible functions */
/* ============================ */ /* ============================ */
gboolean main_dialog (GimpDrawable *drawable); gboolean main_dialog (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpDrawable *drawable);
#endif /* __LIGHTING_UI_H__ */ #endif /* __LIGHTING_UI_H__ */