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): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
28 #include "RNA_define.h"
29 #include "RNA_types.h"
31 #include "rna_internal.h"
33 #include "DNA_material_types.h"
34 #include "DNA_texture_types.h"
35 #include "DNA_world_types.h"
39 static PointerRNA rna_World_ambient_occlusion_get(PointerRNA *ptr)
41 return rna_pointer_inherit_refine(ptr, &RNA_WorldAmbientOcclusion, ptr->id.data);
44 static PointerRNA rna_World_stars_get(PointerRNA *ptr)
46 return rna_pointer_inherit_refine(ptr, &RNA_WorldStarsSettings, ptr->id.data);
49 static PointerRNA rna_World_mist_get(PointerRNA *ptr)
51 return rna_pointer_inherit_refine(ptr, &RNA_WorldMistSettings, ptr->id.data);
54 static void rna_World_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
56 World *wo= (World*)ptr->data;
57 rna_iterator_array_begin(iter, (void*)wo->mtex, sizeof(MTex*), MAX_MTEX, NULL);
60 static PointerRNA rna_World_active_texture_get(PointerRNA *ptr)
62 World *wo= (World*)ptr->data;
64 return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, wo->mtex[(int)wo->texact]);
69 static void rna_def_world_mtex(BlenderRNA *brna)
74 static EnumPropertyItem texco_items[] = {
75 {TEXCO_VIEW, "VIEW", "View", "Uses view vector for the texture coordinates."},
76 {TEXCO_GLOB, "GLOBAL", "Global", "Uses global coordinates for the texture coordinates (interior mist)."},
77 {TEXCO_ANGMAP, "ANGMAP", "AngMap", "Uses 360 degree angular coordinates, e.g. for spherical light probes."},
78 {TEXCO_H_SPHEREMAP, "SPHERE", "Sphere", "For 360 degree panorama sky, spherical mapped, only top half."},
79 {TEXCO_H_TUBEMAP, "TUBE", "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half."},
80 {TEXCO_OBJECT, "OBJECT", "Object", "Uses linked object's coordinates for texture coordinates."},
81 {0, NULL, NULL, NULL}};
83 srna= RNA_def_struct(brna, "WorldTextureSlot", "TextureSlot");
84 RNA_def_struct_sdna(srna, "MTex");
85 RNA_def_struct_ui_text(srna, "World Texture Slot", "Texture slot for textures in a World datablock.");
88 prop= RNA_def_property(srna, "map_to_blend", PROP_BOOLEAN, PROP_NONE);
89 RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_BLEND);
90 RNA_def_property_ui_text(prop, "Map To Blend", "Causes the texture to affect the color progression of the background.");
92 prop= RNA_def_property(srna, "map_to_horizon", PROP_BOOLEAN, PROP_NONE);
93 RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_HORIZ);
94 RNA_def_property_ui_text(prop, "Map To Horizon", "Causes the texture to affect the color of the horizon.");
96 prop= RNA_def_property(srna, "map_to_zenith_up", PROP_BOOLEAN, PROP_NONE);
97 RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENUP);
98 RNA_def_property_ui_text(prop, "Map To Zenith Up", "Causes the texture to affect the color of the zenith above.");
100 prop= RNA_def_property(srna, "map_to_zenith_down", PROP_BOOLEAN, PROP_NONE);
101 RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENDOWN);
102 RNA_def_property_ui_text(prop, "Map To Zenith Down", "Causes the texture to affect the color of the zenith below.");
105 prop= RNA_def_property(srna, "map_to_mist", PROP_BOOLEAN, PROP_NONE);
106 RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_MIST);
107 RNA_def_property_ui_text(prop, "Map To Mist", "Causes the texture to affect the intensity of the mist.");*/
109 prop= RNA_def_property(srna, "texture_coordinates", PROP_ENUM, PROP_NONE);
110 RNA_def_property_enum_sdna(prop, NULL, "texco");
111 RNA_def_property_enum_items(prop, texco_items);
112 RNA_def_property_ui_text(prop, "Texture Coordinates", "Textures coordinates used to map the texture with.");
114 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
115 RNA_def_property_pointer_sdna(prop, NULL, "object");
116 RNA_def_property_struct_type(prop, "Object");
117 RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates.");
120 static void rna_def_ambient_occlusion(BlenderRNA *brna)
125 static EnumPropertyItem blend_mode_items[] = {
126 {WO_AOADD, "ADD", "Add", "Add light and shadow."},
127 {WO_AOSUB, "SUBTRACT", "Subtract", "Subtract light and shadow (needs a normal light to make anything visible.)"},
128 {WO_AOADDSUB, "BOTH", "Both", "Both lighten and darken."},
129 {0, NULL, NULL, NULL}};
131 static EnumPropertyItem prop_color_items[] = {
132 {WO_AOPLAIN, "PLAIN", "White", "Plain diffuse energy (white.)"},
133 {WO_AOSKYCOL, "SKY_COLOR", "Sky Color", "Use horizon and zenith color for diffuse energy."},
134 {WO_AOSKYTEX, "SKY_TEXTURE", "Sky Texture", "Does full Sky texture render for diffuse energy."},
135 {0, NULL, NULL, NULL}};
137 static EnumPropertyItem prop_sample_method_items[] = {
138 {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", "Constant Jittered", ""},
139 {WO_AOSAMP_HALTON, "ADAPTIVE_QMC", "Adaptive QMC", "Fast in high-contrast areas."},
140 {WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", "Constant QMC", "Best quality."},
141 {0, NULL, NULL, NULL}};
143 static EnumPropertyItem prop_gather_method_items[] = {
144 {WO_AOGATHER_RAYTRACE, "RAYTRACE", "Raytrace", "Accurate, but slow when noise-free results are required."},
145 {WO_AOGATHER_APPROX, "APPROXIMATE", "Approximate", "Inaccurate, but faster and without noise."},
146 {0, NULL, NULL, NULL}};
148 srna= RNA_def_struct(brna, "WorldAmbientOcclusion", NULL);
149 RNA_def_struct_sdna(srna, "World");
150 RNA_def_struct_nested(brna, srna, "World");
151 RNA_def_struct_ui_text(srna, "Ambient Occlusion", "Ambient occlusion settings for a World datablock.");
153 prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
154 RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_AMB_OCC);
155 RNA_def_property_ui_text(prop, "Enabled", "");
157 prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
158 RNA_def_property_float_sdna(prop, NULL, "aodist");
159 RNA_def_property_range(prop, 0.001, 5000);
160 RNA_def_property_ui_text(prop, "Distance", "Length of rays, defines how far away other faces give occlusion effect.");
162 prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
163 RNA_def_property_float_sdna(prop, NULL, "aodistfac");
164 RNA_def_property_range(prop, 0.00001, 10);
165 RNA_def_property_ui_text(prop, "Strength", "Distance attenuation factor, the higher, the 'shorter' the shadows.");
167 prop= RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
168 RNA_def_property_float_sdna(prop, NULL, "aoenergy");
169 RNA_def_property_range(prop, 0.01, 3);
170 RNA_def_property_ui_text(prop, "Energy", "Global energy scale for ambient occlusion.");
172 prop= RNA_def_property(srna, "bias", PROP_FLOAT, PROP_NONE);
173 RNA_def_property_float_sdna(prop, NULL, "aobias");
174 RNA_def_property_range(prop, 0, 0.5);
175 RNA_def_property_ui_text(prop, "Bias", "Bias (in radians) to prevent smoothed faces from showing banding (for Raytrace Constant Jittered).");
177 prop= RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
178 RNA_def_property_float_sdna(prop, NULL, "ao_adapt_thresh");
179 RNA_def_property_range(prop, 0, 1);
180 RNA_def_property_ui_text(prop, "Threshold", "Samples below this threshold will be considered fully shadowed/unshadowed and skipped (for Raytrace Adaptive QMC).");
182 prop= RNA_def_property(srna, "adapt_to_speed", PROP_FLOAT, PROP_NONE);
183 RNA_def_property_float_sdna(prop, NULL, "ao_adapt_speed_fac");
184 RNA_def_property_range(prop, 0, 1);
185 RNA_def_property_ui_text(prop, "Adapt To Speed", "Use the speed vector pass to reduce AO samples in fast moving pixels. Higher values result in more aggressive sample reduction. Requires Vec pass enabled (for Raytrace Adaptive QMC).");
187 prop= RNA_def_property(srna, "error_tolerance", PROP_FLOAT, PROP_NONE);
188 RNA_def_property_float_sdna(prop, NULL, "ao_approx_error");
189 RNA_def_property_range(prop, 0.0001, 1);
190 RNA_def_property_ui_text(prop, "Error Tolerance", "Low values are slower and higher quality (for Approximate).");
192 prop= RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE);
193 RNA_def_property_float_sdna(prop, NULL, "ao_approx_correction");
194 RNA_def_property_range(prop, 0, 1);
195 RNA_def_property_ui_text(prop, "Correction", "Ad-hoc correction for over-occlusion due to the approximation (for Approximate).");
197 prop= RNA_def_property(srna, "falloff", PROP_BOOLEAN, PROP_NONE);
198 RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AODIST);
199 RNA_def_property_ui_text(prop, "Falloff", "");
201 prop= RNA_def_property(srna, "pixel_cache", PROP_BOOLEAN, PROP_NONE);
202 RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AOCACHE);
203 RNA_def_property_ui_text(prop, "Pixel Cache", "Cache AO results in pixels and interpolate over neighbouring pixels for speedup (for Approximate).");
205 prop= RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
206 RNA_def_property_int_sdna(prop, NULL, "aosamp");
207 RNA_def_property_range(prop, 0, 1);
208 RNA_def_property_ui_text(prop, "Samples", "");
210 prop= RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE);
211 RNA_def_property_enum_sdna(prop, NULL, "aomix");
212 RNA_def_property_enum_items(prop, blend_mode_items);
213 RNA_def_property_ui_text(prop, "Blend Mode", "Blending mode for how AO mixes with material shading.");
215 prop= RNA_def_property(srna, "color", PROP_ENUM, PROP_NONE);
216 RNA_def_property_enum_sdna(prop, NULL, "aocolor");
217 RNA_def_property_enum_items(prop, prop_color_items);
218 RNA_def_property_ui_text(prop, "Color", "");
220 prop= RNA_def_property(srna, "sample_method", PROP_ENUM, PROP_NONE);
221 RNA_def_property_enum_sdna(prop, NULL, "ao_samp_method");
222 RNA_def_property_enum_items(prop, prop_sample_method_items);
223 RNA_def_property_ui_text(prop, "Sample Method", "Method for generating shadow samples (for Raytrace).");
225 prop= RNA_def_property(srna, "gather_method", PROP_ENUM, PROP_NONE);
226 RNA_def_property_enum_sdna(prop, NULL, "ao_gather_method");
227 RNA_def_property_enum_items(prop, prop_gather_method_items);
228 RNA_def_property_ui_text(prop, "Gather Method", "");
230 prop= RNA_def_property(srna, "passes", PROP_INT, PROP_NONE);
231 RNA_def_property_int_sdna(prop, NULL, "ao_approx_passes");
232 RNA_def_property_range(prop, 0, 10);
233 RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce overocclusion (for Approximate).");
236 static void rna_def_world_mist(BlenderRNA *brna)
241 srna= RNA_def_struct(brna, "WorldMistSettings", NULL);
242 RNA_def_struct_sdna(srna, "World");
243 RNA_def_struct_nested(brna, srna, "World");
244 RNA_def_struct_ui_text(srna, "World Mist", "Mist settings for a World datatblock.");
246 prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
247 RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_MIST);
248 RNA_def_property_ui_text(prop, "Enabled", "Enable mist, occluding objects with the environment color as they are further away.");
250 prop= RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
251 RNA_def_property_float_sdna(prop, NULL, "misi");
252 RNA_def_property_range(prop, 0, 1);
253 RNA_def_property_ui_text(prop, "Intensity", "Intensity of the mist.");
255 prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE);
256 RNA_def_property_float_sdna(prop, NULL, "miststa");
257 RNA_def_property_range(prop, 0, FLT_MAX);
258 RNA_def_property_ui_range(prop, 0, 10000, 10, 2);
259 RNA_def_property_ui_text(prop, "Start", "Starting distance of the mist.");
261 prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_NONE);
262 RNA_def_property_float_sdna(prop, NULL, "mistdist");
263 RNA_def_property_range(prop, 0, FLT_MAX);
264 RNA_def_property_ui_range(prop, 0, 10000, 10, 2);
265 RNA_def_property_ui_text(prop, "Depth", "Depth of the mist.");
267 prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
268 RNA_def_property_float_sdna(prop, NULL, "misthi");
269 RNA_def_property_range(prop, 0, 100);
270 RNA_def_property_ui_text(prop, "Height", "Factor for a less dense mist with increasing height.");
273 static void rna_def_world_stars(BlenderRNA *brna)
278 static EnumPropertyItem falloff_items[] = {
279 {0, "QUADRATIC", "Quadratic", "Mist uses quadratic progression."},
280 {1, "LINEAR", "Linear", "Mist uses linear progression."},
281 {2, "INVERSE_QUADRATIC", "Inverse Quadratic", "Mist uses inverse quadratic progression."},
282 {0, NULL, NULL, NULL}};
284 srna= RNA_def_struct(brna, "WorldStarsSettings", NULL);
285 RNA_def_struct_sdna(srna, "World");
286 RNA_def_struct_nested(brna, srna, "World");
287 RNA_def_struct_ui_text(srna, "World Stars", "Stars setting for a World datatblock.");
289 prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
290 RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_STARS);
291 RNA_def_property_ui_text(prop, "Enabled", "Enable starfield generation.");
293 prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
294 RNA_def_property_float_sdna(prop, NULL, "starsize");
295 RNA_def_property_range(prop, 0, 10);
296 RNA_def_property_ui_text(prop, "Size", "Average screen dimension of stars.");
298 prop= RNA_def_property(srna, "min_distance", PROP_FLOAT, PROP_NONE);
299 RNA_def_property_float_sdna(prop, NULL, "starmindist");
300 RNA_def_property_range(prop, 0, 1000);
301 RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance to the camera for stars.");
303 prop= RNA_def_property(srna, "average_separation", PROP_FLOAT, PROP_NONE);
304 RNA_def_property_float_sdna(prop, NULL, "stardist");
305 RNA_def_property_range(prop, 2, 1000);
306 RNA_def_property_ui_text(prop, "Average Separation", "Average distance between any two stars.");
308 prop= RNA_def_property(srna, "color_randomization", PROP_FLOAT, PROP_NONE);
309 RNA_def_property_float_sdna(prop, NULL, "starcolnoise");
310 RNA_def_property_range(prop, 0, 1);
311 RNA_def_property_ui_text(prop, "Color Randomization", "Randomizes star color.");
313 prop= RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
314 RNA_def_property_enum_sdna(prop, NULL, "mistype");
315 RNA_def_property_enum_items(prop, falloff_items);
316 RNA_def_property_ui_text(prop, "Falloff", "Falloff method for mist.");
319 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
320 RNA_def_property_float_sdna(prop, NULL, "starr");
321 RNA_def_property_array(prop, 3);
322 RNA_def_property_ui_text(prop, "Color", "Stars color.");*/
325 void RNA_def_world(BlenderRNA *brna)
330 static EnumPropertyItem physics_engine_items[] = {
331 {WOPHY_NONE, "NONE", "None", ""},
332 //{WOPHY_ENJI, "ENJI", "Enji", ""},
333 {WOPHY_SUMO, "SUMO", "Sumo (Deprecated)", ""},
334 //{WOPHY_DYNAMO, "DYNAMO", "Dynamo", ""},
335 //{WOPHY_ODE, "ODE", "ODE", ""},
336 {WOPHY_BULLET, "BULLET", "Bullet", ""},
337 {0, NULL, NULL, NULL}};
339 srna= RNA_def_struct(brna, "World", "ID");
340 RNA_def_struct_ui_text(srna, "World", "World datablock describing the environment and ambient lighting of a scene.");
342 rna_def_animdata_common(srna);
343 rna_def_mtex_common(srna, "rna_World_mtex_begin", "rna_World_active_texture_get", "WorldTextureSlot");
346 prop= RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR);
347 RNA_def_property_float_sdna(prop, NULL, "horr");
348 RNA_def_property_array(prop, 3);
349 RNA_def_property_ui_text(prop, "Horizon Color", "Color at the horizon.");
351 prop= RNA_def_property(srna, "zenith_color", PROP_FLOAT, PROP_COLOR);
352 RNA_def_property_float_sdna(prop, NULL, "zenr");
353 RNA_def_property_array(prop, 3);
354 RNA_def_property_ui_text(prop, "Zenith Color", "Color at the zenith.");
356 prop= RNA_def_property(srna, "ambient_color", PROP_FLOAT, PROP_COLOR);
357 RNA_def_property_float_sdna(prop, NULL, "ambr");
358 RNA_def_property_array(prop, 3);
359 RNA_def_property_ui_text(prop, "Ambient Color", "");
362 prop= RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_NONE);
363 RNA_def_property_float_sdna(prop, NULL, "exp");
364 RNA_def_property_range(prop, 0.0, 1.0);
365 RNA_def_property_ui_text(prop, "Exposure", "Amount of exponential color correction for light.");
367 prop= RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE);
368 RNA_def_property_float_sdna(prop, NULL, "range");
369 RNA_def_property_range(prop, 0.2, 5.0);
370 RNA_def_property_ui_text(prop, "Range", "The color amount that will be mapped on color 1.0.");
373 prop= RNA_def_property(srna, "blend_sky", PROP_BOOLEAN, PROP_NONE);
374 RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYBLEND);
375 RNA_def_property_ui_text(prop, "Blend Sky", "Renders background with natural progression from horizon to zenith.");
377 prop= RNA_def_property(srna, "paper_sky", PROP_BOOLEAN, PROP_NONE);
378 RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER);
379 RNA_def_property_ui_text(prop, "Paper Sky", "Flattens blend or texture coordinates.");
381 prop= RNA_def_property(srna, "real_sky", PROP_BOOLEAN, PROP_NONE);
382 RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYREAL);
383 RNA_def_property_ui_text(prop, "Real Sky", "Renders background with a real horizon.");
386 prop= RNA_def_property(srna, "physics_engine", PROP_ENUM, PROP_NONE);
387 RNA_def_property_enum_sdna(prop, NULL, "physicsEngine");
388 RNA_def_property_enum_items(prop, physics_engine_items);
389 RNA_def_property_ui_text(prop, "Physics Engine", "Physics engine used for physics simulation in the game engine.");
391 prop= RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_NONE);
392 RNA_def_property_float_sdna(prop, NULL, "gravity");
393 RNA_def_property_range(prop, 0.0, 20.0);
394 RNA_def_property_ui_text(prop, "Physics Gravity", "Gravitational constant used for physics simulation in the game engine.");
397 prop= RNA_def_property(srna, "ambient_occlusion", PROP_POINTER, PROP_NEVER_NULL);
398 RNA_def_property_struct_type(prop, "WorldAmbientOcclusion");
399 RNA_def_property_pointer_funcs(prop, "rna_World_ambient_occlusion_get", NULL);
400 RNA_def_property_ui_text(prop, "Ambient Occlusion", "World ambient occlusion settings.");
402 prop= RNA_def_property(srna, "mist", PROP_POINTER, PROP_NEVER_NULL);
403 RNA_def_property_struct_type(prop, "WorldMistSettings");
404 RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL);
405 RNA_def_property_ui_text(prop, "Mist", "World mist settings.");
407 prop= RNA_def_property(srna, "stars", PROP_POINTER, PROP_NEVER_NULL);
408 RNA_def_property_struct_type(prop, "WorldStarsSettings");
409 RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL);
410 RNA_def_property_ui_text(prop, "Stars", "World stars settings.");
412 prop= RNA_def_property(srna, "script_link", PROP_POINTER, PROP_NEVER_NULL);
413 RNA_def_property_pointer_sdna(prop, NULL, "scriptlink");
414 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
415 RNA_def_property_ui_text(prop, "Script Link", "Scripts linked to this object.");
417 rna_def_ambient_occlusion(brna);
418 rna_def_world_mist(brna);
419 rna_def_world_stars(brna);
420 rna_def_world_mtex(brna);