elif n.startswith("ankle_"):
b.lockYRot=True
+ def setSphereMap(material, index, blende_type=None):
+ pass
+
else:
# for 2.5
import bpy
#b.ik_dof_y=False
pass
+ def setSphereMap(material, index, blend_type=None):
+ slot=material.texture_slots[index]
+ slot.texture_coordinates='REFLECTION'
+ slot.mapping='SPHERE'
+ if blend_type:
+ slot.blend_type=blend_type
+
###############################################################################
def VtoV(v):
return (pos.x, pos.z, pos.y)
-def convert_uv(uv):
- return (uv.x, 1.0 - uv.y)
-
-
def to_radian(degree):
return math.pi * degree / 180
texture_name=m.getTexture()
if texture_name!='':
- if texture_name in textureMap:
- texture=textureMap[texture_name]
- else:
- try:
- texture, image=bl.texture.create(
- os.path.join(tex_dir, texture_name))
+ for i, t in enumerate(texture_name.split('*')):
+ if t in textureMap:
+ texture=textureMap[t]
+ else:
+ path=os.path.join(tex_dir, t)
+ texture, image=bl.texture.create(path)
textureMap[texture_name]=texture
imageMap[material_index]=image
- except:
- continue
- bl.material.addTexture(material, texture)
+ bl.material.addTexture(material, texture)
+ if t.endswith('sph'):
+ # sphere map
+ setSphereMap(material, i)
+ elif t.endswith('spa'):
+ # sphere map
+ setSphereMap(material, i, 'ADD')
+
bl.mesh.addMaterial(mesh, material)
index+=1
if io.indices[i] in shape_key_used_vertices:
return True
- # shapeキーで使われるマテリアルを記録する
- shape_key_materials=set()
+ material_with_shape=set()
+
# 各マテリアルの開始頂点インデックスを記録する
face_map={}
face_count=0
for i, m in enumerate(io.materials):
face_map[i]=face_count
if isMaterialUsedInShape(face_count, m):
- shape_key_materials.add(i)
+ material_with_shape.add(i)
face_count+=m.vertex_count
- # list化
- material_order=list(shape_key_materials)
+ # shapeキーで使われる頂点のあるマテリアル
+ material_with_shape=list(material_with_shape)
+ material_with_shape.sort()
- # shapeキーに使われていないマテリアルを後ろに追加
+ # shapeキーに使われていないマテリアル
+ material_without_shape=[]
for i in range(len(io.materials)):
- if not i in material_order:
- material_order.append(i)
+ if not i in material_with_shape:
+ material_without_shape.append(i)
- # ã\83\9eã\83\86ã\83ªã\82¢ã\83«16å\80\8bã\81\94ã\81¨ã\81«å\88\86å\89²ã\81\97ã\81\9fã\83¡ã\83\83ã\82·ã\83¥ã\82\92ä½\9cæ\88\90ã\81\99ã\82\8b
- material_offset=0
- mesh_objects=[]
- while material_offset<len(io.materials):
- mesh, meshObject=bl.mesh.create('mesh')
- # create object
- mesh_objects.append(meshObject)
+ # ã\83¡ã\83\83ã\82·ã\83¥ã\81®ç\94\9fæ\88\90
+ def __splitList(l, length):
+ for i in range(0, len(l), length):
+ yield l[i:i+length]
+
+ def __importMeshAndShape(material16, name):
+ mesh, meshObject=bl.mesh.create(name)
# activate object
bl.object.deselectAll()
# shapeキーで使われる順に並べなおしたマテリアル16個分の
# メッシュを作成する
vertex_map=__import16MaerialAndMesh(
- meshObject, io,
- material_order[material_offset:material_offset+16],
- face_map, tex_dir)
+ meshObject, io, material16, face_map, tex_dir)
# crete shape key
__importShape(meshObject, io, vertex_map)
mesh.update()
- material_offset+=16
-
+ return meshObject
+
+ mesh_objects=[__importMeshAndShape(material16, 'with_shape')
+ for material16 in __splitList(material_with_shape, 16)]
+
+ mesh_objects+=[__importMeshAndShape(material16, 'mesh')
+ for material16 in __splitList(material_without_shape, 16)]
+
return mesh_objects