[feat] promote virtools material
- set the default value of virtools material like virtools creation. - add preset in virtools panel for convenient using.
This commit is contained in:
parent
7680d11c0e
commit
ef459a210d
@ -43,6 +43,48 @@ class BALLANCE_OT_parse_virtools_material(bpy.types.Operator):
|
|||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class BALLANCE_OT_preset_virtools_material(bpy.types.Operator):
|
||||||
|
"""Preset Virtools Material with Original Ballance Data."""
|
||||||
|
bl_idname = "ballance.preset_virtools_material"
|
||||||
|
bl_label = "Preset Virtools Material"
|
||||||
|
bl_options = {'UNDO'}
|
||||||
|
|
||||||
|
preset_type: bpy.props.EnumProperty(
|
||||||
|
name="Preset",
|
||||||
|
description="The preset which you want to apply.",
|
||||||
|
items=tuple(
|
||||||
|
(str(idx), item["human-readable"], "Suit for: " + ", ".join(item["member"]))
|
||||||
|
for idx, item in enumerate(UTILS_constants.floor_materialStatistic)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.material is not None
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
wm = context.window_manager
|
||||||
|
return wm.invoke_props_dialog(self)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
self.layout.prop(self, "preset_type")
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
preset_idx = int(self.preset_type)
|
||||||
|
preset_data = UTILS_constants.floor_materialStatistic[preset_idx]
|
||||||
|
|
||||||
|
# get data self and only change core colors
|
||||||
|
mtl = context.material
|
||||||
|
vtmtl = UTILS_virtools_prop.get_virtools_material(mtl)
|
||||||
|
|
||||||
|
vtmtl.ambient = preset_data['data']['ambient']
|
||||||
|
vtmtl.diffuse = preset_data['data']['diffuse']
|
||||||
|
vtmtl.specular = preset_data['data']['specular']
|
||||||
|
vtmtl.emissive = preset_data['data']['emissive']
|
||||||
|
vtmtl.specular_power = preset_data['data']['power']
|
||||||
|
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
class BALLANCE_PT_virtools_material(bpy.types.Panel):
|
class BALLANCE_PT_virtools_material(bpy.types.Panel):
|
||||||
"""Show Virtools Material Properties."""
|
"""Show Virtools Material Properties."""
|
||||||
bl_label = "Virtools Material"
|
bl_label = "Virtools Material"
|
||||||
@ -69,7 +111,9 @@ class BALLANCE_PT_virtools_material(bpy.types.Panel):
|
|||||||
layout.enabled = target.enable_virtools_material
|
layout.enabled = target.enable_virtools_material
|
||||||
|
|
||||||
# draw layout
|
# draw layout
|
||||||
layout.label(text="Basic Parameters")
|
row = layout.row()
|
||||||
|
row.label(text="Basic Parameters")
|
||||||
|
row.operator(BALLANCE_OT_preset_virtools_material.bl_idname, text="", icon="PRESET")
|
||||||
layout.prop(target, 'ambient')
|
layout.prop(target, 'ambient')
|
||||||
layout.prop(target, 'diffuse')
|
layout.prop(target, 'diffuse')
|
||||||
layout.prop(target, 'specular')
|
layout.prop(target, 'specular')
|
||||||
@ -86,6 +130,6 @@ class BALLANCE_PT_virtools_material(bpy.types.Panel):
|
|||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
layout.label(text="Operations")
|
layout.label(text="Operations")
|
||||||
layout.operator("ballance.apply_virtools_material", icon="NODETREE")
|
layout.operator(BALLANCE_OT_apply_virtools_material.bl_idname, icon="NODETREE")
|
||||||
layout.operator("ballance.parse_virtools_material", icon="HIDE_OFF")
|
layout.operator(BALLANCE_OT_parse_virtools_material.bl_idname, icon="HIDE_OFF")
|
||||||
|
|
||||||
|
@ -169,9 +169,10 @@ floor_textureReflactionMap = {
|
|||||||
"BallStone": "Ball_Stone.bmp"
|
"BallStone": "Ball_Stone.bmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
# WARNING: this data is shared with `BallanceVirtoolsPlugin/bvh/features/mapping/fix_texture.cpp`
|
# WARNING: this data is shared with `BallanceVirtoolsPlugin/bvh/features/mapping/bmfile_fix_texture.cpp`
|
||||||
floor_materialStatistic = [
|
floor_materialStatistic = [
|
||||||
{
|
{
|
||||||
|
"human-readable": "Floor Side",
|
||||||
"member": [
|
"member": [
|
||||||
"FloorSide",
|
"FloorSide",
|
||||||
"FloorTopBorder_ForSide",
|
"FloorTopBorder_ForSide",
|
||||||
@ -186,6 +187,7 @@ floor_materialStatistic = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"human-readable": "Floor Top",
|
||||||
"member": [
|
"member": [
|
||||||
"FloorTopBorder",
|
"FloorTopBorder",
|
||||||
"FloorTopBorderless",
|
"FloorTopBorderless",
|
||||||
@ -202,6 +204,7 @@ floor_materialStatistic = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"human-readable": "Transform Paper",
|
||||||
"member": [
|
"member": [
|
||||||
"BallPaper"
|
"BallPaper"
|
||||||
],
|
],
|
||||||
@ -214,6 +217,7 @@ floor_materialStatistic = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"human-readable": "Transform Stone & Wood",
|
||||||
"member": [
|
"member": [
|
||||||
"BallStone",
|
"BallStone",
|
||||||
"BallWood"
|
"BallWood"
|
||||||
@ -225,6 +229,45 @@ floor_materialStatistic = [
|
|||||||
"emissive": (60 / 255.0, 60 / 255.0, 60 / 255.0),
|
"emissive": (60 / 255.0, 60 / 255.0, 60 / 255.0),
|
||||||
"power": 0
|
"power": 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"human-readable": "Rail",
|
||||||
|
"member": [
|
||||||
|
"Rail"
|
||||||
|
],
|
||||||
|
"data": {
|
||||||
|
"ambient": (0.0, 0.0, 0.0),
|
||||||
|
"diffuse": (100 / 255.0, 118 / 255.0, 133 / 255.0),
|
||||||
|
"specular": (210 / 255.0, 210 / 255.0, 210 / 255.0),
|
||||||
|
"emissive": (124 / 255.0, 134 / 255.0, 150 / 255.0),
|
||||||
|
"power": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"human-readable": "Wood Path",
|
||||||
|
"member": [
|
||||||
|
"WoodPanel"
|
||||||
|
],
|
||||||
|
"data": {
|
||||||
|
"ambient": (2 / 255.0, 2 / 255.0, 2 / 255.0),
|
||||||
|
"diffuse": (1.0, 1.0, 1.0),
|
||||||
|
"specular": (59 / 255.0, 59 / 255.0, 59 / 255.0),
|
||||||
|
"emissive": (30 / 255.0, 30 / 255.0, 30 / 255.0),
|
||||||
|
"power": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"human-readable": "Wood Chip",
|
||||||
|
"member": [
|
||||||
|
"WoodPlain2"
|
||||||
|
],
|
||||||
|
"data": {
|
||||||
|
"ambient": (25 / 255.0, 25 / 255.0, 25 / 255.0),
|
||||||
|
"diffuse": (1.0, 1.0, 1.0),
|
||||||
|
"specular": (100 / 255.0, 100 / 255.0, 100 / 255.0),
|
||||||
|
"emissive": (50 / 255.0, 50 / 255.0, 50 / 255.0),
|
||||||
|
"power": 50
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -7,29 +7,37 @@ class BALLANCE_PG_virtools_material(bpy.types.PropertyGroup):
|
|||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
ambient: bpy.props.FloatVectorProperty(name="Ambient",
|
ambient: bpy.props.FloatVectorProperty(
|
||||||
|
name="Ambient",
|
||||||
subtype='COLOR',
|
subtype='COLOR',
|
||||||
min=0.0,
|
min=0.0,
|
||||||
max=1.0,
|
max=1.0,
|
||||||
default=[0.0,0.0,0.0])
|
default=[76 / 255, 76 / 255, 76 / 255]
|
||||||
|
)
|
||||||
|
|
||||||
diffuse: bpy.props.FloatVectorProperty(name="Diffuse",
|
diffuse: bpy.props.FloatVectorProperty(
|
||||||
|
name="Diffuse",
|
||||||
subtype='COLOR',
|
subtype='COLOR',
|
||||||
min=0.0,
|
min=0.0,
|
||||||
max=1.0,
|
max=1.0,
|
||||||
default=[0.0,0.0,0.0])
|
default=[178 / 255, 178 / 255, 178 / 255]
|
||||||
|
)
|
||||||
|
|
||||||
specular: bpy.props.FloatVectorProperty(name="Specular",
|
specular: bpy.props.FloatVectorProperty(
|
||||||
|
name="Specular",
|
||||||
subtype='COLOR',
|
subtype='COLOR',
|
||||||
min=0.0,
|
min=0.0,
|
||||||
max=1.0,
|
max=1.0,
|
||||||
default=[0.0,0.0,0.0])
|
default=[127 / 255, 127 / 255, 127 / 255]
|
||||||
|
)
|
||||||
|
|
||||||
emissive: bpy.props.FloatVectorProperty(name="Emissive",
|
emissive: bpy.props.FloatVectorProperty(
|
||||||
|
name="Emissive",
|
||||||
subtype='COLOR',
|
subtype='COLOR',
|
||||||
min=0.0,
|
min=0.0,
|
||||||
max=1.0,
|
max=1.0,
|
||||||
default=[0.0,0.0,0.0])
|
default=[0.0, 0.0, 0.0]
|
||||||
|
)
|
||||||
|
|
||||||
specular_power: bpy.props.FloatProperty(
|
specular_power: bpy.props.FloatProperty(
|
||||||
name="Specular Power",
|
name="Specular Power",
|
||||||
|
@ -153,6 +153,7 @@ classes = (
|
|||||||
PROPS_virtools_group.BALLANCE_PT_virtools_group,
|
PROPS_virtools_group.BALLANCE_PT_virtools_group,
|
||||||
PROPS_virtools_material.BALLANCE_OT_apply_virtools_material,
|
PROPS_virtools_material.BALLANCE_OT_apply_virtools_material,
|
||||||
PROPS_virtools_material.BALLANCE_OT_parse_virtools_material,
|
PROPS_virtools_material.BALLANCE_OT_parse_virtools_material,
|
||||||
|
PROPS_virtools_material.BALLANCE_OT_preset_virtools_material,
|
||||||
PROPS_virtools_material.BALLANCE_PT_virtools_material,
|
PROPS_virtools_material.BALLANCE_PT_virtools_material,
|
||||||
|
|
||||||
OBJS_group_opers.BALLANCE_OT_select_virtools_group,
|
OBJS_group_opers.BALLANCE_OT_select_virtools_group,
|
||||||
|
Loading…
Reference in New Issue
Block a user