Last active
May 21, 2023 18:16
-
-
Save p2or/fc3fb7b177bf81c128e6cb03b64e85e5 to your computer and use it in GitHub Desktop.
Display OpenGL-Lights on custom panel #Blender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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