def SetupRenderMask(self): """ Set the draw mask for the render node to be visible to all cameras. Since we are adjusting the draw mask of the render node's parent we need to manually set this node's mask or it will inherit those properties. """ showMask = pm.BitMask32().allOn() hideMask = pm.BitMask32() clearMask = pm.BitMask32() render.node().adjustDrawMask(showMask, hideMask, clearMask)
def GetEditorRenderMasks(self): """ Return the show, hide and clear masks for objects that are to be rendered only in the editor viewport. """ show = pm.BitMask32() show.setRangeTo(True, 28, 4) hide = pm.BitMask32().allOn() hide.setRangeTo(False, 28, 4) clear = pm.BitMask32() return show, hide, clear
def replaceCollisionPolysWithPlanes(self, model): newCollisionNode = PM.CollisionNode('collisions') newCollideMask = PM.BitMask32(0) planes = [] collList = model.findAllMatches('**/+CollisionNode') if not collList: collList = [model] for cnp in collList: cn = cnp.node() if not isinstance(cn, PM.CollisionNode): self.notify.warning('Not a collision node: %s' % repr(cnp)) break newCollideMask = newCollideMask | cn.getIntoCollideMask() for i in range(cn.getNumSolids()): solid = cn.getSolid(i) if isinstance(solid, PM.CollisionPolygon): plane = PM.Plane(solid.getPlane()) planes.append(plane) else: self.notify.warning('Unexpected collision solid: %s' % repr(solid)) newCollisionNode.addSolid(plane) newCollisionNode.setIntoCollideMask(newCollideMask) threshold = 0.1 planes.sort(lambda p1, p2: p1.compareTo(p2, threshold)) lastPlane = None for plane in planes: if lastPlane == None or plane.compareTo(lastPlane, threshold) != 0: cp = PM.CollisionPlane(plane) newCollisionNode.addSolid(cp) lastPlane = plane return PM.NodePath(newCollisionNode)
def __loadCamera(self): """Only seperate for organisation, treat it as is part of __init__() . Load the camera & setup segmet & queue for detecting obstructions.""" #Don't rotate the target with the avatar. self.target.node().setEffect(P.CompassEffect.make(render)) camera.reparentTo(self.target) # Attach the camera to target. camera.setPos(0, -self.zoomLvl, 50) # Position the camera self.rotateCam(P.Point2(0, 0)) # Initialize gimbal clamps. self.Q = P.CollisionHandlerQueue() # New queue for camera. self.segment = fromCol( self.target, self.Q, P.CollisionSegment(P.Point3.zero(), camera.getPos(self.target)), P.BitMask32( CameraM)) #CameraM into segment between camera & target.
def replaceCollisionPolysWithPlanes(self, model): newCollisionNode = PM.CollisionNode('collisions') newCollideMask = PM.BitMask32(0) planes = [] collList = model.findAllMatches('**/+CollisionNode') if not collList: collList = [model] for cnp in collList: cn = cnp.node() if not isinstance(cn, PM.CollisionNode): self.notify.warning("Not a collision node: %s" % (repr(cnp))) break newCollideMask = newCollideMask | cn.getIntoCollideMask() for i in range(cn.getNumSolids()): solid = cn.getSolid(i) if isinstance(solid, PM.CollisionPolygon): # Save the plane defined by this polygon plane = PM.Plane(solid.getPlane()) planes.append(plane) else: self.notify.warning("Unexpected collision solid: %s" % (repr(solid))) newCollisionNode.addSolid(plane) newCollisionNode.setIntoCollideMask(newCollideMask) # Now sort all of the planes and remove the nonunique ones. # We can't use traditional dictionary-based tricks, because we # want to use Plane.compareTo(), not Plane.__hash__(), to make # the comparison. threshold = 0.1 planes.sort(lambda p1, p2: p1.compareTo(p2, threshold)) lastPlane = None for plane in planes: if lastPlane == None or plane.compareTo(lastPlane, threshold) != 0: cp = PM.CollisionPlane(plane) newCollisionNode.addSolid(cp) lastPlane = plane return PM.NodePath(newCollisionNode)