本文整理汇总了Python中maya.cmds.exactWorldBoundingBox函数的典型用法代码示例。如果您正苦于以下问题:Python exactWorldBoundingBox函数的具体用法?Python exactWorldBoundingBox怎么用?Python exactWorldBoundingBox使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exactWorldBoundingBox函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: search
def search(self):
for a in self.follicleGrp:
cm.group(n='group_'+str(a), em=True, w=True)
x1, y1, z1, x2, y2, z2 = cm.exactWorldBoundingBox(a)
x1 = (x1+x2)/2
y1 = (y1+y2)/2
z1 = (z1+z2)/2
x1 = abs(x1)
y1 = abs(y1)
z1 = abs(z1)
for b in self.curveGrp:
x1c, y1c, z1c, x2c, y2c, z2c = cm.exactWorldBoundingBox(b)
x1c = abs(x1c)
y1c = abs(y1c)
z1c = abs(z1c)
diffx1=x1c-x1
diffy1=y1c-y1
diffz1=z1c-z1
if diffx1<self.Dist and diffx1>-self.Dist and diffy1<self.Dist and diffy1>-self.Dist and diffz1<self.Dist and diffz1>-self.Dist:
if cm.listRelatives(b, p=False):
print b, 'Has no parent'
cm.parent(b, 'group_'+str(a))
more = 0
for c in self.curveGrp:
if cm.listRelatives(c, p=False):
more = 1
if more==1:
self.Dist += (self.Dist*.8)
print '***Refining search.'
new.refineSearch()
开发者ID:EllieAnsell,项目名称:FMP_Scripts,代码行数:33,代码来源:HairFollicleScript.py
示例2: refineSearch
def refineSearch(self):
for a in self.curveGrp:
if cm.listRelatives(a, p=True):
self.curveGrp.remove(a)
for a in self.follicleGrp:
cm.group(n='group_2_'+str(a), em=True, w=True)
x1, y1, z1, x2, y2, z2 = cm.exactWorldBoundingBox(a)
x1 = (x1+x2)/2
y1 = (y1+y2)/2
z1 = (z1+z2)/2
x1 = abs(x1)
y1 = abs(y1)
z1 = abs(z1)
for b in self.curveGrp:
x1c, y1c, z1c, x2c, y2c, z2c = cm.exactWorldBoundingBox(b)
x1c = abs(x1c)
y1c = abs(y1c)
z1c = abs(z1c)
diffx1=x1c-x1
diffy1=y1c-y1
diffz1=z1c-z1
if diffx1<self.Dist and diffx1>-self.Dist and diffy1<self.Dist and diffy1>-self.Dist and diffz1<self.Dist and diffz1>-self.Dist:
if cm.listRelatives(b, p=False):
print b, 'has no parent'
cm.parent(b, 'group_2_'+str(a))
else:
pass
开发者ID:EllieAnsell,项目名称:FMP_Scripts,代码行数:29,代码来源:HairFollicleScript.py
示例3: BBintersection
def BBintersection(obj1, obj2):
#derive the bounding box that is the intersection of two bounding boxes
#coords returned as MVector
BB1 = mc.exactWorldBoundingBox(obj1)
BB2 = mc.exactWorldBoundingBox(obj2)
BB1min = om.MVector(BB1[0],BB1[1],BB1[2])
BB1max = om.MVector(BB1[3],BB1[4],BB1[5])
BB2min = om.MVector(BB2[0],BB2[1],BB2[2])
BB2max = om.MVector(BB2[3],BB2[4],BB2[5])
if BB1min.x >= BB2min.x: outMinX = BB1min.x
if BB1min.x <= BB2min.x: outMinX = BB2min.x
if BB1min.y >= BB2min.y: outMinY = BB1min.y
if BB1min.y <= BB2min.y: outMinY = BB2min.y
if BB1min.z >= BB2min.z: outMinZ = BB1min.z
if BB1min.z <= BB2min.z: outMinZ = BB2min.z
outMin = om.MVector(outMinX,outMinY,outMinZ)
if BB1max.x <= BB2max.x: outMaxX = BB1max.x
if BB1max.x >= BB2max.x: outMaxX = BB2max.x
if BB1max.y <= BB2max.y: outMaxY = BB1max.y
if BB1max.y >= BB2max.y: outMaxY = BB2max.y
if BB1max.z <= BB2max.z: outMaxZ = BB1max.z
if BB1max.z >= BB2max.z: outMaxZ = BB2max.z
outMax = om.MVector(outMaxX,outMaxY,outMaxZ)
return outMin,outMax
开发者ID:pinkwerks,项目名称:Maya-Scripts,代码行数:32,代码来源:dg_voroPy.py
示例4: placeTreesInSquare
def placeTreesInSquare(squareBbox, shaders):
'''
Places trees randomly in a given square.
squareBbox: A list of two tuples containing the x- and z-coordinates for the
bounding box of a square.
shaders: A list of shaders for the tree crowns.
On exit: A cube of the same size as the square been created and assigned a green
shader in order to make it look like grass. Trees have created using
makeTree(...), and placed randomly using a dart throwing algorithm which
gives up after six failed attempts. Everything is united into one object
which is returned as a tuple with the object name and the node name.
'''
treeList = []
width = squareBbox[1][0] - squareBbox[0][0]
depth = squareBbox[1][1] - squareBbox[0][1]
grass = cmds.polyCube(name = "grass", h = 0.3, w = width, d = depth)
cmds.xform(grass, translation = (squareBbox[0][0] + 0.5 * width,0.15,squareBbox[0][1] + 0.5 * depth))
cmds.sets(grass[0], edit=True, forceElement="grassMaterialGroup")
while True:
failCount = 0
tree = makeTree(shaders)
treeList.append(tree)
bbox1 = cmds.exactWorldBoundingBox(tree[0])
radius = (bbox1[3] - bbox1[0]) / 2.0
coorx = random.uniform(squareBbox[0][0] + radius, squareBbox[1][0] - radius)
coorz = random.uniform(squareBbox[0][1] + radius, squareBbox[1][1] - radius)
cmds.xform(tree[0], translation = (coorx, 0, coorz))
while True:
failed = False
for j in treeList:
bbox1 = cmds.exactWorldBoundingBox(tree[0])
bbox2 = cmds.exactWorldBoundingBox(j[0])
# Check if the tree intersects with element j in treeList.
xinters = (bbox1[0] < bbox2[3] and bbox1[0] > bbox2[0])\
or (bbox2[0] < bbox1[3] and bbox2[0] > bbox1[0])
zinters = (bbox1[2] < bbox2[5] and bbox1[2] > bbox2[2])\
or (bbox2[2] < bbox1[5] and bbox2[2] > bbox1[2])
if xinters and zinters:
coorx = random.uniform(squareBbox[0][0] + radius, squareBbox[1][0] - radius)
coorz = random.uniform(squareBbox[0][1] + radius, squareBbox[1][1] - radius)
cmds.xform(tree[0], translation = (coorx, 0, coorz))
failCount = failCount + 1
failed = True
break
if (failed == False) or (failCount > 5):
break
if (failCount > 5) or (len(treeList) == 10):
break
cmds.delete(tree[0]) # Delete the last tree that was not successfully placed.
treeList.pop()
for i in treeList:
grass = cmds.polyUnite(grass[0], i[0])
return grass
开发者ID:hcbsundberg,项目名称:City_Generator,代码行数:54,代码来源:park.py
示例5: BBoxToCurve
def BBoxToCurve( obj, autoParent = False ):
bbinfo = mc.exactWorldBoundingBox( obj ) # xmin, ymin, zmin, xmax, ymax, zmax
point1 = [bbinfo[0],bbinfo[1],bbinfo[2]]
point2 = [bbinfo[3],bbinfo[4],bbinfo[5]]
coords = ([point1[0], point2[1], point2[2] ],
point2,
[ point2[0], point2[1], point1[2] ],
[ point1[0], point2[1], point1[2] ],
[ point1[0], point2[1], point2[2] ],
[ point1[0], point1[1], point2[2] ],
point1,
[ point2[0], point1[1], point1[2] ],
[ point2[0], point1[1], point2[2] ],
[ point1[0], point1[1], point2[2] ],
[ point2[0], point1[1], point2[2] ],
point2,
[ point2[0], point2[1], point1[2] ],
[ point2[0], point1[1], point1[2] ],
point1,
[ point1[0], point2[1], point1[2] ])
bbox = mc.curve( d = 1, p = coords, k = [ a for a in range(len(coords))], n = "cube#" )
if autoParent:
shape = mc.listRelatives( bbox, f = True, s = True )
mc.select( shape, obj )
mc.parent( add = True, shape = True )
mc.delete( bbox )
return bbox
开发者ID:skarone,项目名称:PipeL,代码行数:27,代码来源:bBoxToCurve.py
示例6: bulge_button
def bulge_button( self, *args ):
if( cmds.objExists( "ZBend" ) ):
cmds.confirmDialog( title="Error", message="First delete the bulge history on the previously\ndeformed object before bulging another.", button="Okie Dokie" )
return 0
latestSelection = cmds.ls( selection=True )
if( len( latestSelection ) == 0 ):
return 0
if( len( latestSelection ) == 1 ):
self.relatives = cmds.listRelatives( children=True )
if( len(self.relatives) == 1 ):
self.bbox = cmds.exactWorldBoundingBox( latestSelection )
cmds.nonLinear( type='bend', curvature=cmds.intSliderGrp( "x_bulge_slider", value=True, query=True ) )
cmds.rename( "XBend" )
cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, "XBend", rpr=True )
cmds.setAttr( "XBend.rotateZ", -90 )
cmds.select( latestSelection )
cmds.nonLinear( type='bend', curvature=cmds.intSliderGrp( "z_bulge_slider", value=True, query=True ) )
cmds.rename( "ZBend" )
cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, "ZBend", rpr=True )
cmds.setAttr( "ZBend.rotateZ", -90 )
cmds.setAttr( "ZBend.rotateX", 90 )
cmds.connectControl( "x_bulge_slider", "bend1.curvature" )
cmds.connectControl( "z_bulge_slider", "bend2.curvature" )
cmds.select( latestSelection )
开发者ID:cwilmot,项目名称:maya-bulge-deformer-tool,代码行数:30,代码来源:MayaBulgeTool.py
示例7: duplicate_button
def duplicate_button( self, *args ):
self.original_selected_objects = cmds.ls( selection=True )
if( len(self.original_selected_objects) == 0 ):
print "Nothing selected"
return 0
elif( len(self.original_selected_objects) == 1 ):
self.relatives = cmds.listRelatives( children=True )
if( len(self.relatives) == 1 ):
print "Skip combine"
cmds.duplicate( self.original_selected_objects, name=self.original_selected_objects[0] + "_Copy" )
cmds.delete( constructionHistory=True )
the_parent = cmds.listRelatives( parent=True )
if( the_parent != None ):
cmds.parent( self.original_selected_objects[0] + "_Copy", world=True )
else:
self.combine()
else:
self.combine()
self.newOriginCopy = cmds.ls( selection=True )[0]
self.bbox = cmds.exactWorldBoundingBox( self.newOriginCopy )
cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, self.newOriginCopy + ".scalePivot", self.newOriginCopy + ".rotatePivot", absolute=True)
cmds.move( 0, 0, 0, self.newOriginCopy, rpr=True )
cmds.makeIdentity( apply=True, t=1, r=1, s=1 )
cmds.delete( constructionHistory=True )
开发者ID:cwilmot,项目名称:maya-bulge-deformer-tool,代码行数:30,代码来源:MayaBulgeTool.py
示例8: setLocs
def setLocs(mesh):
global voxelSize, cubeSize, xmin, xmax, ymin, ymax, zmin, zmax, xLocs, yLocs, zLocs
bb = cmds.exactWorldBoundingBox(mesh)
xmin = bb[0]
ymin = bb[1]
zmin = bb[2]
xmax = bb[3]
ymax = bb[4]
zmax = bb[5]
# make 3 arrays of ray start points, one for each axis
xLocs = []
yLocs = []
zLocs = []
fac = 1/voxelSize
for y in range(int(ymin*fac), int(ymax*fac+1)):
for z in range(int(zmin*fac), int(zmax*fac+1)):
loc = (xmax, y*voxelSize, z*voxelSize)
xLocs.append(loc)
for z in range(int(zmin*fac), int(zmax*fac+1)):
for x in range(int(xmin*fac), int(xmax*fac+1)):
loc = (x*voxelSize, ymax, z*voxelSize)
yLocs.append(loc)
for x in range(int(xmin*fac), int(xmax*fac+1)):
for y in range(int(ymin*fac), int(ymax*fac+1)):
loc = (x*voxelSize, y*voxelSize, zmax)
zLocs.append(loc)
开发者ID:n1ckfg,项目名称:MayaToolbox,代码行数:29,代码来源:other_voxelizer.py
示例9: exactLocalBoundingBox
def exactLocalBoundingBox(*args,**keywords):
if len(args)==0:
args=mc.ls(sl=True)
obj=args[0]
r=False #relative to the rotate pivot
for k in keywords:
if k=='r' or k=='relative':
r=keywords[k]
if k in locals():
exec(k+'=keywords[k]')
t,r,s=mc.getAttr(obj+'.t')[0],mc.getAttr(obj+'.r')[0],mc.getAttr(obj+'.s')[0]
mc.setAttr(obj+'.t',0,0,0)
mc.setAttr(obj+'.r',0,0,0)
mc.setAttr(obj+'.s',1,1,1)
if r:
rp=mc.xform(obj,q=True,ws=True,rp=True)
mc.xform(obj,ws=True,t=(-rp[0],-rp[1],-rp[2]))
returnVal=mc.exactWorldBoundingBox(obj)
mc.setAttr(obj+'.t',*t)
mc.setAttr(obj+'.r',*r)
mc.setAttr(obj+'.s',*s)
return returnVal
开发者ID:jonntd,项目名称:zentools,代码行数:32,代码来源:exactLocalBoundingBox.py
示例10: _get_recommended_pivot_bank
def _get_recommended_pivot_bank(self, geometries, tm_ref, tm_ref_dir, pos_toes, direction=1):
"""
Determine recommended position using ray-cast from the toes.
TODO: If the ray-case fail, use a specified default value.
return: The recommended position as a world pymel.datatypes.Vector
"""
# Sanity check, ensure that at least one point is in the bounds of geometries.
# This can prevent rays from being fired from outside a geometry.
# TODO: Make it more robust.
filtered_geometries = []
for geometry in geometries:
xmin, ymin, zmin, xmax, ymax, zmax = cmds.exactWorldBoundingBox(geometry.__melobject__())
bound = pymel.datatypes.BoundingBox((xmin, ymin, zmin), (xmax, ymax, zmax))
if bound.contains(pos_toes):
filtered_geometries.append(geometry)
dir = pymel.datatypes.Point(direction, 0, 0) * tm_ref_dir
pos = libRigging.ray_cast_nearest(pos_toes, dir, filtered_geometries)
if not pos:
cmds.warning("Can't automatically solve FootRoll bank inn pivot.")
pos = pos_toes
pos.y = 0
return pos
开发者ID:renaudll,项目名称:omtk,代码行数:25,代码来源:rigLeg.py
示例11: make_origin_target
def make_origin_target():
o = cmds.polySphere() # create a sphere
cmds.select(o) # select the sphere
bbox = cmds.exactWorldBoundingBox() # create bounding box around it
bottom = [(bbox[0] + bbox[3])/2, bbox[1], (bbox[2] + bbox[5])/2] # define the bottom of the bounding box
cmds.xform(piv=bottom, ws=True) # move the sphere to the bottom of the bounding box
cmds.move(rpr=True)
cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) # freeze transforms
开发者ID:njculpin,项目名称:maya_scripts,代码行数:8,代码来源:make_fibonacci.py
示例12: isBoundingBoxCross
def isBoundingBoxCross( firstObj, secondObj ):
bboxFirst = cmds.exactWorldBoundingBox( firstObj )
bboxSecond = cmds.exactWorldBoundingBox( secondObj )
firstMin = bboxFirst[:3]
firstMax = bboxFirst[3:]
secondMin = bboxSecond[:3]
secondMax = bboxSecond[3:]
isCross = True
for dimantion in [ [0,1], [1,2], [2,0] ]:
for i in dimantion:
if firstMax[i] < secondMin[i] or firstMin[i] > secondMax[i]:
isCross = False
break
return isCross
开发者ID:jonntd,项目名称:mayadev-1,代码行数:17,代码来源:sgBFunction_dag.py
示例13: failUnlessCubeWidthEqual
def failUnlessCubeWidthEqual(self, timeValueList):
for time, value in timeValueList:
MayaCmds.currentTime(time, update = True)
bbox = MayaCmds.exactWorldBoundingBox('cube')
width = bbox[3] - bbox[0]
self.failUnlessAlmostEqual(
value, width, 3,
'Time: %f, Width: %f (expected) != %f' % (time, value, width))
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:8,代码来源:multipleFrameRange_test.py
示例14: create_guide
def create_guide():
if cmds.objExists('loc_guide_deformer'):
cmds.delete('loc_guide_deformer')
bound_centre = [0,0,0]
if len(cmds.ls(sl=True)) is not 0:
bound = cmds.exactWorldBoundingBox(cmds.ls (sl = True))
bound_centre = [(bound[0] + bound[3])/2, (bound[1] + bound[4])/2, (bound[2] + bound[5])/2]
cmds.spaceLocator (n="loc_guide_deformer", a = True, p = (bound_centre[0], bound_centre[1], bound_centre[2]))
cmds.CenterPivot()
开发者ID:MaxIsJames,项目名称:max-scripts,代码行数:9,代码来源:softcluster.py
示例15: run
def run():
"""Measure the scene bounding box for geometric objects in centimeters.
---
units, bounding box, center and dimensions for scene
sceneboundingbox() -> (string,
float, float, float,
float, float, float,
float, float, float,
float, float, float)
"""
t0 = float(time.time())
verbose = cmds.optionVar(query='checkmateVerbosity')
units = cmds.currentUnit(query=True, linear=True)
if units != 'cm' :
cmds.currentUnit(linear='cm')
#raise InvalidLinearUnits, "current linear unit is not centimeters"
transforms = cmds.ls(transforms=True)
geometry = cmds.ls(geometry=True)
try:
bbox = cmds.exactWorldBoundingBox(geometry)
except TypeError:
return (units,
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0)
(bbMinX, bbMinY, bbMinZ,
bbMaxX, bbMaxY, bbMaxZ) = cmds.exactWorldBoundingBox(geometry)
width = bbMaxX - bbMinX
height = bbMaxY - bbMinY
depth = bbMaxZ - bbMinZ
centerX = ( bbMaxX + bbMinX ) / 2.0
centerY = ( bbMaxY + bbMinY ) / 2.0
centerZ = ( bbMaxZ + bbMinZ ) / 2.0
print '%-24s : %.6f seconds' % ('stats.bbox.run()',
float(time.time())-t0
)
return (units,
bbMinX, bbMinY, bbMinZ,
bbMaxX, bbMaxY, bbMaxZ,
centerX, centerY, centerZ,
width, height, depth)
开发者ID:Kif11,项目名称:turbosquid_maya_publisher,代码行数:44,代码来源:bbox.py
示例16: moveToOrigin
def moveToOrigin():
# group and move all geo to origin
cmds.select(cmds.listRelatives(cmds.ls(geometry=True), p=True, path=True), r=True)
cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
cmds.group(n='tempGroup')
bbox = cmds.exactWorldBoundingBox()
bottom = [(bbox[0] + bbox[3])/2, bbox[1], (bbox[2] + bbox[5])/2]
cmds.xform(piv=bottom, ws=True)
cmds.move(rpr=True)
cmds.ungroup('tempGroup')
开发者ID:njculpin,项目名称:maya_scripts,代码行数:10,代码来源:make_mandlebulb_shape.py
示例17: create_world_button
def create_world_button( self, *args ):
if( cmds.objExists( "OurSampleWorld" ) ):
return 0
else:
cmds.sphere( r=10, sections=40, spans=30, name="OurSampleWorld" )
cmds.setAttr( "OurSampleWorld.scale", 9.599, 9.599, 9.599 )
cmds.makeIdentity( apply=True, t=1, r=1, s=1 )
self.wbbox = cmds.exactWorldBoundingBox( "OurSampleWorld" )
cmds.move((self.wbbox[0] + self.wbbox[3])/2, self.wbbox[4], (self.wbbox[2] + self.wbbox[5])/2, "OurSampleWorld.scalePivot", "OurSampleWorld.rotatePivot", absolute=True)
cmds.move( 0, 0, 0, "OurSampleWorld", rpr=True )
cmds.connectControl( "world_size_slider", "OurSampleWorld.scaleX", "OurSampleWorld.scaleY", "OurSampleWorld.scaleZ" )
开发者ID:cwilmot,项目名称:maya-bulge-deformer-tool,代码行数:11,代码来源:MayaBulgeTool.py
示例18: createBirail
def createBirail(curveGrp) :
eachCrvGrp = cmds.listRelatives(curveGrp)
shapeEachCrvGrp = cmds.listRelatives(eachCrvGrp, children=True)
meshInGrp = cmds.ls(shapeEachCrvGrp, type='mesh')
if len(eachCrvGrp)>3 and len(meshInGrp)==0 :
#checking if curves are in right order
intersect1 = cmds.curveIntersect(eachCrvGrp[0], eachCrvGrp[1])
intersect2 = cmds.curveIntersect(eachCrvGrp[0], eachCrvGrp[2])
intersect3 = cmds.curveIntersect(eachCrvGrp[0], eachCrvGrp[3])
curveOrder = []
if str(intersect1)=='None' :
curveOrder = [eachCrvGrp[0], eachCrvGrp[2], eachCrvGrp[1], eachCrvGrp[3]]
elif str(intersect3)=='None' :
curveOrder = [eachCrvGrp[0], eachCrvGrp[1], eachCrvGrp[3], eachCrvGrp[2]]
else :
curveOrder = eachCrvGrp
#
crv1shape = cmds.listRelatives(curveOrder[1], children=True)
crv1spans = cmds.getAttr(crv1shape[0]+'.spans')
crv2shape = cmds.listRelatives(curveOrder[0], children=True)
crv2spans = cmds.getAttr(crv2shape[0]+'.spans')
#creating birail
if crv1spans<crv2spans :
mesh = cmds.doubleProfileBirailSurface([curveOrder[1], curveOrder[3], curveOrder[0] ,curveOrder[2]], bl = 0.5 ,tp2 = 0 , ch = True , po = 1 ,tm = 1 , tp1 = 0)
else :
mesh = cmds.doubleProfileBirailSurface([curveOrder[0] ,curveOrder[2], curveOrder[1], curveOrder[3]], bl = 0.5 ,tp2 = 0 , ch = True , po = 1 ,tm = 1 , tp1 = 0)
shape = cmds.listRelatives(mesh, children = True)[0]
tess = cmds.listConnections(shape + '.inMesh')
density = 12
bboxGrp = cmds.exactWorldBoundingBox(curveGrp)
cmds.setAttr(tess[0] + '.polygonType', 1)
cmds.setAttr(tess[0] + '.uType', 1)
cmds.setAttr(tess[0] + '.vType', 1)
cmds.setAttr(tess[0] + '.format', 2)
#check the order of u and v for tesselation to be homogeneous
if ((bboxGrp[3] - bboxGrp[0])*density)>((bboxGrp[4] - bboxGrp[1])*density) :
cmds.setAttr(tess[0] + '.uNumber', int((bboxGrp[3] - bboxGrp[0])*density))
cmds.setAttr(tess[0] + '.vNumber', int((bboxGrp[4] - bboxGrp[1])*density))
else :
cmds.setAttr(tess[0] + '.vNumber', int((bboxGrp[3] - bboxGrp[0])*density))
cmds.setAttr(tess[0] + '.uNumber', int((bboxGrp[4] - bboxGrp[1])*density))
cmds.parent(mesh[0], curveGrp)
开发者ID:AndresMWeber,项目名称:aw,代码行数:54,代码来源:marvelousToMaya.py
示例19: bbMinMaxMVector
def bbMinMaxMVector(obj):
#returns the vector values of the BB of an object
objBB = mc.exactWorldBoundingBox(obj)
objBBmin = om.MVector(objBB[0],objBB[1],objBB[2])
objBBmax = om.MVector(objBB[3],objBB[4],objBB[5])
centre = (objBBmin + objBBmax )/2
outmin = objBBmin - centre
outmax = objBBmax - centre
return outmin, outmax
开发者ID:pinkwerks,项目名称:Maya-Scripts,代码行数:11,代码来源:dg_voroPy.py
示例20: buildBoundingBoxGeo
def buildBoundingBoxGeo(objectName, noChildren, ignoreInv):
'''
Builds a bounding box from the selected object.
'''
# as a workaround to a Maya bug duplicate said object to use to evaluate the box size (I know it's messy)
duplicatedObject = cmds.duplicate(objectName, rc=True, un=False, ic=False, n='duplicated_'+objectName)
dupObjChildren = cmds.listRelatives(duplicatedObject, children=True, typ='transform')
# unlock attributes so we can freeze the duped geo
for piece in duplicatedObject:
cmds.setAttr(piece+".translateX", lock=False)
cmds.setAttr(piece+".translateY", lock=False)
cmds.setAttr(piece+".translateZ", lock=False)
cmds.setAttr(piece+".translate", lock=False)
cmds.setAttr(piece+".rotateX", lock=False)
cmds.setAttr(piece+".rotateY", lock=False)
cmds.setAttr(piece+".rotateZ", lock=False)
cmds.setAttr(piece+".rotate", lock=False)
cmds.setAttr(piece+".scaleX", lock=False)
cmds.setAttr(piece+".scaleY", lock=False)
cmds.setAttr(piece+".scaleZ", lock=False)
cmds.setAttr(piece+".scale", lock=False)
# delete children if we want only the one object
if noChildren:
cmds.select(dupObjChildren, r=True)
cmds.delete()
# unparent and freeze the geo (cause maya doesn't calculate the box properly otherwise)
if cmds.listRelatives(duplicatedObject[0], p=True):
newName = cmds.parent(duplicatedObject[0], w=True)
cmds.makeIdentity(duplicatedObject[0], apply=True,translate=True, rotate=True, scale=True)
# get the bounding box then blow away the duped geo
boundingBoxDims = cmds.exactWorldBoundingBox(duplicatedObject[0], ii=ignoreInv)
cmds.delete(duplicatedObject[0])
# calculate the dimensions and centre of the box
boxWidth = boundingBoxDims[3] - boundingBoxDims[0]
boxHeight = boundingBoxDims[4] - boundingBoxDims[1]
boxDepth = boundingBoxDims[5] - boundingBoxDims[2]
boxCentreX = (boxWidth/2)+boundingBoxDims[0]
boxCentreY = (boxHeight/2)+boundingBoxDims[1]
boxCentreZ = (boxDepth/2)+boundingBoxDims[2]
# build the box and put in the right place
cubeName = cmds.polyCube(w=boxWidth, h=boxHeight, d=boxDepth, ch=False, n=objectName+'_bBox')
cmds.xform(cubeName, ws=True, t=(boxCentreX, boxCentreY, boxCentreZ))
return cubeName
开发者ID:adamfok,项目名称:afok_toolset,代码行数:52,代码来源:thumbnail_manager.py
注:本文中的maya.cmds.exactWorldBoundingBox函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论