Blender V2.61 - r43446

rna_material.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), Nathan Letwory
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 
00038 #include "WM_api.h"
00039 #include "WM_types.h"
00040 
00041 static EnumPropertyItem prop_texture_coordinates_items[] = {
00042 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
00043 {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"},
00044 {TEXCO_UV, "UV", 0, "UV", "Use UV coordinates for texture coordinates"},
00045 {TEXCO_ORCO, "ORCO", 0, "Generated", "Use the original undeformed coordinates of the object"},
00046 {TEXCO_STRAND, "STRAND", 0, "Strand / Particle",
00047                "Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"},
00048 {TEXCO_STICKY, "STICKY", 0, "Sticky", "Use mesh's sticky coordinates for the texture coordinates"},
00049 {TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"},
00050 {TEXCO_NORM, "NORMAL", 0, "Normal", "Use normal vector as texture coordinates"},
00051 {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Use reflection vector as texture coordinates"},
00052 {TEXCO_STRESS, "STRESS", 0, "Stress", "Use the difference of edge lengths compared to original coordinates of the mesh"},
00053 {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Use the optional tangent vector as texture coordinates"},
00054 {0, NULL, 0, NULL, NULL}};
00055 
00056 EnumPropertyItem ramp_blend_items[] = {
00057 {MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
00058 {MA_RAMP_ADD, "ADD", 0, "Add", ""},
00059 {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""},
00060 {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""},
00061 {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""},
00062 {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""},
00063 {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""},
00064 {MA_RAMP_DARK, "DARKEN", 0, "Darken", ""},
00065 {MA_RAMP_LIGHT, "LIGHTEN", 0, "Lighten", ""},
00066 {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""},
00067 {MA_RAMP_DODGE, "DODGE", 0, "Dodge", ""},
00068 {MA_RAMP_BURN, "BURN", 0, "Burn", ""},
00069 {MA_RAMP_HUE, "HUE", 0, "Hue", ""},
00070 {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""},
00071 {MA_RAMP_VAL, "VALUE", 0, "Value", ""},
00072 {MA_RAMP_COLOR, "COLOR", 0, "Color", ""},
00073 {MA_RAMP_SOFT, "SOFT_LIGHT", 0, "Soft Light", ""}, 
00074 {MA_RAMP_LINEAR, "LINEAR_LIGHT", 0, "Linear Light", ""}, 
00075 {0, NULL, 0, NULL, NULL}};
00076 
00077 #ifdef RNA_RUNTIME
00078 
00079 #include "MEM_guardedalloc.h"
00080 
00081 #include "DNA_node_types.h"
00082 
00083 #include "BKE_depsgraph.h"
00084 #include "BKE_main.h"
00085 #include "BKE_material.h"
00086 #include "BKE_texture.h"
00087 #include "BKE_node.h"
00088 
00089 #include "ED_node.h"
00090 
00091 static void rna_Material_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
00092 {
00093     Material *ma= ptr->id.data;
00094 
00095     DAG_id_tag_update(&ma->id, 0);
00096     if(scene->gm.matmode == GAME_MAT_GLSL)
00097         WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, ma);
00098     else
00099         WM_main_add_notifier(NC_MATERIAL|ND_SHADING, ma);
00100 }
00101 
00102 static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00103 {
00104     Material *ma= ptr->id.data;
00105 
00106     DAG_id_tag_update(&ma->id, 0);
00107     WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, ma);
00108 }
00109 
00110 static PointerRNA rna_Material_mirror_get(PointerRNA *ptr)
00111 {
00112     return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data);
00113 }
00114 
00115 static PointerRNA rna_Material_transp_get(PointerRNA *ptr)
00116 {
00117     return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceTransparency, ptr->id.data);
00118 }
00119 
00120 static PointerRNA rna_Material_halo_get(PointerRNA *ptr)
00121 {
00122     return rna_pointer_inherit_refine(ptr, &RNA_MaterialHalo, ptr->id.data);
00123 }
00124 
00125 static PointerRNA rna_Material_sss_get(PointerRNA *ptr)
00126 {
00127     return rna_pointer_inherit_refine(ptr, &RNA_MaterialSubsurfaceScattering, ptr->id.data);
00128 }
00129 
00130 static PointerRNA rna_Material_strand_get(PointerRNA *ptr)
00131 {
00132     return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data);
00133 }
00134 
00135 static PointerRNA rna_Material_physics_get(PointerRNA *ptr)
00136 {
00137     return rna_pointer_inherit_refine(ptr, &RNA_MaterialPhysics, ptr->id.data);
00138 }
00139 
00140 static void rna_Material_type_set(PointerRNA *ptr, int value)
00141 {
00142     Material *ma= (Material*)ptr->data;
00143 
00144     if(ma->material_type == MA_TYPE_HALO && value != MA_TYPE_HALO)
00145         ma->mode &= ~(MA_STAR|MA_HALO_XALPHA|MA_ZINV|MA_ENV);
00146 
00147     ma->material_type= value;
00148 }
00149 
00150 static void rna_Material_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00151 {
00152     Material *ma= (Material*)ptr->data;
00153     rna_iterator_array_begin(iter, (void*)ma->mtex, sizeof(MTex*), MAX_MTEX, 0, NULL);
00154 }
00155 
00156 static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr)
00157 {
00158     Material *ma= (Material*)ptr->data;
00159     Tex *tex;
00160 
00161     tex= give_current_material_texture(ma);
00162     return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
00163 }
00164 
00165 static void rna_Material_active_texture_set(PointerRNA *ptr, PointerRNA value)
00166 {
00167     Material *ma= (Material*)ptr->data;
00168 
00169     set_current_material_texture(ma, value.data);
00170 }
00171 
00172 static int rna_Material_active_texture_editable(PointerRNA *ptr)
00173 {
00174     Material *ma= (Material*)ptr->id.data;
00175 
00176     return has_current_material_texture(ma);
00177 }
00178 
00179 static PointerRNA rna_Material_active_node_material_get(PointerRNA *ptr)
00180 {
00181     Material *ma= give_node_material((Material*)ptr->data);
00182     return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
00183 }
00184 
00185 static void rna_Material_active_node_material_set(PointerRNA *ptr, PointerRNA value)
00186 {
00187     Material *ma= (Material*)ptr->data;
00188     Material *ma_act= value.data;
00189 
00190     nodeSetActiveID(ma->nodetree, ID_MA, &ma_act->id);
00191 }
00192 
00193 static void rna_MaterialStrand_start_size_range(PointerRNA *ptr, float *min, float *max)
00194 {
00195     Material *ma= (Material*)ptr->id.data;
00196 
00197     if(ma->mode & MA_STR_B_UNITS) {
00198         *min= 0.0001f;
00199         *max= 2.0f;
00200     }
00201     else {
00202         *min= 0.25f;
00203         *max= 20.0f;
00204     }
00205 }
00206 
00207 static void rna_MaterialStrand_end_size_range(PointerRNA *ptr, float *min, float *max)
00208 {
00209     Material *ma= (Material*)ptr->id.data;
00210 
00211     if(ma->mode & MA_STR_B_UNITS) {
00212         *min= 0.0001f;
00213         *max= 1.0f;
00214     }
00215     else {
00216         *min= 0.25f;
00217         *max= 10.0f;
00218     }
00219 }
00220 
00221 static int rna_MaterialTextureSlot_use_get(PointerRNA *ptr)
00222 {
00223     Material *ma= (Material*)ptr->id.data;
00224     MTex *mtex= (MTex*)ptr->data;
00225     int a;
00226 
00227     for(a=0; a<MAX_MTEX; a++)
00228         if(ma->mtex[a] == mtex)
00229             return (ma->septex & (1<<a)) == 0;
00230     
00231     return 0;
00232 }
00233 
00234 static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, int value)
00235 {
00236     Material *ma= (Material*)ptr->id.data;
00237     MTex *mtex= (MTex*)ptr->data;
00238     int a;
00239 
00240     for(a=0; a<MAX_MTEX; a++) {
00241         if(ma->mtex[a] == mtex) {
00242             if(value)
00243                 ma->septex &= ~(1<<a);
00244             else
00245                 ma->septex |= (1<<a);
00246         }
00247     }
00248 }
00249 
00250 static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, int value)
00251 {
00252     Material *ma= (Material*)ptr->data;
00253 
00254     if(value) ma->mode |= MA_RAMP_COL;
00255     else ma->mode &= ~MA_RAMP_COL;
00256 
00257     if((ma->mode & MA_RAMP_COL) && ma->ramp_col == NULL)
00258         ma->ramp_col= add_colorband(0);
00259 }
00260 
00261 static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value)
00262 {
00263     Material *ma= (Material*)ptr->data;
00264 
00265     if(value) ma->mode |= MA_RAMP_SPEC;
00266     else ma->mode &= ~MA_RAMP_SPEC;
00267 
00268     if((ma->mode & MA_RAMP_SPEC) && ma->ramp_spec == NULL)
00269         ma->ramp_spec= add_colorband(0);
00270 }
00271 
00272 static void rna_Material_use_nodes_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00273 {
00274     Material *ma= (Material*)ptr->data;
00275 
00276     if(ma->use_nodes && ma->nodetree==NULL)
00277         ED_node_shader_default(scene, &ma->id);
00278     
00279     rna_Material_update(bmain, scene, ptr);
00280 }
00281 
00282 static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED(C), PointerRNA *ptr,
00283                                                                 PropertyRNA *UNUSED(prop), int *free)
00284 {
00285     Material *ma= (Material*)ptr->id.data;
00286     EnumPropertyItem *item= NULL;
00287     int totitem= 0;
00288     
00289     RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_GLOB);
00290     RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_OBJECT);
00291     RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_ORCO);
00292     
00293     if(ma->material_type == MA_TYPE_VOLUME) {
00294         
00295     }
00296     else if (ELEM3(ma->material_type, MA_TYPE_SURFACE, MA_TYPE_HALO, MA_TYPE_WIRE)) {
00297         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_UV);
00298         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRAND);
00299         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STICKY);
00300         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_WINDOW);
00301         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_NORM);
00302         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_REFL);
00303         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRESS);
00304         RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_TANGENT);
00305     }
00306     
00307     RNA_enum_item_end(&item, &totitem);
00308     *free= 1;
00309     
00310     return item;
00311 }
00312 
00313 MTex *rna_mtex_texture_slots_add(ID *self_id, struct bContext *C, ReportList *reports)
00314 {
00315     MTex *mtex= add_mtex_id(self_id, -1);
00316     if (mtex == NULL) {
00317         BKE_reportf(reports, RPT_ERROR, "maximum number of textures added %d", MAX_MTEX);
00318         return NULL;
00319     }
00320 
00321     /* for redraw only */
00322     WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
00323 
00324     return mtex;
00325 }
00326 
00327 MTex *rna_mtex_texture_slots_create(ID *self_id, struct bContext *C, ReportList *reports, int index)
00328 {
00329     MTex *mtex;
00330 
00331     if(index < 0 || index >= MAX_MTEX) {
00332         BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index);
00333         return NULL;
00334     }
00335 
00336     mtex= add_mtex_id(self_id, index);
00337 
00338     /* for redraw only */
00339     WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
00340 
00341     return mtex;
00342 }
00343 
00344 void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *reports, int index)
00345 {
00346     MTex **mtex_ar;
00347     short act;
00348 
00349     give_active_mtex(self_id, &mtex_ar, &act);
00350 
00351     if (mtex_ar == NULL) {
00352         BKE_report(reports, RPT_ERROR, "mtex not found for this type");
00353         return;
00354     }
00355     
00356     if(index < 0 || index >= MAX_MTEX) {
00357         BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index);
00358         return;
00359     }
00360 
00361     if(mtex_ar[index]) {
00362         id_us_min((ID *)mtex_ar[index]->tex);
00363         MEM_freeN(mtex_ar[index]);
00364         mtex_ar[index]= NULL;
00365     }
00366 
00367     /* for redraw only */
00368     WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
00369 }
00370 
00371 #else
00372 
00373 static void rna_def_material_mtex(BlenderRNA *brna)
00374 {
00375     StructRNA *srna;
00376     PropertyRNA *prop;
00377 
00378     static EnumPropertyItem prop_mapping_items[] = {
00379         {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
00380         {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
00381         {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
00382         {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
00383         {0, NULL, 0, NULL, NULL}};
00384         
00385     static EnumPropertyItem prop_x_mapping_items[] = {
00386         {0, "NONE", 0, "None", ""},
00387         {1, "X", 0, "X", ""},
00388         {2, "Y", 0, "Y", ""},
00389         {3, "Z", 0, "Z", ""},
00390         {0, NULL, 0, NULL, NULL}};
00391         
00392     static EnumPropertyItem prop_y_mapping_items[] = {
00393         {0, "NONE", 0, "None", ""},
00394         {1, "X", 0, "X", ""},
00395         {2, "Y", 0, "Y", ""},
00396         {3, "Z", 0, "Z", ""},
00397         {0, NULL, 0, NULL, NULL}};
00398         
00399     static EnumPropertyItem prop_z_mapping_items[] = {
00400         {0, "NONE", 0, "None", ""},
00401         {1, "X", 0, "X", ""},
00402         {2, "Y", 0, "Y", ""},
00403         {3, "Z", 0, "Z", ""},
00404         {0, NULL, 0, NULL, NULL}};
00405 
00406     static EnumPropertyItem prop_normal_map_space_items[] = {
00407         {MTEX_NSPACE_CAMERA, "CAMERA", 0, "Camera", ""},
00408         {MTEX_NSPACE_WORLD, "WORLD", 0, "World", ""},
00409         {MTEX_NSPACE_OBJECT, "OBJECT", 0, "Object", ""},
00410         {MTEX_NSPACE_TANGENT, "TANGENT", 0, "Tangent", ""},
00411         {0, NULL, 0, NULL, NULL}};
00412 
00413     static EnumPropertyItem prop_bump_method_items[] = {
00414         {0, "BUMP_ORIGINAL", 0, "Original", ""},
00415         {MTEX_COMPAT_BUMP, "BUMP_COMPATIBLE", 0, "Compatible", ""},
00416         {MTEX_3TAP_BUMP, "BUMP_LOW_QUALITY", 0, "Low Quality", "Use 3 tap filtering"},
00417         {MTEX_5TAP_BUMP, "BUMP_MEDIUM_QUALITY", 0, "Medium Quality", "Use 5 tap filtering"},
00418         {MTEX_BICUBIC_BUMP, "BUMP_BEST_QUALITY", 0, "Best Quality", "Use bicubic filtering (requires OpenGL 3.0+, "
00419                                                     "it will fall back on medium setting for other systems)"},
00420         {0, NULL, 0, NULL, NULL}};
00421 
00422     static EnumPropertyItem prop_bump_space_items[] = {
00423         {0, "BUMP_VIEWSPACE", 0, "ViewSpace", ""},
00424         {MTEX_BUMP_OBJECTSPACE, "BUMP_OBJECTSPACE", 0, "ObjectSpace", ""},
00425         {MTEX_BUMP_TEXTURESPACE, "BUMP_TEXTURESPACE", 0, "TextureSpace", ""},
00426         {0, NULL, 0, NULL, NULL}};
00427     
00428     srna= RNA_def_struct(brna, "MaterialTextureSlot", "TextureSlot");
00429     RNA_def_struct_sdna(srna, "MTex");
00430     RNA_def_struct_ui_text(srna, "Material Texture Slot", "Texture slot for textures in a Material datablock");
00431 
00432     prop= RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
00433     RNA_def_property_enum_sdna(prop, NULL, "texco");
00434     RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
00435     RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Material_texture_coordinates_itemf");
00436     RNA_def_property_ui_text(prop, "Texture Coordinates", "");
00437     RNA_def_property_update(prop, 0, "rna_Material_update");
00438     
00439     prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
00440     RNA_def_property_pointer_sdna(prop, NULL, "object");
00441     RNA_def_property_struct_type(prop, "Object");
00442     RNA_def_property_flag(prop, PROP_EDITABLE);
00443     RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates");
00444     RNA_def_property_update(prop, 0, "rna_Material_update");
00445 
00446     prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
00447     RNA_def_property_string_sdna(prop, NULL, "uvname");
00448     RNA_def_property_ui_text(prop, "UV Map", "UV map to use for mapping with UV texture coordinates");
00449     RNA_def_property_update(prop, 0, "rna_Material_update");
00450 
00451     prop= RNA_def_property(srna, "use_from_dupli", PROP_BOOLEAN, PROP_NONE);
00452     RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_DUPLI_MAPTO);
00453     RNA_def_property_ui_text(prop, "From Dupli",
00454                              "Dupli's instanced from verts, faces or particles, inherit texture coordinate from their parent");
00455     RNA_def_property_update(prop, 0, "rna_Material_update");
00456 
00457     prop= RNA_def_property(srna, "use_from_original", PROP_BOOLEAN, PROP_NONE);
00458     RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_OB_DUPLI_ORIG);
00459     RNA_def_property_ui_text(prop, "From Original",
00460                              "Dupli's derive their object coordinates from the original object's transformation");
00461     RNA_def_property_update(prop, 0, "rna_Material_update");
00462 
00463     prop= RNA_def_property(srna, "use_map_color_diffuse", PROP_BOOLEAN, PROP_NONE);
00464     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COL);
00465     RNA_def_property_ui_text(prop, "Diffuse Color", "The texture affects basic color of the material");
00466     RNA_def_property_update(prop, 0, "rna_Material_update");
00467     
00468     prop= RNA_def_property(srna, "use_map_normal", PROP_BOOLEAN, PROP_NONE);
00469     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_NORM);
00470     RNA_def_property_ui_text(prop, "Normal", "The texture affects the rendered normal");
00471     RNA_def_property_update(prop, 0, "rna_Material_update");
00472     
00473     prop= RNA_def_property(srna, "use_map_color_spec", PROP_BOOLEAN, PROP_NONE);
00474     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLSPEC);
00475     RNA_def_property_ui_text(prop, "Specular Color", "The texture affects the specularity color");
00476     RNA_def_property_update(prop, 0, "rna_Material_update");
00477     
00478     prop= RNA_def_property(srna, "use_map_mirror", PROP_BOOLEAN, PROP_NONE);
00479     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLMIR);
00480     RNA_def_property_ui_text(prop, "Mirror", "The texture affects the mirror color");
00481     RNA_def_property_update(prop, 0, "rna_Material_update");
00482     
00483     prop= RNA_def_property(srna, "use_map_diffuse", PROP_BOOLEAN, PROP_NONE);
00484     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REF);
00485     RNA_def_property_ui_text(prop, "Diffuse", "The texture affects the value of diffuse reflectivity");
00486     RNA_def_property_update(prop, 0, "rna_Material_update");
00487     
00488     prop= RNA_def_property(srna, "use_map_specular", PROP_BOOLEAN, PROP_NONE);
00489     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SPEC);
00490     RNA_def_property_ui_text(prop, "Specular", "The texture affects the value of specular reflectivity");
00491     RNA_def_property_update(prop, 0, "rna_Material_update");
00492     
00493     prop= RNA_def_property(srna, "use_map_ambient", PROP_BOOLEAN, PROP_NONE);
00494     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_AMB);
00495     RNA_def_property_ui_text(prop, "Ambient", "The texture affects the value of ambient");
00496     RNA_def_property_update(prop, 0, "rna_Material_update");
00497     
00498     prop= RNA_def_property(srna, "use_map_hardness", PROP_BOOLEAN, PROP_NONE);
00499     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_HAR);
00500     RNA_def_property_ui_text(prop, "Hardness", "The texture affects the hardness value");
00501     RNA_def_property_update(prop, 0, "rna_Material_update");
00502     
00503     prop= RNA_def_property(srna, "use_map_raymir", PROP_BOOLEAN, PROP_NONE);
00504     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_RAYMIRR);
00505     RNA_def_property_ui_text(prop, "Ray-Mirror", "The texture affects the ray-mirror value");
00506     RNA_def_property_update(prop, 0, "rna_Material_update");
00507     
00508     prop= RNA_def_property(srna, "use_map_alpha", PROP_BOOLEAN, PROP_NONE);
00509     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ALPHA);
00510     RNA_def_property_ui_text(prop, "Alpha", "The texture affects the alpha value");
00511     RNA_def_property_update(prop, 0, "rna_Material_update");
00512     
00513     prop= RNA_def_property(srna, "use_map_emit", PROP_BOOLEAN, PROP_NONE);
00514     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMIT);
00515     RNA_def_property_ui_text(prop, "Emit", "The texture affects the emit value");
00516     RNA_def_property_update(prop, 0, "rna_Material_update");
00517     
00518     prop= RNA_def_property(srna, "use_map_translucency", PROP_BOOLEAN, PROP_NONE);
00519     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSLU);
00520     RNA_def_property_ui_text(prop, "Translucency", "The texture affects the translucency value");
00521     RNA_def_property_update(prop, 0, "rna_Material_update");
00522     
00523     prop= RNA_def_property(srna, "use_map_displacement", PROP_BOOLEAN, PROP_NONE);
00524     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DISPLACE);
00525     RNA_def_property_ui_text(prop, "Displacement", "Let the texture displace the surface");
00526     RNA_def_property_update(prop, 0, "rna_Material_update");
00527     
00528     prop= RNA_def_property(srna, "use_map_warp", PROP_BOOLEAN, PROP_NONE);
00529     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_WARP);
00530     RNA_def_property_ui_text(prop, "Warp", "Let the texture warp texture coordinates of next channels");
00531     RNA_def_property_update(prop, 0, "rna_Material_update");
00532 
00533     prop= RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
00534     RNA_def_property_enum_sdna(prop, NULL, "projx");
00535     RNA_def_property_enum_items(prop, prop_x_mapping_items);
00536     RNA_def_property_ui_text(prop, "X Mapping", "");
00537     RNA_def_property_update(prop, 0, "rna_Material_update");
00538     
00539     prop= RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
00540     RNA_def_property_enum_sdna(prop, NULL, "projy");
00541     RNA_def_property_enum_items(prop, prop_y_mapping_items);
00542     RNA_def_property_ui_text(prop, "Y Mapping", "");
00543     RNA_def_property_update(prop, 0, "rna_Material_update");
00544     
00545     prop= RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
00546     RNA_def_property_enum_sdna(prop, NULL, "projz");
00547     RNA_def_property_enum_items(prop, prop_z_mapping_items);
00548     RNA_def_property_ui_text(prop, "Z Mapping", "");
00549     RNA_def_property_update(prop, 0, "rna_Material_update");
00550 
00551     prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
00552     RNA_def_property_enum_items(prop, prop_mapping_items);
00553     RNA_def_property_ui_text(prop, "Mapping", "");
00554     RNA_def_property_update(prop, 0, "rna_Material_update");
00555 
00556     prop= RNA_def_property(srna, "normal_map_space", PROP_ENUM, PROP_NONE);
00557     RNA_def_property_enum_sdna(prop, NULL, "normapspace");
00558     RNA_def_property_enum_items(prop, prop_normal_map_space_items);
00559     RNA_def_property_ui_text(prop, "Normal Map Space", "Set space of normal map image");
00560     RNA_def_property_update(prop, 0, "rna_Material_update");
00561 
00562     prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE);
00563     RNA_def_property_float_sdna(prop, NULL, "norfac");
00564     RNA_def_property_ui_range(prop, -5, 5, 10, 3);
00565     RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values");
00566     RNA_def_property_update(prop, 0, "rna_Material_update");
00567 
00568     prop= RNA_def_property(srna, "displacement_factor", PROP_FLOAT, PROP_NONE);
00569     RNA_def_property_float_sdna(prop, NULL, "dispfac");
00570     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00571     RNA_def_property_ui_text(prop, "Displacement Factor", "Amount texture displaces the surface");
00572     RNA_def_property_update(prop, 0, "rna_Material_update");
00573 
00574     prop= RNA_def_property(srna, "warp_factor", PROP_FLOAT, PROP_NONE);
00575     RNA_def_property_float_sdna(prop, NULL, "warpfac");
00576     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00577     RNA_def_property_ui_text(prop, "Warp Factor", "Amount texture affects texture coordinates of next channels");
00578     RNA_def_property_update(prop, 0, "rna_Material_update");
00579 
00580     prop= RNA_def_property(srna, "specular_color_factor", PROP_FLOAT, PROP_NONE);
00581     RNA_def_property_float_sdna(prop, NULL, "colspecfac");
00582     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00583     RNA_def_property_ui_text(prop, "Specular Color Factor", "Amount texture affects specular color");
00584     RNA_def_property_update(prop, 0, "rna_Material_update");
00585 
00586     prop= RNA_def_property(srna, "diffuse_color_factor", PROP_FLOAT, PROP_NONE);
00587     RNA_def_property_float_sdna(prop, NULL, "colfac");
00588     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00589     RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color");
00590     RNA_def_property_update(prop, 0, "rna_Material_update");
00591 
00592     prop= RNA_def_property(srna, "mirror_factor", PROP_FLOAT, PROP_NONE);
00593     RNA_def_property_float_sdna(prop, NULL, "mirrfac");
00594     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00595     RNA_def_property_ui_text(prop, "Mirror Factor", "Amount texture affects mirror color");
00596     RNA_def_property_update(prop, 0, "rna_Material_update");
00597 
00598     prop= RNA_def_property(srna, "alpha_factor", PROP_FLOAT, PROP_NONE);
00599     RNA_def_property_float_sdna(prop, NULL, "alphafac");
00600     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00601     RNA_def_property_ui_text(prop, "Alpha Factor", "Amount texture affects alpha");
00602     RNA_def_property_update(prop, 0, "rna_Material_update");
00603 
00604     prop= RNA_def_property(srna, "diffuse_factor", PROP_FLOAT, PROP_NONE);
00605     RNA_def_property_float_sdna(prop, NULL, "difffac");
00606     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00607     RNA_def_property_ui_text(prop, "Diffuse Factor", "Amount texture affects diffuse reflectivity");
00608     RNA_def_property_update(prop, 0, "rna_Material_update");
00609 
00610     prop= RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_NONE);
00611     RNA_def_property_float_sdna(prop, NULL, "specfac");
00612     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00613     RNA_def_property_ui_text(prop, "Specular Factor", "Amount texture affects specular reflectivity");
00614     RNA_def_property_update(prop, 0, "rna_Material_update");
00615 
00616     prop= RNA_def_property(srna, "emit_factor", PROP_FLOAT, PROP_NONE);
00617     RNA_def_property_float_sdna(prop, NULL, "emitfac");
00618     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00619     RNA_def_property_ui_text(prop, "Emit Factor", "Amount texture affects emission");
00620     RNA_def_property_update(prop, 0, "rna_Material_update");
00621 
00622     prop= RNA_def_property(srna, "hardness_factor", PROP_FLOAT, PROP_NONE);
00623     RNA_def_property_float_sdna(prop, NULL, "hardfac");
00624     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00625     RNA_def_property_ui_text(prop, "Hardness Factor", "Amount texture affects hardness");
00626     RNA_def_property_update(prop, 0, "rna_Material_update");
00627 
00628     prop= RNA_def_property(srna, "raymir_factor", PROP_FLOAT, PROP_NONE);
00629     RNA_def_property_float_sdna(prop, NULL, "raymirrfac");
00630     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00631     RNA_def_property_ui_text(prop, "Ray Mirror Factor", "Amount texture affects ray mirror");
00632     RNA_def_property_update(prop, 0, "rna_Material_update");
00633 
00634     prop= RNA_def_property(srna, "translucency_factor", PROP_FLOAT, PROP_NONE);
00635     RNA_def_property_float_sdna(prop, NULL, "translfac");
00636     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00637     RNA_def_property_ui_text(prop, "Translucency Factor", "Amount texture affects translucency");
00638     RNA_def_property_update(prop, 0, "rna_Material_update");
00639 
00640     prop= RNA_def_property(srna, "ambient_factor", PROP_FLOAT, PROP_NONE);
00641     RNA_def_property_float_sdna(prop, NULL, "ambfac");
00642     RNA_def_property_ui_range(prop, -1, 1, 10, 3);
00643     RNA_def_property_ui_text(prop, "Ambient Factor", "Amount texture affects ambient");
00644     RNA_def_property_update(prop, 0, "rna_Material_update");
00645 
00646     /* volume material */
00647     prop= RNA_def_property(srna, "use_map_color_emission", PROP_BOOLEAN, PROP_NONE);
00648     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION_COL);
00649     RNA_def_property_ui_text(prop, "Emission Color", "The texture affects the color of emission");
00650     RNA_def_property_update(prop, 0, "rna_Material_update");
00651     
00652     prop= RNA_def_property(srna, "use_map_color_reflection", PROP_BOOLEAN, PROP_NONE);
00653     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION_COL);
00654     RNA_def_property_ui_text(prop, "Reflection Color", "The texture affects the color of scattered light");
00655     RNA_def_property_update(prop, 0, "rna_Material_update");
00656     
00657     prop= RNA_def_property(srna, "use_map_color_transmission", PROP_BOOLEAN, PROP_NONE);
00658     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSMISSION_COL);
00659     RNA_def_property_ui_text(prop, "Transmission Color",
00660                              "The texture affects the result color after other light has been scattered/absorbed");
00661     RNA_def_property_update(prop, NC_TEXTURE, NULL);
00662     
00663     prop= RNA_def_property(srna, "use_map_density", PROP_BOOLEAN, PROP_NONE);
00664     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DENSITY);
00665     RNA_def_property_ui_text(prop, "Density", "The texture affects the volume's density");
00666     RNA_def_property_update(prop, 0, "rna_Material_update");
00667     
00668     prop= RNA_def_property(srna, "use_map_emission", PROP_BOOLEAN, PROP_NONE);
00669     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION);
00670     RNA_def_property_ui_text(prop, "Emission", "The texture affects the volume's emission");
00671     RNA_def_property_update(prop, 0, "rna_Material_update");
00672     
00673     prop= RNA_def_property(srna, "use_map_scatter", PROP_BOOLEAN, PROP_NONE);
00674     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SCATTERING);
00675     RNA_def_property_ui_text(prop, "Scattering", "The texture affects the volume's scattering");
00676     RNA_def_property_update(prop, 0, "rna_Material_update");
00677     
00678     prop= RNA_def_property(srna, "use_map_reflect", PROP_BOOLEAN, PROP_NONE);
00679     RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION);
00680     RNA_def_property_ui_text(prop, "Reflection", "The texture affects the reflected light's brightness");
00681     RNA_def_property_update(prop, NC_TEXTURE, NULL);
00682     
00683     prop= RNA_def_property(srna, "emission_color_factor", PROP_FLOAT, PROP_NONE);
00684     RNA_def_property_float_sdna(prop, NULL, "colemitfac");
00685     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00686     RNA_def_property_ui_text(prop, "Emission Color Factor", "Amount texture affects emission color");
00687     RNA_def_property_update(prop, 0, "rna_Material_update");
00688     
00689     prop= RNA_def_property(srna, "reflection_color_factor", PROP_FLOAT, PROP_NONE);
00690     RNA_def_property_float_sdna(prop, NULL, "colreflfac");
00691     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00692     RNA_def_property_ui_text(prop, "Reflection Color Factor", "Amount texture affects color of out-scattered light");
00693     RNA_def_property_update(prop, 0, "rna_Material_update");
00694     
00695     prop= RNA_def_property(srna, "transmission_color_factor", PROP_FLOAT, PROP_NONE);
00696     RNA_def_property_float_sdna(prop, NULL, "coltransfac");
00697     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00698     RNA_def_property_ui_text(prop, "Transmission Color Factor",
00699                              "Amount texture affects result color after light has been scattered/absorbed");
00700     RNA_def_property_update(prop, NC_TEXTURE, NULL);
00701     
00702     prop= RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE);
00703     RNA_def_property_float_sdna(prop, NULL, "densfac");
00704     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00705     RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects density");
00706     RNA_def_property_update(prop, 0, "rna_Material_update");
00707     
00708     prop= RNA_def_property(srna, "emission_factor", PROP_FLOAT, PROP_NONE);
00709     RNA_def_property_float_sdna(prop, NULL, "emitfac");
00710     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00711     RNA_def_property_ui_text(prop, "Emission Factor", "Amount texture affects emission");
00712     RNA_def_property_update(prop, 0, "rna_Material_update");
00713     
00714     prop= RNA_def_property(srna, "scattering_factor", PROP_FLOAT, PROP_NONE);
00715     RNA_def_property_float_sdna(prop, NULL, "scatterfac");
00716     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00717     RNA_def_property_ui_text(prop, "Scattering Factor", "Amount texture affects scattering");
00718     RNA_def_property_update(prop, 0, "rna_Material_update");
00719                                   
00720     prop= RNA_def_property(srna, "reflection_factor", PROP_FLOAT, PROP_NONE);
00721     RNA_def_property_float_sdna(prop, NULL, "reflfac");
00722     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
00723     RNA_def_property_ui_text(prop, "Reflection Factor", "Amount texture affects brightness of out-scattered light");
00724     RNA_def_property_update(prop, 0, "rna_Material_update");
00725     
00726     /* end volume material */
00727     
00728     prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
00729     RNA_def_property_boolean_funcs(prop, "rna_MaterialTextureSlot_use_get", "rna_MaterialTextureSlot_use_set");
00730     RNA_def_property_ui_text(prop, "Enabled", "Enable this material texture slot");
00731     RNA_def_property_update(prop, 0, "rna_Material_update");
00732 
00733     prop= RNA_def_property(srna, "bump_method", PROP_ENUM, PROP_NONE);
00734     RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag");
00735     RNA_def_property_enum_items(prop, prop_bump_method_items);
00736     RNA_def_property_ui_text(prop, "Bump Method", "Method to use for bump mapping");
00737     RNA_def_property_update(prop, 0, "rna_Material_update");
00738     
00739     prop= RNA_def_property(srna, "bump_objectspace", PROP_ENUM, PROP_NONE);
00740     RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag");
00741     RNA_def_property_enum_items(prop, prop_bump_space_items);
00742     RNA_def_property_ui_text(prop, "Bump Space", "Space to apply bump mapping in");
00743     RNA_def_property_update(prop, 0, "rna_Material_update");
00744 }
00745 
00746 static void rna_def_material_gamesettings(BlenderRNA *brna)
00747 {
00748     StructRNA *srna;
00749     PropertyRNA *prop;
00750 
00751     static EnumPropertyItem prop_alpha_blend_items[] = {
00752         {GEMAT_SOLID, "OPAQUE", 0, "Opaque", "Render color of textured face as color"},
00753         {GEMAT_ADD, "ADD", 0, "Add", "Render face transparent and add color of face"},
00754         {GEMAT_CLIP, "CLIP", 0, "Alpha Clip", "Use the image alpha values clipped with no blending (binary alpha)"},
00755         {GEMAT_ALPHA, "ALPHA", 0, "Alpha Blend", "Render polygon transparent, depending on alpha channel of the texture"},
00756         {GEMAT_ALPHA_SORT, "ALPHA_SORT", 0, "Alpha Sort", "Sort faces for correct alpha drawing (slow, use Alpha Clip instead when possible)"},     
00757         {0, NULL, 0, NULL, NULL}};
00758 
00759     static EnumPropertyItem prop_face_orientation_items[] = {
00760         {GEMAT_NORMAL,"NORMAL",0,"Normal","No tranformation"},
00761         {GEMAT_HALO, "HALO", 0, "Halo", "Screen aligned billboard"},
00762         {GEMAT_BILLBOARD, "BILLBOARD", 0, "Billboard", "Billboard with Z-axis constraint"},
00763         {GEMAT_SHADOW, "SHADOW", 0, "Shadow", "Faces are used for shadow"},     
00764         {0, NULL, 0, NULL, NULL}};
00765     
00766     srna= RNA_def_struct(brna, "MaterialGameSettings", NULL);
00767     RNA_def_struct_sdna(srna, "GameSettings");
00768     RNA_def_struct_nested(brna, srna, "Material");
00769     RNA_def_struct_ui_text(srna, "Material Game Settings", "Game Engine settings for a Material datablock");
00770     
00771     prop= RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
00772     RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_BACKCULL); /* use bitflags */
00773     RNA_def_property_ui_text(prop, "Backface Culling", "Hide Back of the face in Game Engine ");
00774     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00775 
00776     prop= RNA_def_property(srna, "text", PROP_BOOLEAN, PROP_NONE);
00777     RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_TEXT); /* use bitflags */
00778     RNA_def_property_ui_text(prop, "Text", "Use material as text in Game Engine ");
00779     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00780 
00781     prop= RNA_def_property(srna, "invisible", PROP_BOOLEAN, PROP_NONE);
00782     RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_INVISIBLE); /* use bitflags */
00783     RNA_def_property_ui_text(prop, "Invisible", "Make face invisible");
00784     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00785 
00786     prop= RNA_def_property(srna, "alpha_blend", PROP_ENUM, PROP_NONE);
00787     RNA_def_property_enum_sdna(prop, NULL, "alpha_blend");
00788     RNA_def_property_enum_items(prop, prop_alpha_blend_items);
00789     RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces");
00790     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00791 
00792     prop= RNA_def_property(srna, "face_orientation", PROP_ENUM, PROP_NONE);
00793     RNA_def_property_enum_items(prop, prop_face_orientation_items);
00794     RNA_def_property_ui_text(prop, "Face Orientations", "Especial face orientation options");
00795 
00796     prop= RNA_def_property(srna, "physics", PROP_BOOLEAN, PROP_NONE);
00797     RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GEMAT_NOPHYSICS); /* use bitflags */
00798     RNA_def_property_ui_text(prop, "Physics", "Use physics properties of materials ");
00799 }
00800 
00801 static void rna_def_material_colors(StructRNA *srna)
00802 {
00803     PropertyRNA *prop;
00804 
00805     static EnumPropertyItem prop_ramp_input_items[] = {
00806         {MA_RAMP_IN_SHADER, "SHADER", 0, "Shader", ""},
00807         {MA_RAMP_IN_ENERGY, "ENERGY", 0, "Energy", ""},
00808         {MA_RAMP_IN_NOR, "NORMAL", 0, "Normal", ""},
00809         {MA_RAMP_IN_RESULT, "RESULT", 0, "Result", ""},
00810         {0, NULL, 0, NULL, NULL}};
00811 
00812     prop= RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
00813     RNA_def_property_float_sdna(prop, NULL, "r");
00814     RNA_def_property_array(prop, 3);
00815     RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material");
00816     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00817     
00818     prop= RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);
00819     RNA_def_property_float_sdna(prop, NULL, "specr");
00820     RNA_def_property_array(prop, 3);
00821     RNA_def_property_ui_text(prop, "Specular Color", "Specular color of the material");
00822     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00823     
00824     prop= RNA_def_property(srna, "mirror_color", PROP_FLOAT, PROP_COLOR);
00825     RNA_def_property_float_sdna(prop, NULL, "mirr");
00826     RNA_def_property_array(prop, 3);
00827     RNA_def_property_ui_text(prop, "Mirror Color", "Mirror color of the material");
00828     RNA_def_property_update(prop, 0, "rna_Material_update");
00829     
00830     prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
00831     RNA_def_property_range(prop, 0.0f, 1.0f);
00832     RNA_def_property_ui_text(prop, "Alpha", "Alpha transparency of the material");
00833     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00834 
00835     prop= RNA_def_property(srna, "specular_alpha", PROP_FLOAT, PROP_FACTOR);
00836     RNA_def_property_float_sdna(prop, NULL, "spectra");
00837     RNA_def_property_range(prop, 0.0f, 1.0f);
00838     RNA_def_property_ui_text(prop, "Specular Alpha", "Alpha transparency for specular areas");
00839     RNA_def_property_update(prop, 0, "rna_Material_update");
00840     
00841     /* Color bands */
00842     prop= RNA_def_property(srna, "use_diffuse_ramp", PROP_BOOLEAN, PROP_NONE);
00843     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_COL);
00844     RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_diffuse_ramp_set");
00845     RNA_def_property_ui_text(prop, "Use Diffuse Ramp", "Toggle diffuse ramp operations");
00846     RNA_def_property_update(prop, 0, "rna_Material_update");
00847 
00848     prop= RNA_def_property(srna, "diffuse_ramp", PROP_POINTER, PROP_NONE);
00849     RNA_def_property_pointer_sdna(prop, NULL, "ramp_col");
00850     RNA_def_property_struct_type(prop, "ColorRamp");
00851     RNA_def_property_ui_text(prop, "Diffuse Ramp", "Color ramp used to affect diffuse shading");
00852     RNA_def_property_update(prop, 0, "rna_Material_update");
00853 
00854     prop= RNA_def_property(srna, "use_specular_ramp", PROP_BOOLEAN, PROP_NONE);
00855     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_SPEC);
00856     RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_specular_ramp_set");
00857     RNA_def_property_ui_text(prop, "Use Specular Ramp", "Toggle specular ramp operations");
00858     RNA_def_property_update(prop, 0, "rna_Material_update");
00859 
00860     prop= RNA_def_property(srna, "specular_ramp", PROP_POINTER, PROP_NONE);
00861     RNA_def_property_pointer_sdna(prop, NULL, "ramp_spec");
00862     RNA_def_property_struct_type(prop, "ColorRamp");
00863     RNA_def_property_ui_text(prop, "Specular Ramp", "Color ramp used to affect specular shading");
00864     RNA_def_property_update(prop, 0, "rna_Material_update");
00865     
00866     prop= RNA_def_property(srna, "diffuse_ramp_blend", PROP_ENUM, PROP_NONE);
00867     RNA_def_property_enum_sdna(prop, NULL, "rampblend_col");
00868     RNA_def_property_enum_items(prop, ramp_blend_items);
00869     RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "Blending method of the ramp and the diffuse color");
00870     RNA_def_property_update(prop, 0, "rna_Material_update");
00871     
00872     prop= RNA_def_property(srna, "specular_ramp_blend", PROP_ENUM, PROP_NONE);
00873     RNA_def_property_enum_sdna(prop, NULL, "rampblend_spec");
00874     RNA_def_property_enum_items(prop, ramp_blend_items);
00875     RNA_def_property_ui_text(prop, "Specular Ramp Blend", "Blending method of the ramp and the specular color");
00876     RNA_def_property_update(prop, 0, "rna_Material_update");
00877 
00878     prop= RNA_def_property(srna, "diffuse_ramp_input", PROP_ENUM, PROP_NONE);
00879     RNA_def_property_enum_sdna(prop, NULL, "rampin_col");
00880     RNA_def_property_enum_items(prop, prop_ramp_input_items);
00881     RNA_def_property_ui_text(prop, "Diffuse Ramp Input", "How the ramp maps on the surface");
00882     RNA_def_property_update(prop, 0, "rna_Material_update");
00883     
00884     prop= RNA_def_property(srna, "specular_ramp_input", PROP_ENUM, PROP_NONE);
00885     RNA_def_property_enum_sdna(prop, NULL, "rampin_spec");
00886     RNA_def_property_enum_items(prop, prop_ramp_input_items);
00887     RNA_def_property_ui_text(prop, "Specular Ramp Input", "How the ramp maps on the surface");
00888     RNA_def_property_update(prop, 0, "rna_Material_update");
00889 
00890     prop= RNA_def_property(srna, "diffuse_ramp_factor", PROP_FLOAT, PROP_FACTOR);
00891     RNA_def_property_float_sdna(prop, NULL, "rampfac_col");
00892     RNA_def_property_range(prop, 0.0f, 1.0f);
00893     RNA_def_property_ui_text(prop, "Diffuse Ramp Factor", "Blending factor (also uses alpha in Colorband)");
00894     RNA_def_property_update(prop, 0, "rna_Material_update");
00895 
00896     prop= RNA_def_property(srna, "specular_ramp_factor", PROP_FLOAT, PROP_FACTOR);
00897     RNA_def_property_float_sdna(prop, NULL, "rampfac_spec");
00898     RNA_def_property_range(prop, 0.0f, 1.0f);
00899     RNA_def_property_ui_text(prop, "Specular Ramp Factor", "Blending factor (also uses alpha in Colorband)");
00900     RNA_def_property_update(prop, 0, "rna_Material_update");
00901 }
00902 
00903 static void rna_def_material_diffuse(StructRNA *srna)
00904 {
00905     PropertyRNA *prop;
00906 
00907     static EnumPropertyItem prop_diff_shader_items[] = {
00908         {MA_DIFF_LAMBERT, "LAMBERT", 0, "Lambert", "Use a Lambertian shader"},
00909         {MA_DIFF_ORENNAYAR, "OREN_NAYAR", 0, "Oren-Nayar", "Use an Oren-Nayar shader"},
00910         {MA_DIFF_TOON, "TOON", 0, "Toon", "Use a toon shader"},
00911         {MA_DIFF_MINNAERT, "MINNAERT", 0, "Minnaert", "Use a Minnaert shader"},
00912         {MA_DIFF_FRESNEL, "FRESNEL", 0, "Fresnel", "Use a Fresnel shader"},
00913         {0, NULL, 0, NULL, NULL}};
00914     
00915     prop= RNA_def_property(srna, "diffuse_shader", PROP_ENUM, PROP_NONE);
00916     RNA_def_property_enum_sdna(prop, NULL, "diff_shader");
00917     RNA_def_property_enum_items(prop, prop_diff_shader_items);
00918     RNA_def_property_ui_text(prop, "Diffuse Shader Model", "");
00919     RNA_def_property_update(prop, 0, "rna_Material_update");
00920     
00921     prop= RNA_def_property(srna, "diffuse_intensity", PROP_FLOAT, PROP_FACTOR);
00922     RNA_def_property_float_sdna(prop, NULL, "ref");
00923     RNA_def_property_range(prop, 0.0f, 1.0f);
00924     RNA_def_property_ui_text(prop, "Diffuse Intensity", "Amount of diffuse reflection");
00925     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
00926     
00927     prop= RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_NONE);
00928     RNA_def_property_range(prop, 0.0f, 3.14f);
00929     RNA_def_property_ui_text(prop, "Roughness", "Oren-Nayar Roughness");
00930     RNA_def_property_update(prop, 0, "rna_Material_update");
00931 
00932     prop= RNA_def_property(srna, "diffuse_toon_size", PROP_FLOAT, PROP_NONE);
00933     RNA_def_property_float_sdna(prop, NULL, "param[0]");
00934     RNA_def_property_range(prop, 0.0f, 3.14f);
00935     RNA_def_property_ui_text(prop, "Diffuse Toon Size", "Size of diffuse toon area");
00936     RNA_def_property_update(prop, 0, "rna_Material_update");
00937 
00938     prop= RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_FACTOR);
00939     RNA_def_property_float_sdna(prop, NULL, "param[1]");
00940     RNA_def_property_range(prop, 0.0f, 1.0f);
00941     RNA_def_property_ui_text(prop, "Diffuse Toon Smooth", "Smoothness of diffuse toon area");
00942     RNA_def_property_update(prop, 0, "rna_Material_update");
00943 
00944     prop= RNA_def_property(srna, "diffuse_fresnel", PROP_FLOAT, PROP_NONE);
00945     RNA_def_property_float_sdna(prop, NULL, "param[1]");
00946     RNA_def_property_range(prop, 0.0f, 5.0f);
00947     RNA_def_property_ui_text(prop, "Diffuse Fresnel", "Power of Fresnel");
00948     RNA_def_property_update(prop, 0, "rna_Material_update");
00949 
00950     prop= RNA_def_property(srna, "diffuse_fresnel_factor", PROP_FLOAT, PROP_NONE);
00951     RNA_def_property_float_sdna(prop, NULL, "param[0]");
00952     RNA_def_property_range(prop, 0.0f, 5.0f);
00953     RNA_def_property_ui_text(prop, "Diffuse Fresnel Factor", "Blending factor of Fresnel");
00954     RNA_def_property_update(prop, 0, "rna_Material_update");
00955     
00956     prop= RNA_def_property(srna, "darkness", PROP_FLOAT, PROP_NONE);
00957     RNA_def_property_range(prop, 0.0f, 2.0f);
00958     RNA_def_property_ui_text(prop, "Darkness", "Minnaert darkness");
00959     RNA_def_property_update(prop, 0, "rna_Material_update");
00960 }
00961 
00962 static void rna_def_material_raymirror(BlenderRNA *brna)
00963 {
00964     StructRNA *srna;
00965     PropertyRNA *prop;
00966 
00967     static EnumPropertyItem prop_fadeto_mir_items[] = {
00968         {MA_RAYMIR_FADETOSKY, "FADE_TO_SKY", 0, "Sky", ""},
00969         {MA_RAYMIR_FADETOMAT, "FADE_TO_MATERIAL", 0, "Material", ""},
00970         {0, NULL, 0, NULL, NULL}};
00971 
00972     srna= RNA_def_struct(brna, "MaterialRaytraceMirror", NULL);
00973     RNA_def_struct_sdna(srna, "Material");
00974     RNA_def_struct_nested(brna, srna, "Material");
00975     RNA_def_struct_ui_text(srna, "Material Raytrace Mirror", "Raytraced reflection settings for a Material datablock");
00976 
00977     prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
00978     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYMIRROR); /* use bitflags */
00979     RNA_def_property_ui_text(prop, "Enabled", "Enable raytraced reflections");
00980     RNA_def_property_update(prop, 0, "rna_Material_update");
00981         
00982     prop= RNA_def_property(srna, "reflect_factor", PROP_FLOAT, PROP_FACTOR);
00983     RNA_def_property_float_sdna(prop, NULL, "ray_mirror");
00984     RNA_def_property_range(prop, 0.0f, 1.0f);
00985     RNA_def_property_ui_text(prop, "Reflectivity", "Amount of mirror reflection for raytrace");
00986     RNA_def_property_update(prop, 0, "rna_Material_update");
00987     
00988     prop= RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE);
00989     RNA_def_property_float_sdna(prop, NULL, "fresnel_mir");
00990     RNA_def_property_range(prop, 0.0f, 5.0f);
00991     RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for mirror reflection");
00992     RNA_def_property_update(prop, 0, "rna_Material_update");
00993     
00994     prop= RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR);
00995     RNA_def_property_float_sdna(prop, NULL, "fresnel_mir_i");
00996     RNA_def_property_range(prop, 0.0f, 5.0f);
00997     RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel");
00998     RNA_def_property_update(prop, 0, "rna_Material_update");
00999     
01000     prop= RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR);
01001     RNA_def_property_float_sdna(prop, NULL, "gloss_mir");
01002     RNA_def_property_range(prop, 0.0f, 1.0f);
01003     RNA_def_property_ui_text(prop, "Gloss Amount",
01004                              "The shininess of the reflection (values < 1.0 give diffuse, blurry reflections)");
01005     RNA_def_property_update(prop, 0, "rna_Material_update");
01006     
01007     prop= RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_FACTOR);
01008     RNA_def_property_float_sdna(prop, NULL, "aniso_gloss_mir");
01009     RNA_def_property_range(prop, 0.0f, 1.0f);
01010     RNA_def_property_ui_text(prop, "Gloss Anisotropy",
01011                              "The shape of the reflection, from 0.0 (circular) to 1.0 (fully stretched along the tangent");
01012     RNA_def_property_update(prop, 0, "rna_Material_update");
01013         
01014     prop= RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE);
01015     RNA_def_property_int_sdna(prop, NULL, "samp_gloss_mir");
01016     RNA_def_property_range(prop, 0, 1024);
01017     RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry reflections");
01018     RNA_def_property_update(prop, 0, "rna_Material_update");
01019     
01020     prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR);
01021     RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_mir");
01022     RNA_def_property_range(prop, 0.0f, 1.0f);
01023     RNA_def_property_ui_text(prop, "Gloss Threshold",
01024                              "Threshold for adaptive sampling (if a sample contributes less than "
01025                              "this amount [as a percentage], sampling is stopped)");
01026     RNA_def_property_update(prop, 0, "rna_Material_update");
01027     
01028     prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
01029     RNA_def_property_int_sdna(prop, NULL, "ray_depth");
01030     RNA_def_property_ui_range(prop, 0, 100, 1, 3);
01031     RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-reflections");
01032     RNA_def_property_update(prop, 0, "rna_Material_update");
01033     
01034     prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
01035     RNA_def_property_float_sdna(prop, NULL, "dist_mir");
01036     RNA_def_property_range(prop, 0.0f, 10000.0f);
01037     RNA_def_property_ui_text(prop, "Maximum Distance",
01038                              "Maximum distance of reflected rays (reflections further than this "
01039                              "range fade to sky color or material color)");
01040     RNA_def_property_update(prop, 0, "rna_Material_update");
01041     
01042     prop= RNA_def_property(srna, "fade_to", PROP_ENUM, PROP_NONE);
01043     RNA_def_property_enum_sdna(prop, NULL, "fadeto_mir");
01044     RNA_def_property_enum_items(prop, prop_fadeto_mir_items);
01045     RNA_def_property_ui_text(prop, "Fade-out Color",
01046                              "The color that rays with no intersection within the Max Distance take "
01047                              "(material color can be best for indoor scenes, sky color for outdoor)");
01048     RNA_def_property_update(prop, 0, "rna_Material_update");
01049 }
01050 
01051 static void rna_def_material_raytra(BlenderRNA *brna)
01052 {
01053     StructRNA *srna;
01054     PropertyRNA *prop;
01055 
01056     srna= RNA_def_struct(brna, "MaterialRaytraceTransparency", NULL);
01057     RNA_def_struct_sdna(srna, "Material");
01058     RNA_def_struct_nested(brna, srna, "Material");
01059     RNA_def_struct_ui_text(srna, "Material Raytrace Transparency", "Raytraced refraction settings for a Material datablock");
01060 
01061     prop= RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE);
01062     RNA_def_property_float_sdna(prop, NULL, "ang");
01063     RNA_def_property_range(prop, 0.25f, 4.0f);
01064     RNA_def_property_ui_text(prop, "IOR", "Angular index of refraction for raytraced refraction");
01065     RNA_def_property_update(prop, 0, "rna_Material_update");
01066     
01067     prop= RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE);
01068     RNA_def_property_float_sdna(prop, NULL, "fresnel_tra");
01069     RNA_def_property_range(prop, 0.0f, 5.0f);
01070     RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for transparency (Ray or ZTransp)");
01071     RNA_def_property_update(prop, 0, "rna_Material_update");
01072     
01073     prop= RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR);
01074     RNA_def_property_float_sdna(prop, NULL, "fresnel_tra_i");
01075     RNA_def_property_range(prop, 1.0f, 5.0f);
01076     RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel");
01077     RNA_def_property_update(prop, 0, "rna_Material_update");
01078     
01079     prop= RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR);
01080     RNA_def_property_float_sdna(prop, NULL, "gloss_tra");
01081     RNA_def_property_range(prop, 0.0f, 1.0f);
01082     RNA_def_property_ui_text(prop, "Gloss Amount",
01083                              "The clarity of the refraction. Values < 1.0 give diffuse, blurry refractions");
01084     RNA_def_property_update(prop, 0, "rna_Material_update");
01085     
01086     prop= RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE);
01087     RNA_def_property_int_sdna(prop, NULL, "samp_gloss_tra");
01088     RNA_def_property_range(prop, 0, 1024);
01089     RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry refractions");
01090     RNA_def_property_update(prop, 0, "rna_Material_update");
01091     
01092     prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR);
01093     RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_tra");
01094     RNA_def_property_range(prop, 0.0f, 1.0f);
01095     RNA_def_property_ui_text(prop, "Gloss Threshold",
01096                              "Threshold for adaptive sampling. If a sample contributes less than "
01097                              "this amount (as a percentage), sampling is stopped");
01098     RNA_def_property_update(prop, 0, "rna_Material_update");
01099     
01100     prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
01101     RNA_def_property_int_sdna(prop, NULL, "ray_depth_tra");
01102     RNA_def_property_ui_range(prop, 0, 100, 1, 3);
01103     RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-refractions");
01104     RNA_def_property_update(prop, 0, "rna_Material_update");
01105     
01106     prop= RNA_def_property(srna, "filter", PROP_FLOAT, PROP_FACTOR);
01107     RNA_def_property_float_sdna(prop, NULL, "filter");
01108     RNA_def_property_range(prop, 0.0f, 1.0f);
01109     RNA_def_property_ui_text(prop, "Filter",
01110                              "Amount to blend in the material's diffuse color in raytraced "
01111                              "transparency (simulating absorption)");
01112     RNA_def_property_update(prop, 0, "rna_Material_update");
01113     
01114     prop= RNA_def_property(srna, "depth_max", PROP_FLOAT, PROP_DISTANCE);
01115     RNA_def_property_float_sdna(prop, NULL, "tx_limit");
01116     RNA_def_property_range(prop, 0.0f, 100.0f);
01117     RNA_def_property_ui_text(prop, "Limit",
01118                              "Maximum depth for light to travel through the transparent material "
01119                              "before becoming fully filtered (0.0 is disabled)");
01120     RNA_def_property_update(prop, 0, "rna_Material_update");
01121     
01122     prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
01123     RNA_def_property_float_sdna(prop, NULL, "tx_falloff");
01124     RNA_def_property_range(prop, 0.1f, 10.0f);
01125     RNA_def_property_ui_text(prop, "Falloff", "Falloff power for transmissivity filter effect (1.0 is linear)");
01126     RNA_def_property_update(prop, 0, "rna_Material_update");
01127 }
01128 
01129 static void rna_def_material_volume(BlenderRNA *brna)
01130 {
01131     StructRNA *srna;
01132     PropertyRNA *prop;
01133 
01134     static EnumPropertyItem prop_lighting_items[] = {
01135         {MA_VOL_SHADE_SHADELESS, "SHADELESS", 0, "Shadeless", "Do not calculate lighting and shadows"},
01136         {MA_VOL_SHADE_SHADOWED, "SHADOWED", 0, "Shadowed", ""},
01137         {MA_VOL_SHADE_SHADED, "SHADED", 0, "Shaded", ""},
01138         {MA_VOL_SHADE_MULTIPLE, "MULTIPLE_SCATTERING", 0, "Multiple Scattering", ""},
01139         {MA_VOL_SHADE_SHADEDPLUSMULTIPLE, "SHADED_PLUS_MULTIPLE_SCATTERING", 0, "Shaded + Multiple Scattering", ""},
01140         {0, NULL, 0, NULL, NULL}};
01141 
01142     static EnumPropertyItem prop_stepsize_items[] = {
01143         {MA_VOL_STEP_RANDOMIZED, "RANDOMIZED", 0, "Randomized", ""},
01144         {MA_VOL_STEP_CONSTANT, "CONSTANT", 0, "Constant", ""},
01145         //{MA_VOL_STEP_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", ""},
01146         {0, NULL, 0, NULL, NULL}};
01147         
01148     srna= RNA_def_struct(brna, "MaterialVolume", NULL);
01149     RNA_def_struct_sdna(srna, "VolumeSettings");
01150     RNA_def_struct_nested(brna, srna, "Material");
01151     RNA_def_struct_ui_text(srna, "Material Volume", "Volume rendering settings for a Material datablock");
01152     
01153     prop= RNA_def_property(srna, "step_method", PROP_ENUM, PROP_NONE);
01154     RNA_def_property_enum_sdna(prop, NULL, "stepsize_type");
01155     RNA_def_property_enum_items(prop, prop_stepsize_items);
01156     RNA_def_property_ui_text(prop, "Step Calculation", "Method of calculating the steps through the volume");
01157     RNA_def_property_update(prop, 0, "rna_Material_update");
01158     
01159     prop= RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_NONE);
01160     RNA_def_property_float_sdna(prop, NULL, "stepsize");
01161     RNA_def_property_range(prop, 0.0f, FLT_MAX);
01162     RNA_def_property_ui_range(prop, 0.001f, 1.0f, 1, 3);
01163     RNA_def_property_ui_text(prop, "Step Size", "Distance between subsequent volume depth samples");
01164     RNA_def_property_update(prop, 0, "rna_Material_update");
01165     
01166     prop= RNA_def_property(srna, "light_method", PROP_ENUM, PROP_NONE);
01167     RNA_def_property_enum_sdna(prop, NULL, "shade_type");
01168     RNA_def_property_enum_items(prop, prop_lighting_items);
01169     RNA_def_property_ui_text(prop, "Lighting Mode", "Method of shading, attenuating, and scattering light through the volume");
01170     RNA_def_property_update(prop, 0, "rna_Material_update");
01171     
01172     prop= RNA_def_property(srna, "use_external_shadows", PROP_BOOLEAN, PROP_NONE);
01173     RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_RECV_EXT_SHADOW); /* use bitflags */
01174     RNA_def_property_ui_text(prop, "External Shadows", "Receive shadows from sources outside the volume (temporary)");
01175     RNA_def_property_update(prop, 0, "rna_Material_update");
01176     
01177     prop= RNA_def_property(srna, "use_light_cache", PROP_BOOLEAN, PROP_NONE);
01178     RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_PRECACHESHADING); /* use bitflags */
01179     RNA_def_property_ui_text(prop, "Light Cache",
01180                              "Pre-calculate the shading information into a voxel grid, "
01181                              "speeds up shading at slightly less accuracy");
01182     RNA_def_property_update(prop, 0, "rna_Material_update");
01183     
01184     prop= RNA_def_property(srna, "cache_resolution", PROP_INT, PROP_NONE);
01185     RNA_def_property_int_sdna(prop, NULL, "precache_resolution");
01186     RNA_def_property_range(prop, 1, 1024);
01187     RNA_def_property_ui_text(prop, "Resolution",
01188                              "Resolution of the voxel grid, low resolutions are faster, high resolutions use more memory");
01189     RNA_def_property_update(prop, 0, "rna_Material_update");
01190     
01191     prop= RNA_def_property(srna, "ms_diffusion", PROP_FLOAT, PROP_NONE);
01192     RNA_def_property_float_sdna(prop, NULL, "ms_diff");
01193     RNA_def_property_range(prop, 0.0f, FLT_MAX);
01194     RNA_def_property_ui_text(prop, "Diffusion", "Diffusion factor, the strength of the blurring effect");
01195     RNA_def_property_update(prop, 0, "rna_Material_update");
01196     
01197     prop= RNA_def_property(srna, "ms_spread", PROP_FLOAT, PROP_NONE);
01198     RNA_def_property_float_sdna(prop, NULL, "ms_spread");
01199     RNA_def_property_range(prop, 0, FLT_MAX);
01200     RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
01201     RNA_def_property_ui_text(prop, "Spread", "Proportional distance over which the light is diffused");
01202     RNA_def_property_update(prop, 0, "rna_Material_update");
01203     
01204     prop= RNA_def_property(srna, "ms_intensity", PROP_FLOAT, PROP_NONE);
01205     RNA_def_property_float_sdna(prop, NULL, "ms_intensity");
01206     RNA_def_property_range(prop, 0.0f, FLT_MAX);
01207     RNA_def_property_ui_text(prop, "Intensity", "Multiplier for multiple scattered light energy");
01208     RNA_def_property_update(prop, 0, "rna_Material_update");
01209     
01210     prop= RNA_def_property(srna, "depth_threshold", PROP_FLOAT, PROP_NONE);
01211     RNA_def_property_float_sdna(prop, NULL, "depth_cutoff");
01212     RNA_def_property_range(prop, 0.0f, 1.0f);
01213     RNA_def_property_ui_text(prop, "Depth Cutoff",
01214                              "Stop ray marching early if transmission drops below this luminance - "
01215                              "higher values give speedups in dense volumes at the expense of accuracy");
01216     RNA_def_property_update(prop, 0, "rna_Material_update");
01217     
01218     prop= RNA_def_property(srna, "density", PROP_FLOAT, PROP_FACTOR);
01219     RNA_def_property_float_sdna(prop, NULL, "density");
01220     RNA_def_property_range(prop, 0.0f, 1.0f);
01221     RNA_def_property_ui_text(prop, "Density", "The base density of the volume");
01222     RNA_def_property_update(prop, 0, "rna_Material_update");
01223 
01224     prop= RNA_def_property(srna, "density_scale", PROP_FLOAT, PROP_NONE);
01225     RNA_def_property_float_sdna(prop, NULL, "density_scale");
01226     RNA_def_property_range(prop, 0.0f, FLT_MAX);
01227     RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
01228     RNA_def_property_ui_text(prop, "Density Scale", "Multiplier for the material's density");
01229     RNA_def_property_update(prop, 0, "rna_Material_update");
01230     
01231     prop= RNA_def_property(srna, "scattering", PROP_FLOAT, PROP_NONE);
01232     RNA_def_property_float_sdna(prop, NULL, "scattering");
01233     RNA_def_property_range(prop, 0.0f, FLT_MAX);
01234     RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1 ,3);
01235     RNA_def_property_ui_text(prop, "Scattering",
01236                              "Amount of light that gets scattered out by the volume - "
01237                              "the more out-scattering, the shallower the light will penetrate");
01238     RNA_def_property_update(prop, 0, "rna_Material_update");
01239     
01240     prop= RNA_def_property(srna, "transmission_color", PROP_FLOAT, PROP_COLOR);
01241     RNA_def_property_float_sdna(prop, NULL, "transmission_col");
01242     RNA_def_property_array(prop, 3);
01243     RNA_def_property_ui_text(prop, "Transmission Color",
01244                              "Result color of the volume, after other light has been scattered/absorbed");
01245     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01246     
01247     prop= RNA_def_property(srna, "reflection_color", PROP_FLOAT, PROP_COLOR);
01248     RNA_def_property_float_sdna(prop, NULL, "reflection_col");
01249     RNA_def_property_array(prop, 3);
01250     RNA_def_property_ui_text(prop, "Reflection Color",
01251                              "Color of light scattered out of the volume (does not affect transmission)");
01252     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01253     
01254     prop= RNA_def_property(srna, "reflection", PROP_FLOAT, PROP_NONE);
01255     RNA_def_property_float_sdna(prop, NULL, "reflection");
01256     RNA_def_property_range(prop, 0.0f, FLT_MAX);
01257     RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1 ,3);
01258     RNA_def_property_ui_text(prop, "Reflection",
01259                              "Multiplier to make out-scattered light brighter or darker (non-physically correct)");
01260     RNA_def_property_update(prop, 0, "rna_Material_update");
01261     
01262     prop= RNA_def_property(srna, "emission_color", PROP_FLOAT, PROP_COLOR);
01263     RNA_def_property_float_sdna(prop, NULL, "emission_col");
01264     RNA_def_property_array(prop, 3);
01265     RNA_def_property_ui_text(prop, "Emission Color", "Color of emitted light");
01266     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01267     
01268     prop= RNA_def_property(srna, "emission", PROP_FLOAT, PROP_NONE);
01269     RNA_def_property_float_sdna(prop, NULL, "emission");
01270     RNA_def_property_range(prop, 0.0f, FLT_MAX);
01271     RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
01272     RNA_def_property_ui_text(prop, "Emission", "Amount of light that gets emitted by the volume");
01273     RNA_def_property_update(prop, 0, "rna_Material_update");
01274         
01275     prop= RNA_def_property(srna, "asymmetry", PROP_FLOAT, PROP_NONE);
01276     RNA_def_property_float_sdna(prop, NULL, "asymmetry");
01277     RNA_def_property_range(prop, -1.0f, 1.0f);
01278     RNA_def_property_ui_text(prop, "Asymmetry", "Back scattering (-1.0) to Forward scattering (1.0) and the range in between");
01279     RNA_def_property_update(prop, 0, "rna_Material_update");
01280 }
01281 
01282 
01283 static void rna_def_material_halo(BlenderRNA *brna)
01284 {
01285     StructRNA *srna;
01286     PropertyRNA *prop;
01287 
01288     srna= RNA_def_struct(brna, "MaterialHalo", NULL);
01289     RNA_def_struct_sdna(srna, "Material");
01290     RNA_def_struct_nested(brna, srna, "Material");
01291     RNA_def_struct_ui_text(srna, "Material Halo", "Halo particle effect settings for a Material datablock");
01292 
01293     prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
01294     RNA_def_property_float_sdna(prop, NULL, "hasize");
01295     RNA_def_property_range(prop, 0.0f, 100.0f);
01296     RNA_def_property_ui_text(prop, "Size", "Dimension of the halo");
01297     RNA_def_property_update(prop, 0, "rna_Material_update");
01298     
01299     prop= RNA_def_property(srna, "hardness", PROP_INT, PROP_NONE);
01300     RNA_def_property_int_sdna(prop, NULL, "har");
01301     RNA_def_property_range(prop, 0, 127);
01302     RNA_def_property_ui_text(prop, "Hardness", "Hardness of the halo");
01303     RNA_def_property_update(prop, 0, "rna_Material_update");
01304     
01305     prop= RNA_def_property(srna, "add", PROP_FLOAT, PROP_FACTOR);
01306     RNA_def_property_float_sdna(prop, NULL, "add");
01307     RNA_def_property_range(prop, 0.0f, 1.0f);
01308     RNA_def_property_ui_text(prop, "Add", "Strength of the add effect");
01309     RNA_def_property_update(prop, 0, "rna_Material_update");
01310     
01311     prop= RNA_def_property(srna, "ring_count", PROP_INT, PROP_NONE);
01312     RNA_def_property_int_sdna(prop, NULL, "ringc");
01313     RNA_def_property_range(prop, 0, 24);
01314     RNA_def_property_ui_text(prop, "Rings", "Number of rings rendered over the halo");
01315     RNA_def_property_update(prop, 0, "rna_Material_update");
01316     
01317     prop= RNA_def_property(srna, "line_count", PROP_INT, PROP_NONE);
01318     RNA_def_property_int_sdna(prop, NULL, "linec");
01319     RNA_def_property_range(prop, 0, 250);
01320     RNA_def_property_ui_text(prop, "Line Number", "Number of star shaped lines rendered over the halo");
01321     RNA_def_property_update(prop, 0, "rna_Material_update");
01322     
01323     prop= RNA_def_property(srna, "star_tip_count", PROP_INT, PROP_NONE);
01324     RNA_def_property_int_sdna(prop, NULL, "starc");
01325     RNA_def_property_range(prop, 3, 50);
01326     RNA_def_property_ui_text(prop, "Star Tips", "Number of points on the star shaped halo");
01327     RNA_def_property_update(prop, 0, "rna_Material_update");
01328     
01329     prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
01330     RNA_def_property_int_sdna(prop, NULL, "seed1");
01331     RNA_def_property_range(prop, 0, 255);
01332     RNA_def_property_ui_text(prop, "Seed", "Randomize ring dimension and line location");
01333     RNA_def_property_update(prop, 0, "rna_Material_update");
01334     
01335     prop= RNA_def_property(srna, "use_flare_mode", PROP_BOOLEAN, PROP_NONE);
01336     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_FLARE); /* use bitflags */
01337     RNA_def_property_ui_text(prop, "Flare", "Render halo as a lens flare");
01338     RNA_def_property_update(prop, 0, "rna_Material_update");
01339     
01340     prop= RNA_def_property(srna, "flare_size", PROP_FLOAT, PROP_NONE);
01341     RNA_def_property_float_sdna(prop, NULL, "flaresize");
01342     RNA_def_property_range(prop, 0.1f, 25.0f);
01343     RNA_def_property_ui_text(prop, "Flare Size", "Factor by which the flare is larger than the halo");
01344     RNA_def_property_update(prop, 0, "rna_Material_update");
01345     
01346     prop= RNA_def_property(srna, "flare_subflare_size", PROP_FLOAT, PROP_NONE);
01347     RNA_def_property_float_sdna(prop, NULL, "subsize");
01348     RNA_def_property_range(prop, 0.1f, 25.0f);
01349     RNA_def_property_ui_text(prop, "Flare Subsize", "Dimension of the sub-flares, dots and circles");
01350     RNA_def_property_update(prop, 0, "rna_Material_update");
01351     
01352     prop= RNA_def_property(srna, "flare_boost", PROP_FLOAT, PROP_NONE);
01353     RNA_def_property_float_sdna(prop, NULL, "flareboost");
01354     RNA_def_property_range(prop, 0.1f, 10.0f);
01355     RNA_def_property_ui_text(prop, "Flare Boost", "Give the flare extra strength");
01356     RNA_def_property_update(prop, 0, "rna_Material_update");
01357     
01358     prop= RNA_def_property(srna, "flare_seed", PROP_INT, PROP_NONE);
01359     RNA_def_property_int_sdna(prop, NULL, "seed2");
01360     RNA_def_property_range(prop, 0, 255);
01361     RNA_def_property_ui_text(prop, "Flare Seed", "Offset in the flare seed table");
01362     RNA_def_property_update(prop, 0, "rna_Material_update");
01363     
01364     prop= RNA_def_property(srna, "flare_subflare_count", PROP_INT, PROP_NONE);
01365     RNA_def_property_int_sdna(prop, NULL, "flarec");
01366     RNA_def_property_range(prop, 1, 32);
01367     RNA_def_property_ui_text(prop, "Flares Sub", "Number of sub-flares");
01368     RNA_def_property_update(prop, 0, "rna_Material_update");
01369     
01370     prop= RNA_def_property(srna, "use_ring", PROP_BOOLEAN, PROP_NONE);
01371     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_RINGS);
01372     RNA_def_property_ui_text(prop, "Rings", "Render rings over halo");
01373     RNA_def_property_update(prop, 0, "rna_Material_update");
01374     
01375     prop= RNA_def_property(srna, "use_lines", PROP_BOOLEAN, PROP_NONE);
01376     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_LINES);
01377     RNA_def_property_ui_text(prop, "Lines", "Render star shaped lines over halo");
01378     RNA_def_property_update(prop, 0, "rna_Material_update");
01379     
01380     prop= RNA_def_property(srna, "use_star", PROP_BOOLEAN, PROP_NONE);
01381     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STAR);
01382     RNA_def_property_ui_text(prop, "Star", "Render halo as a star");
01383     RNA_def_property_update(prop, 0, "rna_Material_update");
01384     
01385     prop= RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
01386     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOTEX);
01387     RNA_def_property_ui_text(prop, "Texture", "Give halo a texture");
01388     RNA_def_property_update(prop, 0, "rna_Material_update");
01389     
01390     prop= RNA_def_property(srna, "use_vertex_normal", PROP_BOOLEAN, PROP_NONE);
01391     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOPUNO);
01392     RNA_def_property_ui_text(prop, "Vertex Normal", "Use the vertex normal to specify the dimension of the halo");
01393     RNA_def_property_update(prop, 0, "rna_Material_update");
01394     
01395     prop= RNA_def_property(srna, "use_extreme_alpha", PROP_BOOLEAN, PROP_NONE);
01396     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_XALPHA);
01397     RNA_def_property_ui_text(prop, "Extreme Alpha", "Use extreme alpha");
01398     RNA_def_property_update(prop, 0, "rna_Material_update");
01399     
01400     prop= RNA_def_property(srna, "use_shaded", PROP_BOOLEAN, PROP_NONE);
01401     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SHADE);
01402     RNA_def_property_ui_text(prop, "Shaded", "Let halo receive light and shadows from external objects");
01403     RNA_def_property_update(prop, 0, "rna_Material_update");
01404     
01405     prop= RNA_def_property(srna, "use_soft", PROP_BOOLEAN, PROP_NONE);
01406     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SOFT);
01407     RNA_def_property_ui_text(prop, "Soft", "Soften the edges of halos at intersections with other geometry");
01408     RNA_def_property_update(prop, 0, "rna_Material_update");
01409 }
01410 
01411 static void rna_def_material_sss(BlenderRNA *brna)
01412 {
01413     StructRNA *srna;
01414     PropertyRNA *prop;
01415 
01416     srna= RNA_def_struct(brna, "MaterialSubsurfaceScattering", NULL);
01417     RNA_def_struct_sdna(srna, "Material");
01418     RNA_def_struct_nested(brna, srna, "Material");
01419     RNA_def_struct_ui_text(srna, "Material Subsurface Scattering",
01420                            "Diffuse subsurface scattering settings for a Material datablock");
01421 
01422     prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_COLOR|PROP_UNIT_LENGTH);
01423     RNA_def_property_float_sdna(prop, NULL, "sss_radius");
01424     RNA_def_property_range(prop, 0.001, FLT_MAX);
01425     RNA_def_property_ui_range(prop, 0.001, 10000, 1, 3);
01426     RNA_def_property_ui_text(prop, "Radius", "Mean red/green/blue scattering path length");
01427     RNA_def_property_update(prop, 0, "rna_Material_update");
01428 
01429     prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
01430     RNA_def_property_float_sdna(prop, NULL, "sss_col");
01431     RNA_def_property_ui_text(prop, "Color", "Scattering color");
01432     RNA_def_property_update(prop, 0, "rna_Material_update");
01433 
01434     prop= RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE);
01435     RNA_def_property_float_sdna(prop, NULL, "sss_error");
01436     RNA_def_property_ui_range(prop, 0.0001, 10, 1, 3);
01437     RNA_def_property_ui_text(prop, "Error Tolerance", "Error tolerance (low values are slower and higher quality)");
01438     RNA_def_property_update(prop, 0, "rna_Material_update");
01439 
01440     prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
01441     RNA_def_property_float_sdna(prop, NULL, "sss_scale");
01442     RNA_def_property_ui_range(prop, 0.001, 1000, 1, 3);
01443     RNA_def_property_ui_text(prop, "Scale", "Object scale factor");
01444     RNA_def_property_update(prop, 0, "rna_Material_update");
01445 
01446     prop= RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE);
01447     RNA_def_property_float_sdna(prop, NULL, "sss_ior");
01448     RNA_def_property_ui_range(prop, 0.1, 2, 1, 3);
01449     RNA_def_property_ui_text(prop, "IOR", "Index of refraction (higher values are denser)");
01450     RNA_def_property_update(prop, 0, "rna_Material_update");
01451 
01452     prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_FACTOR);
01453     RNA_def_property_float_sdna(prop, NULL, "sss_colfac");
01454     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
01455     RNA_def_property_ui_text(prop, "Color Factor", "Blend factor for SSS colors");
01456     RNA_def_property_update(prop, 0, "rna_Material_update");
01457 
01458     prop= RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_FACTOR);
01459     RNA_def_property_float_sdna(prop, NULL, "sss_texfac");
01460     RNA_def_property_ui_range(prop, 0, 1, 10, 3);
01461     RNA_def_property_ui_text(prop, "Texture Factor", "Texture scattering blend factor");
01462     RNA_def_property_update(prop, 0, "rna_Material_update");
01463 
01464     prop= RNA_def_property(srna, "front", PROP_FLOAT, PROP_NONE);
01465     RNA_def_property_float_sdna(prop, NULL, "sss_front");
01466     RNA_def_property_range(prop, 0, 2);
01467     RNA_def_property_ui_text(prop, "Front", "Front scattering weight");
01468     RNA_def_property_update(prop, 0, "rna_Material_update");
01469 
01470     prop= RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE);
01471     RNA_def_property_float_sdna(prop, NULL, "sss_back");
01472     RNA_def_property_range(prop, 0, 10);
01473     RNA_def_property_ui_text(prop, "Back", "Back scattering weight");
01474     RNA_def_property_update(prop, 0, "rna_Material_update");
01475 
01476     prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
01477     RNA_def_property_boolean_sdna(prop, NULL, "sss_flag", MA_DIFF_SSS);
01478     RNA_def_property_ui_text(prop, "Enabled", "Enable diffuse subsurface scatting effects in a material");
01479     RNA_def_property_update(prop, 0, "rna_Material_update");
01480 }
01481 
01482 static void rna_def_material_specularity(StructRNA *srna)
01483 {
01484     PropertyRNA *prop;
01485     
01486     static EnumPropertyItem prop_specular_shader_items[] = {
01487         {MA_SPEC_COOKTORR, "COOKTORR", 0, "CookTorr", "Use a Cook-Torrance shader"},
01488         {MA_SPEC_PHONG, "PHONG", 0, "Phong", "Use a Phong shader"},
01489         {MA_SPEC_BLINN, "BLINN", 0, "Blinn", "Use a Blinn shader"},
01490         {MA_SPEC_TOON, "TOON", 0, "Toon", "Use a toon shader"},
01491         {MA_SPEC_WARDISO, "WARDISO", 0, "WardIso", "Use a Ward anisotropic shader"},
01492         {0, NULL, 0, NULL, NULL}};
01493     
01494     prop= RNA_def_property(srna, "specular_shader", PROP_ENUM, PROP_NONE);
01495     RNA_def_property_enum_sdna(prop, NULL, "spec_shader");
01496     RNA_def_property_enum_items(prop, prop_specular_shader_items);
01497     RNA_def_property_ui_text(prop, "Specular Shader Model", "");
01498     RNA_def_property_update(prop, 0, "rna_Material_update");
01499     
01500     prop= RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
01501     RNA_def_property_float_sdna(prop, NULL, "spec");
01502     RNA_def_property_range(prop, 0, 1);
01503     RNA_def_property_ui_text(prop, "Specular Intensity", "How intense (bright) the specular reflection is");
01504     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01505 
01506     /* NOTE: "har", "param", etc are used for multiple purposes depending on
01507      * settings. This should be fixed in DNA once, for RNA we just expose them
01508      * multiple times, which may give somewhat strange changes in the outliner,
01509      * but in the UI they are never visible at the same time. */
01510 
01511     prop= RNA_def_property(srna, "specular_hardness", PROP_INT, PROP_NONE);
01512     RNA_def_property_int_sdna(prop, NULL, "har");
01513     RNA_def_property_range(prop, 1, 511);
01514     RNA_def_property_ui_text(prop, "Specular Hardness", "How hard (sharp) the specular reflection is");
01515     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01516 
01517     prop= RNA_def_property(srna, "specular_ior", PROP_FLOAT, PROP_NONE);
01518     RNA_def_property_float_sdna(prop, NULL, "refrac");
01519     RNA_def_property_range(prop, 1, 10);
01520     RNA_def_property_ui_text(prop, "Specular IOR", "Specular index of refraction");
01521     RNA_def_property_update(prop, 0, "rna_Material_update");
01522 
01523     prop= RNA_def_property(srna, "specular_toon_size", PROP_FLOAT, PROP_NONE);
01524     RNA_def_property_float_sdna(prop, NULL, "param[2]");
01525     RNA_def_property_range(prop, 0.0f, 1.53f);
01526     RNA_def_property_ui_text(prop, "Specular Toon Size", "Size of specular toon area");
01527     RNA_def_property_update(prop, 0, "rna_Material_update");
01528 
01529     prop= RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_FACTOR);
01530     RNA_def_property_float_sdna(prop, NULL, "param[3]");
01531     RNA_def_property_range(prop, 0.0f, 1.0f);
01532     RNA_def_property_ui_text(prop, "Specular Toon Smooth", "Smoothness of specular toon area");
01533     RNA_def_property_update(prop, 0, "rna_Material_update");
01534 
01535     prop= RNA_def_property(srna, "specular_slope", PROP_FLOAT, PROP_FACTOR);
01536     RNA_def_property_float_sdna(prop, NULL, "rms");
01537     RNA_def_property_range(prop, 0, 0.4);
01538     RNA_def_property_ui_text(prop, "Specular Slope", "The standard deviation of surface slope");
01539     RNA_def_property_update(prop, 0, "rna_Material_update");
01540 }
01541 
01542 static void rna_def_material_strand(BlenderRNA *brna)
01543 {
01544     StructRNA *srna;
01545     PropertyRNA *prop;
01546 
01547     srna= RNA_def_struct(brna, "MaterialStrand", NULL);
01548     RNA_def_struct_sdna(srna, "Material");
01549     RNA_def_struct_nested(brna, srna, "Material");
01550     RNA_def_struct_ui_text(srna, "Material Strand", "Strand settings for a Material datablock");
01551 
01552     prop= RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE);
01553     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_STR);
01554     RNA_def_property_ui_text(prop, "Tangent Shading", "Use direction of strands as normal for tangent-shading");
01555     RNA_def_property_update(prop, 0, "rna_Material_update");
01556     
01557     /* this flag is only set when rendering, not to be edited manually */
01558     prop= RNA_def_property(srna, "use_surface_diffuse", PROP_BOOLEAN, PROP_NONE);
01559     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_SURFDIFF);
01560     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01561     RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface");
01562     RNA_def_property_update(prop, 0, "rna_Material_update");
01563 
01564     prop= RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_DISTANCE);
01565     RNA_def_property_float_sdna(prop, NULL, "strand_surfnor");
01566     RNA_def_property_range(prop, 0, 10);
01567     RNA_def_property_ui_text(prop, "Blend Distance", "Worldspace distance over which to blend in the surface normal");
01568     RNA_def_property_update(prop, 0, "rna_Material_update");
01569 
01570     prop= RNA_def_property(srna, "use_blender_units", PROP_BOOLEAN, PROP_NONE);
01571     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_B_UNITS);
01572     RNA_def_property_ui_text(prop, "Blender Units", "Use Blender units for widths instead of pixels");
01573     RNA_def_property_update(prop, 0, "rna_Material_update");
01574 
01575     prop= RNA_def_property(srna, "root_size", PROP_FLOAT, PROP_UNSIGNED);
01576     RNA_def_property_float_sdna(prop, NULL, "strand_sta");
01577     RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_start_size_range");
01578     RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5);
01579     RNA_def_property_ui_text(prop, "Root Size", "Start size of strands in pixels or Blender units");
01580     RNA_def_property_update(prop, 0, "rna_Material_update");
01581 
01582     prop= RNA_def_property(srna, "tip_size", PROP_FLOAT, PROP_UNSIGNED);
01583     RNA_def_property_float_sdna(prop, NULL, "strand_end");
01584     RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5);
01585     RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_end_size_range");
01586     RNA_def_property_ui_text(prop, "Tip Size", "End size of strands in pixels or Blender units");
01587     RNA_def_property_update(prop, 0, "rna_Material_update");
01588 
01589     prop= RNA_def_property(srna, "size_min", PROP_FLOAT, PROP_UNSIGNED);
01590     RNA_def_property_float_sdna(prop, NULL, "strand_min");
01591     RNA_def_property_range(prop, 0.001, 10);
01592     RNA_def_property_ui_text(prop, "Minimum Size", "Minimum size of strands in pixels");
01593     RNA_def_property_update(prop, 0, "rna_Material_update");
01594 
01595     prop= RNA_def_property(srna, "shape", PROP_FLOAT, PROP_NONE);
01596     RNA_def_property_float_sdna(prop, NULL, "strand_ease");
01597     RNA_def_property_range(prop, -0.9, 0.9);
01598     RNA_def_property_ui_text(prop, "Shape", "Positive values make strands rounder, negative ones make strands spiky");
01599     RNA_def_property_update(prop, 0, "rna_Material_update");
01600 
01601     prop= RNA_def_property(srna, "width_fade", PROP_FLOAT, PROP_NONE);
01602     RNA_def_property_float_sdna(prop, NULL, "strand_widthfade");
01603     RNA_def_property_range(prop, 0, 2);
01604     RNA_def_property_ui_text(prop, "Width Fade", "Transparency along the width of the strand");
01605     RNA_def_property_update(prop, 0, "rna_Material_update");
01606 
01607     prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
01608     RNA_def_property_string_sdna(prop, NULL, "strand_uvname");
01609     RNA_def_property_ui_text(prop, "UV Map", "Name of UV map to override");
01610     RNA_def_property_update(prop, 0, "rna_Material_update");
01611 }
01612 
01613 static void rna_def_material_physics(BlenderRNA *brna)
01614 {
01615     StructRNA *srna;
01616     PropertyRNA *prop;
01617     
01618     srna= RNA_def_struct(brna, "MaterialPhysics", NULL);
01619     RNA_def_struct_sdna(srna, "Material");
01620     RNA_def_struct_nested(brna, srna, "Material");
01621     RNA_def_struct_ui_text(srna, "Material Physics", "Physics settings for a Material datablock");
01622     
01623     prop= RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
01624     RNA_def_property_float_sdna(prop, NULL, "friction");
01625     RNA_def_property_range(prop, 0, 100);
01626     RNA_def_property_ui_text(prop, "Friction", "Coulomb friction coefficient, when inside the physics distance area");
01627 
01628     prop= RNA_def_property(srna, "elasticity", PROP_FLOAT, PROP_NONE);
01629     RNA_def_property_float_sdna(prop, NULL, "reflect");
01630     RNA_def_property_range(prop, 0, 1);
01631     RNA_def_property_ui_text(prop, "Elasticity", "Elasticity of collisions");
01632 
01633     /* FH/Force Field Settings */
01634     prop= RNA_def_property(srna, "use_fh_normal", PROP_BOOLEAN, PROP_NONE);
01635     RNA_def_property_boolean_sdna(prop, NULL, "dynamode", MA_FH_NOR);
01636     RNA_def_property_ui_text(prop, "Align to Normal",
01637                              "Align dynamic game objects along the surface normal, when inside the physics distance area");
01638 
01639     prop= RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_NONE);
01640     RNA_def_property_float_sdna(prop, NULL, "fh");
01641     RNA_def_property_range(prop, 0, 1);
01642     RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2);
01643     RNA_def_property_ui_text(prop, "Force", "Upward spring force, when inside the physics distance area");
01644     
01645     prop= RNA_def_property(srna, "fh_distance", PROP_FLOAT, PROP_NONE);
01646     RNA_def_property_float_sdna(prop, NULL, "fhdist");
01647     RNA_def_property_range(prop, 0, 20);
01648     RNA_def_property_ui_text(prop, "Distance", "Distance of the physics area");
01649     
01650     prop= RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE);
01651     RNA_def_property_float_sdna(prop, NULL, "xyfrict");
01652     RNA_def_property_range(prop, 0, 1);
01653     RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area");
01654 }
01655 
01656 void RNA_def_material(BlenderRNA *brna)
01657 {
01658     StructRNA *srna;
01659     PropertyRNA *prop;
01660 
01661     static EnumPropertyItem prop_type_items[] = {
01662         {MA_TYPE_SURFACE, "SURFACE", 0, "Surface", "Render object as a surface"},
01663         {MA_TYPE_WIRE, "WIRE", 0, "Wire", "Render the edges of faces as wires (not supported in raytracing)"},
01664         {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume"},
01665         {MA_TYPE_HALO, "HALO", 0, "Halo", "Render object as halo particles"},
01666         {0, NULL, 0, NULL, NULL}};
01667     static EnumPropertyItem transparency_items[] = {
01668         {0, "MASK", 0, "Mask", "Mask the background"},
01669         {MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces"},
01670         {MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering"},
01671         {0, NULL, 0, NULL, NULL}};
01672     
01673     /* Render Preview Types */
01674     static EnumPropertyItem preview_type_items[] = {
01675         {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"},
01676         {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Sphere"},
01677         {MA_CUBE, "CUBE", ICON_MATCUBE, "Cube", "Cube"},
01678         {MA_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Monkey"},
01679         {MA_HAIR, "HAIR", ICON_HAIR, "Hair", "Hair strands"},
01680         {MA_SPHERE_A, "SPHERE_A", ICON_MAT_SPHERE_SKY, "World Sphere", "Large sphere with sky"},
01681         {0, NULL, 0, NULL, NULL}};
01682 
01683     static EnumPropertyItem prop_shadows_only_items[] = {
01684         {MA_SO_OLD, "SHADOW_ONLY_OLD", 0, "Shadow and Distance", "Old shadow only method"},
01685         {MA_SO_SHADOW, "SHADOW_ONLY", 0, "Shadow Only", "Improved shadow only method"},
01686         {MA_SO_SHADED, "SHADOW_ONLY_SHADED", 0, "Shadow and Shading",
01687                        "Improved shadow only method which also renders lightless areas as shadows"},
01688         {0, NULL, 0, NULL, NULL}};
01689 
01690     srna= RNA_def_struct(brna, "Material", "ID");
01691     RNA_def_struct_ui_text(srna, "Material",
01692                            "Material datablock to define the appearance of geometric objects for rendering");
01693     RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
01694     
01695     prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
01696     RNA_def_property_enum_sdna(prop, NULL, "material_type");
01697     RNA_def_property_enum_items(prop, prop_type_items);
01698     RNA_def_property_ui_text(prop, "Type", "Material type defining how the object is rendered");
01699     RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL);
01700     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01701 
01702     prop= RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE);
01703     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRANSP);
01704     RNA_def_property_ui_text(prop, "Transparency", "Render material as transparent");
01705     RNA_def_property_update(prop, 0, "rna_Material_update");
01706 
01707     prop= RNA_def_property(srna, "transparency_method", PROP_ENUM, PROP_NONE);
01708     RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
01709     RNA_def_property_enum_items(prop, transparency_items);
01710     RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency");
01711     RNA_def_property_update(prop, 0, "rna_Material_update");
01712     
01713     /* For Preview Render */
01714     prop= RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE);
01715     RNA_def_property_enum_sdna(prop, NULL, "pr_type");
01716     RNA_def_property_enum_items(prop, preview_type_items);
01717     RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render");
01718     RNA_def_property_update(prop, 0, "rna_Material_update");
01719     
01720     prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR);
01721     RNA_def_property_float_sdna(prop, NULL, "amb");
01722     RNA_def_property_range(prop, 0, 1);
01723     RNA_def_property_ui_text(prop, "Ambient", "Amount of global ambient color the material receives");
01724     RNA_def_property_update(prop, 0, "rna_Material_update");
01725 
01726     prop= RNA_def_property(srna, "emit", PROP_FLOAT, PROP_NONE);
01727     RNA_def_property_range(prop, 0, FLT_MAX);
01728     RNA_def_property_ui_range(prop, 0, 2.0f, 1, 2);
01729     RNA_def_property_ui_text(prop, "Emit", "Amount of light to emit");
01730     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01731 
01732     prop= RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_FACTOR);
01733     RNA_def_property_range(prop, 0, 1);
01734     RNA_def_property_ui_text(prop, "Translucency", "Amount of diffuse shading on the back side");
01735     RNA_def_property_update(prop, 0, "rna_Material_update");
01736         
01737     prop= RNA_def_property(srna, "use_cubic", PROP_BOOLEAN, PROP_NONE);
01738     RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_CUBIC);
01739     RNA_def_property_ui_text(prop, "Cubic Interpolation",
01740                              "Use cubic interpolation for diffuse values, for smoother transitions");
01741     RNA_def_property_update(prop, 0, "rna_Material_update");
01742     
01743     prop= RNA_def_property(srna, "use_object_color", PROP_BOOLEAN, PROP_NONE);
01744     RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_OBCOLOR);
01745     RNA_def_property_ui_text(prop, "Object Color", "Modulate the result with a per-object color");
01746     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01747 
01748     prop= RNA_def_property(srna, "shadow_ray_bias", PROP_FLOAT, PROP_NONE);
01749     RNA_def_property_float_sdna(prop, NULL, "sbias");
01750     RNA_def_property_range(prop, 0, 0.25);
01751     RNA_def_property_ui_text(prop, "Shadow Ray Bias",
01752                              "Shadow raytracing bias to prevent terminator problems on shadow boundary");
01753 
01754     prop= RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
01755     RNA_def_property_float_sdna(prop, NULL, "lbias");
01756     RNA_def_property_range(prop, 0, 10);
01757     RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Factor to multiply shadow buffer bias with (0 is ignore)");
01758 
01759     prop= RNA_def_property(srna, "shadow_cast_alpha", PROP_FLOAT, PROP_FACTOR);
01760     RNA_def_property_float_sdna(prop, NULL, "shad_alpha");
01761     RNA_def_property_range(prop, 0.001, 1);
01762     RNA_def_property_ui_text(prop, "Shadow Casting Alpha",
01763                              "Shadow casting alpha, in use for Irregular and Deep shadow buffer");
01764     RNA_def_property_update(prop, 0, "rna_Material_update");
01765 
01766     prop= RNA_def_property(srna, "light_group", PROP_POINTER, PROP_NONE);
01767     RNA_def_property_pointer_sdna(prop, NULL, "group");
01768     RNA_def_property_struct_type(prop, "Group");
01769     RNA_def_property_flag(prop, PROP_EDITABLE);
01770     RNA_def_property_ui_text(prop, "Light Group", "Limit lighting to lamps in this Group");
01771     RNA_def_property_update(prop, 0, "rna_Material_update");
01772 
01773     prop= RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
01774     RNA_def_property_int_sdna(prop, NULL, "index");
01775     RNA_def_property_ui_text(prop, "Pass Index", "Index number for the IndexMA render pass");
01776     RNA_def_property_update(prop, NC_OBJECT, NULL);
01777 
01778     /* flags */
01779     
01780     prop= RNA_def_property(srna, "use_light_group_exclusive", PROP_BOOLEAN, PROP_NONE);
01781     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_GROUP_NOLAY);
01782     RNA_def_property_ui_text(prop, "Light Group Exclusive",
01783                              "Material uses the light group exclusively - these lamps are excluded from other scene lighting");
01784     RNA_def_property_update(prop, 0, "rna_Material_update");
01785     
01786     prop= RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE);
01787     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE);
01788     RNA_def_property_ui_text(prop, "Traceable",
01789                              "Include this material and geometry that uses it in raytracing calculations");
01790     RNA_def_property_update(prop, 0, "rna_Material_update");
01791     
01792     prop= RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE);
01793     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW);
01794     RNA_def_property_ui_text(prop, "Shadows", "Allow this material to receive shadows");
01795     RNA_def_property_update(prop, 0, "rna_Material_update");
01796     
01797     prop= RNA_def_property(srna, "use_shadeless", PROP_BOOLEAN, PROP_NONE);
01798     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHLESS);
01799     RNA_def_property_ui_text(prop, "Shadeless", "Make this material insensitive to light or shadow");
01800     RNA_def_property_update(prop, 0, "rna_Material_draw_update");
01801     
01802     prop= RNA_def_property(srna, "use_vertex_color_light", PROP_BOOLEAN, PROP_NONE);
01803     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOL);
01804     RNA_def_property_ui_text(prop, "Vertex Color Light", "Add vertex colors as additional lighting");
01805     RNA_def_property_update(prop, 0, "rna_Material_update");
01806 
01807     prop= RNA_def_property(srna, "use_vertex_color_paint", PROP_BOOLEAN, PROP_NONE);
01808     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOLP);
01809     RNA_def_property_ui_text(prop, "Vertex Color Paint",
01810                              "Replace object base color with vertex colors (multiply with "
01811                              "'texture face' face assigned textures)");
01812     RNA_def_property_update(prop, 0, "rna_Material_update");
01813     
01814     prop= RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE);
01815     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ZINV);
01816     RNA_def_property_ui_text(prop, "Invert Z Depth", "Render material's faces with an inverted Z buffer (scanline only)");
01817     RNA_def_property_update(prop, 0, "rna_Material_update");
01818 
01819     prop= RNA_def_property(srna, "offset_z", PROP_FLOAT, PROP_NONE);
01820     RNA_def_property_float_sdna(prop, NULL, "zoffs");
01821     RNA_def_property_ui_text(prop, "Z Offset", "Give faces an artificial offset in the Z buffer for Z transparency");
01822     RNA_def_property_update(prop, 0, "rna_Material_update");
01823     
01824     prop= RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE);
01825     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ENV);
01826     RNA_def_property_ui_text(prop, "Sky",
01827                              "Render this material with zero alpha, with sky background in place (scanline only)");
01828     RNA_def_property_update(prop, 0, "rna_Material_update");
01829     
01830     prop= RNA_def_property(srna, "use_only_shadow", PROP_BOOLEAN, PROP_NONE);
01831     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYSHADOW);
01832     RNA_def_property_ui_text(prop, "Only Shadow",
01833                              "Render shadows as the material's alpha value, making the material "
01834                              "transparent except for shadowed areas");
01835     RNA_def_property_update(prop, 0, "rna_Material_update");
01836 
01837     prop= RNA_def_property(srna, "shadow_only_type", PROP_ENUM, PROP_NONE);
01838     RNA_def_property_enum_bitflag_sdna(prop, NULL, "shadowonly_flag");
01839     RNA_def_property_enum_items(prop, prop_shadows_only_items);
01840     RNA_def_property_ui_text(prop, "Shadow Type", "How to draw shadows");
01841     RNA_def_property_update(prop, 0, "rna_Material_update");
01842     
01843     prop= RNA_def_property(srna, "use_face_texture", PROP_BOOLEAN, PROP_NONE);
01844     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE);
01845     RNA_def_property_ui_text(prop, "Face Textures",
01846                              "Replace the object's base color with color from UV map image textures");
01847     RNA_def_property_update(prop, 0, "rna_Material_update");
01848     
01849     prop= RNA_def_property(srna, "use_face_texture_alpha", PROP_BOOLEAN, PROP_NONE);
01850     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE_ALPHA);
01851     RNA_def_property_ui_text(prop, "Face Textures Alpha",
01852                              "Replace the object's base alpha value with alpha from UV map image textures");
01853     RNA_def_property_update(prop, 0, "rna_Material_update");
01854     
01855     prop= RNA_def_property(srna, "use_cast_shadows_only", PROP_BOOLEAN, PROP_NONE);
01856     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYCAST);
01857     RNA_def_property_ui_text(prop, "Cast Shadows Only",
01858                              "Make objects with this material appear invisible (not rendered), only casting shadows");
01859     RNA_def_property_update(prop, 0, "rna_Material_update");
01860     
01861     prop= RNA_def_property(srna, "use_mist", PROP_BOOLEAN, PROP_NONE);
01862     RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", MA_NOMIST);
01863     RNA_def_property_ui_text(prop, "Use Mist", "Use mist with this material (in world settings)");
01864     RNA_def_property_update(prop, 0, "rna_Material_update");
01865     
01866     prop= RNA_def_property(srna, "use_transparent_shadows", PROP_BOOLEAN, PROP_NONE);
01867     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW_TRA);
01868     RNA_def_property_ui_text(prop, "Receive Transparent Shadows",
01869                              "Allow this object to receive transparent shadows cast through other objects");
01870     RNA_def_property_update(prop, 0, "rna_Material_update");
01871     
01872     prop= RNA_def_property(srna, "use_ray_shadow_bias", PROP_BOOLEAN, PROP_NONE);
01873     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYBIAS);
01874     RNA_def_property_ui_text(prop, "Ray Shadow Bias",
01875                              "Prevent raytraced shadow errors on surfaces with smooth shaded normals (terminator problem)");
01876     RNA_def_property_update(prop, 0, "rna_Material_update");
01877     
01878     prop= RNA_def_property(srna, "use_full_oversampling", PROP_BOOLEAN, PROP_NONE);
01879     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FULL_OSA);
01880     RNA_def_property_ui_text(prop, "Full Oversampling",
01881                              "Force this material to render full shading/textures for all anti-aliasing samples");
01882     RNA_def_property_update(prop, 0, "rna_Material_update");
01883 
01884     prop= RNA_def_property(srna, "use_cast_buffer_shadows", PROP_BOOLEAN, PROP_NONE);
01885     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADBUF);
01886     RNA_def_property_ui_text(prop, "Cast Buffer Shadows",
01887                              "Allow this material to cast shadows from shadow buffer lamps");
01888     RNA_def_property_update(prop, 0, "rna_Material_update");
01889 
01890     prop= RNA_def_property(srna, "use_cast_approximate", PROP_BOOLEAN, PROP_NONE);
01891     RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_APPROX_OCCLUSION);
01892     RNA_def_property_ui_text(prop, "Cast Approximate",
01893                              "Allow this material to cast shadows when using approximate ambient occlusion");
01894     RNA_def_property_update(prop, 0, "rna_Material_update");
01895     
01896     prop= RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE);
01897     RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V);
01898     RNA_def_property_ui_text(prop, "Tangent Shading",
01899                              "Use the material's tangent vector instead of the normal for shading "
01900                              "- for anisotropic shading effects");
01901     RNA_def_property_update(prop, 0, "rna_Material_update");
01902     
01903     /* nested structs */
01904     prop= RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NONE);
01905     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01906     RNA_def_property_struct_type(prop, "MaterialRaytraceMirror");
01907     RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL, NULL, NULL);
01908     RNA_def_property_ui_text(prop, "Raytrace Mirror", "Raytraced reflection settings for the material");
01909 
01910     prop= RNA_def_property(srna, "raytrace_transparency", PROP_POINTER, PROP_NONE);
01911     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01912     RNA_def_property_struct_type(prop, "MaterialRaytraceTransparency");
01913     RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL, NULL, NULL);
01914     RNA_def_property_ui_text(prop, "Raytrace Transparency", "Raytraced transparency settings for the material");
01915 
01916     prop= RNA_def_property(srna, "volume", PROP_POINTER, PROP_NONE);
01917     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01918     RNA_def_property_pointer_sdna(prop, NULL, "vol");
01919     RNA_def_property_struct_type(prop, "MaterialVolume");
01920     RNA_def_property_ui_text(prop, "Volume", "Volume settings for the material");
01921 
01922     prop= RNA_def_property(srna, "halo", PROP_POINTER, PROP_NONE);
01923     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01924     RNA_def_property_struct_type(prop, "MaterialHalo");
01925     RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL, NULL, NULL);
01926     RNA_def_property_ui_text(prop, "Halo", "Halo settings for the material");
01927 
01928     prop= RNA_def_property(srna, "subsurface_scattering", PROP_POINTER, PROP_NONE);
01929     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01930     RNA_def_property_struct_type(prop, "MaterialSubsurfaceScattering");
01931     RNA_def_property_pointer_funcs(prop, "rna_Material_sss_get", NULL, NULL, NULL);
01932     RNA_def_property_ui_text(prop, "Subsurface Scattering", "Subsurface scattering settings for the material");
01933 
01934     prop= RNA_def_property(srna, "strand", PROP_POINTER, PROP_NONE);
01935     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01936     RNA_def_property_struct_type(prop, "MaterialStrand");
01937     RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL, NULL);
01938     RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material");
01939     
01940     prop= RNA_def_property(srna, "physics", PROP_POINTER, PROP_NONE);
01941     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01942     RNA_def_property_struct_type(prop, "MaterialPhysics");
01943     RNA_def_property_pointer_funcs(prop, "rna_Material_physics_get", NULL, NULL, NULL);
01944     RNA_def_property_ui_text(prop, "Physics", "Game physics settings");
01945 
01946     /* game settings */
01947     prop= RNA_def_property(srna, "game_settings", PROP_POINTER, PROP_NONE);
01948     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01949     RNA_def_property_pointer_sdna(prop, NULL, "game");
01950     RNA_def_property_struct_type(prop, "MaterialGameSettings");
01951     RNA_def_property_ui_text(prop, "Game Settings", "Game material settings");
01952 
01953     /* nodetree */
01954     prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
01955     RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
01956     RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based materials");
01957 
01958     prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
01959     RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
01960     RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
01961     RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material");
01962     RNA_def_property_update(prop, 0, "rna_Material_use_nodes_update");
01963 
01964     prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
01965     RNA_def_property_struct_type(prop, "Material");
01966     RNA_def_property_flag(prop, PROP_EDITABLE);
01967     RNA_def_property_pointer_funcs(prop, "rna_Material_active_node_material_get",
01968                                    "rna_Material_active_node_material_set", NULL, NULL);
01969     RNA_def_property_ui_text(prop, "Material", "Active node material");
01970     RNA_def_property_update(prop, NC_MATERIAL, NULL);
01971 
01972     /* common */
01973     rna_def_animdata_common(srna);
01974     rna_def_mtex_common(brna, srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get",
01975         "rna_Material_active_texture_set", "rna_Material_active_texture_editable",
01976         "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update");
01977 
01978     /* only material has this one */
01979     prop= RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
01980     RNA_def_property_boolean_negative_sdna(prop, NULL, "septex", 1);
01981     RNA_def_property_array(prop, 18);
01982     RNA_def_property_ui_text(prop, "Use Textures", "Enable/Disable each texture");
01983     RNA_def_property_update(prop, 0, "rna_Material_update");
01984 
01985     rna_def_material_colors(srna);
01986     rna_def_material_diffuse(srna);
01987     rna_def_material_specularity(srna);
01988 
01989     /* nested structs */
01990     rna_def_material_raymirror(brna);
01991     rna_def_material_raytra(brna);
01992     rna_def_material_volume(brna);
01993     rna_def_material_halo(brna);
01994     rna_def_material_sss(brna);
01995     rna_def_material_mtex(brna);
01996     rna_def_material_strand(brna);
01997     rna_def_material_physics(brna);
01998     rna_def_material_gamesettings(brna);
01999 
02000     RNA_api_material(srna);
02001 }
02002 
02003 
02004 static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const char *structname, const char *structname_slots)
02005 {
02006     StructRNA *srna;
02007 
02008     FunctionRNA *func;
02009     PropertyRNA *parm;
02010 
02011     RNA_def_property_srna(cprop, structname_slots);
02012     srna= RNA_def_struct(brna, structname_slots, NULL);
02013     RNA_def_struct_sdna(srna, "ID");
02014     RNA_def_struct_ui_text(srna, "Texture Slots", "Collection of texture slots");
02015 
02016     /* functions */
02017     func= RNA_def_function(srna, "add", "rna_mtex_texture_slots_add");
02018     RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
02019     parm= RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
02020     RNA_def_function_return(func, parm);
02021     
02022     func= RNA_def_function(srna, "create", "rna_mtex_texture_slots_create");
02023     RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
02024     parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to initialize", 0, INT_MAX);
02025     RNA_def_property_flag(parm, PROP_REQUIRED);
02026     parm= RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
02027     RNA_def_function_return(func, parm);
02028     
02029     func= RNA_def_function(srna, "clear", "rna_mtex_texture_slots_clear");
02030     RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
02031     parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to clear", 0, INT_MAX);
02032     RNA_def_property_flag(parm, PROP_REQUIRED);
02033 }
02034 
02035 void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin,
02036     const char *activeget, const char *activeset, const char *activeeditable,
02037     const char *structname, const char *structname_slots, const char *update)
02038 {
02039     PropertyRNA *prop;
02040 
02041     /* mtex */
02042     prop= RNA_def_property(srna, "texture_slots", PROP_COLLECTION, PROP_NONE);
02043     RNA_def_property_struct_type(prop, structname);
02044     RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", NULL, NULL, NULL, NULL);
02045     RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures");
02046     rna_def_texture_slots(brna, prop, structname, structname_slots);
02047 
02048     prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
02049     RNA_def_property_struct_type(prop, "Texture");
02050     RNA_def_property_flag(prop, PROP_EDITABLE);
02051     if(activeeditable)
02052         RNA_def_property_editable_func(prop, activeeditable);
02053     RNA_def_property_pointer_funcs(prop, activeget, activeset, NULL, NULL);
02054     RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed");
02055     RNA_def_property_update(prop, 0, update);
02056 
02057     prop= RNA_def_property(srna, "active_texture_index", PROP_INT, PROP_UNSIGNED);
02058     RNA_def_property_int_sdna(prop, NULL, "texact");
02059     RNA_def_property_range(prop, 0, MAX_MTEX-1);
02060     RNA_def_property_ui_text(prop, "Active Texture Index", "Index of active texture slot");
02061     RNA_def_property_update(prop, 0, update);
02062 }
02063 
02064 #endif
02065 
02066