当前位置: 首页>>代码示例>>Python>>正文


Python BitMask32.bit方法代码示例

本文整理汇总了Python中pandac.PandaModules.BitMask32.bit方法的典型用法代码示例。如果您正苦于以下问题:Python BitMask32.bit方法的具体用法?Python BitMask32.bit怎么用?Python BitMask32.bit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandac.PandaModules.BitMask32的用法示例。


在下文中一共展示了BitMask32.bit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_collisions

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
    def handle_collisions(self):
        self.collision_handling_mutex.acquire()
	self.groundCol.setIntoCollideMask(BitMask32.bit(0))
        self.groundCol.setFromCollideMask(BitMask32.bit(1))

        # Now check for collisions.

        self.cTrav.traverse(render)

        # Keep the camera at one foot above the terrain,
        # or two feet above the actor, whichever is greater.
        
        entries = []
        for i in range(self.groundHandler.getNumEntries()):
            entry = self.groundHandler.getEntry(i)
            entries.append(entry)
        entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
                                     x.getSurfacePoint(render).getZ()))
        if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):
            base.camera.setZ(entries[0].getSurfacePoint(render).getZ()+1.0)
        if (base.camera.getZ() < self.actor.getZ() + 2.0):
            base.camera.setZ(self.actor.getZ() + 2.0)
        
	self.groundCol.setIntoCollideMask(BitMask32.bit(0))
        self.groundCol.setFromCollideMask(BitMask32.bit(0))
        self.collision_handling_mutex.release()
开发者ID:aryat,项目名称:IsisWorld,代码行数:28,代码来源:simulator.py

示例2: makeNew

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
 def makeNew(self, pos, nor, parent = None):
   """Makes a new bullet hole."""
   if parent == None:
     parent = self.container
   else:
     # Add a subnode to the parent, if it's not already there
     child = parent.find('bullet-holes')
     if child.isEmpty():
       parent = parent.attachNewNode('bullet-holes')
     else:
       parent = child
   newhole = NodePath(self.card.generate())
   newhole.reparentTo(parent)
   newhole.lookAt(render, Point3(newhole.getPos(render) - nor))
   newhole.setR(newhole, random() * 360.0)
   newhole.setPos(render, pos)
   # Offset it a little to avoid z-fighting
   # Increase this value if you still see it.
   newhole.setY(newhole, -.001 - random() * 0.01)
   del newhole
   # We don't want one batch per bullet hole, so flatten it.
   # This could be made smarter to preserve culling, but
   # I have yet to see a performance loss.
   # The clearTexture() is a necessary hack.
   parent.clearTexture()
   parent.flattenStrong()
   parent.setTexture(self.texture)
   parent.setTransparency(TransparencyAttrib.MDual)
   parent.setShaderOff(1)
   parent.hide(BitMask32.bit(2)) # Invisible to volumetric lighting camera (speedup)
   parent.hide(BitMask32.bit(3)) # Invisible to shadow cameras (speedup)
开发者ID:StephenLujan,项目名称:Naith,代码行数:33,代码来源:bulletholes.py

示例3: __init__

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
  def __init__(self, ywn):
      '''
      Constructor
      '''
      Thing.__init__(self, "Lightswitch", ywn)
      
      self.model = loader.loadModel('models/Lightswitch')
      
      self.model.find("**/Piattina").node().setIntoCollideMask(BitMask32.bit(1))
      self.model.find("**/Piattina").node().setTag('ID', self.Id)
      self.model.find("**/Piattina").node().setTag('nodeId', "Piattina")
      
      self.model.find("**/Switch").node().setIntoCollideMask(BitMask32.bit(1))
      self.model.find("**/Switch").node().setTag('ID', self.Id)
      self.model.find("**/Switch").node().setTag('nodeId', "Switch")
      self.model.find("**/Switch").setP(332)
      
      self.model.find("**/TopScrew").node().setIntoCollideMask(BitMask32.bit(1))
      self.model.find("**/TopScrew").node().setTag('ID', self.Id)
      self.model.find("**/TopScrew").node().setTag('nodeId', "TopScrew")
 
      self.model.find("**/BottomScrew").node().setIntoCollideMask(BitMask32.bit(1))
      self.model.find("**/BottomScrew").node().setTag('ID', self.Id)
      self.model.find("**/BottomScrew").node().setTag('nodeId', "BottomScrew")
      
      self.model.setTag('ID', self.Id)
      
      self.status = Lightswitch.SWITCH_OFF
开发者ID:sambarza,项目名称:bo,代码行数:30,代码来源:Lightswitch.py

示例4: setupCollisions

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
    def setupCollisions(self):

        #player sphere
        cPlayerSphere = CollisionSphere(Point3(0, 0, .5), 10)
        cPlayerNode = CollisionNode("Player")
        cPlayerNode.addSolid(cPlayerSphere)
        
        cPlayerNode.setFromCollideMask(BitMask32.bit(4))
        cPlayerNode.setIntoCollideMask(BitMask32(20))
        
        cPlayerNP = self.player.attachNewNode(cPlayerNode)
        self.cTrav.addCollider(cPlayerNP, self.playerGroundHandler)
        #self.cTrav.addCollider(cPlayerNP, self.cRocketHandler)
        #cPlayerNP.show()
        
        
        #enemy sphere
        cEnemySphere = CollisionSphere(Point3(0, 0, .5), 10)
        cEnemyNode = CollisionNode("Enemy")
        cEnemyNode.addSolid(cEnemySphere)
        
        cEnemyNode.setFromCollideMask(BitMask32.bit(4))
        cEnemyNode.setIntoCollideMask(BitMask32(18))
        
        cEnemyNP = self.enemy.attachNewNode(cEnemyNode)
        self.cTrav.addCollider(cEnemyNP, self.enemyGroundHandler)
开发者ID:LordPaido,项目名称:RPIPortfolio,代码行数:28,代码来源:game.py

示例5: __init__

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
    def __init__(self, model, run, walk, startPos, scale, select,ralph,saysome):

        self.actor = Actor(model, {"run":run, "walk":walk})
        self.actor.reparentTo(render)
        self.actor.setScale(scale)
        self.actor.setPos(startPos)
        self.actor.setHpr(90,0,0)
        self.playerGUI = saysome
        self.myralph = ralph
        self.setAI()

        self.cTrav = CollisionTraverser()

        self.groundRay = CollisionRay(0,0,1000,0,0,-1)  
        self.groundCol = CollisionNode('dinoRay')
        self.groundCol.addSolid(self.groundRay)
        self.groundCol.setFromCollideMask(BitMask32.bit(1))
        self.groundCol.setIntoCollideMask(BitMask32.allOff())
        self.groundColNp = self.actor.attachNewNode(self.groundCol)
        self.groundHandler = CollisionHandlerQueue()
        self.cTrav.addCollider(self.groundColNp, self.groundHandler)

        self.sphere = CollisionSphere(0,0,5,13)
        self.spherecol = CollisionNode('dinoSphere')
        self.spherecol.addSolid(self.sphere)
        self.spherecol.setCollideMask(BitMask32.bit(1))
        self.dinocolhs = self.actor.attachNewNode(self.spherecol)
开发者ID:meghnatolani,项目名称:RunningRalph,代码行数:29,代码来源:main.py

示例6: start

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
  def start(self):
    if self.bgColour!=None: base.setBackgroundColor(self.bgColour)

    if self.model!=None:
      self.model.show()
      self.model.hide(BitMask32.bit(1)) # Hide from the reflection camera
      self.model.hide(BitMask32.bit(2)) # Hide from the volumetric lighting camera
      self.model.hide(BitMask32.bit(3)) # Hide from the shadow camera(s), if any
开发者ID:StephenLujan,项目名称:Naith,代码行数:10,代码来源:sky.py

示例7: initialize_collision_handling

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
	def initialize_collision_handling(self):
		self.collision_handling_mutex = Lock()
		
		self.cTrav = CollisionTraverser()
		
		self.groundRay = CollisionRay()
		self.groundRay.setOrigin(0,0,1000)
		self.groundRay.setDirection(0,0,-1)
		self.groundCol = CollisionNode(self.attach_object.name + "_collision_node")
		self.groundCol.setIntoCollideMask(BitMask32.bit(0))
		self.groundCol.setFromCollideMask(BitMask32.bit(0))
		self.groundCol.addSolid(self.groundRay)
		self.groundColNp = self.attach_object.render_model.attachNewNode(self.groundCol)
		self.groundHandler = CollisionHandlerQueue()
		self.cTrav.addCollider(self.groundColNp, self.groundHandler)
开发者ID:aryat,项目名称:IsisWorld,代码行数:17,代码来源:simulator.py

示例8: placeItem

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
    def placeItem(self, item):
        # Add ground collision detector to the health item
        self.cTrav1 = CollisionTraverser()

        self.collectGroundRay = CollisionRay()
        self.collectGroundRay.setOrigin(0,0,300)
        self.collectGroundRay.setDirection(0,0,-1)
        self.collectGroundCol = CollisionNode('colRay')
        self.collectGroundCol.addSolid(self.collectGroundRay)
        self.collectGroundCol.setFromCollideMask(BitMask32.bit(1))
        self.collectGroundCol.setIntoCollideMask(BitMask32.allOff())
        self.collectGroundColNp = item.attachNewNode(self.collectGroundCol)
        self.collectGroundHandler = CollisionHandlerQueue()
        base.cTrav1.addCollider(self.collectGroundColNp, self.collectGroundHandler)
        
        placed = False;
        while placed == False:
            # re-randomize position
            item.setPos(-random.randint(-350,300),-random.randint(-100,150),0)
            
            base.cTrav1.traverse(render)
            
            # Get Z position from terrain collision
            entries = []
            for j in range(self.collectGroundHandler.getNumEntries()):
                entry = self.collectGroundHandler.getEntry(j)
                entries.append(entry)
            entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
                                         x.getSurfacePoint(render).getZ()))
        
            if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):
                item.setZ(entries[0].getSurfacePoint(render).getZ()+4)
                placed = True
开发者ID:meghnatolani,项目名称:RunningRalph,代码行数:35,代码来源:main.py

示例9: __init__

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
 def __init__(self, ywn):
     '''
     Constructor
     '''
     Thing.__init__(self, "Book", ywn)
     
     self.model = loader.loadModel('models/Book')
     
     self.model.find("**/Front").node().setIntoCollideMask(BitMask32.bit(1))
     self.model.find("**/Back").node().setIntoCollideMask(BitMask32.bit(1))
     self.model.find("**/Front").node().setTag('ID', self.Id)
     self.model.find("**/Back").node().setTag('ID', self.Id)
     self.model.find("**/Front").node().setTag('nodeId', "front")
     self.model.find("**/Back").node().setTag('nodeId', "back")
     
     self.model.setTag('ID', self.Id)
开发者ID:sambarza,项目名称:bo,代码行数:18,代码来源:Book.py

示例10: __setupNPC

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
    def __setupNPC(self):
        # This is to support the collisions for each node. See the paragraph comment
        # above where we modify the npc's collision node
#        playerCollisionNP = self.__mainTarget.find("* collision node")

        modelStanding = "models/ralph"
        modelRunning = "models/ralph-run"
        modelWalking = "models/ralph-walk"
        self.__NPC = NPC(modelStanding, 
                                {"run":modelRunning, "walk":modelWalking},
                                turnRate = 150, 
                                speed = 15,
                                agentList = self.__globalAgentList,
                                name = "Ralph",
                                collisionMask = BitMask32.bit(3),
                                rangeFinderCount = 13,
                                adjacencySensorThreshold = 5,
                                radarSlices = 5,
                                radarLength = 0,
                                scale = 1.0,
                                massKg = 35.0,
                                collisionHandler = self.physicsCollisionHandler,
                                collisionTraverser = self.cTrav,
                                waypoints = self.roomWaypoints)
        self.__NPC.setFluidPos(render, 20, 10, 0)#-190
        self.__NPC.setScale(render, 1)
        self.__NPC.setTarget(self.__mainTarget)

        self.__NPC.reparentTo(render)
	self.__NPC.start()
开发者ID:Babi-Wan,项目名称:robotic-agent-path-planning-project,代码行数:32,代码来源:robotworld.py

示例11: __init__

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
 def __init__(self, render, camera):
     #Since we are using collision detection to do picking, we set it up like any other collision detection system with a traverser and a handler 
     self.picker = CollisionTraverser()            #Make a traverser 
     self.pq     = CollisionHandlerQueue()         #Make a handler 
     #Make a collision node for our picker ray 
     self.pickerNode = CollisionNode('mouseRay') 
     #Attach that node to the camera since the ray will need to be positioned relative to it 
     self.pickerNP = camera.attachNewNode(self.pickerNode) 
     #Everything to be picked will use bit 1. This way if we were doing other collision we could seperate it 
     self.pickerNode.setFromCollideMask(BitMask32.bit(1)) 
     self.pickerRay = CollisionRay()               #Make our ray 
     self.pickerNode.addSolid(self.pickerRay)      #Add it to the collision node 
     #Register the ray as something that can cause collisions 
     self.picker.addCollider(self.pickerNP, self.pq) 
     #self.picker.showCollisions(render) 
     
     self.pst = CollisionTraverser()            #Make a traverser 
     self.hqp     = CollisionHandlerQueue()         #Make a handler 
     #Make a collision node for our picker ray 
     
     self.pstNode = CollisionNode('mouseRaytoObj') 
     #Attach that node to the camera since the ray will need to be positioned relative to it 
     self.pstNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
     self.pstNode2 = camera.attachNewNode(self.pstNode) 
     self.pickerRayObj = CollisionRay()   
     #Everything to be picked will use bit 1. This way if we were doing other collision we could seperate it 
     #self.pstNode.setFromCollideMask(BitMask32.bit(1)) 
     self.pstNode.addSolid(self.pickerRayObj)      #Add it to the collision node 
     #Register the ray as something that can cause collisions 
     self.pst.addCollider(self.pstNode2, self.hqp) 
     #self.pst.showCollisions(render) 
开发者ID:eliasmoura,项目名称:ProjetoJogo,代码行数:33,代码来源:mouseLoad.py

示例12: __init__

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
    def __init__(self, parserClass, mainClass, mapLoaderClass, modelLoaderClass):
        self.switchState = False

        # self.t = Timer()

        self.keyMap = {"left": 0, "right": 0, "forward": 0, "backward": 0}
        self.ralph = Actor(
            "data/models/units/ralph/ralph",
            {"run": "data/models/units/ralph/ralph-run", "walk": "data/models/units/ralph/ralph-walk"},
        )
        self.ralph.reparentTo(render)
        # 		self.ralph.setPos(42, 30, 0)
        self.ralph.setPos(6, 10, 0)
        self.ralph.setScale(0.1)

        self.accept("escape", sys.exit)
        self.accept("arrow_left", self.setKey, ["left", 1])
        self.accept("arrow_left-up", self.setKey, ["left", 0])
        self.accept("arrow_right", self.setKey, ["right", 1])
        self.accept("arrow_right-up", self.setKey, ["right", 0])
        self.accept("arrow_up", self.setKey, ["forward", 1])
        self.accept("arrow_up-up", self.setKey, ["forward", 0])
        self.accept("arrow_down", self.setKey, ["backward", 1])
        self.accept("arrow_down-up", self.setKey, ["backward", 0])

        self.isMoving = False

        self.cTrav = CollisionTraverser()

        self.ralphGroundRay = CollisionRay()
        self.ralphGroundRay.setOrigin(0, 0, 1000)
        self.ralphGroundRay.setDirection(0, 0, -1)
        self.ralphGroundCol = CollisionNode("ralphRay")
        self.ralphGroundCol.addSolid(self.ralphGroundRay)
        self.ralphGroundCol.setFromCollideMask(BitMask32.bit(0))
        self.ralphGroundCol.setIntoCollideMask(BitMask32.allOff())
        self.ralphGroundColNp = self.ralph.attachNewNode(self.ralphGroundCol)
        self.ralphGroundHandler = CollisionHandlerQueue()
        self.cTrav.addCollider(self.ralphGroundColNp, self.ralphGroundHandler)
        # self.ralphGroundCol.show()

        base.cam.reparentTo(self.ralph)
        base.cam.setPos(0, 9, 7)
        self.floater2 = NodePath(PandaNode("floater2"))
        self.floater2.reparentTo(self.ralph)
        self.floater2.setZ(self.floater2.getZ() + 6)
        base.cam.lookAt(self.floater2)

        # Uncomment this line to see the collision rays
        # 		self.ralphGroundColNp.show()
        # 		self.camGroundColNp.show()

        # Uncomment this line to show a visual representation of the
        # collisions occuring
        # 		self.cTrav.showCollisions(render)

        self.floater = NodePath(PandaNode("floater"))
        self.floater.reparentTo(render)

        taskMgr.add(self.move, "movingTask", extraArgs=[mainClass, parserClass, mapLoaderClass, modelLoaderClass])
开发者ID:croza,项目名称:RR2,代码行数:62,代码来源:fpsTest.py

示例13: make

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
	def make(self):
		"""Build a finished renderable heightMap."""
		
		# apply shader
		#logging.info( "applying shader")
		self.terrain.texturer.apply(self.getRoot())
		
		# detail settings
		#self.getRoot().setSz(1.0 / self.heightMapDetail)
		#self.getRoot().setSy(1.0 / self.heightMapDetail)
		
		#logging.info( "making height map")
		self.makeHeightMap()
		#logging.info( "setHeight()")
		self.setHeight()
		#self.getRoot().setSz(self.maxHeight)
		
		#http://www.panda3d.org/forums/viewtopic.php?=t=12054
		self.calcAmbientOcclusion()
		#loggin.info( "generate()")
		self.generate()
		self.getRoot().setCollideMask(BitMask32.bit(1))
		
		#self.makeSlopeMap()
		#logging.info( "createGroups()")
		self.createGroups()
		self.terrain.populator.populate(self)
开发者ID:Vetrik,项目名称:python-utils,代码行数:29,代码来源:terraintile.py

示例14: __init__

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
    def __init__(self, manager, xml):
        self.light = PDirectionalLight("dlight")
        self.lightNode = NodePath(self.light)
        self.lightNode.setCompass()
        if hasattr(self.lightNode.node(), "setCameraMask"):
            self.lightNode.node().setCameraMask(BitMask32.bit(3))

        self.reload(manager, xml)
开发者ID:figo-sh,项目名称:naith,代码行数:10,代码来源:dirlight.py

示例15: intersect

# 需要导入模块: from pandac.PandaModules import BitMask32 [as 别名]
# 或者: from pandac.PandaModules.BitMask32 import bit [as 别名]
def intersect(lbase, delta, mask=None):
    t = time.time()
    root = lbase.rootnode
    terrain = root.getChildren()[2]
    terrain.setCollideMask(BitMask32.bit(1))
    player = root
    collTrav = CollisionTraverser() #the collision traverser. we need this to perform collide in the end
    fromObject = player.attachNewNode(CollisionNode('colNode'))

    camera_pos = tuple(lbase.cameras.getPos())

    lens = lbase.cameras.getChildren()[0].node().getLens()
    fov = np.radians(lens.getMinFov())
    zpos = camera_pos[1]
    sw = 2. * np.abs(zpos) * np.tan(fov / 2.)

    rvals = np.arange(-sw/2., sw/2., delta)
    if mask is None:
        poses = [(xpos , -1 * zpos, ypos) for xpos in rvals for ypos in rvals]
    else:
        assert mask.shape == (len(rvals), len(rvals))
        poses = [(xpos , -1 * zpos, ypos) for _i, xpos in enumerate(rvals) for _j, ypos in enumerate(rvals) if mask[_j, _i] < 1]
        print(len(poses), 'lp', len(rvals)**2)
    print('1a', time.time() - t)
    t = time.time()
    for p in poses:
        vec = camera_pos + p
        fromObject.node().addSolid(CollisionRay(*vec))
    print('1', time.time() - t)
    t = time.time()

    #and now we turn turn of the collision for the playermodel so it wont collide with the ray or anything.
    player.node().setIntoCollideMask(BitMask32.allOff())
    fromObject.node().setFromCollideMask(BitMask32.bit(1))

    queue = CollisionHandlerQueue()
    collTrav.addCollider(fromObject, queue)
    print('2', time.time() - t)
    t = time.time()

    collTrav.traverse(root)
    print('3', time.time() - t)
    return queue
开发者ID:dicarlolab,项目名称:genthor,代码行数:45,代码来源:surface_normals.py


注:本文中的pandac.PandaModules.BitMask32.bit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。