io_scene_3ds: Moved specular color texture to specular tint #104918

Merged
Sebastian Sille merged 89 commits from :main into main 2023-09-27 00:42:09 +02:00
2 changed files with 36 additions and 14 deletions
Showing only changes of commit 8c5950824b - Show all commits

View File

@ -18,7 +18,7 @@ import bpy
bl_info = { bl_info = {
"name": "Autodesk 3DS format", "name": "Autodesk 3DS format",
"author": "Bob Holcomb, Campbell Barton, Andreas Atteneder, Sebastian Schrand", "author": "Bob Holcomb, Campbell Barton, Andreas Atteneder, Sebastian Schrand",
"version": (2, 4, 5), "version": (2, 4, 6),
"blender": (3, 6, 0), "blender": (3, 6, 0),
"location": "File > Import-Export", "location": "File > Import-Export",
"description": "3DS Import/Export meshes, UVs, materials, textures, " "description": "3DS Import/Export meshes, UVs, materials, textures, "
@ -188,13 +188,14 @@ class Export3DS(bpy.types.Operator, ExportHelper):
) )
object_filter: bpy.props.EnumProperty( object_filter: bpy.props.EnumProperty(
name="Object Filter", options={'ENUM_FLAG'}, name="Object Filter", options={'ENUM_FLAG'},
items=(('MESH',"Mesh".rjust(11),"",'MESH_DATA',0x1), items=(('WORLD', "World".rjust(11), "", 'WORLD_DATA',0x1),
('LIGHT',"Light".rjust(12),"",'LIGHT_DATA',0x2), ('MESH', "Mesh".rjust(11), "", 'MESH_DATA', 0x2),
('CAMERA',"Camera".rjust(11),"",'CAMERA_DATA',0x4), ('LIGHT', "Light".rjust(12), "", 'LIGHT_DATA',0x4),
('EMPTY',"Empty".rjust(11),"",'EMPTY_DATA',0x8), ('CAMERA', "Camera".rjust(11), "", 'CAMERA_DATA',0x8),
), ('EMPTY', "Empty".rjust(11), "", 'EMPTY_DATA',0x10),
),
description="Object types to export", description="Object types to export",
default={'MESH', 'LIGHT', 'CAMERA', 'EMPTY'}, default={'WORLD', 'MESH', 'LIGHT', 'CAMERA', 'EMPTY'},
) )
use_hierarchy: BoolProperty( use_hierarchy: BoolProperty(
name="Export Hierarchy", name="Export Hierarchy",
@ -248,10 +249,8 @@ class MAX3DS_PT_export_include(bpy.types.Panel):
operator = sfile.active_operator operator = sfile.active_operator
layout.prop(operator, "use_selection") layout.prop(operator, "use_selection")
laysub = layout.column(align=True) layout.column().prop(operator, "object_filter")
laysub.enabled = (not operator.use_selection) layout.prop(operator, "use_hierarchy")
laysub.prop(operator, "object_filter")
layout.column().prop(operator, "use_hierarchy")
layout.prop(operator, "write_keyframe") layout.prop(operator, "write_keyframe")

View File

@ -30,6 +30,12 @@ KFDATA = 0xB000 # This is the header for all of the keyframe info
# >----- sub defines of OBJECTINFO # >----- sub defines of OBJECTINFO
OBJECTINFO = 0x3D3D # Main mesh object chunk before material and object information OBJECTINFO = 0x3D3D # Main mesh object chunk before material and object information
MESHVERSION = 0x3D3E # This gives the version of the mesh MESHVERSION = 0x3D3E # This gives the version of the mesh
BITMAP = 0x1100 # The background image name
USE_BITMAP = 0x1101 # The background image flag
SOLIDBACKGND = 0x1200 # The background color (RGB)
USE_SOLIDBGND = 0x1201 # The background color flag
VGRADIENT = 0x1300 # The background gradient colors
USE_VGRADIENT = 0x1301 # The background gradient flag
AMBIENTLIGHT = 0x2100 # The color of the ambient light AMBIENTLIGHT = 0x2100 # The color of the ambient light
MATERIAL = 45055 # 0xAFFF // This stored the texture info MATERIAL = 45055 # 0xAFFF // This stored the texture info
OBJECT = 16384 # 0x4000 // This stores the faces, vertices, etc... OBJECT = 16384 # 0x4000 // This stores the faces, vertices, etc...
@ -1549,13 +1555,30 @@ def save(operator, context, filepath="", scale_factor=1.0, apply_unit=False, use
curtime = scene.frame_current curtime = scene.frame_current
kfdata = make_kfdata(revision, start, stop, curtime) kfdata = make_kfdata(revision, start, stop, curtime)
# Add AMBIENT color # Add AMBIENT and BACKGROUND color
if world is not None: if world is not None and 'WORLD' in object_filter:
ambient_chunk = _3ds_chunk(AMBIENTLIGHT) ambient_chunk = _3ds_chunk(AMBIENTLIGHT)
ambient_light = _3ds_chunk(RGB) ambient_light = _3ds_chunk(RGB)
ambient_light.add_variable("ambient", _3ds_float_color(world.color)) ambient_light.add_variable("ambient", _3ds_float_color(world.color))
ambient_chunk.add_subchunk(ambient_light) ambient_chunk.add_subchunk(ambient_light)
object_info.add_subchunk(ambient_chunk) object_info.add_subchunk(ambient_chunk)
if world.use_nodes:
ntree = world.node_tree.links
background_color = _3ds_chunk(RGB)
background_chunk = _3ds_chunk(SOLIDBACKGND)
background_flag = _3ds_chunk(USE_SOLIDBGND)
bgcol, bgtex, nworld = 'BACKGROUND', 'TEX_IMAGE', 'OUTPUT_WORLD'
bg_color = next((lk.from_node.inputs[0].default_value[:3] for lk in ntree if lk.to_node.type == nworld), world.color)
bg_image = next((lk.from_node.image.name for lk in ntree if lk.from_node.type == bgtex and lk.to_node.type in {bgcol, nworld}), False)
background_color.add_variable("color", _3ds_float_color(bg_color))
background_chunk.add_subchunk(background_color)
if bg_image:
background_image = _3ds_chunk(BITMAP)
background_flag = _3ds_chunk(USE_BITMAP)
background_image.add_variable("image", _3ds_string(sane_name(bg_image)))
object_info.add_subchunk(background_image)
object_info.add_subchunk(background_chunk)
object_info.add_subchunk(background_flag)
if write_keyframe and world.animation_data: if write_keyframe and world.animation_data:
kfdata.add_subchunk(make_ambient_node(world)) kfdata.add_subchunk(make_ambient_node(world))
@ -1564,7 +1587,7 @@ def save(operator, context, filepath="", scale_factor=1.0, apply_unit=False, use
mesh_objects = [] mesh_objects = []
if use_selection: if use_selection:
objects = [ob for ob in scene.objects if ob.visible_get(view_layer=layer) and ob.select_get(view_layer=layer)] objects = [ob for ob in scene.objects if ob.type in object_filter and ob.visible_get(view_layer=layer) and ob.select_get(view_layer=layer)]
else: else:
objects = [ob for ob in scene.objects if ob.type in object_filter and ob.visible_get(view_layer=layer)] objects = [ob for ob in scene.objects if ob.type in object_filter and ob.visible_get(view_layer=layer)]