本文整理汇总了Python中panda3d.bullet.BulletWorld.attachVehicle方法的典型用法代码示例。如果您正苦于以下问题:Python BulletWorld.attachVehicle方法的具体用法?Python BulletWorld.attachVehicle怎么用?Python BulletWorld.attachVehicle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletWorld
的用法示例。
在下文中一共展示了BulletWorld.attachVehicle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RonnieRacer
# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import attachVehicle [as 别名]
#.........这里部分代码省略.........
# Plane
img = PNMImage(Filename('media/terrain/SIMP_Assignment_2_Terrain_1.png'))
shape = BulletHeightfieldShape(img, 50.0, ZUp)
np = self.worldNP.attachNewNode(BulletRigidBodyNode('Ground'))
np.node().addShape(shape)
np.setPos(0, 0, 0)
np.setCollideMask(BitMask32.allOn())
self.world.attachRigidBody(np.node())
#skybox
skybox = loader.loadModel('media/models/skybox/skybox_01.X')
skybox.reparentTo(render)
# Chassis
shape = BulletBoxShape(Vec3(0.6, 1.4, 0.5))
ts = TransformState.makePos(Point3(0, 0, 1.0))
self.vehicleNP = self.worldNP.attachNewNode(BulletRigidBodyNode('Vehicle'))
self.vehicleNP.node().addShape(shape, ts)
self.vehicleNP.setPos(-93, -88, -7)#-93, -88, -7) #(-82,65.8,-8) #(55,8.38,-6)#(45, -19, -8)#(-93, -88, -7)
self.vehicleNP.setHpr(-90,0,0)
self.vehicleNP.node().setMass(5.0)
self.vehicleNP.node().setDeactivationEnabled(False)
base.cam.setPos(self.vehicleNP.getPos().getX()+2,self.vehicleNP.getPos().getY()+2,self.vehicleNP.getPos().getZ()+2)
self.world.attachRigidBody(self.vehicleNP.node())
# Vehicle
self.vehicle = BulletVehicle(self.world, self.vehicleNP.node())
self.vehicle.setCoordinateSystem(ZUp)
self.world.attachVehicle(self.vehicle)
self.hummerNP = loader.loadModel('media/models/vehicle/body.X')
self.hummerNP.reparentTo(self.vehicleNP)
# Right front wheel
np = loader.loadModel('media/models/vehicle/front_right.X')
np.reparentTo(self.worldNP)
self.addWheel(Point3( 0.8, 0.9, 0.8), True, np)
# Left front wheel
np = loader.loadModel('media/models/vehicle/front_left.X')
np.reparentTo(self.worldNP)
self.addWheel(Point3(-0.8, 0.9, 0.8), True, np)
# Right rear wheel
np = loader.loadModel('media/models/vehicle/back_right.X')
np.reparentTo(self.worldNP)
self.addWheel(Point3( 0.8, -0.7, 0.8), False, np)
# Left rear wheel
np = loader.loadModel('media/models/vehicle/back_left.X')
np.reparentTo(self.worldNP)
self.addWheel(Point3(-0.8, -0.7, 0.8), False, np)
#Obstacles
self.setupObstacleOne(Vec3(50, -5, -4), 1.8, Vec3(60, 0, 0))
self.setupObstacleFour(Vec3(63.3, 59.2, -10), 1.5, Vec3(0,0,0))
self.setupObstacleFour(Vec3(41, 57, -10), 1.5, Vec3(0,0,0))
self.setupObstacleFour(Vec3(7.5, 53.8, -10), 1.5, Vec3(0,0,0))
self.setupObstacleFour(Vec3(-28, 81.4, -10), 1.5, Vec3(0,0,0))
self.setupObstacleSix(Vec3(-91, 81 , -6), 1, Vec3(60,0,0))
示例2: __init__
# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import attachVehicle [as 别名]
#.........这里部分代码省略.........
self.ground_node = BulletRigidBodyNode("The ground")
self.ground_node.addShape(self.ground)
self.ground_np = render.attachNewNode(self.ground_node)
self.ground_np.setPos(0, 0, -2)
scene.attachRigidBody(self.ground_node)
self.ground_model = loader.loadModel("Models/plane.egg")
self.ground_model.reparentTo(render)
self.ground_model.setPos(0,0,-1)
self.ground_model.setScale(3)
self.ground_tex = loader.loadTexture("Textures/ground.png")
self.ground_tex2 = loader.loadTexture("Textures/ground2.png")
self.ground_tex3 = loader.loadTexture("Textures/ground3.png")
self.ground_model.setTexture(self.ground_tex, 1)
#The car
Car_shape = BulletBoxShape(Vec3(1, 2.0, 1.0))
Car_node = BulletRigidBodyNode("The Car")
Car_node.setMass(1200.0)
Car_node.addShape(Car_shape)
Car_np = render.attachNewNode(Car_node)
Car_np.setPos(0,0,3)
Car_np.setHpr(0,0,0)
Car_np.node().setDeactivationEnabled(False)
scene.attachRigidBody(Car_node)
Car_model = loader.loadModel("Models/Car.egg")
Car_model.reparentTo(Car_np)
Car_tex = loader.loadTexture("Textures/Car1.png")
Car_model.setTexture(Car_tex, 1)
self.Car_sim = BulletVehicle(scene, Car_np.node())
self.Car_sim.setCoordinateSystem(ZUp)
scene.attachVehicle(self.Car_sim)
#The inside of the car
Car_int = loader.loadModel("Models/inside.egg")
Car_int.reparentTo(Car_np)
Car_int_tex = loader.loadTexture("Textures/inside.png")
Car_int.setTexture(Car_int_tex, 1)
Car_int.setTransparency(TransparencyAttrib.MAlpha)
#The steering wheel
Sw = loader.loadModel("Models/Steering wheel.egg")
Sw.reparentTo(Car_np)
Sw.setPos(0.25,0,-0.025)
#The first headlight
Headlight1 = Spotlight("Headlight1")
lens = PerspectiveLens()
lens.setFov(180)
Headlight1.setLens(lens)
Headlight1np = render.attachNewNode(Headlight1)
Headlight1np.reparentTo(Car_np)
Headlight1np.setPos(-0.8,2.5,-0.5)
Headlight1np.setP(-15)
render.setLight(Headlight1np)
#The second headlight
Headlight2 = Spotlight("Headlight2")
Headlight2.setLens(lens)
Headlight2np = render.attachNewNode(Headlight2)
Headlight2np.reparentTo(Car_np)
Headlight2np.setPos(0.8,2.5,-0.5)
Headlight2np.setP(-15)
render.setLight(Headlight2np)
示例3: Game
# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import attachVehicle [as 别名]
#.........这里部分代码省略.........
self.processInput(dt)
self.world.doPhysics(dt, 10, 0.008)
#print self.vehicle.getWheel(0).getRaycastInfo().isInContact()
#print self.vehicle.getWheel(0).getRaycastInfo().getContactPointWs()
#print self.vehicle.getChassis().isKinematic()
return task.cont
def cleanup(self):
self.world = None
self.worldNP.removeNode()
def setup(self):
self.worldNP = render.attachNewNode('World')
# World
self.debugNP = self.worldNP.attachNewNode(BulletDebugNode('Debug'))
self.debugNP.show()
self.world = BulletWorld()
self.world.setGravity(Vec3(0, 0, -9.81))
self.world.setDebugNode(self.debugNP.node())
# Plane
shape = BulletPlaneShape(Vec3(0, 0, 1), 0)
np = self.worldNP.attachNewNode(BulletRigidBodyNode('Ground'))
np.node().addShape(shape)
np.setPos(0, 0, -1)
np.setCollideMask(BitMask32.allOn())
self.world.attachRigidBody(np.node())
# Chassis
shape = BulletBoxShape(Vec3(0.6, 1.4, 0.5))
ts = TransformState.makePos(Point3(0, 0, 0.5))
np = self.worldNP.attachNewNode(BulletRigidBodyNode('Vehicle'))
np.node().addShape(shape, ts)
np.setPos(0, 0, 1)
np.node().setMass(800.0)
np.node().setDeactivationEnabled(False)
self.world.attachRigidBody(np.node())
#np.node().setCcdSweptSphereRadius(1.0)
#np.node().setCcdMotionThreshold(1e-7)
# Vehicle
self.vehicle = BulletVehicle(self.world, np.node())
self.vehicle.setCoordinateSystem(ZUp)
self.world.attachVehicle(self.vehicle)
self.yugoNP = loader.loadModel('models/yugo/yugo.egg')
self.yugoNP.reparentTo(np)
# Right front wheel
np = loader.loadModel('models/yugo/yugotireR.egg')
np.reparentTo(self.worldNP)
self.addWheel(Point3( 0.70, 1.05, 0.3), True, np)
# Left front wheel
np = loader.loadModel('models/yugo/yugotireL.egg')
np.reparentTo(self.worldNP)
self.addWheel(Point3(-0.70, 1.05, 0.3), True, np)
# Right rear wheel
np = loader.loadModel('models/yugo/yugotireR.egg')
np.reparentTo(self.worldNP)
self.addWheel(Point3( 0.70, -1.05, 0.3), False, np)
# Left rear wheel
np = loader.loadModel('models/yugo/yugotireL.egg')
np.reparentTo(self.worldNP)
self.addWheel(Point3(-0.70, -1.05, 0.3), False, np)
# Steering info
self.steering = 0.0 # degree
self.steeringClamp = 45.0 # degree
self.steeringIncrement = 120.0 # degree per second
def addWheel(self, pos, front, np):
wheel = self.vehicle.createWheel()
wheel.setNode(np.node())
wheel.setChassisConnectionPointCs(pos)
wheel.setFrontWheel(front)
wheel.setWheelDirectionCs(Vec3(0, 0, -1))
wheel.setWheelAxleCs(Vec3(1, 0, 0))
wheel.setWheelRadius(0.25)
wheel.setMaxSuspensionTravelCm(40.0)
wheel.setSuspensionStiffness(40.0)
wheel.setWheelsDampingRelaxation(2.3)
wheel.setWheelsDampingCompression(4.4)
wheel.setFrictionSlip(100.0);
wheel.setRollInfluence(0.1)