diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-07-03 21:44:20 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-07-03 21:44:20 +0400 |
commit | 2a23fda9d55034e524be32bd8cb196ae4cd93920 (patch) | |
tree | 0bf24db1bfb14f3baeef133fbc98211b637144cc /source/blender/makesrna/intern | |
parent | 617851bf21ac5da10bfd171816187e1336cd4a69 (diff) |
OBJ importer almost converted, except a few features (NURBS, NGON, FGON and sharp edges).
Added to API:
- Main.add_image
- Material.z_transparency
- two temporary properties: Image.depth and Image.has_data
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 17 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 5 |
3 files changed, 57 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index c74e46c17da..fbef838d06c 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -66,6 +66,29 @@ static int rna_Image_dirty_get(PointerRNA *ptr) return 0; } +static int rna_Image_has_data_get(PointerRNA *ptr) +{ + Image *im= (Image*)ptr->data; + + if (im->ibufs.first) + return 1; + + return 0; +} + +static int rna_Image_depth_get(PointerRNA *ptr) +{ + Image *im= (Image*)ptr->data; + ImBuf *ibuf= BKE_image_get_ibuf(im, NULL); + + if (!ibuf) return 0; + + if (ibuf->rect_float) + return 128; + + return ibuf->depth; +} + #else static void rna_def_imageuser(BlenderRNA *brna) @@ -275,6 +298,20 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V); RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically."); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); + + /* + Image.has_data and Image.depth are temporary, + Update import_obj.py when they are replaced (Arystan) + */ + prop= RNA_def_property(srna, "has_data", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Image_has_data_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has data", "True if this image has data."); + + prop= RNA_def_property(srna, "depth", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_Image_depth_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Depth", "Image bit depth."); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); } void RNA_def_image(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 9dc32acff6f..17f3800e10e 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -33,6 +33,8 @@ #include "RNA_types.h" #include "DNA_object_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" #ifdef RNA_RUNTIME @@ -41,8 +43,7 @@ #include "BKE_library.h" #include "BKE_object.h" #include "BKE_material.h" - -#include "DNA_mesh_types.h" +#include "BKE_image.h" static Mesh *rna_Main_add_mesh(Main *main, char *name) { @@ -102,6 +103,11 @@ struct Tex *rna_Main_add_texture(Main *main, char *name) /* TODO: remove texture? */ +struct Image *rna_Main_add_image(Main *main, char *filename) +{ + return BKE_add_image_file(filename, 0); +} + #else void RNA_api_main(StructRNA *srna) @@ -164,6 +170,13 @@ void RNA_api_main(StructRNA *srna) parm= RNA_def_pointer(func, "texture", "Texture", "", "New texture."); RNA_def_function_return(func, parm); + func= RNA_def_function(srna, "add_image", "rna_Main_add_image"); + RNA_def_function_ui_description(func, "Add a new image."); + parm= RNA_def_string(func, "filename", "", 0, "", "Filename to load image from."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "image", "Image", "", "New image."); + RNA_def_function_return(func, parm); + } #endif diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 6de13dbd440..326c37d8597 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1082,6 +1082,11 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V); RNA_def_property_ui_text(prop, "Tangent Shading", "Use the material's tangent vector instead of the normal for shading - for anisotropic shading effects"); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "z_transparency", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ZTRA); + RNA_def_property_ui_text(prop, "ZTransp", "Z-buffer transparency"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); /* nested structs */ prop= RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NEVER_NULL); |