本文整理汇总了Python中pandac.PandaModules.GeomNode.getDefaultCollideMask方法的典型用法代码示例。如果您正苦于以下问题:Python GeomNode.getDefaultCollideMask方法的具体用法?Python GeomNode.getDefaultCollideMask怎么用?Python GeomNode.getDefaultCollideMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.GeomNode
的用法示例。
在下文中一共展示了GeomNode.getDefaultCollideMask方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [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)
示例2: __init__
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
def __init__(self,gmap,gaming_zone):
DirectObject.__init__(self)
#gaming zone (used for mouse movement), as a tools.Rectangle
self.gaming_zone=gaming_zone
#actual camera node
self.p3dcam=base.camera
#what the cam is oriented to
self._target=base.render.attachNewNode('GaminCam.target')
#range=[0,1] between min and max closeness to ground
self.level=.7
#
#keys_down acts as a pool containing keys (+mouse buttons) currently down
self.keys_down=[]
update_list.append(self.update)
#setup for mouse picking
picker_node=CollisionNode('gcam_to_mouse_ray')#general collision node
picker_node.setFromCollideMask(GeomNode.getDefaultCollideMask())
self.picker_ray=CollisionRay()#solid ray to attach to coll node
picker_node.addSolid(self.picker_ray)
self.picker_np=self.p3dcam.attachNewNode(picker_node)#attach this node to gcam
self.collision_queue=CollisionHandlerQueue()#stores collisions
self.collision_traverser=CollisionTraverser('gcam_traverser')#actual computer
self.collision_traverser.addCollider(self.picker_np,self.collision_queue)
base.cTrav=self.collision_traverser
self.gmap=gmap
#stack of states (state=pos+zoom)
self.states_stack=[]
#enable the cam to move according to keyboard and mouse
self.move_enabled=True
示例3: collideWithGeom
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.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())
示例4: init_collide
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
def init_collide(self):
from pandac.PandaModules import CollisionTraverser, CollisionNode
from pandac.PandaModules import CollisionHandlerQueue, CollisionRay
self.cTrav = CollisionTraverser('MousePointer')
self.cQueue = CollisionHandlerQueue()
self.cNode = CollisionNode('MousePointer')
self.cNodePath = base.camera.attachNewNode(self.cNode)
self.cNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
self.cRay = CollisionRay()
self.cNode.addSolid(self.cRay)
self.cTrav.addCollider(self.cNodePath, self.cQueue)
示例5: create_ray
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
def create_ray(self, object, entity, name, show = False, x = 0, y = 0, z = 0,
dx = 0, dy = 0, dz = -1):
# create queue
object.queue = CollisionHandlerQueue()
# create ray
object.rayNP = entity.attachNewNode(CollisionNode(name))
object.ray = CollisionRay(x, y, 1, dx, dy, dz)
object.rayNP.node().addSolid(object.ray)
object.rayNP.node().setFromCollideMask(GeomNode.getDefaultCollideMask())
base.cTrav.addCollider(object.rayNP, object.queue)
if show:
object.rayNP.show()
示例6: createRay
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.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())
sandbox.pickTrav.addCollider(obj.rayNP, obj.queue)
if show:
obj.rayNP.show()
示例7: __init__
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
def __init__(self):
''' Should the traverser be shared? '''
LOG.debug("[Selector] Initializing")
# The collision traverser does the checking of solids for collisions
self.cTrav = CollisionTraverser()
# The collision handler queue is a simple handler that records all
# detected collisions during traversal
self.cHandler = CollisionHandlerQueue()
self.pickerNode = CollisionNode('mouseRay')
self.pickerNP = camera.attachNewNode(self.pickerNode)
self.pickerNode.setFromCollideMask(GeomNode.getDefaultCollideMask())
self.pickerRay = CollisionRay()
self.pickerNode.addSolid(self.pickerRay)
self.cTrav.addCollider(self.pickerNP, self.cHandler)
# Start listening to clicks
self.resume()
示例8: init_ui
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
def init_ui(self):
self.cTrav = CollisionTraverser('ui_collision_traverser')
self.collision_handler = CollisionHandlerQueue()
picker_node = CollisionNode('mouse_click_ray')
self.picker_node_path = self.camera.attachNewNode(picker_node)
picker_node.setFromCollideMask(GeomNode.getDefaultCollideMask())
self.picker_ray = CollisionRay()
picker_node.addSolid(self.picker_ray)
self.cTrav.addCollider(self.picker_node_path, self.collision_handler)
'''
#debug: make a visible line segment
from pandac.PandaModules import LineSegs, LVecBase4f, NodePath
seg_drawer = LineSegs()
seg_drawer.setColor(LVecBase4f(1, 0, 0, 1)) #red
seg_drawer.moveTo(0,0,0)
seg_drawer.drawTo(0,100,0)
NodePath(seg_drawer.create()).reparentTo(self.picker_node_path)
'''
self.accept('a', self.mouse_ray)
示例9: PathFinder
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
from pandac.PandaModules import CollisionRay
from pandac.PandaModules import CollisionHandlerQueue
from pandac.PandaModules import CollisionTraverser
from pandac.PandaModules import GeomNode
from pandac.PandaModules import LineSegs
from pandac.PandaModules import NodePath
from pandac.PandaModules import Point3
from pandac.PandaModules import Vec3
import math
from math import sqrt
wallRayNP = render.attachNewNode(CollisionNode("wall ray collision node"))
wallRayNP.node().addSolid(CollisionRay(0,0,0,0,1,0))
wallRayNP.node().setIntoCollideMask(BitMask32.allOff())
wallRayNP.node().setFromCollideMask(BitMask32.allOn() & ~GeomNode.getDefaultCollideMask())
wallRayNP.node().setFromCollideMask(wallRayNP.node().getFromCollideMask() & ~BitMask32.bit(1))
#wallRayNP.show()
collisionHandler = CollisionHandlerQueue()
collisionTraverser = CollisionTraverser("pathfinder's collisionTraverser")
collisionTraverser.addCollider(wallRayNP, collisionHandler)
collisionTraverser.setRespectPrevTransform(True)
class PathFinder():
## def __init__(self, position, ID = -1):
## NodePath.__init__(self, "Waypoint")
## self.position = position
## self.texture = loader.loadTexture("textures/blue.jpg")
## self.costToThisNode = 0
示例10: __init__
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
def __init__( self, _base, state):
self.base = _base
self.state = state
# Create mouse
base.disableMouse()
self.mouse = gizmo_core.Mouse()
self.mouse.Start()
# Create camera
self.camera = gizmo_core.Camera( pos=(-250, -250, 200), style=
gizmo_core.CAM_USE_DEFAULT |
gizmo_core.CAM_VIEWPORT_AXES )
self.camera.Start()
# Create grid
grid = DirectGrid( parent=render, planeColor=(0.5, 0.5, 0.5, 0.5) )
# Create scene root node
self.rootNp = render.attachNewNode( 'rootNode' )
# Create node picker
self.nodePicker = gizmo_core.MousePicker( 'mouse', self.camera, self.rootNp, fromCollideMask=GeomNode.getDefaultCollideMask(), pickTag=PICK_TAG )
self.nodePicker.Start()
# Bind node picker events
self.accept( 'mouse1', self.StartSelection )
#self.accept( 'control-mouse1', self.StartSelection, [False] ) # Can't seem to get this to prioritise properly
self.accept( 'mouse1-up', self.StopSelection )
# Create gizmo manager
self.gizmoMgr = gizmos.Manager()
self.gizmoMgr.AddGizmo( gizmos.Translation( 'pos', self.camera ) )
self.gizmoMgr.AddGizmo( gizmos.Rotation( 'rot', self.camera ) )
self.gizmoMgr.AddGizmo( gizmos.Scale( 'scl', self.camera ) )
# Bind gizmo manager events
self.accept( 'q', self.gizmoMgr.SetActiveGizmo, [None] )
self.accept( 'w', self.gizmoMgr.SetActiveGizmo, ['pos'] )
self.accept( 'e', self.gizmoMgr.SetActiveGizmo, ['rot'] )
self.accept( 'r', self.gizmoMgr.SetActiveGizmo, ['scl'] )
self.accept( 'space', self.ToggleAllGizmoLocalMode )
self.accept( '+', self.gizmoMgr.SetSize, [2] )
self.accept( '-', self.gizmoMgr.SetSize, [0.5] )
# Create gizmo manager mouse picker
self.gizmoPicker = gizmo_core.MousePicker( 'mouse', self.camera )
self.gizmoPicker.Start()
'''# Create some objects
for i in range( 20 ):
ball = loader.loadModel( 'smiley' )
ball.setTag( PICK_TAG, '1' )
ball.reparentTo( self.rootNp )
ball.setPos( random.randint( -30, 30 ) * 2, random.randint( -30, 30 ) * 2, random.randint( -30, 30 ) * 2 )
ball.setScale( 10, 10, 10 )'''
'''
# Create a light
dlight = DirectionalLight('dlight')
dlight.setColor( ( 1, 1, 1, 1 ) )
dlnp = render.attachNewNode(dlight)
dlnp.setHpr(0, 0, 0)
render.setLight(dlnp)
dlnp.reparentTo( self.camera )'''
# Create tasks
taskMgr.add( self.MouseTask, 'mouseTask' )
示例11: __setupCollisionHandling
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getDefaultCollideMask [as 别名]
def __setupCollisionHandling(self, collisionHandler, collisionTraverser):
if not collisionTraverser.getRespectPrevTransform():
collisionTraverser.setRespectPrevTransform(True)
# We do this so we don't take into account the actual model, but the collision sphere
self.actor.setCollideMask(BitMask32.allOff())
self.node().getPhysicsObject().setMass(self.massKg)
base.physicsMgr.attachPhysicalNode(self.node())
fromObject = self.attachNewNode(CollisionNode(self.name + " collision node"))
fromObject.node().setIntoCollideMask(fromObject.node().getIntoCollideMask() & ~GeomNode.getDefaultCollideMask())
fromObject.node().setFromCollideMask(self.collisionMask)
fromObject.node().addSolid(CollisionSphere(0, 0, 2.5, 2.5))
collisionHandler.addCollider(fromObject, self)
collisionTraverser.addCollider(fromObject, collisionHandler)