MtsBlend: miscellaneous UI improvements
parent
02d6129df9
commit
2b899db68c
|
@ -152,7 +152,7 @@ void GeometryConverter::convert(const fs::path &inputFile,
|
|||
fs::create_directory(textureDirectory);
|
||||
}
|
||||
|
||||
if (!fs::exists(meshesDirectory)) {
|
||||
if (!fs::exists(meshesDirectory) && !m_packGeometry) {
|
||||
SLog(EInfo, "Creating directory \"%s\" ..", meshesDirectory.file_string().c_str());
|
||||
fs::create_directory(meshesDirectory);
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ void GeometryConverter::convertOBJ(const fs::path &inputFile,
|
|||
SLog(EInfo, "Saving mesh \"%s\"", mesh->getName().c_str());
|
||||
mesh->serialize(m_geometryFile);
|
||||
os << "\t\t<string name=\"filename\" value=\"" << m_geometryFileName.filename() << "\"/>" << endl;
|
||||
os << "\t\t<integername=\"shapeIndex\" value=\"" << (m_geometryDict.size()-1) << "\"/>" << endl;
|
||||
os << "\t\t<integer name=\"shapeIndex\" value=\"" << (m_geometryDict.size()-1) << "\"/>" << endl;
|
||||
}
|
||||
|
||||
if (mesh->getBSDF() != NULL &&
|
||||
|
|
|
@ -211,3 +211,48 @@ class EXPORT_OT_mitsuba(bpy.types.Operator):
|
|||
|
||||
menu_func = lambda self, context: self.layout.operator("export.mitsuba", text="Export Mitsuba scene...")
|
||||
bpy.types.INFO_MT_file_export.append(menu_func)
|
||||
|
||||
class MITSUBA_OT_material_slot_move(bpy.types.Operator):
|
||||
''' Rearrange the material slots '''
|
||||
bl_idname = 'mitsuba.material_slot_move'
|
||||
bl_label = 'Move a material entry up or down'
|
||||
type = bpy.props.StringProperty(name='type')
|
||||
|
||||
def execute(self, context):
|
||||
obj = bpy.context.active_object
|
||||
index = obj.active_material_index
|
||||
new_index = index-1 if self.properties.type == 'UP' else index+1
|
||||
size = len(obj.material_slots)
|
||||
|
||||
if new_index >= 0 and new_index < size:
|
||||
obj.active_material_index = 0
|
||||
# Can't write to material_slots, hence the kludge
|
||||
materials = []
|
||||
for i in range(0, size):
|
||||
materials += [obj.material_slots[i].name]
|
||||
for i in range(0, size):
|
||||
mat = obj.data.materials.pop(0)
|
||||
del(mat)
|
||||
temp = materials[index]
|
||||
materials[index] = materials[new_index]
|
||||
materials[new_index] = temp
|
||||
for i in range(0, size):
|
||||
obj.data.materials.append(bpy.data.materials[materials[i]])
|
||||
|
||||
obj.active_material_index = new_index
|
||||
return {'FINISHED'}
|
||||
|
||||
class MITSUBA_OT_material_add(bpy.types.Operator):
|
||||
''' Append a new material '''
|
||||
bl_idname = 'mitsuba.material_add'
|
||||
bl_label = 'Append a new material'
|
||||
type = bpy.props.StringProperty(name='type')
|
||||
|
||||
def execute(self, context):
|
||||
obj = bpy.context.active_object
|
||||
index = obj.active_material_index
|
||||
curName = obj.material_slots[index].name
|
||||
mat = bpy.data.materials.new(name=curName)
|
||||
obj.data.materials.append(mat)
|
||||
obj.active_material_index = len(obj.data.materials)-1
|
||||
return {'FINISHED'}
|
||||
|
|
|
@ -60,11 +60,13 @@ class MATERIAL_PT_context_material_mts(MaterialButtonsPanel, bpy.types.Panel):
|
|||
if ob:
|
||||
row = layout.row()
|
||||
|
||||
row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
|
||||
row.template_list(ob, "material_slots", ob, "active_material_index", rows=4)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
|
||||
col.operator("mitsuba.material_add", icon='ZOOMIN', text="")
|
||||
col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
|
||||
col.operator("mitsuba.material_slot_move", text="", icon='TRIA_UP').type = 'UP'
|
||||
col.operator("mitsuba.material_slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
|
||||
|
||||
col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
|
||||
|
||||
|
@ -74,7 +76,7 @@ class MATERIAL_PT_context_material_mts(MaterialButtonsPanel, bpy.types.Panel):
|
|||
row.operator("object.material_slot_select", text="Select")
|
||||
row.operator("object.material_slot_deselect", text="Deselect")
|
||||
|
||||
split = layout.split(percentage=0.65)
|
||||
split = layout.split(percentage=0.75)
|
||||
|
||||
if ob:
|
||||
split.template_ID(ob, "active_material", new="material.new")
|
||||
|
|
Loading…
Reference in New Issue