Blender V2.61 - r43446

rna_world.c

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