2022-04-08 21:50:31 +08:00
|
|
|
import bpy
|
|
|
|
from . import UTILS_constants, UTILS_functions, UTILS_virtools_prop
|
|
|
|
|
2022-04-12 15:40:06 +08:00
|
|
|
class BALLANCE_OT_apply_virtools_material(bpy.types.Operator):
|
|
|
|
"""Apply Virtools Material to Blender Material."""
|
|
|
|
bl_idname = "ballance.apply_virtools_material"
|
|
|
|
bl_label = "Apply Virtools Material"
|
|
|
|
bl_options = {'UNDO'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return context.material is not None
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
mtl = context.material
|
|
|
|
mtl_data = UTILS_virtools_prop.get_virtools_material_data(mtl)
|
2022-07-23 17:22:44 +08:00
|
|
|
UTILS_functions.create_material_nodes(mtl, mtl_data)
|
2022-04-12 15:40:06 +08:00
|
|
|
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
2022-04-08 21:50:31 +08:00
|
|
|
class BALLANCE_PT_virtools_material(bpy.types.Panel):
|
|
|
|
"""Show Virtools Material Properties."""
|
|
|
|
bl_label = "Virtools Material"
|
|
|
|
bl_idname = "BALLANCE_PT_virtools_material"
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "material"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return context.material is not None
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
#target = bpy.context.active_object.active_material
|
|
|
|
target = UTILS_virtools_prop.get_virtools_material(context.material)
|
|
|
|
|
2022-04-12 15:40:06 +08:00
|
|
|
layout.prop(target, 'texture', emboss=True)
|
2022-04-08 21:50:31 +08:00
|
|
|
layout.prop(target, 'ambient')
|
|
|
|
layout.prop(target, 'diffuse')
|
|
|
|
layout.prop(target, 'specular')
|
|
|
|
layout.prop(target, 'emissive')
|
|
|
|
layout.prop(target, 'specular_power')
|
2022-07-23 17:22:44 +08:00
|
|
|
layout.prop(target, 'alpha_test')
|
|
|
|
layout.prop(target, 'alpha_blend')
|
|
|
|
layout.prop(target, 'z_buffer')
|
|
|
|
layout.prop(target, 'two_sided')
|
2022-04-08 21:50:31 +08:00
|
|
|
|
2022-04-12 15:40:06 +08:00
|
|
|
layout.operator("ballance.apply_virtools_material", icon="NODETREE")
|
|
|
|
|