[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20886] branches/soc-2009-yukishiro: add UI for lightenv.
Jingyuan Huang
jingyuan.huang at gmail.com
Mon Jun 15 01:33:44 CEST 2009
Revision: 20886
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20886
Author: yukishiro
Date: 2009-06-15 01:33:43 +0200 (Mon, 15 Jun 2009)
Log Message:
-----------
add UI for lightenv. Provide a list of images for light probe type of light envs
Modified Paths:
--------------
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/interface/interface_templates.c
branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h
branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_ID.c
branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_lightenv.c
Added Paths:
-----------
branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py
Removed Paths:
-------------
branches/soc-2009-yukishiro/release/ui/buttons_light.py
Deleted: branches/soc-2009-yukishiro/release/ui/buttons_light.py
===================================================================
--- branches/soc-2009-yukishiro/release/ui/buttons_light.py 2009-06-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/release/ui/buttons_light.py 2009-06-14 23:33:43 UTC (rev 20886)
@@ -1,32 +0,0 @@
-
-import bpy
-
-class LightButtonsPanel(bpy.types.Panel):
- __space_type__ = "BUTTONS_WINDOW"
- __region_type__ = "WINDOW"
- __context__ = "lightenv"
-
-
-class LIGHT_PT_preview(LightButtonsPanel):
- __idname__= "LIGHT_PT_preview"
- __label__ = "Preview"
-
- def poll(self, context):
- return context.lightenv
-
- def draw(self, context):
- layout = self.layout
-
- lightenv = context.lightenv
- layout.template_preview(lightenv)
-
-
-class LIGHT_PT_type(LightButtonsPanel):
- __idname__= "LIGHT_PT_type"
- __label__ = "Light Environment Type"
-
- def draw(self, context):
- layout = self.layout
-
-bpy.types.register(LIGHT_PT_preview)
-bpy.types.register(LIGHT_PT_type)
Copied: branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py (from rev 20838, branches/soc-2009-yukishiro/release/ui/buttons_light.py)
===================================================================
--- branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py (rev 0)
+++ branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py 2009-06-14 23:33:43 UTC (rev 20886)
@@ -0,0 +1,53 @@
+
+import bpy
+
+class LightButtonsPanel(bpy.types.Panel):
+ __space_type__ = "BUTTONS_WINDOW"
+ __region_type__ = "WINDOW"
+ __context__ = "lightenv"
+
+
+class LIGHT_PT_preview(LightButtonsPanel):
+ __idname__= "LIGHT_PT_preview"
+ __label__ = "Preview"
+
+ def poll(self, context):
+ return context.lightenv
+
+ def draw(self, context):
+ layout = self.layout
+
+ lightenv = context.lightenv
+ layout.template_preview(lightenv)
+
+
+class LIGHT_PT_type(LightButtonsPanel):
+ __idname__= "LIGHT_PT_type"
+ __label__ = "Light Environment Type"
+
+ def draw(self, context):
+ layout = self.layout
+ lightenv = context.lightenv
+
+ row = layout.row()
+ row.itemR(lightenv, "type", text="Type")
+
+class LIGHT_PT_probe_image(LightButtonsPanel):
+ __idname__= "LIGHT_PT_probe_image"
+ __label__ = "Probe Image"
+
+ def poll(self, context):
+ lightenv = context.lightenv
+ return (lightenv and lightenv.type == 'PROBE')
+
+ def draw(self, context):
+ layout = self.layout
+ split = layout.split(percentage=0.65)
+
+ lightenv = context.lightenv
+ scene = context.scene
+ split.template_ID(context, lightenv, "probe_image", new="IMAGE_OT_open")
+
+bpy.types.register(LIGHT_PT_preview)
+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-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h 2009-06-14 23:33:43 UTC (rev 20886)
@@ -37,12 +37,14 @@
struct LightEnv;
struct Scene;
+struct Image;
void init_def_lightenv(void);
void free_lightenv(struct LightEnv *env);
void add_lightenv(struct Scene *scene, char *name);
void load_probe_image(struct LightEnv *env, char *image_name);
+void set_probe_image(struct LightEnv *env, struct Image *image);
#ifdef __cplusplus
}
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-14 23:33:43 UTC (rev 20886)
@@ -72,7 +72,7 @@
val[2] = fval[2];
}
-static void load_probe_image(LightEnv *env, const char *image_name)
+void load_probe_image(LightEnv *env, const char *image_name)
{
env->probe_image = BKE_add_image_file(image_name, 0);
env->type = LE_PROBE;
@@ -80,6 +80,14 @@
SH_ComputeLightCoefficients(env);
}
+void set_probe_image(LightEnv *env, Image *image)
+{
+ env->probe_image = image;
+ env->type = LE_PROBE;
+ env->light_func = probe_value;
+ SH_ComputeLightCoefficients(env);
+}
+
static void save_probe_image(LightEnv *env, char *image_name, int w, int h)
{
ImBuf * ibuf= IMB_allocImBuf(w, h, 32, IB_rectfloat, 0);
Modified: branches/soc-2009-yukishiro/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/interface/interface_templates.c 2009-06-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/editors/interface/interface_templates.c 2009-06-14 23:33:43 UTC (rev 20886)
@@ -1372,8 +1372,8 @@
uiBlock *block;
Material *ma;
- if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) {
- printf("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n");
+ if(id && !ELEM5(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA, ID_LE)) {
+ printf("uiTemplatePreview: expected ID of type material, texture, lamp, world, or lightenv.\n");
return;
}
Modified: branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c 2009-06-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c 2009-06-14 23:33:43 UTC (rev 20886)
@@ -54,6 +54,7 @@
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_lamp_types.h"
+#include "DNA_lightenv_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_scene_types.h"
@@ -431,6 +432,10 @@
sce->lay= 1<<MA_SKY;
sce->world= (World *)id;
}
+ else if(id_type==ID_LE) {
+ sce->lay= 1<<MA_LIGHT;
+ sce->lightenv = (LightEnv *)id;
+ }
return sce;
}
Modified: branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c 2009-06-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c 2009-06-14 23:33:43 UTC (rev 20886)
@@ -2494,14 +2494,15 @@
unsigned char *shcol= DM_get_face_data_layer(dm, CD_SH_MCOL);
if (shcol == NULL) shcol = add_sh_mcol_dm(scene, ob, dm);
- glDisable(GL_LIGHTING);
- glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
-
if (rv3d->rflag & RV3D_RECALCMCOL) {
calc_sh_color(scene, ob, dm, shcol);
}
+ glDisable(GL_LIGHTING);
+
+ glColorMaterial(GL_FRONT,GL_DIFFUSE);
+ glEnable(GL_COLOR_MATERIAL);
+
dm->drawFacesColored(dm, me->flag, shcol, NULL);
glDisable(GL_COLOR_MATERIAL);
GPU_disable_material();
Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h 2009-06-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h 2009-06-14 23:33:43 UTC (rev 20886)
@@ -325,6 +325,7 @@
#define MA_SKY 7
#define MA_HAIR 10
#define MA_ATMOS 11
+#define MA_LIGHT 12
/* pr_back */
#define MA_DARK 1
Modified: branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_ID.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_ID.c 2009-06-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_ID.c 2009-06-14 23:33:43 UTC (rev 20886)
@@ -70,6 +70,7 @@
//if(RNA_struct_is_a(type, &RNA_Ipo)) return case ID_IP;
if(RNA_struct_is_a(type, &RNA_Key)) return ID_KE;
if(RNA_struct_is_a(type, &RNA_Lamp)) return ID_LA;
+ if(RNA_struct_is_a(type, &RNA_LightEnv)) return ID_LE;
if(RNA_struct_is_a(type, &RNA_Library)) return ID_LI;
if(RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT;
if(RNA_struct_is_a(type, &RNA_Material)) return ID_MA;
@@ -103,6 +104,7 @@
//case ID_IP: return &RNA_Ipo;
case ID_KE: return &RNA_Key;
case ID_LA: return &RNA_Lamp;
+ case ID_LE: return &RNA_LightEnv;
case ID_LI: return &RNA_Library;
case ID_LT: return &RNA_Lattice;
case ID_MA: return &RNA_Material;
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-14 20:52:43 UTC (rev 20885)
+++ branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_lightenv.c 2009-06-14 23:33:43 UTC (rev 20886)
@@ -30,10 +30,21 @@
#include "rna_internal.h"
+#include "BKE_context.h"
+#include "BKE_lightenv.h"
+
#include "DNA_lightenv_types.h"
+#include "WM_types.h"
+
#ifdef RNA_RUNTIME
+static void rna_LightEnv_probe_set(PointerRNA *ptr, PointerRNA value)
+{
+ LightEnv *env = (LightEnv*)ptr->data;
+ set_probe_image(env, value.data);
+}
+
#else
void RNA_def_lightenv(BlenderRNA *brna)
@@ -54,8 +65,13 @@
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "Type", "LightEnv types.");
- //RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL);
- //RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL);
+
+ prop= RNA_def_property(srna, "probe_image", PROP_POINTER, PROP_NONE);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list