yyc12345
84dd5b76f1
- add support of 4 alpha fields intorduced in BM spec recently. - optimize material creation functions argv passing strategy. - change related func calls of (2). - optimize material parameter pick code to reduce useless check.
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
import bpy
|
|
from . import UTILS_constants, UTILS_functions, UTILS_virtools_prop
|
|
|
|
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)
|
|
UTILS_functions.create_material_nodes(mtl, mtl_data)
|
|
|
|
return {'FINISHED'}
|
|
|
|
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)
|
|
|
|
layout.prop(target, 'texture', emboss=True)
|
|
layout.prop(target, 'ambient')
|
|
layout.prop(target, 'diffuse')
|
|
layout.prop(target, 'specular')
|
|
layout.prop(target, 'emissive')
|
|
layout.prop(target, 'specular_power')
|
|
layout.prop(target, 'alpha_test')
|
|
layout.prop(target, 'alpha_blend')
|
|
layout.prop(target, 'z_buffer')
|
|
layout.prop(target, 'two_sided')
|
|
|
|
layout.operator("ballance.apply_virtools_material", icon="NODETREE")
|
|
|