[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21011] branches/soc-2009-yukishiro: add a button to save hdr (need to improve image suffix

Jingyuan Huang jingyuan.huang at gmail.com
Fri Jun 19 17:14:24 CEST 2009


Revision: 21011
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21011
Author:   yukishiro
Date:     2009-06-19 17:14:24 +0200 (Fri, 19 Jun 2009)

Log Message:
-----------
add a button to save hdr (need to improve image suffix

Modified Paths:
--------------
    branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py
    branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h
    branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
    branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
    branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h
    branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_lightenv.c

Modified: branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py
===================================================================
--- branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py	2009-06-19 15:14:24 UTC (rev 21011)
@@ -9,9 +9,9 @@
 	def poll(self, context):
 		return context.lightenv
 
-class LIGHT_PT_compute(LightButtonsPanel):
-	__idname__= "LIGHT_PT_compute"
-	__label__ = "Compute"
+class LIGHT_PT_properties(LightButtonsPanel):
+	__idname__= "LIGHT_PT_properties"
+	__label__ = "Properties"
 
 	def draw(self, context):
 		layout = self.layout
@@ -24,7 +24,23 @@
 		row = layout.row()
 		row.itemO("PAINT_OT_light_paint_recompute", text="Recompute LightEnv", icon='ICON_LIGHTENV')
 
+class LIGHT_PT_save(LightButtonsPanel):
+	__idname__= "LIGHT_PT_save"
+	__label__ = "Save Light Env"
 
+	def draw(self, context):
+		layout = self.layout
+		lightenv = context.lightenv
+
+		row = layout.row()
+		row.itemR(lightenv, "output_width", text="Width")
+		row.itemR(lightenv, "output_height", text="Height")
+
+		row = layout.row()
+		row.itemO("PAINT_OT_light_paint_save", text="Save LightEnv")
+
+
+
 class LIGHT_PT_preview(LightButtonsPanel):
 	__idname__= "LIGHT_PT_preview"
 	__label__ = "Preview"
@@ -64,7 +80,8 @@
                 #split.template_ID(context, lightenv, "probe_image", new="IMAGE_OT_open")
 		layout.itemR(lightenv, "probe_image")
 
-bpy.types.register(LIGHT_PT_compute)
+bpy.types.register(LIGHT_PT_properties)
 bpy.types.register(LIGHT_PT_preview)
+bpy.types.register(LIGHT_PT_save)
 bpy.types.register(LIGHT_PT_type)
 bpy.types.register(LIGHT_PT_probe_image)

Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h	2009-06-19 15:14:24 UTC (rev 21011)
@@ -42,6 +42,7 @@
 void init_def_lightenv(void);
 void free_lightenv(struct LightEnv *env); 
 void add_lightenv(struct Scene *scene, char *name);
+void save_lightenv(struct LightEnv *env, char *image_name);
 
 void update_light_func(struct LightEnv *env);
 

Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c	2009-06-19 15:14:24 UTC (rev 21011)
@@ -95,9 +95,9 @@
         SH_computeLightCoefficients(env);
 }
 
-static void save_probe_image(LightEnv *env, char *image_name, int w, int h)
+void save_lightenv(LightEnv *env, char *image_name)
 {
-        ImBuf * ibuf= IMB_allocImBuf(w, h, 32, IB_rectfloat, 0);
+        ImBuf * ibuf= IMB_allocImBuf(env->output_width, env->output_height, 32, IB_rectfloat, 0);
         SH_reconstructLightProbe(env, ibuf);
         IMB_saveiff(ibuf, image_name, 0);
         IMB_freeImBuf(ibuf);
@@ -118,6 +118,7 @@
         env->light_func = def_synthetic;
 	env->degree = 2;
 	env->num_samples = 10;
+	env->output_width = env->output_height = 512;
         SH_computeLightCoefficients(env);
 
         scene->lightenv = env;

Modified: branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h	2009-06-19 15:14:24 UTC (rev 21011)
@@ -62,6 +62,7 @@
 void PAINT_OT_light_paint_radial_control(struct wmOperatorType *ot);
 void PAINT_OT_light_paint_rotate(struct wmOperatorType *ot);
 void PAINT_OT_light_paint_recompute(struct wmOperatorType *ot);
+void PAINT_OT_light_paint_save(struct wmOperatorType *ot);
 
 /* paint_utils.c */
 int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index);

Modified: branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c	2009-06-19 15:14:24 UTC (rev 21011)
@@ -770,7 +770,29 @@
 	return light_paint_compute(C, 1);
 }
 
+/************************ light paint save ************************/
+static int light_paint_save_exec(bContext *C, wmOperator *op)
+{
+	Scene *scene = CTX_data_scene(C);
+	LightEnv *env = scene->lightenv;
+	char str[FILE_MAX];
+	
+	RNA_string_get(op->ptr, "filename", str);
+	save_lightenv(env, str);
 
+	return OPERATOR_FINISHED;
+}
+
+static int light_paint_save_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+	if(RNA_property_is_set(op->ptr, "filename"))
+		return light_paint_save_exec(C, op);
+
+	RNA_string_set(op->ptr, "filename", "");
+	WM_event_add_fileselect(C, op); 
+	return OPERATOR_RUNNING_MODAL;
+}
+
 void PAINT_OT_light_paint_toggle(wmOperatorType *ot)
 {
 	/* identifiers */
@@ -841,3 +863,16 @@
 	ot->exec= light_paint_recompute;
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
+
+
+void PAINT_OT_light_paint_save(struct wmOperatorType *ot)
+{
+	ot->name= "Light Paint Save";
+	ot->idname = "PAINT_OT_light_paint_save";
+
+	ot->invoke= light_paint_save_invoke;
+	ot->exec= light_paint_save_exec;
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+	RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of the output image.");
+}

Modified: branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c	2009-06-19 15:14:24 UTC (rev 21011)
@@ -35,5 +35,6 @@
         WM_operatortype_append(PAINT_OT_light_paint_radial_control);
         WM_operatortype_append(PAINT_OT_light_paint_rotate);
 	WM_operatortype_append(PAINT_OT_light_paint_recompute);
+	WM_operatortype_append(PAINT_OT_light_paint_save);
 }
 

Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h	2009-06-19 15:14:24 UTC (rev 21011)
@@ -41,6 +41,7 @@
 
         short flag, type;
 	int degree, num_samples;
+	int output_width, output_height;
         float shcoeffs[25][3];
 
         void (*light_func)(float i1, float i2, float val[3], void *data);

Modified: branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_lightenv.c	2009-06-19 14:56:49 UTC (rev 21010)
+++ branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_lightenv.c	2009-06-19 15:14:24 UTC (rev 21011)
@@ -85,6 +85,16 @@
 	RNA_def_property_int_sdna(prop, NULL, "num_samples");
 	RNA_def_property_range(prop, 5, 100);
 	RNA_def_property_ui_text(prop, "Sqrt(Samples)", "The sqrt of number of samples.");
+
+	prop= RNA_def_property(srna, "output_width", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "output_width");
+	RNA_def_property_range(prop, 128, 2048);
+	RNA_def_property_ui_text(prop, "Width", "Width of the output image");
+
+	prop= RNA_def_property(srna, "output_height", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "output_height");
+	RNA_def_property_range(prop, 128, 2048);
+	RNA_def_property_ui_text(prop, "Height", "Height of the output image");
 }
 
 #endif





More information about the Bf-blender-cvs mailing list