Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # get verts near edges of bounding box
- # get unique sets
- # add unique sets to setArray\
- """
- Bit 000000 = z+,x-,z-,x+,y+,y-
- ValidType = 000000 type
- ValidOk = Compatible pairs
- ValidType 4444 (Roof)
- ValidOk = 4,3 (Roof, walls)
- 0 = ground
- 1 = road
- 3 = wall
- 4 = roof
- 5 = roof wall
- 6 = wall to ground
- 8 = under
- 9 = above
- """
- from pymel.core import *
- def isIn(BoundingBox, Position):#(bb,obj):#xmin ymin zmin xmax ymax zmax.
- isInBounds = False
- if Position[0] <= BoundingBox[0] or Position[0] >= BoundingBox[3]:
- add = 0
- elif Position[1] <= BoundingBox[1] or Position[1] >= BoundingBox[4]:
- add = 0
- elif Position[2] <= BoundingBox[2] or Position[2] >= BoundingBox[5]:
- add = 0
- else:
- add=1
- if add:
- isInBounds = True
- return isInBounds
- class Piece:
- def __init__(self):
- self.obj = []
- self.bb = []
- self.validType = []
- self.validOk = []
- self.pointPosArray = []
- self.validObjs = []
- def GetPoints(self, useBB):
- meshPoints = []
- for o in self.obj.listRelatives(c=1):
- for vtx in o.vtx:
- vtxPos = pointPosition(vtx,w=1)
- vtxPos = [vtxPos[0],vtxPos[1],vtxPos[2]]
- if useBB:
- bbOffset = [self.bb[0]-.1,self.bb[1]-.1,self.bb[2]-.1,self.bb[3]-.1,self.bb[4]-.1,self.bb[5]-.1]
- if not isIn(bbOffset, vtxPos):
- self.pointPosArray.append(vtxPos)
- def CompareMesh(self, Compare):
- meshCompatible = False
- meshLen = len(self.pointPosArray)
- meshCompareLen = len(Compare.pointPosArray)
- i = 0
- for p in self.pointPosArray:
- for pp in Compare.pointPosArray:
- if p == pp:
- print p, pp
- i+=1
- if i == meshLen:
- meshCompatible = True
- return meshCompatible
- # Create Piece object array
- PiecesGrp = ls("Pieces")[0].listRelatives(c=1)
- PiecesGrpLen = len(PiecesGrp)
- PieceArray = []
- for piece in PiecesGrp:
- newPiece = Piece()
- newPiece.obj = piece
- newPiece.validType = piece.listRelatives(c=1)[-2]
- newPiece.validOk = piece.listRelatives(c=1)[-1]
- #newPiece.bb = xform(piece,bb=1,q=1)
- #newPiece.GetPoints(1)
- """
- # Compare pieces
- PiecesGrpLen = len(PiecesGrp)
- for pieceObj in PieceArray:
- for pPieceObj in PieceArray:
- if pieceObj != pPieceObj:
- compareCheck = pieceObj.CompareMesh(pPieceObj)
- #print compareCheck
- if compareCheck:
- pieceObj.validObjs.append(pPieceObj)
- for validPiece in pieceObj.validObjs:
- print validPiece.obj
- """
Advertisement
Add Comment
Please, Sign In to add comment