2.5 Material:
[blender-staging.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(self, context):
41                 layout = self.layout
42                 sss = context.active_object.active_material.subsurface_scattering
43                 
44                 if not sss:
45                         return
46                 
47                 layout.itemR(sss, "enabled", text="Enable")
48                 
49                 flow = layout.column_flow()
50                 flow.itemR(sss, "error_tolerance")
51                 flow.itemR(sss, "ior")
52                 flow.itemR(sss, "scale")
53                 
54                 row = layout.row()
55                 row.column().itemR(sss, "color")
56                 row.column().itemR(sss, "radius")
57                 
58                 flow = layout.column_flow()
59                 flow.itemR(sss, "color_factor")
60                 flow.itemR(sss, "texture_factor")
61                 flow.itemR(sss, "front")
62                 flow.itemR(sss, "back")
63                 
64 class MATERIAL_PT_raymir(MaterialButtonsPanel):
65         __idname__= "MATERIAL_PT_raymir"
66         __label__ = "Ray Mirror"
67         
68         def poll(self, context):
69                 ob = context.active_object
70                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
71         
72         def draw_header(self, context):
73                 raym = context.active_object.active_material.raytrace_mirror
74
75                 layout = self.layout
76                 layout.itemR(raym, "enabled", text=self.__label__)
77         
78         def draw(self, context):
79                 layout = self.layout
80                 raym = context.active_object.active_material.raytrace_mirror
81
82                 split = layout.split()
83                 
84                 sub = split.column()
85                 sub.itemR(raym, "reflect", text="RayMir")
86                 sub.itemR(raym, "fresnel")
87                 sub.itemR(raym, "fresnel_fac", text="Fac")
88                 
89                 sub = split.column()
90                 sub.itemR(raym, "gloss")
91                 sub.itemR(raym, "gloss_threshold")
92                 sub.itemR(raym, "gloss_samples")
93                 sub.itemR(raym, "gloss_anisotropic")
94                 
95                 flow = layout.column_flow()
96                 flow.itemR(raym, "distance", text="Max Dist")
97                 flow.itemR(raym, "depth")
98                 flow.itemR(raym, "fade_to")
99                 
100 class MATERIAL_PT_raytransp(MaterialButtonsPanel):
101         __idname__= "MATERIAL_PT_raytransp"
102         __label__= "Ray Transparency"
103         
104         def poll(self, context):
105                 ob = context.active_object
106                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
107
108         def draw(self, context):
109                 layout = self.layout
110                 rayt = context.active_object.active_material.raytrace_transparency
111
112                 layout.itemR(rayt, "enabled", text="Enable")
113                 
114                 split = layout.split()
115                 
116                 sub = split.column()
117                 sub.itemR(rayt, "ior")
118                 sub.itemR(rayt, "fresnel")
119                 sub.itemR(rayt, "fresnel_fac", text="Fac")
120                 
121                 sub = split.column()
122                 sub.itemR(rayt, "gloss")
123                 sub.itemR(rayt, "gloss_threshold")
124                 sub.itemR(rayt, "gloss_samples")
125                 
126                 flow = layout.column_flow()
127                 flow.itemR(rayt, "filter")
128                 flow.itemR(rayt, "limit")
129                 flow.itemR(rayt, "falloff")
130                 flow.itemR(rayt, "specular_opacity")
131                 flow.itemR(rayt, "depth")
132                 
133 class MATERIAL_PT_halo(MaterialButtonsPanel):
134         __idname__= "MATERIAL_PT_halo"
135         __label__= "Halo"
136         
137         def poll(self, context):
138                 ob = context.active_object
139                 return (ob and ob.active_material and ob.active_material.type == "HALO")
140         
141         def draw(self, context):
142                 layout = self.layout
143                 mat = context.active_object.active_material
144                 halo = mat.halo
145
146                 split = layout.split()
147                 
148                 sub = split.column()
149                 sub.itemL(text="General Settings:")
150                 sub.itemR(halo, "size")
151                 sub.itemR(halo, "hardness")
152                 sub.itemR(halo, "add")
153                 
154                 sub = split.column()
155                 sub.itemL(text="Elements:")
156                 sub.itemR(halo, "ring")
157                 sub.itemR(halo, "lines")
158                 sub.itemR(halo, "star")
159                 sub.itemR(halo, "flare_mode")
160
161                 row = layout.row()
162                 
163                 sub = row.column()
164                 sub.itemL(text="Options:")
165                 sub.itemR(halo, "use_texture", text="Texture")
166                 sub.itemR(halo, "use_vertex_normal", text="Vertex Normal")
167                 sub.itemR(halo, "xalpha")
168                 sub.itemR(halo, "shaded")
169                 sub.itemR(halo, "soft")
170         
171                 sub = row.column()
172                 if (halo.ring):
173                         sub.itemR(halo, "rings")
174                 if (halo.lines):
175                         sub.itemR(halo, "line_number")
176                 if (halo.ring or halo.lines):
177                         sub.itemR(halo, "seed")
178                 if (halo.star):
179                         sub.itemR(halo, "star_tips")
180                 if (halo.flare_mode):
181                         sub.itemL(text="Flare:")
182                         sub.itemR(halo, "flare_size", text="Size")
183                         sub.itemR(halo, "flare_subsize", text="Subsize")
184                         sub.itemR(halo, "flare_boost", text="Boost")
185                         sub.itemR(halo, "flare_seed", text="Seed")
186                         sub.itemR(halo, "flares_sub", text="Sub")
187                                 
188 bpy.types.register(MATERIAL_PT_material)
189 bpy.types.register(MATERIAL_PT_raymir)
190 bpy.types.register(MATERIAL_PT_raytransp)
191 bpy.types.register(MATERIAL_PT_sss)
192 bpy.types.register(MATERIAL_PT_halo)