|
Blender
V2.59
|
00001 /* 00002 * $Id: rna_lamp.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 <stdlib.h> 00031 00032 #include "RNA_define.h" 00033 #include "RNA_enum_types.h" 00034 00035 #include "rna_internal.h" 00036 00037 #include "DNA_lamp_types.h" 00038 #include "DNA_material_types.h" 00039 #include "DNA_texture_types.h" 00040 00041 #include "BLI_math_base.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 #include "WM_types.h" 00053 00054 static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value) 00055 { 00056 Lamp *la= (Lamp*)ptr->data; 00057 00058 CLAMP(value, 512, 10240); 00059 la->bufsize= value; 00060 la->bufsize &= (~15); /* round to multiple of 16 */ 00061 } 00062 00063 static PointerRNA rna_Lamp_sky_settings_get(PointerRNA *ptr) 00064 { 00065 return rna_pointer_inherit_refine(ptr, &RNA_LampSkySettings, ptr->id.data); 00066 } 00067 00068 static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00069 { 00070 Lamp *la= (Lamp*)ptr->data; 00071 rna_iterator_array_begin(iter, (void*)la->mtex, sizeof(MTex*), MAX_MTEX, 0, NULL); 00072 } 00073 00074 static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr) 00075 { 00076 Lamp *la= (Lamp*)ptr->data; 00077 Tex *tex; 00078 00079 tex= give_current_lamp_texture(la); 00080 return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex); 00081 } 00082 00083 static void rna_Lamp_active_texture_set(PointerRNA *ptr, PointerRNA value) 00084 { 00085 Lamp *la= (Lamp*)ptr->data; 00086 00087 set_current_lamp_texture(la, value.data); 00088 } 00089 00090 static StructRNA* rna_Lamp_refine(struct PointerRNA *ptr) 00091 { 00092 Lamp *la= (Lamp*)ptr->data; 00093 00094 switch(la->type) { 00095 case LA_LOCAL: 00096 return &RNA_PointLamp; 00097 case LA_SUN: 00098 return &RNA_SunLamp; 00099 case LA_SPOT: 00100 return &RNA_SpotLamp; 00101 case LA_HEMI: 00102 return &RNA_HemiLamp; 00103 case LA_AREA: 00104 return &RNA_AreaLamp; 00105 default: 00106 return &RNA_Lamp; 00107 } 00108 } 00109 00110 static void rna_Lamp_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) 00111 { 00112 Lamp *la= ptr->id.data; 00113 00114 DAG_id_tag_update(&la->id, 0); 00115 if(scene->gm.matmode == GAME_MAT_GLSL) 00116 WM_main_add_notifier(NC_LAMP|ND_LIGHTING_DRAW, la); 00117 else 00118 WM_main_add_notifier(NC_LAMP|ND_LIGHTING, la); 00119 } 00120 00121 static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00122 { 00123 Lamp *la= ptr->id.data; 00124 00125 DAG_id_tag_update(&la->id, 0); 00126 WM_main_add_notifier(NC_LAMP|ND_LIGHTING_DRAW, la); 00127 } 00128 00129 static void rna_Lamp_sky_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00130 { 00131 Lamp *la= ptr->id.data; 00132 00133 DAG_id_tag_update(&la->id, 0); 00134 WM_main_add_notifier(NC_LAMP|ND_SKY, la); 00135 } 00136 00137 /* only for rad/deg conversion! can remove later */ 00138 static float rna_Lamp_spot_size_get(PointerRNA *ptr) 00139 { 00140 Lamp *la= ptr->id.data; 00141 return DEG2RADF(la->spotsize); 00142 } 00143 00144 static void rna_Lamp_spot_size_set(PointerRNA *ptr, float value) 00145 { 00146 Lamp *la= ptr->id.data; 00147 la->spotsize= RAD2DEGF(value); 00148 } 00149 00150 00151 #else 00152 00153 EnumPropertyItem lamp_type_items[] = { 00154 {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"}, 00155 {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"}, 00156 {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"}, 00157 {LA_HEMI, "HEMI", 0, "Hemi", "180 degree constant light source"}, 00158 {LA_AREA, "AREA", 0, "Area", "Directional area light source"}, 00159 {0, NULL, 0, NULL, NULL}}; 00160 00161 static void rna_def_lamp_mtex(BlenderRNA *brna) 00162 { 00163 StructRNA *srna; 00164 PropertyRNA *prop; 00165 00166 static EnumPropertyItem prop_texture_coordinates_items[] = { 00167 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates"}, 00168 {TEXCO_VIEW, "VIEW", 0, "View", "Uses view coordinates for the texture coordinates"}, 00169 {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates"}, 00170 {0, NULL, 0, NULL, NULL}}; 00171 00172 srna= RNA_def_struct(brna, "LampTextureSlot", "TextureSlot"); 00173 RNA_def_struct_sdna(srna, "MTex"); 00174 RNA_def_struct_ui_text(srna, "Lamp Texture Slot", "Texture slot for textures in a Lamp datablock"); 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, prop_texture_coordinates_items); 00179 RNA_def_property_ui_text(prop, "Texture Coordinates", ""); 00180 00181 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); 00182 RNA_def_property_pointer_sdna(prop, NULL, "object"); 00183 RNA_def_property_struct_type(prop, "Object"); 00184 RNA_def_property_flag(prop, PROP_EDITABLE); 00185 RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates"); 00186 00187 prop= RNA_def_property(srna, "use_map_color", PROP_BOOLEAN, PROP_NONE); 00188 RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_COL); 00189 RNA_def_property_ui_text(prop, "Color", "Lets the texture affect the basic color of the lamp"); 00190 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00191 00192 prop= RNA_def_property(srna, "use_map_shadow", PROP_BOOLEAN, PROP_NONE); 00193 RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_SHAD); 00194 RNA_def_property_ui_text(prop, "Shadow", "Lets the texture affect the shadow color of the lamp"); 00195 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00196 00197 prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE); 00198 RNA_def_property_float_sdna(prop, NULL, "colfac"); 00199 RNA_def_property_ui_range(prop, 0, 1, 10, 3); 00200 RNA_def_property_ui_text(prop, "Color Factor", "Amount texture affects color values"); 00201 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00202 00203 prop= RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_NONE); 00204 RNA_def_property_float_sdna(prop, NULL, "shadowfac"); 00205 RNA_def_property_ui_range(prop, 0, 1, 10, 3); 00206 RNA_def_property_ui_text(prop, "Shadow Factor", "Amount texture affects shadow"); 00207 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00208 } 00209 00210 static void rna_def_lamp_sky_settings(BlenderRNA *brna) 00211 { 00212 StructRNA *srna; 00213 PropertyRNA *prop; 00214 00215 static EnumPropertyItem prop_skycolorspace_items[] = { 00216 {0, "SMPTE", 0, "SMPTE", ""}, 00217 {1, "REC709", 0, "REC709", ""}, 00218 {2, "CIE", 0, "CIE", ""}, 00219 {0, NULL, 0, NULL, NULL}}; 00220 00221 srna= RNA_def_struct(brna, "LampSkySettings", NULL); 00222 RNA_def_struct_sdna(srna, "Lamp"); 00223 RNA_def_struct_nested(brna, srna, "SunLamp"); 00224 RNA_def_struct_ui_text(srna, "Lamp Sky Settings", "Sky related settings for a sun lamp"); 00225 00226 prop= RNA_def_property(srna, "sky_color_space", PROP_ENUM, PROP_NONE); 00227 RNA_def_property_enum_sdna(prop, NULL, "sky_colorspace"); 00228 RNA_def_property_enum_items(prop, prop_skycolorspace_items); 00229 RNA_def_property_ui_text(prop, "Sky Color Space", "Color space to use for internal XYZ->RGB color conversion"); 00230 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00231 00232 prop= RNA_def_property(srna, "sky_blend_type", PROP_ENUM, PROP_NONE); 00233 RNA_def_property_enum_sdna(prop, NULL, "skyblendtype"); 00234 RNA_def_property_enum_items(prop, ramp_blend_items); 00235 RNA_def_property_ui_text(prop, "Sky Blend Mode", "Blend mode for combining sun sky with world sky"); 00236 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00237 00238 /* Number values */ 00239 00240 prop= RNA_def_property(srna, "horizon_brightness", PROP_FLOAT, PROP_NONE); 00241 RNA_def_property_range(prop, 0.0f, 20.0f); 00242 RNA_def_property_ui_text(prop, "Horizon Brightness", "Horizon brightness"); 00243 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00244 00245 prop= RNA_def_property(srna, "spread", PROP_FLOAT, PROP_NONE); 00246 RNA_def_property_range(prop, 0.0f, 10.0f); 00247 RNA_def_property_ui_text(prop, "Horizon Spread", "Horizon Spread"); 00248 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00249 00250 prop= RNA_def_property(srna, "sun_brightness", PROP_FLOAT, PROP_NONE); 00251 RNA_def_property_range(prop, 0.0f, 10.0f); 00252 RNA_def_property_ui_text(prop, "Sun Brightness", "Sun brightness"); 00253 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00254 00255 prop= RNA_def_property(srna, "sun_size", PROP_FLOAT, PROP_NONE); 00256 RNA_def_property_range(prop, 0.0f, 10.0f); 00257 RNA_def_property_ui_text(prop, "Sun Size", "Sun size"); 00258 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00259 00260 prop= RNA_def_property(srna, "backscattered_light", PROP_FLOAT, PROP_NONE); 00261 RNA_def_property_range(prop, -1.0f, 1.0f); 00262 RNA_def_property_ui_text(prop, "Backscattered Light", "Backscattered light"); 00263 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00264 00265 prop= RNA_def_property(srna, "sun_intensity", PROP_FLOAT, PROP_NONE); 00266 RNA_def_property_range(prop, 0.0f, 10.0f); 00267 RNA_def_property_ui_text(prop, "Sun Intensity", "Sun intensity"); 00268 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00269 00270 prop= RNA_def_property(srna, "atmosphere_turbidity", PROP_FLOAT, PROP_NONE); 00271 RNA_def_property_float_sdna(prop, NULL, "atm_turbidity"); 00272 RNA_def_property_range(prop, 1.0f, 30.0f); 00273 RNA_def_property_ui_range(prop, 2.0f, 10.0f, 1, 2); 00274 RNA_def_property_ui_text(prop, "Atmosphere Turbidity", "Sky turbidity"); 00275 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00276 00277 prop= RNA_def_property(srna, "atmosphere_inscattering", PROP_FLOAT, PROP_NONE); 00278 RNA_def_property_float_sdna(prop, NULL, "atm_inscattering_factor"); 00279 RNA_def_property_range(prop, 0.0f, 1.0f); 00280 RNA_def_property_ui_text(prop, "Atmosphere Inscatter", "Scatter contribution factor"); 00281 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00282 00283 prop= RNA_def_property(srna, "atmosphere_extinction", PROP_FLOAT, PROP_NONE); 00284 RNA_def_property_float_sdna(prop, NULL, "atm_extinction_factor"); 00285 RNA_def_property_range(prop, 0.0f, 1.0f); 00286 RNA_def_property_ui_text(prop, "Atmosphere Extinction", "Extinction scattering contribution factor"); 00287 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00288 00289 prop= RNA_def_property(srna, "atmosphere_distance_factor", PROP_FLOAT, PROP_NONE); 00290 RNA_def_property_float_sdna(prop, NULL, "atm_distance_factor"); 00291 RNA_def_property_range(prop, 0.0f, 500.0f); 00292 RNA_def_property_ui_text(prop, "Atmosphere Distance Factor", "Multiplier to convert blender units to physical distance"); 00293 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00294 00295 prop= RNA_def_property(srna, "sky_blend", PROP_FLOAT, PROP_NONE); 00296 RNA_def_property_float_sdna(prop, NULL, "skyblendfac"); 00297 RNA_def_property_range(prop, 0.0f, 2.0f); 00298 RNA_def_property_ui_text(prop, "Sky Blend", "Blend factor with sky"); 00299 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00300 00301 prop= RNA_def_property(srna, "sky_exposure", PROP_FLOAT, PROP_NONE); 00302 RNA_def_property_range(prop, 0.0f, 20.0f); 00303 RNA_def_property_ui_text(prop, "Sky Exposure", "Strength of sky shading exponential exposure correction"); 00304 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00305 00306 /* boolean */ 00307 00308 prop= RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE); 00309 RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_SKY); 00310 RNA_def_property_ui_text(prop, "Sky", "Apply sun effect on sky"); 00311 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00312 00313 prop= RNA_def_property(srna, "use_atmosphere", PROP_BOOLEAN, PROP_NONE); 00314 RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_AP); 00315 RNA_def_property_ui_text(prop, "Atmosphere", "Apply sun effect on atmosphere"); 00316 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); 00317 } 00318 00319 static void rna_def_lamp(BlenderRNA *brna) 00320 { 00321 StructRNA *srna; 00322 PropertyRNA *prop; 00323 00324 srna= RNA_def_struct(brna, "Lamp", "ID"); 00325 RNA_def_struct_refine_func(srna, "rna_Lamp_refine"); 00326 RNA_def_struct_ui_text(srna, "Lamp", "Lamp datablock for lighting a scene"); 00327 RNA_def_struct_ui_icon(srna, ICON_LAMP_DATA); 00328 00329 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); 00330 RNA_def_property_enum_items(prop, lamp_type_items); 00331 RNA_def_property_ui_text(prop, "Type", "Type of Lamp"); 00332 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00333 00334 prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); 00335 RNA_def_property_float_sdna(prop, NULL, "dist"); 00336 RNA_def_property_range(prop, 0, INT_MAX); 00337 RNA_def_property_ui_range(prop, 0, 1000, 1, 3); 00338 RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point"); 00339 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00340 00341 prop= RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE); 00342 RNA_def_property_ui_range(prop, 0, 10, 1, 3); 00343 RNA_def_property_ui_text(prop, "Energy", "Amount of light that the lamp emits"); 00344 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00345 00346 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); 00347 RNA_def_property_float_sdna(prop, NULL, "r"); 00348 RNA_def_property_array(prop, 3); 00349 RNA_def_property_ui_text(prop, "Color", "Light color"); 00350 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00351 00352 prop= RNA_def_property(srna, "use_own_layer", PROP_BOOLEAN, PROP_NONE); 00353 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER); 00354 RNA_def_property_ui_text(prop, "Layer", "Illuminates objects only on the same layer the lamp is on"); 00355 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00356 00357 prop= RNA_def_property(srna, "use_negative", PROP_BOOLEAN, PROP_NONE); 00358 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_NEG); 00359 RNA_def_property_ui_text(prop, "Negative", "Lamp casts negative light"); 00360 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00361 00362 prop= RNA_def_property(srna, "use_specular", PROP_BOOLEAN, PROP_NONE); 00363 RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_SPEC); 00364 RNA_def_property_ui_text(prop, "Specular", "Lamp creates specular highlights"); 00365 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00366 00367 prop= RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE); 00368 RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_DIFF); 00369 RNA_def_property_ui_text(prop, "Diffuse", "Lamp does diffuse shading"); 00370 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00371 00372 /* common */ 00373 rna_def_animdata_common(srna); 00374 00375 /* textures */ 00376 rna_def_mtex_common(brna, srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get", 00377 "rna_Lamp_active_texture_set", NULL, "LampTextureSlot", "LampTextureSlots", "rna_Lamp_update"); 00378 } 00379 00380 static void rna_def_lamp_falloff(StructRNA *srna) 00381 { 00382 PropertyRNA *prop; 00383 00384 static EnumPropertyItem prop_fallofftype_items[] = { 00385 {LA_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", ""}, 00386 {LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", 0, "Inverse Linear", ""}, 00387 {LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", 0, "Inverse Square", ""}, 00388 {LA_FALLOFF_CURVE, "CUSTOM_CURVE", 0, "Custom Curve", ""}, 00389 {LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", 0, "Lin/Quad Weighted", ""}, 00390 {0, NULL, 0, NULL, NULL}}; 00391 00392 prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); 00393 RNA_def_property_enum_items(prop, prop_fallofftype_items); 00394 RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance"); 00395 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00396 00397 prop= RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); 00398 RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); 00399 RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); 00400 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00401 00402 prop= RNA_def_property(srna, "use_sphere", PROP_BOOLEAN, PROP_NONE); 00403 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SPHERE); 00404 RNA_def_property_ui_text(prop, "Sphere", "Sets light intensity to zero beyond lamp distance"); 00405 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00406 00407 prop= RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_NONE); 00408 RNA_def_property_float_sdna(prop, NULL, "att1"); 00409 RNA_def_property_range(prop, 0.0f, 1.0f); 00410 RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attenuation"); 00411 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00412 00413 prop= RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_NONE); 00414 RNA_def_property_float_sdna(prop, NULL, "att2"); 00415 RNA_def_property_range(prop, 0.0f, 1.0f); 00416 RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attenuation"); 00417 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00418 } 00419 00420 static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) 00421 { 00422 PropertyRNA *prop; 00423 00424 static EnumPropertyItem prop_shadow_items[] = { 00425 {0, "NOSHADOW", 0, "No Shadow", ""}, 00426 {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow"}, 00427 {0, NULL, 0, NULL, NULL}}; 00428 00429 static EnumPropertyItem prop_spot_shadow_items[] = { 00430 {0, "NOSHADOW", 0, "No Shadow", ""}, 00431 {LA_SHAD_BUF, "BUFFER_SHADOW", 0, "Buffer Shadow", "Lets spotlight produce shadows using shadow buffer"}, 00432 {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow"}, 00433 {0, NULL, 0, NULL, NULL}}; 00434 00435 static EnumPropertyItem prop_ray_sampling_method_items[] = { 00436 {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""}, 00437 {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""}, 00438 {0, NULL, 0, NULL, NULL}}; 00439 00440 static EnumPropertyItem prop_spot_ray_sampling_method_items[] = { 00441 {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""}, 00442 {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""}, 00443 {LA_SAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""}, 00444 {0, NULL, 0, NULL, NULL}}; 00445 00446 prop= RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE); 00447 RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); 00448 RNA_def_property_enum_items(prop, (spot)? prop_spot_shadow_items: prop_shadow_items); 00449 RNA_def_property_ui_text(prop, "Shadow Method", "Method to compute lamp shadow with"); 00450 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00451 00452 prop= RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR); 00453 RNA_def_property_float_sdna(prop, NULL, "shdwr"); 00454 RNA_def_property_array(prop, 3); 00455 RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the lamp"); 00456 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00457 00458 prop= RNA_def_property(srna, "use_only_shadow", PROP_BOOLEAN, PROP_NONE); 00459 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_ONLYSHADOW); 00460 RNA_def_property_ui_text(prop, "Only Shadow", "Causes light to cast shadows only without illuminating objects"); 00461 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00462 00463 prop= RNA_def_property(srna, "shadow_ray_sample_method", PROP_ENUM, PROP_NONE); 00464 RNA_def_property_enum_sdna(prop, NULL, "ray_samp_method"); 00465 RNA_def_property_enum_items(prop, (area)? prop_spot_ray_sampling_method_items: prop_ray_sampling_method_items); 00466 RNA_def_property_ui_text(prop, "Shadow Ray Sampling Method", "Method for generating shadow samples: Adaptive QMC is fastest, Constant QMC is less noisy but slower"); 00467 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00468 00469 prop= RNA_def_property(srna, (area)? "shadow_ray_samples_x": "shadow_ray_samples", PROP_INT, PROP_NONE); 00470 RNA_def_property_int_sdna(prop, NULL, "ray_samp"); 00471 RNA_def_property_range(prop, 1, 64); 00472 RNA_def_property_ui_text(prop, (area)? "Shadow Ray Samples": "Shadow Ray Samples X","Amount of samples taken extra (samples x samples)"); 00473 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00474 00475 if(area) { 00476 prop= RNA_def_property(srna, "shadow_ray_samples_y", PROP_INT, PROP_NONE); 00477 RNA_def_property_int_sdna(prop, NULL, "ray_sampy"); 00478 RNA_def_property_range(prop, 1, 64); 00479 RNA_def_property_ui_text(prop, "Shadow Ray Samples Y", "Amount of samples taken extra (samples x samples)"); 00480 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00481 } 00482 00483 prop= RNA_def_property(srna, "shadow_adaptive_threshold", PROP_FLOAT, PROP_NONE); 00484 RNA_def_property_float_sdna(prop, NULL, "adapt_thresh"); 00485 RNA_def_property_range(prop, 0.0f, 1.0f); 00486 RNA_def_property_ui_text(prop, "Shadow Adaptive Threshold", "Threshold for Adaptive Sampling (Raytraced shadows)"); 00487 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00488 00489 prop= RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE); 00490 RNA_def_property_float_sdna(prop, NULL, "area_size"); 00491 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); 00492 RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)"); 00493 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00494 00495 prop= RNA_def_property(srna, "use_shadow_layer", PROP_BOOLEAN, PROP_NONE); 00496 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER_SHADOW); 00497 RNA_def_property_ui_text(prop, "Shadow Layer", "Causes only objects on the same layer to cast shadows"); 00498 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00499 } 00500 00501 static void rna_def_point_lamp(BlenderRNA *brna) 00502 { 00503 StructRNA *srna; 00504 00505 srna= RNA_def_struct(brna, "PointLamp", "Lamp"); 00506 RNA_def_struct_sdna(srna, "Lamp"); 00507 RNA_def_struct_ui_text(srna, "Point Lamp", "Omnidirectional point lamp"); 00508 RNA_def_struct_ui_icon(srna, ICON_LAMP_POINT); 00509 00510 rna_def_lamp_falloff(srna); 00511 rna_def_lamp_shadow(srna, 0, 0); 00512 } 00513 00514 static void rna_def_area_lamp(BlenderRNA *brna) 00515 { 00516 StructRNA *srna; 00517 PropertyRNA *prop; 00518 00519 static EnumPropertyItem prop_areashape_items[] = { 00520 {LA_AREA_SQUARE, "SQUARE", 0, "Square", ""}, 00521 {LA_AREA_RECT, "RECTANGLE", 0, "Rectangle", ""}, 00522 {0, NULL, 0, NULL, NULL}}; 00523 00524 srna= RNA_def_struct(brna, "AreaLamp", "Lamp"); 00525 RNA_def_struct_sdna(srna, "Lamp"); 00526 RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp"); 00527 RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA); 00528 00529 rna_def_lamp_shadow(srna, 0, 1); 00530 00531 prop= RNA_def_property(srna, "use_umbra", PROP_BOOLEAN, PROP_NONE); 00532 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_UMBRA); 00533 RNA_def_property_ui_text(prop, "Umbra", "Emphasize parts that are fully shadowed (Constant Jittered sampling)"); 00534 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00535 00536 prop= RNA_def_property(srna, "use_dither", PROP_BOOLEAN, PROP_NONE); 00537 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_DITHER); 00538 RNA_def_property_ui_text(prop, "Dither", "Use 2x2 dithering for sampling (Constant Jittered sampling)"); 00539 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00540 00541 prop= RNA_def_property(srna, "use_jitter", PROP_BOOLEAN, PROP_NONE); 00542 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_JITTER); 00543 RNA_def_property_ui_text(prop, "Jitter", "Use noise for sampling (Constant Jittered sampling)"); 00544 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00545 00546 prop= RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE); 00547 RNA_def_property_enum_sdna(prop, NULL, "area_shape"); 00548 RNA_def_property_enum_items(prop, prop_areashape_items); 00549 RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp"); 00550 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00551 00552 prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE); 00553 RNA_def_property_float_sdna(prop, NULL, "area_size"); 00554 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); 00555 RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes"); 00556 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00557 00558 prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); 00559 RNA_def_property_float_sdna(prop, NULL, "area_sizey"); 00560 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); 00561 RNA_def_property_ui_text(prop, "Size Y", "Size of the area of the area Lamp in the Y direction for Rectangle shapes"); 00562 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00563 00564 prop= RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE); 00565 RNA_def_property_float_sdna(prop, NULL, "k"); 00566 RNA_def_property_ui_range(prop, 0.001, 2.0, 0.1, 3); 00567 RNA_def_property_ui_text(prop, "Gamma", "Light gamma correction value"); 00568 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00569 } 00570 00571 static void rna_def_spot_lamp(BlenderRNA *brna) 00572 { 00573 StructRNA *srna; 00574 PropertyRNA *prop; 00575 00576 static EnumPropertyItem prop_shadbuftype_items[] = { 00577 {LA_SHADBUF_REGULAR , "REGULAR", 0, "Classical", "Classic shadow buffer"}, 00578 {LA_SHADBUF_HALFWAY, "HALFWAY", 0, "Classic-Halfway", "Regular buffer, averaging the closest and 2nd closest Z value to reducing bias artifacts"}, 00579 {LA_SHADBUF_IRREGULAR, "IRREGULAR", 0, "Irregular", "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing"}, 00580 {LA_SHADBUF_DEEP, "DEEP", 0, "Deep", "Deep shadow buffer supports transparency and better filtering, at the cost of more memory usage and processing time"}, 00581 {0, NULL, 0, NULL, NULL}}; 00582 00583 static EnumPropertyItem prop_shadbuffiltertype_items[] = { 00584 {LA_SHADBUF_BOX , "BOX", 0, "Box", "Apply the Box filter to shadow buffer samples"}, 00585 {LA_SHADBUF_TENT, "TENT", 0, "Tent", "Apply the Tent Filter to shadow buffer samples"}, 00586 {LA_SHADBUF_GAUSS, "GAUSS", 0, "Gauss", "Apply the Gauss filter to shadow buffer samples"}, 00587 {0, NULL, 0, NULL, NULL}}; 00588 00589 static EnumPropertyItem prop_numbuffer_items[] = { 00590 {1, "BUFFERS_1", 0, "1", "Only one buffer rendered"}, 00591 {4, "BUFFERS_4", 0, "4", "Renders 4 buffers for better AA, this quadruples memory usage"}, 00592 {9, "BUFFERS_9", 0, "9", "Renders 9 buffers for better AA, this uses nine times more memory"}, 00593 {0, NULL, 0, NULL, NULL}}; 00594 00595 srna= RNA_def_struct(brna, "SpotLamp", "Lamp"); 00596 RNA_def_struct_sdna(srna, "Lamp"); 00597 RNA_def_struct_ui_text(srna, "Spot Lamp", "Directional cone lamp"); 00598 RNA_def_struct_ui_icon(srna, ICON_LAMP_SPOT); 00599 00600 rna_def_lamp_falloff(srna); 00601 rna_def_lamp_shadow(srna, 1, 0); 00602 00603 prop= RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE); 00604 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE); 00605 RNA_def_property_ui_text(prop, "Square", "Casts a square spot light shape"); 00606 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00607 00608 prop= RNA_def_property(srna, "use_halo", PROP_BOOLEAN, PROP_NONE); 00609 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_HALO); 00610 RNA_def_property_ui_text(prop, "Halo", "Renders spotlight with a volumetric halo"); 00611 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00612 00613 prop= RNA_def_property(srna, "halo_intensity", PROP_FLOAT, PROP_NONE); 00614 RNA_def_property_float_sdna(prop, NULL, "haint"); 00615 RNA_def_property_ui_range(prop, 0, 5.0, 0.1, 3); 00616 RNA_def_property_ui_text(prop, "Halo Intensity", "Brightness of the spotlight's halo cone"); 00617 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00618 00619 prop= RNA_def_property(srna, "halo_step", PROP_INT, PROP_NONE); 00620 RNA_def_property_int_sdna(prop, NULL, "shadhalostep"); 00621 RNA_def_property_range(prop, 0, 12); 00622 RNA_def_property_ui_text(prop, "Halo Step", "Volumetric halo sampling frequency"); 00623 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00624 00625 prop= RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE); 00626 RNA_def_property_int_sdna(prop, NULL, "bufsize"); 00627 RNA_def_property_range(prop, 512, 10240); 00628 RNA_def_property_ui_text(prop, "Shadow Buffer Size", "Resolution of the shadow buffer, higher values give crisper shadows but use more memory"); 00629 RNA_def_property_int_funcs(prop, NULL, "rna_Lamp_buffer_size_set", NULL); 00630 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00631 00632 prop= RNA_def_property(srna, "shadow_filter_type", PROP_ENUM, PROP_NONE); 00633 RNA_def_property_enum_sdna(prop, NULL, "filtertype"); 00634 RNA_def_property_enum_items(prop, prop_shadbuffiltertype_items); 00635 RNA_def_property_ui_text(prop, "Shadow Filter Type", "Type of shadow filter (Buffer Shadows)"); 00636 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00637 00638 prop= RNA_def_property(srna, "shadow_sample_buffers", PROP_ENUM, PROP_NONE); 00639 RNA_def_property_enum_sdna(prop, NULL, "buffers"); 00640 RNA_def_property_enum_items(prop, prop_numbuffer_items); 00641 RNA_def_property_ui_text(prop, "Shadow Sample Buffers", "Number of shadow buffers to render for better AA, this increases memory usage"); 00642 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00643 00644 prop= RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE); 00645 RNA_def_property_float_sdna(prop, NULL, "spotblend"); 00646 RNA_def_property_range(prop, 0.0f ,1.0f); 00647 RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge"); 00648 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00649 00650 prop= RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE); 00651 // RNA_def_property_float_sdna(prop, NULL, "spotsize"); 00652 RNA_def_property_range(prop, M_PI/180.0, M_PI); 00653 RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam in degrees"); 00654 RNA_def_property_float_funcs(prop, "rna_Lamp_spot_size_get", "rna_Lamp_spot_size_set", NULL); /* only for deg/rad conversion */ 00655 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00656 00657 prop= RNA_def_property(srna, "show_cone", PROP_BOOLEAN, PROP_NONE); 00658 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHOW_CONE); 00659 RNA_def_property_ui_text(prop, "Show Cone", "Draw transparent cone in 3D view to visualize which objects are contained in it"); 00660 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00661 00662 prop= RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE); 00663 RNA_def_property_float_sdna(prop, NULL, "clipsta"); 00664 RNA_def_property_range(prop, 0.0f, 9999.0f); 00665 RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start: objects closer will not generate shadows"); 00666 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00667 00668 prop= RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE); 00669 RNA_def_property_float_sdna(prop, NULL, "clipend"); 00670 RNA_def_property_range(prop, 0.0f, 9999.0f); 00671 RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end beyond which objects will not generate shadows"); 00672 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00673 00674 prop= RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE); 00675 RNA_def_property_float_sdna(prop, NULL, "bias"); 00676 RNA_def_property_range(prop, 0.001f, 5.0f); 00677 RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Shadow buffer sampling bias"); 00678 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00679 00680 prop= RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE); 00681 RNA_def_property_float_sdna(prop, NULL, "soft"); 00682 RNA_def_property_range(prop, 0.0f, 100.0f); 00683 RNA_def_property_ui_text(prop, "Shadow Buffer Soft", "Size of shadow buffer sampling area"); 00684 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00685 00686 prop= RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE); 00687 RNA_def_property_int_sdna(prop, NULL, "samp"); 00688 RNA_def_property_range(prop, 1, 16); 00689 RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples"); 00690 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00691 00692 prop= RNA_def_property(srna, "shadow_buffer_type", PROP_ENUM, PROP_NONE); 00693 RNA_def_property_enum_sdna(prop, NULL, "buftype"); 00694 RNA_def_property_enum_items(prop, prop_shadbuftype_items); 00695 RNA_def_property_ui_text(prop, "Shadow Buffer Type", "Type of shadow buffer"); 00696 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00697 00698 prop= RNA_def_property(srna, "use_auto_clip_start", PROP_BOOLEAN, PROP_NONE); 00699 RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_START); 00700 RNA_def_property_ui_text(prop, "Autoclip Start", "Automatic calculation of clipping-start, based on visible vertices"); 00701 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00702 00703 prop= RNA_def_property(srna, "use_auto_clip_end", PROP_BOOLEAN, PROP_NONE); 00704 RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_END); 00705 RNA_def_property_ui_text(prop, "Autoclip End", "Automatic calculation of clipping-end, based on visible vertices"); 00706 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); 00707 00708 prop= RNA_def_property(srna, "compression_threshold", PROP_FLOAT, PROP_NONE); 00709 RNA_def_property_float_sdna(prop, NULL, "compressthresh"); 00710 RNA_def_property_range(prop, 0.0f, 1.0f); 00711 RNA_def_property_ui_text(prop, "Compress", "Deep shadow map compression threshold"); 00712 RNA_def_property_update(prop, 0, "rna_Lamp_update"); 00713 } 00714 00715 static void rna_def_sun_lamp(BlenderRNA *brna) 00716 { 00717 StructRNA *srna; 00718 PropertyRNA *prop; 00719 00720 srna= RNA_def_struct(brna, "SunLamp", "Lamp"); 00721 RNA_def_struct_sdna(srna, "Lamp"); 00722 RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp"); 00723 RNA_def_struct_ui_icon(srna, ICON_LAMP_SUN); 00724 00725 rna_def_lamp_shadow(srna, 0, 0); 00726 00727 /* sky */ 00728 prop= RNA_def_property(srna, "sky", PROP_POINTER, PROP_NONE); 00729 RNA_def_property_flag(prop, PROP_NEVER_NULL); 00730 RNA_def_property_struct_type(prop, "LampSkySettings"); 00731 RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL, NULL, NULL); 00732 RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps"); 00733 00734 rna_def_lamp_sky_settings(brna); 00735 } 00736 00737 static void rna_def_hemi_lamp(BlenderRNA *brna) 00738 { 00739 StructRNA *srna; 00740 00741 srna= RNA_def_struct(brna, "HemiLamp", "Lamp"); 00742 RNA_def_struct_sdna(srna, "Lamp"); 00743 RNA_def_struct_ui_text(srna, "Hemi Lamp", "180 degree constant lamp"); 00744 RNA_def_struct_ui_icon(srna, ICON_LAMP_HEMI); 00745 } 00746 00747 void RNA_def_lamp(BlenderRNA *brna) 00748 { 00749 rna_def_lamp(brna); 00750 rna_def_point_lamp(brna); 00751 rna_def_area_lamp(brna); 00752 rna_def_spot_lamp(brna); 00753 rna_def_sun_lamp(brna); 00754 rna_def_hemi_lamp(brna); 00755 rna_def_lamp_mtex(brna); 00756 } 00757 00758 #endif 00759