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