665a522373789b3517ca568a137d5d106e36827d
[blender.git] / release / ui / buttons_material.py
1
2 import bpy
3
4 class MaterialButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "material"
8
9         def poll(self, context):
10                 ob = context.active_object
11                 return (ob and ob.active_material)
12         
13 class MATERIAL_PT_material(MaterialButtonsPanel):
14         __idname__= "MATERIAL_PT_material"
15         __label__ = "Material"
16
17         def draw(self, context):
18                 layout = self.layout
19                 mat = context.active_object.active_material
20         
21                 row = layout.row()
22                 row.itemR(mat, "type", expand=True)
23
24                 row = layout.row()
25                 row.column().itemR(mat, "diffuse_color")
26                 row.column().itemR(mat, "specular_color")
27                 row.column().itemR(mat, "mirror_color")
28                 
29                 row = layout.row()
30                 row.itemR(mat, "alpha")
31                         
32 class MATERIAL_PT_sss(MaterialButtonsPanel):
33         __idname__= "MATERIAL_PT_sss"
34         __label__ = "Subsurface Scattering"
35
36         def poll(self, context):
37                 ob = context.active_object
38                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
39
40         def draw_header(self, context):
41                 sss = context.active_object.active_material.subsurface_scattering
42
43                 layout = self.layout
44                 layout.itemR(sss, "enabled", text="")
45         
46         def draw(self, context):
47                 layout = self.layout
48                 sss = context.active_object.active_material.subsurface_scattering
49                 
50                 flow = layout.column_flow()
51                 flow.itemR(sss, "error_tolerance")
52                 flow.itemR(sss, "ior")
53                 flow.itemR(sss, "scale")
54                 
55                 row = layout.row()
56                 row.column().itemR(sss, "color")
57                 row.column().itemR(sss, "radius")
58                 
59                 flow = layout.column_flow()
60                 flow.itemR(sss, "color_factor")
61                 flow.itemR(sss, "texture_factor")
62                 flow.itemR(sss, "front")
63                 flow.itemR(sss, "back")
64                 
65 class MATERIAL_PT_raymir(MaterialButtonsPanel):
66         __idname__= "MATERIAL_PT_raymir"
67         __label__ = "Ray Mirror"
68         
69         def poll(self, context):
70                 ob = context.active_object
71                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
72         
73         def draw_header(self, context):
74                 raym = context.active_object.active_material.raytrace_mirror
75
76                 layout = self.layout
77                 layout.itemR(raym, "enabled", text="")
78         
79         def draw(self, context):
80                 layout = self.layout
81                 raym = context.active_object.active_material.raytrace_mirror
82
83                 split = layout.split()
84                 
85                 sub = split.column()
86                 sub.itemR(raym, "reflect", text="RayMir")
87                 sub.itemR(raym, "fresnel")
88                 sub.itemR(raym, "fresnel_fac", text="Fac")
89                 
90                 sub = split.column()
91                 sub.itemR(raym, "gloss")
92                 sub.itemR(raym, "gloss_threshold")
93                 sub.itemR(raym, "gloss_samples")
94                 sub.itemR(raym, "gloss_anisotropic")
95                 
96                 flow = layout.column_flow()
97                 flow.itemR(raym, "distance", text="Max Dist")
98                 flow.itemR(raym, "depth")
99                 flow.itemR(raym, "fade_to")
100                 
101 class MATERIAL_PT_raytransp(MaterialButtonsPanel):
102         __idname__= "MATERIAL_PT_raytransp"
103         __label__= "Ray Transparency"
104         
105         def poll(self, context):
106                 ob = context.active_object
107                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
108
109         def draw_header(self, context):
110                 rayt = context.active_object.active_material.raytrace_transparency
111
112                 layout = self.layout
113                 layout.itemR(rayt, "enabled", text="")
114
115         def draw(self, context):
116                 layout = self.layout
117                 rayt = context.active_object.active_material.raytrace_transparency
118                 
119                 split = layout.split()
120                 
121                 sub = split.column()
122                 sub.itemR(rayt, "ior")
123                 sub.itemR(rayt, "fresnel")
124                 sub.itemR(rayt, "fresnel_fac", text="Fac")
125                 
126                 sub = split.column()
127                 sub.itemR(rayt, "gloss")
128                 sub.itemR(rayt, "gloss_threshold")
129                 sub.itemR(rayt, "gloss_samples")
130                 
131                 flow = layout.column_flow()
132                 flow.itemR(rayt, "filter")
133                 flow.itemR(rayt, "limit")
134                 flow.itemR(rayt, "falloff")
135                 flow.itemR(rayt, "specular_opacity")
136                 flow.itemR(rayt, "depth")
137                 
138 class MATERIAL_PT_halo(MaterialButtonsPanel):
139         __idname__= "MATERIAL_PT_halo"
140         __label__= "Halo"
141         
142         def poll(self, context):
143                 ob = context.active_object
144                 return (ob and ob.active_material and ob.active_material.type == "HALO")
145         
146         def draw(self, context):
147                 layout = self.layout
148                 mat = context.active_object.active_material
149                 halo = mat.halo
150
151                 split = layout.split()
152                 
153                 sub = split.column()
154                 sub.itemL(text="General Settings:")
155                 sub.itemR(halo, "size")
156                 sub.itemR(halo, "hardness")
157                 sub.itemR(halo, "add")
158                 
159                 sub = split.column()
160                 sub.itemL(text="Elements:")
161                 sub.itemR(halo, "ring")
162                 sub.itemR(halo, "lines")
163                 sub.itemR(halo, "star")
164                 sub.itemR(halo, "flare_mode")
165
166                 row = layout.row()
167                 
168                 sub = row.column()
169                 sub.itemL(text="Options:")
170                 sub.itemR(halo, "use_texture", text="Texture")
171                 sub.itemR(halo, "use_vertex_normal", text="Vertex Normal")
172                 sub.itemR(halo, "xalpha")
173                 sub.itemR(halo, "shaded")
174                 sub.itemR(halo, "soft")
175         
176                 sub = row.column()
177                 if (halo.ring):
178                         sub.itemR(halo, "rings")
179                 if (halo.lines):
180                         sub.itemR(halo, "line_number")
181                 if (halo.ring or halo.lines):
182                         sub.itemR(halo, "seed")
183                 if (halo.star):
184                         sub.itemR(halo, "star_tips")
185                 if (halo.flare_mode):
186                         sub.itemL(text="Flare:")
187                         sub.itemR(halo, "flare_size", text="Size")
188                         sub.itemR(halo, "flare_subsize", text="Subsize")
189                         sub.itemR(halo, "flare_boost", text="Boost")
190                         sub.itemR(halo, "flare_seed", text="Seed")
191                         sub.itemR(halo, "flares_sub", text="Sub")
192                                 
193 bpy.types.register(MATERIAL_PT_material)
194 bpy.types.register(MATERIAL_PT_raymir)
195 bpy.types.register(MATERIAL_PT_raytransp)
196 bpy.types.register(MATERIAL_PT_sss)
197 bpy.types.register(MATERIAL_PT_halo)