X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=swig%2Fblender%2Fmqo_import.py;h=630501ec3a5ca415b8fb4e727635b7f36be1c8f9;hb=e4436302445448dfac7da7b9b9666786611d33ab;hp=1124a41b6edc84bd91319fa5859ff40c6675438d;hpb=49e6bf278e016039253ecfc21cd0999c49a4ac5d;p=meshio%2Fmeshio.git diff --git a/swig/blender/mqo_import.py b/swig/blender/mqo_import.py index 1124a41..630501e 100644 --- a/swig/blender/mqo_import.py +++ b/swig/blender/mqo_import.py @@ -46,12 +46,15 @@ if isBlender24(): def createMqoMaterial(m): material = Blender.Material.New( m.getName().encode(bl.INTERNAL_ENCODING)) - material.mode |= Blender.Material.Modes.SHADELESS + #material.mode |= Blender.Material.Modes.SHADELESS + # diffuse material.rgbCol = [m.color.r, m.color.g, m.color.b] material.alpha = m.color.a - material.amb = m.ambient - material.spec = m.specular - material.hard = int(255 * m.power) + # other + material.amb=m.ambient + material.spec=m.specular + material.hard=int(255 * m.power) + material.emit=m.emmit return material else: @@ -64,9 +67,19 @@ else: def createMqoMaterial(m): material = bpy.data.materials.new(m.getName()) + # shader + if m.shader==1: + material.diffuse_shader='FRESNEL' + else: + material.diffuse_shader='LAMBERT' + # diffuse material.diffuse_color=[m.color.r, m.color.g, m.color.b] - material.alpha=m.color.a material.diffuse_intensity=m.diffuse + material.alpha=m.color.a + # other + material.ambient = m.ambient + #material.specular = m.specular + material.emit=m.emit return material @@ -144,9 +157,9 @@ def __createObjects(mqo, root, materials, imageMap, scale): if o.getName().startswith('sdef'): objects.append(mesh_object) elif o.getName().startswith('anchor'): - bl.object.layerMask(mesh_object, [0, 1]) + bl.object.setLayerMask(mesh_object, [0, 1]) elif o.getName().startswith('bone'): - bl.object.layerMask(mesh_object, [0, 1]) + bl.object.setLayerMask(mesh_object, [0, 1]) # geometry vertices=[(v.x * scale, -v.z * scale, v.y * scale) for v in o.vertices] @@ -175,6 +188,7 @@ def __createObjects(mqo, root, materials, imageMap, scale): bl.mesh.addUV(mesh) for i, (f, face) in enumerate(zip(o.faces, mesh.faces)): uv_array=[] + # ToDo FIX # flip face for j in reversed(range(f.index_count)): uv_array.append((f.getUV(j).x, 1.0-f.getUV(j).y)) @@ -186,7 +200,7 @@ def __createObjects(mqo, root, materials, imageMap, scale): # mirror modifier if o.mirror: - bl.object.addMirrorModifier(mesh_object) + bl.modifier.addMirror(mesh_object) # set smoothing bl.mesh.setSmooth(mesh, o.smoothing)