本文整理汇总了Python中vehicle.Vehicle.posInterval方法的典型用法代码示例。如果您正苦于以下问题:Python Vehicle.posInterval方法的具体用法?Python Vehicle.posInterval怎么用?Python Vehicle.posInterval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vehicle.Vehicle
的用法示例。
在下文中一共展示了Vehicle.posInterval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: from vehicle import Vehicle [as 别名]
# 或者: from vehicle.Vehicle import posInterval [as 别名]
#.........这里部分代码省略.........
target.reparentTo(self.targetRoot)
self.targets.append(target)
self.setWorldLight(target)
def setupLights(self):
#ambient light
self.ambientLight = AmbientLight("ambientLight")
#four values, RGBA (alpha is largely irrelevent), value range is 0:1
self.ambientLight.setColor((.10, .10, .10, 1))
self.ambientLightNP = render.attachNewNode(self.ambientLight)
#the nodepath that calls setLight is what gets illuminated by the light
render.setLight(self.ambientLightNP)
#call clearLight() to turn it off
self.keyLight = DirectionalLight("keyLight")
self.keyLight.setColor((.20,.20,.20, 1))
self.keyLightNP = render.attachNewNode(self.keyLight)
self.keyLightNP.setHpr(0, -26, 0)
self.fillLight = DirectionalLight("fillLight")
self.fillLight.setColor((.05,.05,.05, 1))
self.fillLightNP = render.attachNewNode(self.fillLight)
self.fillLightNP.setHpr(30, 0, 0)
def drive(self):
"""compound interval for driveing"""
#some interval methods:
# start(), loop(), pause(), resume(), finish()
# start() can take arguments: start(starttime, endtime, playrate)
dist = 5
angle = deg2Rad(self.player.getH())
dx = dist * math.sin(angle)
dy = dist * -math.cos(angle)
playerdrive = Parallel(self.player.posInterval(1, (self.player.getX() + dx, self.player.getY() + dy, 0)), \
self.player.actorInterval("drive", loop=1, duration=2))
playerdrive.start()
def setupCollisions(self):
#instantiates a collision traverser and sets it to the default
base.cTrav = CollisionTraverser()
self.cHandler = CollisionHandlerEvent()
#set pattern for event sent on collision
# "%in" is substituted with the name of the into object
self.cHandler.setInPattern("ate-%in")
cSphere = CollisionSphere((0,0,200), 450) #because the player is scaled way down
self.playerRay = CollisionRay()
self.playerRay.setOrigin(0,0,2000)
self.playerRay.setDirection(0,0,-1)
self.playerNode = CollisionNode("playerRay")
self.playerNode.addSolid(self.playerRay)
self.playerNode.setFromCollideMask(BitMask32.bit(0))
self.playerNode.setIntoCollideMask(BitMask32.allOff())
self.playerNodePath = self.player.attachNewNode(self.playerNode)
self.playerNodePath.show()
self.playerGroundHandler = CollisionHandlerFloor()
self.playerGroundHandler.addCollider(self.playerNodePath, self.player)
base.cTrav.addCollider(self.playerNodePath, self.playerGroundHandler)
cNode = CollisionNode("player")
cNode.addSolid(cSphere)
cNode.setIntoCollideMask(BitMask32.allOff()) #player is *only* a from object
#cNode.setFromCollideMask(BitMask32.bit(0))
cNodePath = self.player.attachNewNode(cNode)
#registers a from object with the traverser with a corresponding handler
base.cTrav.addCollider(cNodePath, self.cHandler)