本文整理汇总了Python中panda3d.bullet.BulletRigidBodyNode.setTag方法的典型用法代码示例。如果您正苦于以下问题:Python BulletRigidBodyNode.setTag方法的具体用法?Python BulletRigidBodyNode.setTag怎么用?Python BulletRigidBodyNode.setTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletRigidBodyNode
的用法示例。
在下文中一共展示了BulletRigidBodyNode.setTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Vehicle
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setTag [as 别名]
#.........这里部分代码省略.........
# Update acceleration and braking
wheelForce = self.vehicleControlState["throttle"] * self.specs["maxWheelForce"]
self.reversing = self.vehicleControlState["reverse"]
if self.reversing:
# Make reversing a bit slower than moving forward
wheelForce *= -0.5
brakeForce = self.vehicleControlState["brake"] * self.specs["brakeForce"]
# Update steering
# Steering control state is from -1 to 1
steering = self.vehicleControlState["steering"] * self.specs["steeringLock"]
self.applyForcesAndSteering(steering, wheelForce, brakeForce)
return [steering, wheelForce, brakeForce]
def setVehiclePos(self, x,y, z, h, p, r):
#self.chassisNP.setX(x)
#self.chassisNP.setY(y)
#self.chassisNP.setP(p)
#self.chassisNP.setR(r)
self.chassisNP.setPosHpr(x, y, z, h, p, r)
return
def setupVehicle(self, main):
scale = 0.5
# Chassis
shape = BulletBoxShape(Vec3(0.6, 1.4, 0.5))
ts = TransformState.makePos(Point3(0, 0, 0.5 * scale))
name = self.username
self.chassisNode = BulletRigidBodyNode(name)
self.chassisNode.setTag('username', str(name))
self.chassisNP = main.worldNP.attachNewNode(self.chassisNode)
self.chassisNP.setName(str(name))
self.chassisNP.node().addShape(shape, ts)
self.chassisNP.setScale(scale)
self.chassisNP.setPos(self.pos)
if self.isCurrentPlayer:
self.chassisNP.node().notifyCollisions(True)
self.chassisNP.node().setMass(800.0)
else:
self.chassisNP.node().notifyCollisions(True)
self.chassisNP.node().setMass(400.0)
self.chassisNP.node().setDeactivationEnabled(False)
main.world.attachRigidBody(self.chassisNP.node())
#np.node().setCcdSweptSphereRadius(1.0)
#np.node().setCcdMotionThreshold(1e-7)
# Vehicle
self.vehicle = BulletVehicle(main.world, self.chassisNP.node())
self.vehicle.setCoordinateSystem(ZUp)
main.world.attachVehicle(self.vehicle)
self.yugoNP = loader.loadModel('models/yugo/yugo.egg')
self.yugoNP.reparentTo(self.chassisNP)
#self.carNP = loader.loadModel('models/batmobile-chassis.egg')
#self.yugoNP.setScale(.7)
#self.carNP.reparentTo(self.chassisNP)
# Right front wheel
示例2: Vehicle
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setTag [as 别名]
#.........这里部分代码省略.........
self.vehicleControlState["steering"] = steering
# """Updates acceleration, braking and steering
# These are all passed in through a controlState dictionary
# """
# Update acceleration and braking
wheelForce = self.vehicleControlState["throttle"] * self.specs["maxWheelForce"]
self.reversing = self.vehicleControlState["reverse"]
if self.reversing:
# Make reversing a bit slower than moving forward
wheelForce *= -0.5
brakeForce = self.vehicleControlState["brake"] * self.specs["brakeForce"]
# Update steering
# Steering control state is from -1 to 1
steering = self.vehicleControlState["steering"] * self.specs["steeringLock"]
self.applyForcesAndSteering(steering, wheelForce, brakeForce)
return [steering, wheelForce, brakeForce]
def setVehiclePos(self, x,y, z, h, p, r):
self.chassisNP.setPosHpr(x, y, z, h, p, r)
def setupVehicle(self, bulletWorld):
# Chassis
shape = BulletBoxShape(Vec3(1, 2.2, 0.5))
ts = TransformState.makePos(Point3(0, 0, .7))
if self.isMainChar:
self.chassisNode = BulletRigidBodyNode(self.username)
else:
self.chassisNode = BulletRigidBodyNode('vehicle')
self.chassisNode.setTag("username", str(self.username))
self.chassisNP = render.attachNewNode(self.chassisNode)
self.chassisNP.node().addShape(shape, ts)
if self.isMainChar:
self.chassisNP.node().notifyCollisions(True)
else:
self.chassisNP.node().notifyCollisions(False)
self.setVehiclePos(self.pos[0], self.pos[1], self.pos[2], self.pos[3], self.pos[4], self.pos[5])
# self.chassisNP.setPos(-5.34744, 114.773, 6)
#self.chassisNP.setPos(49.2167, 64.7968, 10)
self.chassisNP.node().setMass(800.0)
self.chassisNP.node().setDeactivationEnabled(False)
bulletWorld.attachRigidBody(self.chassisNP.node())
#np.node().setCcdSweptSphereRadius(1.0)
#np.node().setCcdMotionThreshold(1e-7)
# Vehicle
self.vehicle = BulletVehicle(bulletWorld, self.chassisNP.node())
self.vehicle.setCoordinateSystem(ZUp)
bulletWorld.attachVehicle(self.vehicle)
self.carNP = loader.loadModel('models/batmobile-chassis.egg')
#self.yugoNP.setScale(.7)
self.carNP.reparentTo(self.chassisNP)
# Right front wheel
np = loader.loadModel('models/batmobile-wheel-right.egg')
np.reparentTo(render)
self.addWheel(Point3(1, 1.1, .7), True, np)