Blender  V2.59
rna_world.c
Go to the documentation of this file.
00001 /*
00002  * $Id: rna_world.c 37078 2011-06-01 16:17:38Z blendix $
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): Blender Foundation (2008).
00021  *
00022  * ***** END GPL LICENSE BLOCK *****
00023  */
00024 
00030 #include <float.h>
00031 #include <stdlib.h>
00032 
00033 #include "RNA_define.h"
00034 
00035 #include "rna_internal.h"
00036 
00037 #include "DNA_material_types.h"
00038 #include "DNA_texture_types.h"
00039 #include "DNA_world_types.h"
00040 
00041 #include "WM_types.h"
00042 
00043 #ifdef RNA_RUNTIME
00044 
00045 #include "MEM_guardedalloc.h"
00046 
00047 #include "BKE_depsgraph.h"
00048 #include "BKE_main.h"
00049 #include "BKE_texture.h"
00050 
00051 #include "WM_api.h"
00052 
00053 static PointerRNA rna_World_lighting_get(PointerRNA *ptr)
00054 {
00055         return rna_pointer_inherit_refine(ptr, &RNA_WorldLighting, ptr->id.data);
00056 }
00057 
00058 static PointerRNA rna_World_stars_get(PointerRNA *ptr)
00059 {
00060         return rna_pointer_inherit_refine(ptr, &RNA_WorldStarsSettings, ptr->id.data);
00061 }
00062 
00063 static PointerRNA rna_World_mist_get(PointerRNA *ptr)
00064 {
00065         return rna_pointer_inherit_refine(ptr, &RNA_WorldMistSettings, ptr->id.data);
00066 }
00067 
00068 static void rna_World_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00069 {
00070         World *wo= (World*)ptr->data;
00071         rna_iterator_array_begin(iter, (void*)wo->mtex, sizeof(MTex*), MAX_MTEX, 0, NULL);
00072 }
00073 
00074 static PointerRNA rna_World_active_texture_get(PointerRNA *ptr)
00075 {
00076         World *wo= (World*)ptr->data;
00077         Tex *tex;
00078 
00079         tex= give_current_world_texture(wo);
00080         return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
00081 }
00082 
00083 static void rna_World_active_texture_set(PointerRNA *ptr, PointerRNA value)
00084 {
00085         World *wo= (World*)ptr->data;
00086 
00087         set_current_world_texture(wo, value.data);
00088 }
00089 
00090 static void rna_World_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00091 {
00092         World *wo= ptr->id.data;
00093 
00094         DAG_id_tag_update(&wo->id, 0);
00095         WM_main_add_notifier(NC_WORLD, wo);
00096 }
00097 
00098 static void rna_World_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00099 {
00100         World *wo= ptr->id.data;
00101 
00102         DAG_id_tag_update(&wo->id, 0);
00103         WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, wo);
00104 }
00105 
00106 /* so camera mist limits redraw */
00107 static void rna_World_draw_mist_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00108 {
00109         World *wo= ptr->id.data;
00110 
00111         DAG_id_tag_update(&wo->id, 0);
00112         WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, wo);
00113         WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL);
00114 }
00115 
00116 static void rna_World_stars_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00117 {
00118         World *wo= ptr->id.data;
00119 
00120         DAG_id_tag_update(&wo->id, 0);
00121         WM_main_add_notifier(NC_WORLD|ND_WORLD_STARS, wo);
00122 }
00123 
00124 
00125 #else
00126 
00127 static void rna_def_world_mtex(BlenderRNA *brna)
00128 {
00129         StructRNA *srna;
00130         PropertyRNA *prop;
00131 
00132         static EnumPropertyItem texco_items[] = {
00133                 {TEXCO_VIEW, "VIEW", 0, "View", "Uses view vector for the texture coordinates"},
00134                 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates (interior mist)"},
00135                 {TEXCO_ANGMAP, "ANGMAP", 0, "AngMap", "Uses 360 degree angular coordinates, e.g. for spherical light probes"},
00136                 {TEXCO_H_SPHEREMAP, "SPHERE", 0, "Sphere", "For 360 degree panorama sky, spherical mapped, only top half"},
00137                 {TEXCO_H_TUBEMAP, "TUBE", 0, "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half"},
00138                 {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates"},
00139                 {0, NULL, 0, NULL, NULL}};
00140 
00141         srna= RNA_def_struct(brna, "WorldTextureSlot", "TextureSlot");
00142         RNA_def_struct_sdna(srna, "MTex");
00143         RNA_def_struct_ui_text(srna, "World Texture Slot", "Texture slot for textures in a World datablock");
00144 
00145         /* map to */
00146         prop= RNA_def_property(srna, "use_map_blend", PROP_BOOLEAN, PROP_NONE);
00147         RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_BLEND);
00148         RNA_def_property_ui_text(prop, "Blend", "Affect the color progression of the background");
00149         RNA_def_property_update(prop, 0, "rna_World_update");
00150 
00151         prop= RNA_def_property(srna, "use_map_horizon", PROP_BOOLEAN, PROP_NONE);
00152         RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_HORIZ);
00153         RNA_def_property_ui_text(prop, "Horizon", "Affect the color of the horizon");
00154         RNA_def_property_update(prop, 0, "rna_World_update");
00155 
00156         prop= RNA_def_property(srna, "use_map_zenith_up", PROP_BOOLEAN, PROP_NONE);
00157         RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENUP);
00158         RNA_def_property_ui_text(prop, "Zenith Up", "Affect the color of the zenith above");
00159         RNA_def_property_update(prop, 0, "rna_World_update");
00160 
00161         prop= RNA_def_property(srna, "use_map_zenith_down", PROP_BOOLEAN, PROP_NONE);
00162         RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENDOWN);
00163         RNA_def_property_ui_text(prop, "Zenith Down", "Affect the color of the zenith below");
00164         RNA_def_property_update(prop, 0, "rna_World_update");
00165 
00166         /* unused
00167         prop= RNA_def_property(srna, "map_mist", PROP_BOOLEAN, PROP_NONE);
00168         RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_MIST);
00169         RNA_def_property_ui_text(prop, "Mist", "Causes the texture to affect the intensity of the mist");*/
00170 
00171         prop= RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
00172         RNA_def_property_enum_sdna(prop, NULL, "texco");
00173         RNA_def_property_enum_items(prop, texco_items);
00174         RNA_def_property_ui_text(prop, "Texture Coordinates", "Texture coordinates used to map the texture onto the background");
00175         RNA_def_property_update(prop, 0, "rna_World_update");
00176 
00177         prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
00178         RNA_def_property_pointer_sdna(prop, NULL, "object");
00179         RNA_def_property_struct_type(prop, "Object");
00180         RNA_def_property_flag(prop, PROP_EDITABLE);
00181         RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates");
00182         RNA_def_property_update(prop, 0, "rna_World_update");
00183 
00184         prop= RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE);
00185         RNA_def_property_float_sdna(prop, NULL, "blendfac");
00186         RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00187         RNA_def_property_ui_text(prop, "Blend Factor", "Amount texture affects color progression of the background");
00188         RNA_def_property_update(prop, 0, "rna_World_update");
00189 
00190         prop= RNA_def_property(srna, "horizon_factor", PROP_FLOAT, PROP_NONE);
00191         RNA_def_property_float_sdna(prop, NULL, "colfac");
00192         RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00193         RNA_def_property_ui_text(prop, "Horizon Factor", "Amount texture affects color of the horizon");
00194         RNA_def_property_update(prop, 0, "rna_World_update");
00195 
00196         prop= RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_NONE);
00197         RNA_def_property_float_sdna(prop, NULL, "zenupfac");
00198         RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00199         RNA_def_property_ui_text(prop, "Zenith Up Factor", "Amount texture affects color of the zenith above");
00200         RNA_def_property_update(prop, 0, "rna_World_update");
00201 
00202         prop= RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_NONE);
00203         RNA_def_property_float_sdna(prop, NULL, "zendownfac");
00204         RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00205         RNA_def_property_ui_text(prop, "Zenith Down Factor", "Amount texture affects color of the zenith below");
00206         RNA_def_property_update(prop, 0, "rna_World_update");
00207 }
00208 
00209 static void rna_def_lighting(BlenderRNA *brna)
00210 {
00211         StructRNA *srna;
00212         PropertyRNA *prop;
00213 
00214         static EnumPropertyItem blend_mode_items[] = {
00215                 {WO_AOMUL, "MULTIPLY", 0, "Multiply", "Multiply direct lighting with ambient occlusion, darkening the result"},
00216                 {WO_AOADD, "ADD", 0, "Add", "Add light and shadow"},
00217                 {0, NULL, 0, NULL, NULL}};
00218 
00219         static EnumPropertyItem prop_color_items[] = {
00220                 {WO_AOPLAIN, "PLAIN", 0, "White", "Plain diffuse energy (white.)"},
00221                 {WO_AOSKYCOL, "SKY_COLOR", 0, "Sky Color", "Use horizon and zenith color for diffuse energy"},
00222                 {WO_AOSKYTEX, "SKY_TEXTURE", 0, "Sky Texture", "Does full Sky texture render for diffuse energy"},
00223                 {0, NULL, 0, NULL, NULL}};
00224 
00225         static EnumPropertyItem prop_sample_method_items[] = {
00226                 {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", "Fastest and gives the most noise"},
00227                 {WO_AOSAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", "Fast in high-contrast areas"},
00228                 {WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", "Best quality"},
00229                 {0, NULL, 0, NULL, NULL}};
00230 
00231         static EnumPropertyItem prop_gather_method_items[] = {
00232                 {WO_AOGATHER_RAYTRACE, "RAYTRACE", 0, "Raytrace", "Accurate, but slow when noise-free results are required"},
00233                 {WO_AOGATHER_APPROX, "APPROXIMATE", 0, "Approximate", "Inaccurate, but faster and without noise"},
00234                 {0, NULL, 0, NULL, NULL}};
00235 
00236         srna= RNA_def_struct(brna, "WorldLighting", NULL);
00237         RNA_def_struct_sdna(srna, "World");
00238         RNA_def_struct_nested(brna, srna, "World");
00239         RNA_def_struct_ui_text(srna, "Lighting", "Lighting for a World datablock");
00240 
00241         /* ambient occlusion */
00242         prop= RNA_def_property(srna, "use_ambient_occlusion", PROP_BOOLEAN, PROP_NONE);
00243         RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_AMB_OCC);
00244         RNA_def_property_ui_text(prop, "Use Ambient Occlusion", "Use Ambient Occlusion to add shadowing based on distance between objects");
00245         RNA_def_property_update(prop, 0, "rna_World_update");
00246 
00247         prop= RNA_def_property(srna, "ao_factor", PROP_FLOAT, PROP_FACTOR);
00248         RNA_def_property_float_sdna(prop, NULL, "aoenergy");
00249         RNA_def_property_range(prop, 0, INT_MAX);
00250         RNA_def_property_ui_range(prop, 0, 1, 0.1, 2);
00251         RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending");
00252         RNA_def_property_update(prop, 0, "rna_World_update");
00253 
00254         prop= RNA_def_property(srna, "ao_blend_type", PROP_ENUM, PROP_NONE);
00255         RNA_def_property_enum_sdna(prop, NULL, "aomix");
00256         RNA_def_property_enum_items(prop, blend_mode_items);
00257         RNA_def_property_ui_text(prop, "Blend Mode", "Defines how AO mixes with material shading");
00258         RNA_def_property_update(prop, 0, "rna_World_update");
00259 
00260         /* environment lighting */
00261         prop= RNA_def_property(srna, "use_environment_light", PROP_BOOLEAN, PROP_NONE);
00262         RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_ENV_LIGHT);
00263         RNA_def_property_ui_text(prop, "Use Environment Lighting", "Add light coming from the environment");
00264         RNA_def_property_update(prop, 0, "rna_World_update");
00265 
00266         prop= RNA_def_property(srna, "environment_energy", PROP_FLOAT, PROP_NONE);
00267         RNA_def_property_float_sdna(prop, NULL, "ao_env_energy");
00268         RNA_def_property_ui_range(prop, 0, FLT_MAX, 1, 3);
00269         RNA_def_property_ui_text(prop, "Environment Color", "Defines the strength of environment light");
00270         RNA_def_property_update(prop, 0, "rna_World_update");
00271 
00272         prop= RNA_def_property(srna, "environment_color", PROP_ENUM, PROP_NONE);
00273         RNA_def_property_enum_sdna(prop, NULL, "aocolor");
00274         RNA_def_property_enum_items(prop, prop_color_items);
00275         RNA_def_property_ui_text(prop, "Environment Color", "Defines where the color of the environment light comes from");
00276         RNA_def_property_update(prop, 0, "rna_World_update");
00277 
00278         /* indirect lighting */
00279         prop= RNA_def_property(srna, "use_indirect_light", PROP_BOOLEAN, PROP_NONE);
00280         RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_INDIRECT_LIGHT);
00281         RNA_def_property_ui_text(prop, "Use Indirect Lighting", "Add indirect light bouncing of surrounding objects");
00282         RNA_def_property_update(prop, 0, "rna_World_update");
00283 
00284         prop= RNA_def_property(srna, "indirect_factor", PROP_FLOAT, PROP_FACTOR);
00285         RNA_def_property_float_sdna(prop, NULL, "ao_indirect_energy");
00286         RNA_def_property_range(prop, 0, INT_MAX);
00287         RNA_def_property_ui_range(prop, 0, 1, 0.1, 2);
00288         RNA_def_property_ui_text(prop, "Indirect Factor", "Factor for how much surrounding objects contribute to light");
00289         RNA_def_property_update(prop, 0, "rna_World_update");
00290 
00291         prop= RNA_def_property(srna, "indirect_bounces", PROP_INT, PROP_UNSIGNED);
00292         RNA_def_property_int_sdna(prop, NULL, "ao_indirect_bounces");
00293         RNA_def_property_range(prop, 1, SHRT_MAX);
00294         RNA_def_property_ui_text(prop, "Bounces", "Number of indirect diffuse light bounces");
00295         RNA_def_property_update(prop, 0, "rna_World_update");
00296 
00297         /* gathering parameters */
00298         prop= RNA_def_property(srna, "gather_method", PROP_ENUM, PROP_NONE);
00299         RNA_def_property_enum_sdna(prop, NULL, "ao_gather_method");
00300         RNA_def_property_enum_items(prop, prop_gather_method_items);
00301         RNA_def_property_ui_text(prop, "Gather Method", "");
00302         RNA_def_property_update(prop, 0, "rna_World_update");
00303 
00304         prop= RNA_def_property(srna, "passes", PROP_INT, PROP_NONE);
00305         RNA_def_property_int_sdna(prop, NULL, "ao_approx_passes");
00306         RNA_def_property_range(prop, 0, 10);
00307         RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce overocclusion");
00308         RNA_def_property_update(prop, 0, "rna_World_update");
00309 
00310         prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
00311         RNA_def_property_float_sdna(prop, NULL, "aodist");
00312         RNA_def_property_ui_text(prop, "Distance", "Length of rays, defines how far away other faces give occlusion effect");
00313         RNA_def_property_update(prop, 0, "rna_World_update");
00314 
00315         prop= RNA_def_property(srna, "falloff_strength", PROP_FLOAT, PROP_NONE);
00316         RNA_def_property_float_sdna(prop, NULL, "aodistfac");
00317         RNA_def_property_ui_text(prop, "Strength", "Attenuation falloff strength, the higher, the less influence distant objects have");
00318         RNA_def_property_update(prop, 0, "rna_World_update");
00319 
00320         prop= RNA_def_property(srna, "bias", PROP_FLOAT, PROP_NONE);
00321         RNA_def_property_float_sdna(prop, NULL, "aobias");
00322         RNA_def_property_range(prop, 0, 0.5);
00323         RNA_def_property_ui_text(prop, "Bias", "Bias (in radians) to prevent smoothed faces from showing banding (for Raytrace Constant Jittered)");
00324         RNA_def_property_update(prop, 0, "rna_World_update");
00325 
00326         prop= RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
00327         RNA_def_property_float_sdna(prop, NULL, "ao_adapt_thresh");
00328         RNA_def_property_range(prop, 0, 1);
00329         RNA_def_property_ui_text(prop, "Threshold", "Samples below this threshold will be considered fully shadowed/unshadowed and skipped (for Raytrace Adaptive QMC)");
00330         RNA_def_property_update(prop, 0, "rna_World_update");
00331 
00332         prop= RNA_def_property(srna, "adapt_to_speed", PROP_FLOAT, PROP_NONE);
00333         RNA_def_property_float_sdna(prop, NULL, "ao_adapt_speed_fac");
00334         RNA_def_property_range(prop, 0, 1);
00335         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)");
00336         RNA_def_property_update(prop, 0, "rna_World_update");
00337 
00338         prop= RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE);
00339         RNA_def_property_float_sdna(prop, NULL, "ao_approx_error");
00340         RNA_def_property_range(prop, 0.0001, 10);
00341         RNA_def_property_ui_text(prop, "Error Tolerance", "Low values are slower and higher quality");
00342         RNA_def_property_update(prop, 0, "rna_World_update");
00343 
00344         prop= RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE);
00345         RNA_def_property_float_sdna(prop, NULL, "ao_approx_correction");
00346         RNA_def_property_range(prop, 0, 1);
00347         RNA_def_property_ui_range(prop, 0, 1, 0.1, 2);
00348         RNA_def_property_ui_text(prop, "Correction", "Ad-hoc correction for over-occlusion due to the approximation");
00349         RNA_def_property_update(prop, 0, "rna_World_update");
00350 
00351         prop= RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE);
00352         RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AODIST);
00353         RNA_def_property_ui_text(prop, "Falloff", "Distance will be used to attenuate shadows");
00354         RNA_def_property_update(prop, 0, "rna_World_update");
00355 
00356         prop= RNA_def_property(srna, "use_cache", PROP_BOOLEAN, PROP_NONE);
00357         RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AOCACHE);
00358         RNA_def_property_ui_text(prop, "Pixel Cache", "Cache AO results in pixels and interpolate over neighbouring pixels for speedup");
00359         RNA_def_property_update(prop, 0, "rna_World_update");
00360 
00361         prop= RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
00362         RNA_def_property_int_sdna(prop, NULL, "aosamp");
00363         RNA_def_property_range(prop, 1, 32);
00364         RNA_def_property_ui_text(prop, "Samples", "Amount of ray samples. Higher values give smoother results and longer rendering times");
00365         RNA_def_property_update(prop, 0, "rna_World_update");
00366 
00367         prop= RNA_def_property(srna, "sample_method", PROP_ENUM, PROP_NONE);
00368         RNA_def_property_enum_sdna(prop, NULL, "ao_samp_method");
00369         RNA_def_property_enum_items(prop, prop_sample_method_items);
00370         RNA_def_property_ui_text(prop, "Sample Method", "Method for generating shadow samples (for Raytrace)");
00371         RNA_def_property_update(prop, 0, "rna_World_update");
00372 }
00373 
00374 static void rna_def_world_mist(BlenderRNA *brna)
00375 {
00376         StructRNA *srna;
00377         PropertyRNA *prop;
00378         
00379         static EnumPropertyItem falloff_items[] = {
00380                 {0, "QUADRATIC", 0, "Quadratic", "Mist uses quadratic progression"},
00381                 {1, "LINEAR", 0, "Linear", "Mist uses linear progression"},
00382                 {2, "INVERSE_QUADRATIC", 0, "Inverse Quadratic", "Mist uses inverse quadratic progression"},
00383                 {0, NULL, 0, NULL, NULL}};
00384 
00385         srna= RNA_def_struct(brna, "WorldMistSettings", NULL);
00386         RNA_def_struct_sdna(srna, "World");
00387         RNA_def_struct_nested(brna, srna, "World");
00388         RNA_def_struct_ui_text(srna, "World Mist", "Mist settings for a World data-block");
00389 
00390         prop= RNA_def_property(srna, "use_mist", PROP_BOOLEAN, PROP_NONE);
00391         RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_MIST);
00392         RNA_def_property_ui_text(prop, "Use Mist", "Occlude objects with the environment color as they are further away");
00393         RNA_def_property_update(prop, 0, "rna_World_draw_update");
00394 
00395         prop= RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
00396         RNA_def_property_float_sdna(prop, NULL, "misi");
00397         RNA_def_property_range(prop, 0, 1);
00398         RNA_def_property_ui_text(prop, "Intensity", "Intensity of the mist effect");
00399         RNA_def_property_update(prop, 0, "rna_World_update");
00400 
00401         prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_DISTANCE);
00402         RNA_def_property_float_sdna(prop, NULL, "miststa");
00403         RNA_def_property_range(prop, 0, FLT_MAX);
00404         RNA_def_property_ui_range(prop, 0, 10000, 10, 2);
00405         RNA_def_property_ui_text(prop, "Start", "Starting distance of the mist, measured from the camera");
00406         RNA_def_property_update(prop, 0, "rna_World_draw_mist_update");
00407 
00408         prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE);
00409         RNA_def_property_float_sdna(prop, NULL, "mistdist");
00410         RNA_def_property_range(prop, 0, FLT_MAX);
00411         RNA_def_property_ui_range(prop, 0, 10000, 10, 2);
00412         RNA_def_property_ui_text(prop, "Depth", "The distance over which the mist effect fades in");
00413         RNA_def_property_update(prop, 0, "rna_World_draw_mist_update");
00414 
00415         prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE);
00416         RNA_def_property_float_sdna(prop, NULL, "misthi");
00417         RNA_def_property_range(prop, 0, 100);
00418         RNA_def_property_ui_text(prop, "Height", "Control how much mist density decreases with height");
00419         RNA_def_property_update(prop, 0, "rna_World_update");
00420         
00421         prop= RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
00422         RNA_def_property_enum_sdna(prop, NULL, "mistype");
00423         RNA_def_property_enum_items(prop, falloff_items);
00424         RNA_def_property_ui_text(prop, "Falloff", "Type of transition used to fade mist");
00425         RNA_def_property_update(prop, 0, "rna_World_update");
00426 }
00427 
00428 static void rna_def_world_stars(BlenderRNA *brna)
00429 {
00430         StructRNA *srna;
00431         PropertyRNA *prop;
00432 
00433         srna= RNA_def_struct(brna, "WorldStarsSettings", NULL);
00434         RNA_def_struct_sdna(srna, "World");
00435         RNA_def_struct_nested(brna, srna, "World");
00436         RNA_def_struct_ui_text(srna, "World Stars", "Stars setting for a World data-block");
00437 
00438         prop= RNA_def_property(srna, "use_stars", PROP_BOOLEAN, PROP_NONE);
00439         RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_STARS);
00440         RNA_def_property_ui_text(prop, "Use Stars", "Enable starfield generation");
00441         RNA_def_property_update(prop, 0, "rna_World_stars_update");
00442 
00443         prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
00444         RNA_def_property_float_sdna(prop, NULL, "starsize");
00445         RNA_def_property_range(prop, 0, 10);
00446         RNA_def_property_ui_text(prop, "Size", "Average screen dimension of stars");
00447         RNA_def_property_update(prop, 0, "rna_World_draw_update"); /* use normal update since this isnt visualized */
00448 
00449         prop= RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_DISTANCE);
00450         RNA_def_property_float_sdna(prop, NULL, "starmindist");
00451         RNA_def_property_range(prop, 0, 1000);
00452         RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance to the camera for stars");
00453         RNA_def_property_update(prop, 0, "rna_World_stars_update");
00454 
00455         prop= RNA_def_property(srna, "average_separation", PROP_FLOAT, PROP_NONE);
00456         RNA_def_property_float_sdna(prop, NULL, "stardist");
00457         RNA_def_property_range(prop, 2, 1000);
00458         RNA_def_property_ui_text(prop, "Average Separation", "Average distance between any two stars");
00459         RNA_def_property_update(prop, 0, "rna_World_stars_update");
00460 
00461         prop= RNA_def_property(srna, "color_random", PROP_FLOAT, PROP_NONE);
00462         RNA_def_property_float_sdna(prop, NULL, "starcolnoise");
00463         RNA_def_property_range(prop, 0, 1);
00464         RNA_def_property_ui_text(prop, "Color Randomization", "Randomize star colors");
00465         RNA_def_property_update(prop, 0, "rna_World_stars_update");
00466         
00467         /* unused
00468         prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
00469         RNA_def_property_float_sdna(prop, NULL, "starr");
00470         RNA_def_property_array(prop, 3);
00471         RNA_def_property_ui_text(prop, "Color", "Stars color");
00472         RNA_def_property_update(prop, 0, "rna_World_update");*/
00473 }
00474 
00475 void RNA_def_world(BlenderRNA *brna)
00476 {
00477         StructRNA *srna;
00478         PropertyRNA *prop;
00479 
00480 /*
00481         static EnumPropertyItem physics_engine_items[] = {
00482                 {WOPHY_NONE, "NONE", 0, "None", ""},
00483                 //{WOPHY_ENJI, "ENJI", 0, "Enji", ""},
00484                 //{WOPHY_SUMO, "SUMO", 0, "Sumo (Deprecated)", ""},
00485                 //{WOPHY_DYNAMO, "DYNAMO", 0, "Dynamo", ""},
00486                 //{WOPHY_ODE, "ODE", 0, "ODE", ""},
00487                 {WOPHY_BULLET, "BULLET", 0, "Bullet", ""},
00488                 {0, NULL, 0, NULL, NULL}};
00489 */
00490 
00491         srna= RNA_def_struct(brna, "World", "ID");
00492         RNA_def_struct_ui_text(srna, "World", "World datablock describing the environment and ambient lighting of a scene");
00493         RNA_def_struct_ui_icon(srna, ICON_WORLD_DATA);
00494 
00495         rna_def_animdata_common(srna);
00496         rna_def_mtex_common(brna, srna, "rna_World_mtex_begin", "rna_World_active_texture_get",
00497                 "rna_World_active_texture_set", NULL, "WorldTextureSlot", "WorldTextureSlots", "rna_World_update");
00498 
00499         /* colors */
00500         prop= RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR);
00501         RNA_def_property_float_sdna(prop, NULL, "horr");
00502         RNA_def_property_array(prop, 3);
00503         RNA_def_property_ui_text(prop, "Horizon Color", "Color at the horizon");
00504         /* RNA_def_property_update(prop, 0, "rna_World_update"); */
00505         /* render-only uses this */
00506         RNA_def_property_update(prop, NC_WORLD|ND_WORLD_DRAW, "rna_World_update");
00507 
00508         
00509         prop= RNA_def_property(srna, "zenith_color", PROP_FLOAT, PROP_COLOR);
00510         RNA_def_property_float_sdna(prop, NULL, "zenr");
00511         RNA_def_property_array(prop, 3);
00512         RNA_def_property_ui_text(prop, "Zenith Color", "Color at the zenith");
00513         RNA_def_property_update(prop, 0, "rna_World_update");
00514 
00515         prop= RNA_def_property(srna, "ambient_color", PROP_FLOAT, PROP_COLOR);
00516         RNA_def_property_float_sdna(prop, NULL, "ambr");
00517         RNA_def_property_array(prop, 3);
00518         RNA_def_property_ui_text(prop, "Ambient Color", "Ambient color of the world");
00519         RNA_def_property_update(prop, 0, "rna_World_update");
00520 
00521         /* exp, range */
00522         prop= RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_NONE);
00523         RNA_def_property_float_sdna(prop, NULL, "exp");
00524         RNA_def_property_range(prop, 0.0, 1.0);
00525         RNA_def_property_ui_text(prop, "Exposure", "Amount of exponential color correction for light");
00526         RNA_def_property_update(prop, 0, "rna_World_update");
00527 
00528         prop= RNA_def_property(srna, "color_range", PROP_FLOAT, PROP_NONE);
00529         RNA_def_property_float_sdna(prop, NULL, "range");
00530         RNA_def_property_range(prop, 0.2, 5.0);
00531         RNA_def_property_ui_text(prop, "Range", "The color range that will be mapped to 0-1");
00532         RNA_def_property_update(prop, 0, "rna_World_update");
00533 
00534         /* sky type */
00535         prop= RNA_def_property(srna, "use_sky_blend", PROP_BOOLEAN, PROP_NONE);
00536         RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYBLEND);
00537         RNA_def_property_ui_text(prop, "Blend Sky", "Render background with natural progression from horizon to zenith");
00538         RNA_def_property_update(prop, 0, "rna_World_update");
00539 
00540         prop= RNA_def_property(srna, "use_sky_paper", PROP_BOOLEAN, PROP_NONE);
00541         RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER);
00542         RNA_def_property_ui_text(prop, "Paper Sky", "Flatten blend or texture coordinates");
00543         RNA_def_property_update(prop, 0, "rna_World_update");
00544 
00545         prop= RNA_def_property(srna, "use_sky_real", PROP_BOOLEAN, PROP_NONE);
00546         RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYREAL);
00547         RNA_def_property_ui_text(prop, "Real Sky", "Render background with a real horizon, relative to the camera angle");
00548         RNA_def_property_update(prop, 0, "rna_World_update");
00549 
00550         /* nested structs */
00551         prop= RNA_def_property(srna, "light_settings", PROP_POINTER, PROP_NONE);
00552         RNA_def_property_flag(prop, PROP_NEVER_NULL);
00553         RNA_def_property_struct_type(prop, "WorldLighting");
00554         RNA_def_property_pointer_funcs(prop, "rna_World_lighting_get", NULL, NULL, NULL);
00555         RNA_def_property_ui_text(prop, "Lighting", "World lighting settings");
00556 
00557         prop= RNA_def_property(srna, "mist_settings", PROP_POINTER, PROP_NONE);
00558         RNA_def_property_flag(prop, PROP_NEVER_NULL);
00559         RNA_def_property_struct_type(prop, "WorldMistSettings");
00560         RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL, NULL, NULL);
00561         RNA_def_property_ui_text(prop, "Mist", "World mist settings");
00562 
00563         prop= RNA_def_property(srna, "star_settings", PROP_POINTER, PROP_NONE);
00564         RNA_def_property_flag(prop, PROP_NEVER_NULL);
00565         RNA_def_property_struct_type(prop, "WorldStarsSettings");
00566         RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL, NULL, NULL);
00567         RNA_def_property_ui_text(prop, "Stars", "World stars settings");
00568 
00569         rna_def_lighting(brna);
00570         rna_def_world_mist(brna);
00571         rna_def_world_stars(brna);
00572         rna_def_world_mtex(brna);
00573 }
00574 
00575 #endif