New Addon: Import Autodesk .max #105013

Closed
Sebastian Sille wants to merge 136 commits from (deleted):nrgsille-import_max into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 30 additions and 2 deletions
Showing only changes of commit 76f58d2769 - Show all commits

View File

@ -54,6 +54,8 @@ MATSHINESS = 0xA040 # Specular intensity of the object/material (percent)
MATSHIN2 = 0xA041 # Reflection of the object/material (percent) MATSHIN2 = 0xA041 # Reflection of the object/material (percent)
MATSHIN3 = 0xA042 # metallic/mirror of the object/material (percent) MATSHIN3 = 0xA042 # metallic/mirror of the object/material (percent)
MATTRANS = 0xA050 # Transparency value (100-OpacityValue) (percent) MATTRANS = 0xA050 # Transparency value (100-OpacityValue) (percent)
MATXPFALL = 0xA052 # Transparency falloff ratio (percent)
MATREFBLUR = 0xA053 # Reflection blurring ratio (percent)
MATSELFILLUM = 0xA080 # # Material self illumination flag MATSELFILLUM = 0xA080 # # Material self illumination flag
MATSELFILPCT = 0xA084 # Self illumination strength (percent) MATSELFILPCT = 0xA084 # Self illumination strength (percent)
MATWIRE = 0xA085 # Material wireframe rendered flag MATWIRE = 0xA085 # Material wireframe rendered flag
@ -706,6 +708,7 @@ def make_material_chunk(material, image):
material_chunk.add_subchunk(make_percent_subchunk(MATSHIN2, wrap.specular)) material_chunk.add_subchunk(make_percent_subchunk(MATSHIN2, wrap.specular))
material_chunk.add_subchunk(make_percent_subchunk(MATSHIN3, wrap.metallic)) material_chunk.add_subchunk(make_percent_subchunk(MATSHIN3, wrap.metallic))
material_chunk.add_subchunk(make_percent_subchunk(MATTRANS, 1 - wrap.alpha)) material_chunk.add_subchunk(make_percent_subchunk(MATTRANS, 1 - wrap.alpha))
material_chunk.add_subchunk(make_percent_subchunk(MATXPFALL, wrap.transmission))
material_chunk.add_subchunk(make_percent_subchunk(MATSELFILPCT, wrap.emission_strength)) material_chunk.add_subchunk(make_percent_subchunk(MATSELFILPCT, wrap.emission_strength))
material_chunk.add_subchunk(shading) material_chunk.add_subchunk(shading)

View File

@ -361,6 +361,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
contextColor = None contextColor = None
contextWrapper = None contextWrapper = None
contextMatrix = None contextMatrix = None
contextTransmission = None
contextMesh_vertls = None contextMesh_vertls = None
contextMesh_facels = None contextMesh_facels = None
contextMesh_flag = None contextMesh_flag = None
@ -537,6 +538,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
contextWrapper.base_color = contextColor[:] contextWrapper.base_color = contextColor[:]
contextWrapper.metallic = contextMaterial.metallic contextWrapper.metallic = contextMaterial.metallic
contextWrapper.roughness = contextMaterial.roughness contextWrapper.roughness = contextMaterial.roughness
contextWrapper.transmission = contextTransmission
contextWrapper.specular = contextMaterial.specular_intensity contextWrapper.specular = contextMaterial.specular_intensity
contextWrapper.specular_tint = contextMaterial.specular_color[:] contextWrapper.specular_tint = contextMaterial.specular_color[:]
contextWrapper.emission_color = contextMaterial.line_color[:3] contextWrapper.emission_color = contextMaterial.line_color[:3]
@ -905,6 +907,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
# If material chunk # If material chunk
elif new_chunk.ID == MATERIAL: elif new_chunk.ID == MATERIAL:
contextAlpha = True contextAlpha = True
contextTransmission = False
contextColor = mathutils.Color((0.8, 0.8, 0.8)) contextColor = mathutils.Color((0.8, 0.8, 0.8))
contextMaterial = bpy.data.materials.new('Material') contextMaterial = bpy.data.materials.new('Material')
contextWrapper = PrincipledBSDFWrapper(contextMaterial, is_readonly=False, use_nodes=False) contextWrapper = PrincipledBSDFWrapper(contextMaterial, is_readonly=False, use_nodes=False)
@ -993,6 +996,14 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
contextMaterial.blend_method = 'BLEND' contextMaterial.blend_method = 'BLEND'
new_chunk.bytes_read += temp_chunk.bytes_read new_chunk.bytes_read += temp_chunk.bytes_read
elif new_chunk.ID == MAT_XPFALL:
read_chunk(file, temp_chunk)
if temp_chunk.ID == PCTI:
contextTransmission = float(read_short(temp_chunk) / 100)
else:
skip_to_end(file, temp_chunk)
new_chunk.bytes_read += temp_chunk.bytes_read
elif new_chunk.ID == MAT_SELF_ILPCT: elif new_chunk.ID == MAT_SELF_ILPCT:
read_chunk(file, temp_chunk) read_chunk(file, temp_chunk)
if temp_chunk.ID == PCT_SHORT: if temp_chunk.ID == PCT_SHORT:
@ -1010,6 +1021,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
contextWrapper.base_color = contextColor[:] contextWrapper.base_color = contextColor[:]
contextWrapper.metallic = contextMaterial.metallic contextWrapper.metallic = contextMaterial.metallic
contextWrapper.roughness = contextMaterial.roughness contextWrapper.roughness = contextMaterial.roughness
contextWrapper.transmission = contextTransmission
contextWrapper.specular = contextMaterial.specular_intensity contextWrapper.specular = contextMaterial.specular_intensity
contextWrapper.specular_tint = contextMaterial.specular_color[:] contextWrapper.specular_tint = contextMaterial.specular_color[:]
contextWrapper.emission_color = contextMaterial.line_color[:3] contextWrapper.emission_color = contextMaterial.line_color[:3]

View File

@ -18,7 +18,7 @@
bl_info = { bl_info = {
"name": "Sun Position", "name": "Sun Position",
"author": "Michael Martin, Damien Picard", "author": "Michael Martin, Damien Picard",
"version": (3, 5, 3), "version": (3, 5, 4),
"blender": (3, 2, 0), "blender": (3, 2, 0),
"location": "World > Sun Position", "location": "World > Sun Position",
"description": "Show sun position with objects and/or sky texture", "description": "Show sun position with objects and/or sky texture",

View File

@ -78,7 +78,19 @@ class SUNPOS_OT_ShowHdr(bpy.types.Operator):
@classmethod @classmethod
def poll(self, context): def poll(self, context):
sun_props = context.scene.sun_pos_properties sun_props = context.scene.sun_pos_properties
return sun_props.hdr_texture and sun_props.sun_object is not None if sun_props.sun_object is None:
self.poll_message_set("Please select a Sun object")
return False
if not sun_props.hdr_texture:
self.poll_message_set("Please select an Environment Texture node")
return False
nt = context.scene.world.node_tree.nodes
env_tex_node = nt.get(context.scene.sun_pos_properties.hdr_texture)
if env_tex_node is None or env_tex_node.type != "TEX_ENVIRONMENT":
self.poll_message_set("Please select a valid Environment Texture node")
return False
return True
def update(self, context, event): def update(self, context, event):
sun_props = context.scene.sun_pos_properties sun_props = context.scene.sun_pos_properties

View File

@ -116,6 +116,7 @@ class SunPosProperties(PropertyGroup):
description="Enter coordinates from an online map", description="Enter coordinates from an online map",
get=get_coordinates, get=get_coordinates,
set=set_coordinates, set=set_coordinates,
default="00°0000.00″ 00°0000.00″",
options={'SKIP_SAVE'}) options={'SKIP_SAVE'})
latitude: FloatProperty( latitude: FloatProperty(