Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- def GetSceneBounds(boundsList, doRound):#xmin ymin zmin xmax ymax zmax.
- sceneBB = [1000,1000,1000,-1000,-1000,-1000]
- for BB in boundsList:
- if BB[0] < sceneBB[0]:
- sceneBB[0] = BB[0]
- if BB[1] < sceneBB[1]:
- sceneBB[1] = BB[1]
- if BB[2] < sceneBB[2]:
- sceneBB[2] = BB[2]
- if BB[3] > sceneBB[3]:
- sceneBB[3] = BB[3]
- if BB[4] > sceneBB[4]:
- sceneBB[4] = BB[4]
- if BB[5] > sceneBB[5]:
- sceneBB[5] = BB[5]
- if doRound:
- sceneBBRounded = [0,0,0,0,0,0]
- i=0
- for BB in sceneBB:
- print round(BB)
- sceneBBRounded[i] = round(BB)
- i+=1
- return sceneBBRounded
- else:
- return sceneBB
- def showBB(BB):
- newBB = BB
- c = polyCube(w=0,h=0,d=0, n = "showCube_")
- move(newBB[0]+.5,0,0, str(c[0])+".f[5]", r=1,wd=1,ws=1)
- move(0,newBB[1]+.5,0, str(c[0])+".f[3]", r=1,wd=1,ws=1)
- move(0,0,newBB[2]+.5, str(c[0])+".f[2]", r=1,wd=1,ws=1)
- move(newBB[3]-.5,0,0, str(c[0])+".f[4]", r=1,wd=1,ws=1)
- move(0,newBB[4]-.5,0, str(c[0])+".f[1]", r=1,wd=1,ws=1)
- move(0,0,newBB[5]-.5, str(c[0])+".f[0]", r=1,wd=1,ws=1)
- def VoxelizeFromBB(BB):
- toGrp = []
- print BB[0]+BB[3]
- for i in range(BB[0],BB[3]):
- refresh(cw=1)
- c = polyCube()[0]
- move(c, x, y, z)
- scale(c, .2,.2,.2)
- toGrp.append(c)
- parent(toGrp, tmpGrp)
- class GridNode:
- def __init__(self):
- self.pos = []
- self.obj = []
- self.isActive = False
- ThingsGrp = ls("ThingsGrp")[0].listRelatives(c=1)
- #Bounding box objects
- BoundsGrp = ls("BoundsObjs")[0].listRelatives(c=1)
- BBList = []
- for bounds in BoundsGrp:
- BB = xform(bounds,bb=1,q=1)
- BBList.append(BB)
- sceneBB = GetSceneBounds(BBList, 0) # bb list, doRound
- #sceneBBCenter = (sceneBB[0]+sceneBB[3])/2, (sceneBB[1]+sceneBB[4])/2, (sceneBB[2]+sceneBB[5])/2
- showBB(sceneBB)
- #VoxelizeFromBB(sceneBB)
- """
- for s in ThingsGrp:
- for BB in BBList:
- boundCheck = isIn(BB,s.getTranslation())
- if not boundCheck:
- scale(s,.1,.1,.1)
- else:
- scale(s,1,1,1)
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement