[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27985] trunk/blender/source/blender: 2. 5 Preview Render:
Thomas Dinges
dingto at gmx.de
Sun Apr 4 14:09:59 CEST 2010
Revision: 27985
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27985
Author: dingto
Date: 2010-04-04 14:09:59 +0200 (Sun, 04 Apr 2010)
Log Message:
-----------
2.5 Preview Render:
* Converted Type Buttons (Flat, Cube, Monkey etc.) in Material Preview to RNA.
* "Alpha" option in texture Preview Render is back!
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface_templates.c
trunk/blender/source/blender/makesrna/intern/rna_material.c
trunk/blender/source/blender/makesrna/intern/rna_texture.c
Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c 2010-04-04 11:07:42 UTC (rev 27984)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c 2010-04-04 12:09:59 UTC (rev 27985)
@@ -1286,6 +1286,7 @@
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
#include "DNA_world_types.h"
#define B_MATPRV 1
@@ -1304,8 +1305,11 @@
uiLayout *row, *col;
uiBlock *block;
Material *ma= NULL;
+ Tex *tex = (Tex*)id;
ID *pid, *pparent;
short *pr_texture= NULL;
+ PointerRNA material_ptr;
+ PointerRNA texture_ptr;
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");
@@ -1348,20 +1352,20 @@
if(GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) {
if(GS(pid->name) == ID_MA) ma= (Material*)pid;
else ma= (Material*)pparent;
+
+ /* Create RNA Pointer */
+ RNA_pointer_create(id, &RNA_Material, ma, &material_ptr);
- uiLayoutColumn(row, 1);
-
- uiDefIconButC(block, ROW, B_MATPRV, ICON_MATPLANE, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_FLAT, 0, 0, "Preview type: Flat XY plane");
- uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE, 0, 0, "Preview type: Sphere");
- uiDefIconButC(block, ROW, B_MATPRV, ICON_MATCUBE, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_CUBE, 0, 0, "Preview type: Cube");
- uiDefIconButC(block, ROW, B_MATPRV, ICON_MONKEY, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_MONKEY, 0, 0, "Preview type: Monkey");
- uiDefIconButC(block, ROW, B_MATPRV, ICON_HAIR, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_HAIR, 0, 0, "Preview type: Hair strands");
- uiDefIconButC(block, ROW, B_MATPRV, ICON_MAT_SPHERE_SKY, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE_A, 0, 0, "Preview type: Large sphere with sky");
+ col = uiLayoutColumn(row, 1);
+ uiLayoutSetScaleX(col, 1.5);
+ uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", 0);
}
if(pr_texture) {
+ /* Create RNA Pointer */
+ RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr);
+
uiLayoutRow(layout, 1);
-
uiDefButS(block, ROW, B_MATPRV, "Texture", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, "");
if(GS(parent->name) == ID_MA)
uiDefButS(block, ROW, B_MATPRV, "Material", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
@@ -1370,6 +1374,12 @@
else if(GS(parent->name) == ID_WO)
uiDefButS(block, ROW, B_MATPRV, "World", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
uiDefButS(block, ROW, B_MATPRV, "Both", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_BOTH, 0, 0, "");
+
+ /* Alpha buton for texture preview */
+ if(*pr_texture!=TEX_PR_OTHER) {
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, 0);
+ }
}
}
}
Modified: trunk/blender/source/blender/makesrna/intern/rna_material.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_material.c 2010-04-04 11:07:42 UTC (rev 27984)
+++ trunk/blender/source/blender/makesrna/intern/rna_material.c 2010-04-04 12:09:59 UTC (rev 27985)
@@ -1486,6 +1486,16 @@
{MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces"},
{MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering"},
{0, NULL, 0, NULL, NULL}};
+
+ /* Render Preview Types */
+ static EnumPropertyItem preview_type_items[] = {
+ {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Preview type: Flat XY plane"},
+ {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Preview type: Sphere"},
+ {MA_CUBE, "CUBE", ICON_MATCUBE, "Flat", "Preview type: Cube"},
+ {MA_MONKEY, "MONKEY", ICON_MONKEY, "Flat", "Preview type: Monkey"},
+ {MA_HAIR, "HAIR", ICON_HAIR, "Flat", "Preview type: Hair strands"},
+ {MA_SPHERE_A, "SPHERE_A", ICON_MAT_SPHERE_SKY, "Flat", "Preview type: Large sphere with sky"},
+ {0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "Material", "ID");
RNA_def_struct_ui_text(srna, "Material", "Material datablock to defined the appearance of geometric objects for rendering");
@@ -1509,6 +1519,13 @@
RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency");
RNA_def_property_update(prop, 0, "rna_Material_update");
+ /* For Preview Render */
+ prop= RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "pr_type");
+ RNA_def_property_enum_items(prop, preview_type_items);
+ RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render");
+ RNA_def_property_update(prop, 0, "rna_Material_update");
+
prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "amb");
RNA_def_property_range(prop, 0, 1);
Modified: trunk/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_texture.c 2010-04-04 11:07:42 UTC (rev 27984)
+++ trunk/blender/source/blender/makesrna/intern/rna_texture.c 2010-04-04 12:09:59 UTC (rev 27985)
@@ -1725,6 +1725,12 @@
RNA_def_property_ui_text(prop, "Factor Blue", "");
RNA_def_property_update(prop, 0, "rna_Texture_update");
+ /* Alpha for preview render */
+ prop= RNA_def_property(srna, "use_preview_alpha", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PRV_ALPHA);
+ RNA_def_property_ui_text(prop, "Show Alpha", "Show Alpha in Preview Render");
+ RNA_def_property_update(prop, 0, "rna_Texture_update");
+
/* nodetree */
prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
More information about the Bf-blender-cvs
mailing list