重複頂点の検索キー
"""
__slots__=[
- 'index',
+ 'obj', 'index',
'x', 'y', 'z', # 位置
'nx', 'ny', 'nz', # 法線
'u', 'v', # uv
]
- def __init__(self, index, x, y, z, nx, ny, nz, u, v):
+ def __init__(self, obj, index, x, y, z, nx, ny, nz, u, v):
+ self.obj=obj
self.index=index
self.x=x
self.y=y
#return near(self.x, rhs.x) and near(self.y, rhs.y) and near(self.z, rhs.z) and near(self.nx, rhs.nx) and near(self.ny, rhs.ny) and near(self.nz, rhs.nz) and near(self.u, rhs.u) and near(self.v, rhs.v)
#return near(self.x, rhs.x) and near(self.y, rhs.y) and near(self.z, rhs.z)
#return self.x==rhs.x and self.y==rhs.y and self.z==rhs.z
- return self.index==rhs.index
+ return self.obj==rhs.obj and self.index==rhs.index
class VertexArray(object):
self.vertices, self.normals, self.uvs,
self.b0, self.b1, self.weight)
- def __getIndex(self, base_index, pos, normal, uv, b0, b1, weight0):
+ def __getIndex(self, obj, base_index, pos, normal, uv, b0, b1, weight0):
"""
頂点属性からその頂点のインデックスを得る
"""
key=VertexKey(
- base_index,
+ obj, base_index,
pos[0], pos[1], pos[2],
normal[0], normal[1], normal[2],
uv[0], uv[1])
return self.indexMap[base_index]
def addTriangle(self,
- material,
+ obj, material,
base_index0, base_index1, base_index2,
pos0, pos1, pos2,
n0, n1, n2,
if not material in self.indexArrays:
self.indexArrays[material]=[]
- index0=self.__getIndex(base_index0, pos0, n0, uv0, b0_0, b1_0, weight0)
- index1=self.__getIndex(base_index1, pos1, n1, uv1, b0_1, b1_1, weight1)
- index2=self.__getIndex(base_index2, pos2, n2, uv2, b0_2, b1_2, weight2)
+ index0=self.__getIndex(obj, base_index0, pos0, n0, uv0, b0_0, b1_0, weight0)
+ index1=self.__getIndex(obj, base_index1, pos1, n1, uv1, b0_1, b1_1, weight1)
+ index2=self.__getIndex(obj, base_index2, pos2, n2, uv2, b0_2, b1_2, weight2)
self.indexArrays[material]+=[index0, index1, index2]
class OneSkinMesh(object):
- __slots__=['scene', 'vertexArray', 'morphList']
+ __slots__=['obj_index', 'scene', 'vertexArray', 'morphList']
def __init__(self, scene):
self.vertexArray=VertexArray()
self.morphList=[]
self.scene=scene
+ self.obj_index=0
def __str__(self):
return "<OneSkinMesh %s, morph:%d>" % (
if faceVertexCount==3:
# triangle
self.vertexArray.addTriangle(
- material.name,
+ self.obj_index, material.name,
v[0].index, v[1].index, v[2].index,
v[0].co, v[1].co, v[2].co,
# ToDo vertex normal
elif faceVertexCount==4:
# quadrangle
self.vertexArray.addTriangle(
- material.name,
+ self.obj_index, material.name,
v[0].index, v[1].index, v[2].index,
v[0].co, v[1].co, v[2].co,
#v0.no, v1.no, v2.no,
weightMap[v[2].index][1]
)
self.vertexArray.addTriangle(
- material.name,
+ self.obj_index, material.name,
v[2].index, v[3].index, v[0].index,
v[2].co, v[3].co, v[0].co,
#v2.no, v3.no, v0.no,
weightMap[v[0].index][1]
)
bl.objectDelete(self.scene, copyObj)
+ self.obj_index+=1
def __skin(self, obj):
if not bl.objectHasShapeKey(obj):