New Addon: Import Autodesk .max #105013
@ -1,10 +1,6 @@
|
||||
# SPDX-FileCopyrightText: 2023 Sebastian Schrand
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
|
||||
#--- LICENSE ---
|
||||
# GNU GPL
|
||||
# Import is based on using information from olefile IO sourcecode
|
||||
# and the FreeCAD Autodesk 3DS Max importer ImportMAX
|
||||
#
|
||||
@ -37,8 +33,6 @@ import struct, array
|
||||
import time, datetime
|
||||
import math, mathutils
|
||||
import bpy, bpy_extras
|
||||
from bpy_extras import node_shader_utils
|
||||
from bpy_extras.image_utils import load_image
|
||||
from bpy_extras.io_utils import axis_conversion
|
||||
from bpy_extras.io_utils import orientation_helper
|
||||
|
||||
@ -1017,16 +1011,16 @@ def read_video_postqueue(maxfile, filename):
|
||||
def get_point(floatval, default=0.0):
|
||||
uid = get_guid(floatval)
|
||||
if (uid == 0x2007): # Bezier-Float
|
||||
fl = floatval.get_first(0x7127)
|
||||
if (fl):
|
||||
flv = floatval.get_first(0x7127)
|
||||
if (flv):
|
||||
try:
|
||||
return fl.get_first(0x2501).data[0]
|
||||
return flv.get_first(0x2501).data[0]
|
||||
except:
|
||||
print("SyntaxError: %s - assuming 0.0!\n" %(floatval))
|
||||
return default
|
||||
if (uid == 0x71F11549498702E7): # Float Wire
|
||||
fl = get_references(floatval)[0]
|
||||
return get_point(fl)
|
||||
flv = get_references(floatval)[0]
|
||||
return get_point(flv)
|
||||
else:
|
||||
return default
|
||||
|
||||
@ -1142,6 +1136,14 @@ def get_color(colors, idx):
|
||||
return None
|
||||
|
||||
|
||||
def get_value(colors, idx):
|
||||
prop = get_property(colors, idx)
|
||||
if (prop is not None):
|
||||
val, offset = get_float(prop.data, 15)
|
||||
return val
|
||||
return None
|
||||
|
||||
|
||||
def get_standard_material(refs):
|
||||
material = None
|
||||
try:
|
||||
@ -1153,9 +1155,9 @@ def get_standard_material(refs):
|
||||
material.set('diffuse', get_color(parameters, 0x01))
|
||||
material.set('specular', get_color(parameters, 0x02))
|
||||
material.set('emissive', get_color(parameters, 0x08))
|
||||
material.set('shinines', get_float(parameters, 0x0A))
|
||||
material.set('shinines', get_value(parameters, 0x0A))
|
||||
transparency = refs[4] # ParameterBlock2
|
||||
material.set('transparency', get_float(transparency, 0x02))
|
||||
material.set('transparency', get_value(transparency, 0x02))
|
||||
except:
|
||||
pass
|
||||
return material
|
||||
@ -1168,8 +1170,8 @@ def get_vray_material(vry):
|
||||
material.set('ambient', get_color(vry, 0x02))
|
||||
material.set('specular', get_color(vry, 0x05))
|
||||
material.set('emissive', get_color(vry, 0x05))
|
||||
material.set('shinines', get_float(vry, 0x0B))
|
||||
material.set('transparency', get_float(vry, 0x02))
|
||||
material.set('shinines', get_value(vry, 0x0B))
|
||||
material.set('transparency', get_value(vry, 0x02))
|
||||
except:
|
||||
pass
|
||||
return material
|
||||
@ -1182,8 +1184,8 @@ def get_arch_material(ad):
|
||||
material.set('ambient', get_color(ad, 0x02))
|
||||
material.set('specular', get_color(ad, 0x05))
|
||||
material.set('emissive', get_color(ad, 0x05))
|
||||
material.set('shinines', get_float(ad, 0x0B))
|
||||
material.set('transparency', get_float(ad, 0x02))
|
||||
material.set('shinines', get_value(ad, 0x0B))
|
||||
material.set('transparency', get_value(ad, 0x02))
|
||||
except:
|
||||
pass
|
||||
return material
|
||||
@ -1209,7 +1211,7 @@ def adjust_material(obj, mat):
|
||||
objMaterial = bpy.data.materials.new(get_class_name(mat))
|
||||
obj.data.materials.append(objMaterial)
|
||||
objMaterial.diffuse_color[:3] = material.get('diffuse', (0.8,0.8,0.8))
|
||||
objMaterial.specular_color[:3] = material.get('specular', (0,0,0))
|
||||
objMaterial.specular_color[:3] = material.get('specular', (1.0,1.0,1.0))
|
||||
objMaterial.roughness = 1.0 - material.get('shinines', 0.6)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user