Skip to content

Commit

Permalink
add: material list panel and node editor context
Browse files Browse the repository at this point in the history
  • Loading branch information
bdancer committed Feb 16, 2016
1 parent 8b265b8 commit dad4656
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
25 changes: 25 additions & 0 deletions nodes/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,30 @@ def get_from_context(cls, context):
return (None, None, None)


class VRayMaterialEditor(VRayNodeTree):
bl_label = "V-Ray Material Editor"
bl_idname = 'VRayMaterialEditor'
bl_icon = 'MATERIAL'

@classmethod
def get_from_context(cls, context):
VRayExporter = context.scene.vray.Exporter

listIndex = VRayExporter.materialListIndex if VRayExporter.materialListIndex >= 0 else 0
numMaterials = len(bpy.data.materials)

if numMaterials:
if listIndex >= numMaterials:
VRayExporter.materialListIndex = 0
listIndex = 0

material = bpy.data.materials[listIndex]
if material:
return material.vray.ntree, material, material

return (None, None, None)


######## ######## ###### #### ###### ######## ######## ### ######## #### ####### ## ##
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ##
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### ##
Expand All @@ -201,6 +225,7 @@ def GetRegClasses():
VRayNodeTreeScene,

VRayNodeTreeEditor,
VRayMaterialEditor,
)


Expand Down
7 changes: 7 additions & 0 deletions plugins/system/Exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ class VRayExporter(bpy.types.PropertyGroup):
default = -1,
)

materialListIndex = bpy.props.IntProperty(
name = "Material List Index",
description = "Material list index",
min = -1,
default = -1,
)

useSeparateFiles = bpy.props.BoolProperty(
name = "Separate Files",
description = "Export plugins to separate files",
Expand Down
9 changes: 9 additions & 0 deletions ui/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,14 @@ def draw_item(self, context, layout, data, item, icon, active_data, active_propn
layout.label(text=item.name, translate=False)


class VRayListMaterials(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
split = layout.split(percentage=0.1)

split.column().prop(item, 'diffuse_color', text="")
split.column().label(text=item.name, translate=False)


######## ######## ###### #### ###### ######## ######## ### ######## #### ####### ## ##
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ##
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### ##
Expand All @@ -537,6 +545,7 @@ def GetRegClasses():
VRayListUse,
VRayListDR,
VRayList,
VRayListMaterials,

VRayOpListItemNew,
VRayOpListItemDel,
Expand Down
11 changes: 11 additions & 0 deletions ui/properties_render_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ def draw(self, context):
box_row.operator("vray.remove_fake_textures", text="Remove Unused Data", icon='ERROR')


class VRayPanelMaterials(classes.VRayRenderLayersPanel):
bl_label = "Scene Materials"
bl_options = {'DEFAULT_CLOSED'}

def draw(self, context):
VRayExporter = context.scene.vray.Exporter

self.layout.template_list("VRayListMaterials", "", bpy.data, 'materials', VRayExporter, 'materialListIndex', rows=15)


class VRayPanelLightLister(classes.VRayRenderLayersPanel):
bl_label = "Lights"
bl_options = {'DEFAULT_CLOSED'}
Expand Down Expand Up @@ -228,6 +238,7 @@ def renderExportSetItem(layout, item):

def GetRegClasses():
return (
VRayPanelMaterials,
VRayPanelMiscTools,
VRayPanelNodeTrees,
VRayPanelLightLister,
Expand Down

0 comments on commit dad4656

Please sign in to comment.