Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# for http://blender.stackexchange.com/q/74766/3710
import bpy
def opengl_lamp_display(column, lamp):
split = column.split(percentage=0.1)
split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA')
col = split.column()
col.active = lamp.use
row = col.row()
row.label(text="Diffuse:")
row.prop(lamp, "diffuse_color", text="")
row = col.row()
row.label(text="Specular:")
row.prop(lamp, "specular_color", text="")
col = split.column()
col.active = lamp.use
col.prop(lamp, "direction", text="")
class MyOpenGlLightPanel(bpy.types.Panel):
bl_idname = "MyOpenGlLightPanel"
bl_label = "Solid OpenGL Lights"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "Tools"
bl_context = "objectmode"
@classmethod
def poll(self,context):
return context.object is not None
def draw(self, context):
layout = self.layout
layout = self.layout
userpref = context.user_preferences
system = userpref.system
split = layout.split()
column = split.column()
split = column.split(percentage=0.1)
split.label()
split.label(text="Colors:")
split.label(text="Direction:")
lamp = system.solid_lights[0]
opengl_lamp_display(column, lamp)
lamp = system.solid_lights[1]
opengl_lamp_display(column, lamp)
lamp = system.solid_lights[2]
opengl_lamp_display(column, lamp)
# ------------------------------------------------------------------------
# register and unregister
# ------------------------------------------------------------------------
def register():
bpy.utils.register_class(MyOpenGlLightPanel)
def unregister():
bpy.utils.unregister_class(MyOpenGlLightPanel)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.