Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * Contributor(s): Brecht Van Lommel 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 00028 #include <stdlib.h> 00029 00030 #include "RNA_define.h" 00031 #include "RNA_enum_types.h" 00032 00033 #include "rna_internal.h" 00034 00035 #include "DNA_image_types.h" 00036 #include "DNA_scene_types.h" 00037 00038 #include "BKE_context.h" 00039 #include "BKE_depsgraph.h" 00040 #include "BKE_image.h" 00041 00042 #include "WM_types.h" 00043 #include "WM_api.h" 00044 00045 static EnumPropertyItem image_source_items[]= { 00046 {IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"}, 00047 {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"}, 00048 {IMA_SRC_MOVIE, "MOVIE", 0, "Movie File", "Movie file"}, 00049 {IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"}, 00050 {IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"}, 00051 {0, NULL, 0, NULL, NULL}}; 00052 00053 #ifdef RNA_RUNTIME 00054 00055 #include "IMB_imbuf_types.h" 00056 00057 static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00058 { 00059 Image *ima= (Image*)ptr->data; 00060 int nr; 00061 00062 if(ima->flag & IMA_TWINANIM) { 00063 nr= ima->xrep*ima->yrep; 00064 if(ima->twsta>=nr) ima->twsta= 1; 00065 if(ima->twend>=nr) ima->twend= nr-1; 00066 if(ima->twsta>ima->twend) ima->twsta= 1; 00067 } 00068 } 00069 00070 static int rna_Image_dirty_get(PointerRNA *ptr) 00071 { 00072 Image *ima= (Image*)ptr->data; 00073 ImBuf *ibuf; 00074 00075 for(ibuf=ima->ibufs.first; ibuf; ibuf=ibuf->next) 00076 if(ibuf->userflags & IB_BITMAPDIRTY) 00077 return 1; 00078 00079 return 0; 00080 } 00081 00082 static void rna_Image_source_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00083 { 00084 Image *ima= ptr->id.data; 00085 BKE_image_signal(ima, NULL, IMA_SIGNAL_SRC_CHANGE); 00086 DAG_id_tag_update(&ima->id, 0); 00087 } 00088 00089 static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00090 { 00091 Image *ima= ptr->id.data; 00092 ImBuf *ibuf; 00093 void *lock; 00094 00095 ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); 00096 00097 if(ibuf) { 00098 short nr= 0; 00099 00100 if(!(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields)) nr= 1; 00101 if((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr= 1; 00102 00103 if(nr) 00104 BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); 00105 } 00106 00107 BKE_image_release_ibuf(ima, lock); 00108 } 00109 00110 static void rna_Image_free_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00111 { 00112 Image *ima= ptr->id.data; 00113 BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); 00114 WM_main_add_notifier(NC_IMAGE|NA_EDITED, &ima->id); 00115 DAG_id_tag_update(&ima->id, 0); 00116 } 00117 00118 00119 static void rna_Image_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00120 { 00121 Image *ima= ptr->id.data; 00122 BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); 00123 WM_main_add_notifier(NC_IMAGE|NA_EDITED, &ima->id); 00124 DAG_id_tag_update(&ima->id, 0); 00125 } 00126 00127 static void rna_Image_generated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00128 { 00129 Image *ima= ptr->id.data; 00130 BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); 00131 } 00132 00133 static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) 00134 { 00135 ImageUser *iuser= ptr->data; 00136 00137 BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); 00138 } 00139 00140 00141 char *rna_ImageUser_path(PointerRNA *ptr) 00142 { 00143 if (ptr->id.data) { 00144 // ImageUser *iuser= ptr->data; 00145 00146 switch(GS(((ID *)ptr->id.data)->name)) { 00147 case ID_TE: 00148 return BLI_strdup("image_user"); 00149 } 00150 } 00151 00152 return BLI_strdup(""); 00153 } 00154 00155 static EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) 00156 { 00157 Image *ima= (Image*)ptr->data; 00158 EnumPropertyItem *item= NULL; 00159 int totitem= 0; 00160 00161 if(ima->source == IMA_SRC_VIEWER) { 00162 RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_VIEWER); 00163 } 00164 else { 00165 RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_FILE); 00166 RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_SEQUENCE); 00167 RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_MOVIE); 00168 RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_GENERATED); 00169 } 00170 00171 RNA_enum_item_end(&item, &totitem); 00172 *free= 1; 00173 00174 return item; 00175 } 00176 00177 static int rna_Image_file_format_get(PointerRNA *ptr) 00178 { 00179 Image *image= (Image*)ptr->data; 00180 ImBuf *ibuf= BKE_image_get_ibuf(image, NULL); 00181 return BKE_ftype_to_imtype(ibuf ? ibuf->ftype : 0); 00182 } 00183 00184 static void rna_Image_file_format_set(PointerRNA *ptr, int value) 00185 { 00186 Image *image= (Image*)ptr->data; 00187 if(BKE_imtype_is_movie(value) == 0) { /* should be able to throw an error here */ 00188 ImBuf *ibuf; 00189 int ftype= BKE_imtype_to_ftype(value); 00190 00191 /* 00192 ibuf= BKE_image_get_ibuf(image, NULL); 00193 if(ibuf) 00194 ibuf->ftype= ftype; 00195 */ 00196 00197 /* to be safe change all buffer file types */ 00198 for(ibuf= image->ibufs.first; ibuf; ibuf= ibuf->next) { 00199 ibuf->ftype= ftype; 00200 } 00201 } 00202 } 00203 00204 static int rna_Image_has_data_get(PointerRNA *ptr) 00205 { 00206 Image *im= (Image*)ptr->data; 00207 00208 if (im->ibufs.first) 00209 return 1; 00210 00211 return 0; 00212 } 00213 00214 static void rna_Image_size_get(PointerRNA *ptr,int *values) 00215 { 00216 Image *im= (Image*)ptr->data; 00217 ImBuf *ibuf; 00218 void *lock; 00219 00220 ibuf = BKE_image_acquire_ibuf(im, NULL , &lock); 00221 if (ibuf) { 00222 values[0]= ibuf->x; 00223 values[1]= ibuf->y; 00224 } 00225 else { 00226 values[0]= 0; 00227 values[1]= 0; 00228 } 00229 00230 BKE_image_release_ibuf(im, lock); 00231 } 00232 00233 static void rna_Image_resolution_get(PointerRNA *ptr, float *values) 00234 { 00235 Image *im= (Image*)ptr->data; 00236 ImBuf *ibuf; 00237 void *lock; 00238 00239 ibuf = BKE_image_acquire_ibuf(im, NULL , &lock); 00240 if (ibuf) { 00241 values[0]= ibuf->ppm[0]; 00242 values[1]= ibuf->ppm[1]; 00243 } 00244 else { 00245 values[0]= 0; 00246 values[1]= 0; 00247 } 00248 00249 BKE_image_release_ibuf(im, lock); 00250 } 00251 00252 static void rna_Image_resolution_set(PointerRNA *ptr, const float *values) 00253 { 00254 Image *im= (Image*)ptr->data; 00255 ImBuf *ibuf; 00256 void *lock; 00257 00258 ibuf = BKE_image_acquire_ibuf(im, NULL , &lock); 00259 if (ibuf) { 00260 ibuf->ppm[0]= values[0]; 00261 ibuf->ppm[1]= values[1]; 00262 } 00263 00264 BKE_image_release_ibuf(im, lock); 00265 } 00266 00267 static int rna_Image_depth_get(PointerRNA *ptr) 00268 { 00269 Image *im= (Image*)ptr->data; 00270 ImBuf *ibuf; 00271 void *lock; 00272 int planes; 00273 00274 ibuf= BKE_image_acquire_ibuf(im, NULL, &lock); 00275 00276 if(!ibuf) 00277 planes= 0; 00278 else if(ibuf->rect_float) 00279 planes= ibuf->planes * 4; 00280 else 00281 planes= ibuf->planes; 00282 00283 BKE_image_release_ibuf(im, lock); 00284 00285 return planes; 00286 } 00287 00288 static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) 00289 { 00290 Image *ima= ptr->id.data; 00291 ImBuf *ibuf; 00292 void *lock; 00293 00294 ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); 00295 00296 if(ibuf) 00297 length[0]= ibuf->x*ibuf->y*ibuf->channels; 00298 else 00299 length[0]= 0; 00300 00301 BKE_image_release_ibuf(ima, lock); 00302 00303 return length[0]; 00304 } 00305 00306 static void rna_Image_pixels_get(PointerRNA *ptr, float *values) 00307 { 00308 Image *ima= ptr->id.data; 00309 ImBuf *ibuf; 00310 void *lock; 00311 int i, size; 00312 00313 ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); 00314 00315 if(ibuf) { 00316 size= ibuf->x*ibuf->y*ibuf->channels; 00317 00318 if(ibuf->rect_float) { 00319 memcpy(values, ibuf->rect_float, sizeof(float)*size); 00320 } 00321 else { 00322 for(i = 0; i < size; i++) 00323 values[i] = ((unsigned char*)ibuf->rect)[i]*(1.0f/255.0f); 00324 } 00325 } 00326 00327 BKE_image_release_ibuf(ima, lock); 00328 } 00329 00330 static void rna_Image_pixels_set(PointerRNA *ptr, const float *values) 00331 { 00332 Image *ima= ptr->id.data; 00333 ImBuf *ibuf; 00334 void *lock; 00335 int i, size; 00336 00337 ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); 00338 00339 if(ibuf) { 00340 size= ibuf->x*ibuf->y*ibuf->channels; 00341 00342 if(ibuf->rect_float) { 00343 memcpy(ibuf->rect_float, values, sizeof(float)*size); 00344 } 00345 else { 00346 for(i = 0; i < size; i++) 00347 ((unsigned char*)ibuf->rect)[i] = FTOCHAR(values[i]); 00348 } 00349 00350 ibuf->userflags |= IB_BITMAPDIRTY; 00351 } 00352 00353 BKE_image_release_ibuf(ima, lock); 00354 } 00355 00356 #else 00357 00358 static void rna_def_imageuser(BlenderRNA *brna) 00359 { 00360 StructRNA *srna; 00361 PropertyRNA *prop; 00362 00363 srna= RNA_def_struct(brna, "ImageUser", NULL); 00364 RNA_def_struct_ui_text(srna, "Image User", "Parameters defining how an Image datablock is used by another datablock"); 00365 RNA_def_struct_path_func(srna, "rna_ImageUser_path"); 00366 00367 prop= RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE); 00368 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS); 00369 RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes"); 00370 RNA_def_property_update(prop, 0, "rna_ImageUser_update"); 00371 00372 /* animation */ 00373 prop= RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE); 00374 RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0); 00375 RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie"); 00376 RNA_def_property_update(prop, 0, "rna_ImageUser_update"); 00377 00378 prop= RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE); 00379 RNA_def_property_int_sdna(prop, NULL, "frames"); 00380 RNA_def_property_range(prop, 0, MAXFRAMEF); 00381 RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use"); 00382 RNA_def_property_update(prop, 0, "rna_ImageUser_update"); 00383 00384 prop= RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE); 00385 RNA_def_property_int_sdna(prop, NULL, "offset"); 00386 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); 00387 RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation"); 00388 RNA_def_property_update(prop, 0, "rna_ImageUser_update"); 00389 00390 prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); 00391 RNA_def_property_int_sdna(prop, NULL, "sfra"); 00392 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); 00393 RNA_def_property_ui_text(prop, "Start Frame", "Global starting frame of the movie/sequence, assuming first picture has a #1"); 00394 RNA_def_property_update(prop, 0, "rna_ImageUser_update"); 00395 00396 prop= RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE); 00397 RNA_def_property_int_sdna(prop, NULL, "fie_ima"); 00398 RNA_def_property_range(prop, 1, 200); 00399 RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)"); 00400 RNA_def_property_update(prop, 0, "rna_ImageUser_update"); 00401 00402 prop= RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED); 00403 RNA_def_property_int_sdna(prop, NULL, "layer"); 00404 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */ 00405 RNA_def_property_ui_text(prop, "Layer", "Layer in multilayer image"); 00406 00407 prop= RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED); 00408 RNA_def_property_int_sdna(prop, NULL, "pass"); 00409 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */ 00410 RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image"); 00411 } 00412 00413 static void rna_def_image(BlenderRNA *brna) 00414 { 00415 StructRNA *srna; 00416 PropertyRNA *prop; 00417 static const EnumPropertyItem prop_type_items[]= { 00418 {IMA_TYPE_IMAGE, "IMAGE", 0, "Image", ""}, 00419 {IMA_TYPE_MULTILAYER, "MULTILAYER", 0, "Multilayer", ""}, 00420 {IMA_TYPE_UV_TEST, "UV_TEST", 0, "UV Test", ""}, 00421 {IMA_TYPE_R_RESULT, "RENDER_RESULT", 0, "Render Result", ""}, 00422 {IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""}, 00423 {0, NULL, 0, NULL, NULL}}; 00424 static const EnumPropertyItem prop_generated_type_items[]= { 00425 {0, "BLANK", 0, "Blank", "Generate a blank image"}, 00426 {1, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"}, 00427 {2, "COLOR_GRID", 0, "Color Grid", "Generated improved UV grid to test UV mappings"}, 00428 {0, NULL, 0, NULL, NULL}}; 00429 static const EnumPropertyItem prop_mapping_items[]= { 00430 {0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"}, 00431 {IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"}, 00432 {0, NULL, 0, NULL, NULL}}; 00433 static const EnumPropertyItem prop_field_order_items[]= { 00434 {0, "EVEN", 0, "Upper First", "Upper field first"}, 00435 {IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"}, 00436 {0, NULL, 0, NULL, NULL}}; 00437 00438 srna= RNA_def_struct(brna, "Image", "ID"); 00439 RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image"); 00440 RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA); 00441 00442 prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); 00443 RNA_def_property_string_sdna(prop, NULL, "name"); 00444 RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name"); 00445 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_reload_update"); 00446 00447 /* eek. this is horrible but needed so we can save to a new name without blanking the data :( */ 00448 prop= RNA_def_property(srna, "filepath_raw", PROP_STRING, PROP_FILEPATH); 00449 RNA_def_property_string_sdna(prop, NULL, "name"); 00450 RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name (without data refreshing)"); 00451 00452 prop= RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); 00453 RNA_def_property_enum_items(prop, image_type_items); 00454 RNA_def_property_enum_funcs(prop, "rna_Image_file_format_get", "rna_Image_file_format_set", NULL); 00455 RNA_def_property_ui_text(prop, "File Format", "Format used for re-saving this file"); 00456 00457 prop= RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); 00458 RNA_def_property_enum_items(prop, image_source_items); 00459 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Image_source_itemf"); 00460 RNA_def_property_ui_text(prop, "Source", "Where the image comes from"); 00461 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_source_update"); 00462 00463 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); 00464 RNA_def_property_enum_items(prop, prop_type_items); 00465 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00466 RNA_def_property_ui_text(prop, "Type", "How to generate the image"); 00467 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00468 00469 prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); 00470 RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); 00471 RNA_def_property_ui_text(prop, "Packed File", ""); 00472 00473 prop= RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE); 00474 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); 00475 RNA_def_property_enum_items(prop, prop_field_order_items); 00476 RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)"); 00477 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00478 00479 /* booleans */ 00480 prop= RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE); 00481 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); 00482 RNA_def_property_ui_text(prop, "Fields", "Use fields of the image"); 00483 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_fields_update"); 00484 00485 prop= RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE); 00486 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL); 00487 RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha"); 00488 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_free_update"); 00489 00490 prop= RNA_def_property(srna, "use_color_unpremultiply", PROP_BOOLEAN, PROP_NONE); 00491 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_CM_PREDIVIDE); 00492 RNA_def_property_ui_text(prop, "Color Unpremultiply", "For premultiplied alpha images, do color space conversion on colors without alpha, to avoid fringing for images with light backgrounds"); 00493 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_free_update"); 00494 00495 prop= RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE); 00496 RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL); 00497 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00498 RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved"); 00499 00500 /* generated image (image_generated_change_cb) */ 00501 prop= RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE); 00502 RNA_def_property_enum_sdna(prop, NULL, "gen_type"); 00503 RNA_def_property_enum_items(prop, prop_generated_type_items); 00504 RNA_def_property_ui_text(prop, "Generated Type", "Generated image type"); 00505 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update"); 00506 00507 prop= RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE); 00508 RNA_def_property_int_sdna(prop, NULL, "gen_x"); 00509 RNA_def_property_range(prop, 1, 16384); 00510 RNA_def_property_ui_text(prop, "Generated Width", "Generated image width"); 00511 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update"); 00512 00513 prop= RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE); 00514 RNA_def_property_int_sdna(prop, NULL, "gen_y"); 00515 RNA_def_property_range(prop, 1, 16384); 00516 RNA_def_property_ui_text(prop, "Generated Height", "Generated image height"); 00517 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update"); 00518 00519 prop= RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE); 00520 RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT); 00521 RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer"); 00522 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update"); 00523 00524 /* realtime properties */ 00525 prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); 00526 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); 00527 RNA_def_property_enum_items(prop, prop_mapping_items); 00528 RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine"); 00529 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00530 00531 prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ); 00532 RNA_def_property_float_sdna(prop, NULL, "aspx"); 00533 RNA_def_property_array(prop, 2); 00534 RNA_def_property_range(prop, 0.1f, 5000.0f); 00535 RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering"); 00536 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00537 00538 prop= RNA_def_property(srna, "use_animation", PROP_BOOLEAN, PROP_NONE); 00539 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM); 00540 RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine"); 00541 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update"); 00542 00543 prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); 00544 RNA_def_property_int_sdna(prop, NULL, "twsta"); 00545 RNA_def_property_range(prop, 0, 128); 00546 RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture"); 00547 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update"); 00548 00549 prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE); 00550 RNA_def_property_int_sdna(prop, NULL, "twend"); 00551 RNA_def_property_range(prop, 0, 128); 00552 RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture"); 00553 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update"); 00554 00555 prop= RNA_def_property(srna, "fps", PROP_INT, PROP_NONE); 00556 RNA_def_property_int_sdna(prop, NULL, "animspeed"); 00557 RNA_def_property_range(prop, 1, 100); 00558 RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second"); 00559 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00560 00561 prop= RNA_def_property(srna, "use_tiles", PROP_BOOLEAN, PROP_NONE); 00562 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES); 00563 RNA_def_property_ui_text(prop, "Tiles", "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)"); 00564 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00565 00566 prop= RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE); 00567 RNA_def_property_int_sdna(prop, NULL, "xrep"); 00568 RNA_def_property_range(prop, 1, 16); 00569 RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction"); 00570 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00571 00572 prop= RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE); 00573 RNA_def_property_int_sdna(prop, NULL, "yrep"); 00574 RNA_def_property_range(prop, 1, 16); 00575 RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction"); 00576 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00577 00578 prop= RNA_def_property(srna, "use_clamp_x", PROP_BOOLEAN, PROP_NONE); 00579 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U); 00580 RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally"); 00581 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00582 00583 prop= RNA_def_property(srna, "use_clamp_y", PROP_BOOLEAN, PROP_NONE); 00584 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V); 00585 RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically"); 00586 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00587 00588 prop= RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED); 00589 RNA_def_property_int_sdna(prop, NULL, "bindcode"); 00590 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00591 RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode"); 00592 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); 00593 00594 /* 00595 Image.has_data and Image.depth are temporary, 00596 Update import_obj.py when they are replaced (Arystan) 00597 */ 00598 prop= RNA_def_property(srna, "has_data", PROP_BOOLEAN, PROP_NONE); 00599 RNA_def_property_boolean_funcs(prop, "rna_Image_has_data_get", NULL); 00600 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00601 RNA_def_property_ui_text(prop, "Has data", "True if this image has data"); 00602 00603 prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED); 00604 RNA_def_property_int_funcs(prop, "rna_Image_depth_get", NULL, NULL); 00605 RNA_def_property_ui_text(prop, "Depth", "Image bit depth"); 00606 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00607 00608 prop= RNA_def_int_vector(srna, "size" , 2 , NULL , 0, 0, "Size" , "Width and height in pixels, zero when image data cant be loaded" , 0 , 0); 00609 RNA_def_property_int_funcs(prop, "rna_Image_size_get" , NULL, NULL); 00610 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00611 00612 prop= RNA_def_float_vector(srna, "resolution" , 2 , NULL , 0, 0, "Resolution" , "X/Y pixels per meter" , 0 , 0); 00613 RNA_def_property_float_funcs(prop, "rna_Image_resolution_get" , "rna_Image_resolution_set", NULL); 00614 00615 prop= RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE); 00616 RNA_def_property_flag(prop, PROP_DYNAMIC); 00617 RNA_def_property_multi_array(prop, 1, NULL); 00618 RNA_def_property_ui_text(prop, "Pixels", "Image pixels in floating point values"); 00619 RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length"); 00620 RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL); 00621 00622 RNA_api_image(srna); 00623 } 00624 00625 void RNA_def_image(BlenderRNA *brna) 00626 { 00627 rna_def_image(brna); 00628 rna_def_imageuser(brna); 00629 } 00630 00631 #endif 00632