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


Python GeomNode.getDefaultCollideMask方法代码示例

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


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

示例1: setupMouseCollision

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
    def setupMouseCollision(self):
        """ """
        #Since we are using collision detection to do picking, we set it up
        #any other collision detection system with a traverser and a handler
        self.mPickerTraverser = CollisionTraverser()            #Make a traverser
        self.mCollisionQueue  = CollisionHandlerQueue()

        #create a collision solid ray to detect against
        self.mPickRay = CollisionRay()
        #self.mPickRay.setOrigin(base.camera.getPos(render))
        #self.mPickRay.setDirection(render.getRelativeVector(base.camera, Vec3(0,1,0)))

        #create our collison Node to hold the ray
        self.mPickNode = CollisionNode('pickRay')
        self.mPickNode.addSolid(self.mPickRay)

        #Attach that node to the camera since the ray will need to be positioned
        #relative to it, returns a new nodepath
        #well use the default geometry mask
        #this is inefficent but its for mouse picking only

        self.mPickNP = base.camera.attachNewNode(self.mPickNode)

        #well use what panda calls the "from" node.  This is reall a silly convention
        #but from nodes are nodes that are active, while into nodes are usually passive environments
        #this isnt a hard rule, but following it usually reduces processing

        #Everything to be picked will use bit 1. This way if we were doing other
        #collision we could seperate it, we use bitmasks to determine what we check other objects against
        #if they dont have a bitmask for bit 1 well skip them!
        self.mPickNode.setFromCollideMask(GeomNode.getDefaultCollideMask())

        #Register the ray as something that can cause collisions
        self.mPickerTraverser.addCollider(self.mPickNP, self.mCollisionQueue)
开发者ID:StephenLujan,项目名称:Panda-3d-Procedural-Terrain-Engine,代码行数:36,代码来源:mapeditor.py

示例2: __init__

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
    def __init__(self, nick):
        self.player = player.Player(nick=nick)
        self.controller = controller.ClientController(self.player)
        self.handgui = hand.HandGUI(self.player.hand)
        camera.setPos(0, -20, 0)
        self.accept("turn_time_changed", self.update_turn_time)
        self.turn_timer = TurnTimer()

        # Mouse detection:
        base.cTrav = CollisionTraverser()
        self.mouse_ray_handler = CollisionHandlerQueue()
        mouse_ray_node = CollisionNode('mouse_ray')
        mouse_ray_np = camera.attachNewNode(mouse_ray_node)
        mouse_ray_node.setFromCollideMask(GeomNode.getDefaultCollideMask())
        mouse_ray_node.setIntoCollideMask(0)
        self.mouse_ray = CollisionRay()
        mouse_ray_node.addSolid(self.mouse_ray)
        base.cTrav.addCollider(mouse_ray_np, self.mouse_ray_handler)

        self.mouse_overed_entry = None

        self.accept("mouse_enter", self.enlarge_entry)
        self.accept("mouse_leave", self.shrink_entry)

        self.accept("p-up", self.change_card_picture)

        taskMgr.doMethodLater(0.1, self.check_mouse_over, "check_mouse_over")
开发者ID:Allexit,项目名称:tgc-game,代码行数:29,代码来源:battle.py

示例3: setupClickCollision

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
 def setupClickCollision(self):
     self.clickHandler = CollisionHandlerQueue()
     self.traverser = CollisionTraverser('ClickTraverser')
     base.cTrave = self.traverser
     self.clickerNode = CollisionNode('mouseClick')
     self.clickerNodePoint = self.camera.attachNewNode(self.clickerNode)
     self.clickerNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
     self.clickerRay = CollisionRay()
     self.clickerNode.addSolid(self.clickerRay)
     self.traverser.addCollider(self.clickerNodePoint,self.clickHandler)
开发者ID:dKentDSU,项目名称:HexEditor,代码行数:12,代码来源:application.py

示例4: setupMouseCollision

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
	def setupMouseCollision(self):
		self.mouseTraverser = CollisionTraverser()
		self.mouseCollisionQueue    = CollisionHandlerQueue()
		self.mouseRay = CollisionRay()
		self.mouseRay.setOrigin(self.pandaScene.camera.getPos(self.pandaScene.render))
		self.mouseRay.setDirection(self.pandaScene.render.getRelativeVector(self.pandaScene.camera, Vec3(0,1,0)))
		self.mouseNode = CollisionNode('mouseRay')
		self.mouseNode.addSolid(self.mouseRay)
		self.mouseNodePath = self.pandaScene.camera.attachNewNode(self.mouseNode)
		self.mouseNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
		self.mouseTraverser.addCollider(self.mouseNodePath, self.mouseCollisionQueue)
开发者ID:silverbullet1,项目名称:bbauv,代码行数:13,代码来源:MouseHandler.py

示例5: collideWithGeom

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
 def collideWithGeom(self):
     # The into collide mask is the bit pattern colliders look at
     # when deciding whether or not to test for a collision "into"
     # this collision solid.  Set to all Off so this collision solid
     # will not be considered in any collision tests
     self.collisionNode.setIntoCollideMask(BitMask32().allOff())
     # The from collide mask is the bit pattern *this* collision solid
     # compares against the into collide mask of candidate collision solids
     # Turn this mask all off since we're not testing for collisions against
     # collision solids, but we do want to test against geometry
     self.collisionNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
开发者ID:Astron,项目名称:panda3d,代码行数:13,代码来源:seSelection.py

示例6: createRay

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
 def createRay(self,obj,ent,name,show=False,x=0,y=0,z=0,dx=0,dy=0,dz=-1):
     #create queue
     obj.queue=CollisionHandlerQueue()
     #create ray  
     obj.rayNP=ent.attachNewNode(CollisionNode(name))
     obj.ray=CollisionRay(x,y,z,dx,dy,dz)
     obj.rayNP.node().addSolid(obj.ray)
     obj.rayNP.node().setFromCollideMask(GeomNode.getDefaultCollideMask())
     #base.cTrav.addCollider(obj.rayNP, obj.queue)
     self.cTrav.addCollider(obj.rayNP, obj.queue) 
     if show: obj.rayNP.show()
开发者ID:croxis,项目名称:CityMania,代码行数:13,代码来源:gui.py

示例7: init_picker

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
 def init_picker(self):
     # Collision traverser
     self.traverser = CollisionTraverser("traverser")
     # Collision handler
     self.handler = CollisionHandlerQueue()
     # Initialize and set up picker ray node and NodePath
     self.picker = CollisionNode("mouse_ray")
     self.pickerNP = self.camera.attachNewNode(self.picker)
     self.picker.setFromCollideMask(GeomNode.getDefaultCollideMask())
     self.picker_ray = CollisionRay()
     self.picker.addSolid(self.picker_ray)
     self.traverser.addCollider(self.pickerNP, self.handler)
     mark_color = (1, 1, 1, 0.3)
     self.base_mark = self.create_mark(color=mark_color)
     connector_color = (1, 1, 1, 1)
     self.base_connector = self.create_connector(color=connector_color)
开发者ID:jhamrick,项目名称:scenesim,代码行数:18,代码来源:picker.py

示例8: setupMouseCollision

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
	def setupMouseCollision(self):

		self.mClicker = CollisionTraverser()          
		self.mCollisionQue    = CollisionHandlerQueue()

		self.mClickRay = CollisionRay()
		self.mClickRay.setOrigin(self.camera.getPos(self.render))
		self.mClickRay.setDirection(render.getRelativeVector(camera, Vec3(0,1,0)))

		self.mClickNode = CollisionNode('clickRay')
		self.mClickNode.addSolid(self.mClickRay)

		self.mClickNP = self.camera.attachNewNode(self.mClickNode)

		self.mClickNode.setFromCollideMask(GeomNode.getDefaultCollideMask())

		self.mClicker.addCollider(self.mClickNP, self.mCollisionQue)
开发者ID:svfgit,项目名称:calangos-based-rts,代码行数:19,代码来源:CalangosRTS.py

示例9: __init__

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
    def __init__(self):
        ShowBase.__init__(self);
        
        # setup the environment or model
        self.model = \
            self.loader.loadModel("/usr/share/panda3d/models/box");
        self.model.reparentTo(self.render);
        self.model.setTag('Model', '1');
        self.model.setScale(1.5, 1.5, 1.5);
        
        # setup camera
        self.camera.setPos(5,5,5)
        self.camera.lookAt(0,0,0)
        
        # Disable mouse control
        self.disableMouse();
        
        # Handle mouse events.
        self.accept('mouse1', self.mouse_down);
        
        # convert image from opencv to panda3d texture
#         self.taskMgr.add(self.read_image_cv, "cvImageTask");
        
        # Setup collision handler
        self.handler = CollisionHandlerQueue()
        self.traverser = CollisionTraverser('ColTraverser')
        self.traverser.traverse(self.model)
        self.ray = CollisionRay()
        pickerNode = CollisionNode('MouseRay')
        pickerNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
        pickerNP = self.camera.attachNewNode(pickerNode)
        pickerNode.addSolid(self.ray)
        self.traverser.addCollider(pickerNP, self.handler)
        
        self.load_shader();
        
        self.first_frame_loaded = False;
开发者ID:nagyistoce,项目名称:augmented-reality-uncalibrated,代码行数:39,代码来源:p3dapp.py

示例10: initialize

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
    def initialize(self):
        """Reset everything except LevitorNP and selected, also called inside __init__"""
        self.notify = DirectNotify().newCategory('grabberErr')
        self.currPlaneColNorm = Vec3(0.0)
        self.isCameraControlOn = False
        self.isDragging = False
        self.isMultiselect = False
        self.grabScaleFactor = .075
        self.currTransformDir = Point3(0.0)
        self.interFrameMousePosition = Point3(0.0)
        self.init3DemVal = Point3(0.0)
        # initCommVal holds the value before a command operation has taken place
        self.initialCommandTrgVal = None
        # To load the grabber model, this climbs up the absolute path to /barebones/ to gain access to the model folder
        self.grabModelNP = loader.loadModel(Filename.fromOsSpecific(
                                            ntpath.split( ntpath.split(inspect.stack()[0][1])[0] )[0])
                                            + '/EditorModels/widget')
        self.grabModelNP.setPos(0.0, 0.0, 0.0)
        self.grabModelNP.setBin("fixed", 40)
        self.grabModelNP.setDepthTest(False)
        self.grabModelNP.setDepthWrite(False)
        self.transformOpEnum = Enum('rot, scale, trans')
        self.currTransformOperation = None
        # TODO For readability, use this enum in the nested if/else as was the original intent.
        self.grabInd = Enum('xRot, yRot, zRot, xScaler, yScaler, zScaler, xTrans, yTrans, zTrans, xyTrans, xzTrans, zyTrans, grabCore')
        grbrNodLst = [self.grabModelNP.find("**/XRotator;+h-s-i"),       # 0
                       self.grabModelNP.find("**/YRotator;+h-s-i"),      # 1
                       self.grabModelNP.find("**/ZRotator;+h-s-i"),      # 2 end rotate
                       self.grabModelNP.find("**/XScaler;+h-s-i"),       # 3
                       self.grabModelNP.find("**/YScaler;+h-s-i"),       # 4
                       self.grabModelNP.find("**/ZScaler;+h-s-i"),       # 5 end scale
                       self.grabModelNP.find("**/XTranslator;+h-s-i"),   # 6
                       self.grabModelNP.find("**/YTranslator;+h-s-i"),   # 7
                       self.grabModelNP.find("**/ZTranslator;+h-s-i"),   # 8 end translate / end single dir operations
                       self.grabModelNP.find("**/XYTranslator;+h-s-i"),  # 9
                       self.grabModelNP.find("**/XZTranslator;+h-s-i"),  # 10
                       self.grabModelNP.find("**/ZYTranslator;+h-s-i"),  # 11 end bi-directional operations
                       self.grabModelNP.find("**/WidgetCore;+h-s-i")]    # 12
        #Mat4.yToZUpMat()  # change coordinate to z up
        grbrNodLst[12].getParent().setHprScale(0, 0, 0, 1, 1, -1)
        self.grabModelNP.setPythonTag('grabberRoot', grbrNodLst)
        self.grabModelNP.reparentTo(BBGlobalVars.bareBonesObj.levitorNP)
        self.grabModelNP.hide()
        #self.grabIntoBitMask = COLLISIONMASKS
        self.grabModelNP.setCollideMask(COLLISIONMASKS['default'])
        self.grabModelNP.setPythonTag('grabber', self)

        ##############################################################################
        # This whole section is the basics for setting up mouse selection
        # --The mouse events are added in the events section (next)

        # Create the collision node for the picker ray to add traverser as a 'from' collider
        self.grabberColNode = CollisionNode('grabberMouseRay')
        # Set the collision bitmask
        # TODO: define collision bitmask (let user define thiers? likely not)
        self.defaultBitMask = GeomNode.getDefaultCollideMask()
        self.grabberColNode.setFromCollideMask(self.defaultBitMask)
        self.grabberRayColNP = camera.attachNewNode(self.grabberColNode)
        # Create the grabberRay and add it to the picker CollisionNode
        self.grabberRay = CollisionRay(0.0, 0.0, 0.0,
                                       0.0, 1.0, 0.0)
        self.grabberRayNP = self.grabberColNode.addSolid(self.grabberRay)
        # create a collision queue for the traverser
        self.colHandlerQueue = CollisionHandlerQueue()
        # Create collision traverser
        self.colTraverser = CollisionTraverser('grabberTraverser')
        # Set the collision traverser's 'fromObj' and handler
        # e.g. trav.addCollider( fromObj, handler )
        self.colTraverser.addCollider(self.grabberRayColNP, self.colHandlerQueue)


        ############################################################
        # setup event handling with the messenger
        # URGENT remove all of this messenger code throughout Grabber, especially the camera control
        # disable the mouse when the ~ is pressed (w/o shift)
        self.disableCamera()                            # disable camera control by the mouse
        messenger.accept('`', self, self.enableCamera)  # enable camera control when the ~ key is pressed w/o shift
        messenger.accept('`-up', self, self.disableCamera)  # disable camera control when the ~ key is released

        # handle mouse selection/deselection & manipulating the scene
        messenger.accept('mouse1', self, self.handleM1, persistent=1)  # deselect in event handler

        taskMgr.add(self.scaleGrabber, 'scaleGrabber')
开发者ID:jkcavin1,项目名称:barebones,代码行数:85,代码来源:Grabber.py

示例11: BitMask32

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
__author__ = 'Lab Hatter'
from panda3d.core import BitMask32, GeomNode


COLLISIONMASKS = {'grabber': BitMask32(1<<31), 'default': GeomNode.getDefaultCollideMask()}
开发者ID:jkcavin1,项目名称:barebones,代码行数:7,代码来源:BBConstants.py

示例12:

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
# -*- coding: utf-8 -*-

from panda3d.core import BitMask32, GeomNode

LEVELMODEL = 'models/room1'
AZERTY = True
JUMP_FORCE = 25
GRAVITY = 15
RUN_SPEED = 25
PLAYER_TO_FLOOR_TOLERANCE = .3
PLAYER_TO_FLOOR_TOLERANCE_FOR_REJUMP = 1
ORANGE = (242/255., 181/255., 75/255.,1)
BLUE = (89/255.,100/255.,122/255.,1)

COLLISIONMASKS = {
    'player': BitMask32.bit(1),
    'portals': BitMask32.bit(2),
    'mouseRay': BitMask32.bit(3),
    'exit': BitMask32.bit(4),
    'lava': BitMask32.bit(5),
    'geometry': GeomNode.getDefaultCollideMask(),
}

TEXTURES = {}
开发者ID:court-jus,项目名称:Gate_OpenPortal,代码行数:26,代码来源:constants.py

示例13: __init__

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getDefaultCollideMask [as 别名]
    def __init__(self, _main):
        self.main = _main

        # Stats
        self.moveSpeed = 8
        self.inventory = []
        self.maxCarryWeight = 20.0 #kg ?
        self.currentInventoryWeight = 0.0

        # Inventory GUI
        self.inventoryGui = Inventory()
        self.inventoryGui.hide()
        self.inventoryActive = False
        self.craftInventory = CraftInventory()
        self.craftInventory.hide()

        # enable movements through the level
        self.keyMap = {"left":0, "right":0, "forward":0, "backward":0}
        self.player = NodePath("Player")#loader.loadModel("smiley")
        self.player.setPos(149.032, 329.324, 11.3384)
        self.player.setH(180)
        self.player.reparentTo(render)

        self.accept("w", self.setKey, ["forward",1])
        self.accept("w-up", self.setKey, ["forward",0])
        self.accept("a", self.setKey, ["left",1])
        self.accept("a-up", self.setKey, ["left",0])
        self.accept("s", self.setKey, ["backward",1])
        self.accept("s-up", self.setKey, ["backward",0])
        self.accept("d", self.setKey, ["right",1])
        self.accept("d-up", self.setKey, ["right",0])
        self.accept("mouse1", self.handleLeftMouse)
        self.accept("i", self.toggleInventory)
        self.accept("c", self.toggleCraftInventory)


        # screen sizes
        self.winXhalf = base.win.getXSize() / 2
        self.winYhalf = base.win.getYSize() / 2

        self.mouseSpeedX = 0.1
        self.mouseSpeedY = 0.1

        camera.setH(180)
        camera.reparentTo(self.player)
        camera.setZ(self.player, 2)
        base.camLens.setFov(75)
        base.camLens.setNear(0.8)

        # Mouse controls
        self.mouseNode = CollisionNode('mouseRay')
        self.mouseNodeNP = camera.attachNewNode(self.mouseNode)
        self.mouseNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
        self.mouseRay = CollisionRay()
        self.mouseNode.addSolid(self.mouseRay)
        self.mouseRayHandler = CollisionHandlerQueue()

        # Collision Traverser
        self.traverser = CollisionTraverser("Player Traverser")
        base.cTrav = self.traverser
        self.traverser.addCollider(self.mouseNodeNP, self.mouseRayHandler)
开发者ID:grimfang,项目名称:OWP_Miner,代码行数:63,代码来源:player.py


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