4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Brecht Van Lommel
22 * ***** END GPL LICENSE BLOCK *****
27 #include "RNA_define.h"
28 #include "RNA_types.h"
30 #include "rna_internal.h"
32 #include "DNA_image_types.h"
33 #include "DNA_scene_types.h"
35 #include "BKE_context.h"
36 #include "BKE_image.h"
42 static void rna_Image_animated_update(bContext *C, PointerRNA *ptr)
44 Image *ima= (Image*)ptr->data;
47 if(ima->flag & IMA_TWINANIM) {
48 nr= ima->xrep*ima->yrep;
49 if(ima->twsta>=nr) ima->twsta= 1;
50 if(ima->twend>=nr) ima->twend= nr-1;
51 if(ima->twsta>ima->twend) ima->twsta= 1;
57 static void rna_def_imageuser(BlenderRNA *brna)
62 srna= RNA_def_struct(brna, "ImageUser", NULL);
63 RNA_def_struct_ui_text(srna, "Image User", "Parameters defining how an Image datablock is used by another datablock.");
65 prop= RNA_def_property(srna, "auto_refresh", PROP_BOOLEAN, PROP_NONE);
66 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS);
67 RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes.");
70 prop= RNA_def_property(srna, "cyclic", PROP_BOOLEAN, PROP_NONE);
71 RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0);
72 RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie.");
74 prop= RNA_def_property(srna, "frames", PROP_INT, PROP_NONE);
75 RNA_def_property_range(prop, 0, MAXFRAMEF);
76 RNA_def_property_ui_text(prop, "Frames", "Sets the number of images of a movie to use.");
78 prop= RNA_def_property(srna, "offset", PROP_INT, PROP_NONE);
79 RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF);
80 RNA_def_property_ui_text(prop, "Offset", "Offsets the number of the frame to use in the animation.");
82 prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
83 RNA_def_property_int_sdna(prop, NULL, "sfra");
84 RNA_def_property_range(prop, 1.0f, MAXFRAMEF);
85 RNA_def_property_ui_text(prop, "Start Frame", "Sets the global starting frame of the movie.");
87 prop= RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE);
88 RNA_def_property_int_sdna(prop, NULL, "fie_ima");
89 RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF);
90 RNA_def_property_ui_text(prop, "Fields per Frame", "The number of fields per rendered frame (2 fields is 1 image).");
92 prop= RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
93 RNA_def_property_int_sdna(prop, NULL, "layer");
94 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
95 RNA_def_property_ui_text(prop, "Layer", "Layer in multilayer image.");
97 prop= RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED);
98 RNA_def_property_int_sdna(prop, NULL, "pass");
99 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
100 RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image.");
103 static void rna_def_image(BlenderRNA *brna)
107 static const EnumPropertyItem prop_type_items[]= {
108 {IMA_TYPE_IMAGE, "IMAGE", 0, "Image", ""},
109 {IMA_TYPE_MULTILAYER, "MULTILAYER", 0, "Multilayer", ""},
110 {IMA_TYPE_UV_TEST, "UVTEST", 0, "UV Test", ""},
111 {IMA_TYPE_R_RESULT, "RENDERRESULT", 0, "Render Result", ""},
112 {IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
113 {0, NULL, 0, NULL, NULL}};
114 static const EnumPropertyItem prop_source_items[]= {
115 {IMA_SRC_FILE, "FILE", 0, "File", "Single image file"},
116 {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Sequence", "Multiple image files, as a sequence"},
117 {IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"},
118 {IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"},
119 {IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"},
120 {0, NULL, 0, NULL, NULL}};
121 static const EnumPropertyItem prop_generated_type_items[]= {
122 {0, "BLANK", 0, "Blank", "Generate a blank image"},
123 {1, "UVTESTGRID", 0, "UV Test Grid", "Generated grid to test UV mappings"},
124 {0, NULL, 0, NULL, NULL}};
125 static const EnumPropertyItem prop_mapping_items[]= {
126 {0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"},
127 {IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"},
128 {0, NULL, 0, NULL, NULL}};
130 srna= RNA_def_struct(brna, "Image", "ID");
131 RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image.");
132 RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA);
134 prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH);
135 RNA_def_property_string_sdna(prop, NULL, "name");
136 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* imagechanged */
137 RNA_def_property_ui_text(prop, "Filename", "Image/Movie file name.");
138 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
140 prop= RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
141 RNA_def_property_enum_items(prop, prop_source_items);
142 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* imagechanged */
143 RNA_def_property_ui_text(prop, "Source", "Where the image comes from.");
144 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
146 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
147 RNA_def_property_enum_items(prop, prop_type_items);
148 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* imagechanged */
149 RNA_def_property_ui_text(prop, "Type", "How to generate the image.");
150 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
152 prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
153 RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
154 RNA_def_property_ui_text(prop, "Packed File", "");
157 prop= RNA_def_property(srna, "fields", PROP_BOOLEAN, PROP_NONE);
158 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS);
159 RNA_def_property_ui_text(prop, "Fields", "Use fields of the image.");
160 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
162 prop= RNA_def_property(srna, "odd_fields", PROP_BOOLEAN, PROP_NONE);
163 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_STD_FIELD);
164 RNA_def_property_ui_text(prop, "Odd Fields", "Standard field toggle.");
165 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
167 prop= RNA_def_property(srna, "antialias", PROP_BOOLEAN, PROP_NONE);
168 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANTIALI);
169 RNA_def_property_ui_text(prop, "Anti-alias", "Toggles image anti-aliasing, only works with solid colors");
170 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
172 prop= RNA_def_property(srna, "premultiply", PROP_BOOLEAN, PROP_NONE);
173 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL);
174 RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha.");
175 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
177 /* generated image (image_generated_change_cb) */
178 prop= RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
179 RNA_def_property_enum_sdna(prop, NULL, "gen_type");
180 RNA_def_property_enum_items(prop, prop_generated_type_items);
181 RNA_def_property_ui_text(prop, "Generated Type", "Generated image type.");
182 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
184 prop= RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE);
185 RNA_def_property_int_sdna(prop, NULL, "gen_x");
186 RNA_def_property_range(prop, 1, 16384);
187 RNA_def_property_ui_text(prop, "Generated Width", "Generated image width.");
188 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
190 prop= RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE);
191 RNA_def_property_int_sdna(prop, NULL, "gen_y");
192 RNA_def_property_range(prop, 1, 16384);
193 RNA_def_property_ui_text(prop, "Generated Height", "Generated image height.");
194 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
196 /* realtime properties */
197 prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
198 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
199 RNA_def_property_enum_items(prop, prop_mapping_items);
200 RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine.");
201 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
203 prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_VECTOR);
204 RNA_def_property_float_sdna(prop, NULL, "aspx");
205 RNA_def_property_array(prop, 2);
206 RNA_def_property_range(prop, 0.1f, 5000.0f);
207 RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering.");
208 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
210 prop= RNA_def_property(srna, "animated", PROP_BOOLEAN, PROP_NONE);
211 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM);
212 RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine.");
213 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update");
215 prop= RNA_def_property(srna, "animation_start", PROP_INT, PROP_NONE);
216 RNA_def_property_int_sdna(prop, NULL, "twsta");
217 RNA_def_property_range(prop, 0, 128);
218 RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture.");
219 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update");
221 prop= RNA_def_property(srna, "animation_end", PROP_INT, PROP_NONE);
222 RNA_def_property_int_sdna(prop, NULL, "twend");
223 RNA_def_property_range(prop, 0, 128);
224 RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture.");
225 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update");
227 prop= RNA_def_property(srna, "animation_speed", PROP_INT, PROP_NONE);
228 RNA_def_property_int_sdna(prop, NULL, "animspeed");
229 RNA_def_property_range(prop, 1, 100);
230 RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second.");
231 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
233 prop= RNA_def_property(srna, "tiles", PROP_BOOLEAN, PROP_NONE);
234 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES);
235 RNA_def_property_ui_text(prop, "Tiles", "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces).");
236 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
238 prop= RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE);
239 RNA_def_property_int_sdna(prop, NULL, "xrep");
240 RNA_def_property_range(prop, 1, 16);
241 RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction.");
242 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
244 prop= RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE);
245 RNA_def_property_int_sdna(prop, NULL, "yrep");
246 RNA_def_property_range(prop, 1, 16);
247 RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction.");
248 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
250 prop= RNA_def_property(srna, "clamp_x", PROP_BOOLEAN, PROP_NONE);
251 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U);
252 RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally.");
253 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
255 prop= RNA_def_property(srna, "clamp_y", PROP_BOOLEAN, PROP_NONE);
256 RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V);
257 RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically.");
258 RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
261 void RNA_def_image(BlenderRNA *brna)
264 rna_def_imageuser(brna);