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


Python TransformState.makePos方法代码示例

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


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

示例1: doCollisionSweepTestZ

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
  def doCollisionSweepTestZ(self,col_mask = CollisionMasks.PLATFORM_RIGID_BODY,from_z = 0, to_z = 0):
    '''
    doCollisionSweepTestZ(double from_z = 0, double to_z = 0)
    Performs a collision sweep test along z in order to determine the height 
    at which the character's active rigid body comes into contact with an obstacle.  This is useful during 
    landing actions.
    
    @param col_mask: [optional] collision mask of the object(s) to check for collisions with.
    @param from_z:   [optional] z value for the start position
    @param to_z:     [optional] z value for the end position  
    '''
    
    pos = self.getPos()
    if abs(from_z - to_z) < 1e-5:
      height = self.getHeight()
      from_z = pos.getZ() + 0.5* height
      to_z = pos.getZ() - 0.5* height
    t0 = TransformState.makePos(Vec3(pos.getX(),pos.getY(),from_z))
    t1 = TransformState.makePos(Vec3(pos.getX(),pos.getY(),to_z))
    
    rigid_body = self.getRigidBody()
    if rigid_body.node().getNumShapes() <= 0:
      logging.warn("Rigid body contains no shapes, collision sweep test canceled")
      return
    
    aabb_shape = rigid_body.node().getShape(0)
    result = self.physics_world_.sweepTestClosest(aabb_shape,t0,t1,col_mask,0.0)

    if not result.hasHit():
      logging.warn("No collision from collision sweep closest test from %s to %s "%(t0.getPos(),t1.getPos()))
    else:
      logging.debug("Found collision at point %s between p0: %s to p1 %s"%(result.getHitPos(),t0.getPos(),t1.getPos()))
      
    return result
开发者ID:jrgnicho,项目名称:platformer_games_project,代码行数:36,代码来源:character_base.py

示例2: sweepRay

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
 def sweepRay(self, startp,endp):
     tsFrom = TransformState.makePos(Point3(0, 0, 0))
     tsTo = TransformState.makePos(Point3(10, 0, 0))
     shape = BulletSphereShape(0.5)
     penetration = 0.0
     result = self.world.sweepTestClosest(shape, tsFrom, tsTo, penetration)
     return result 
开发者ID:brettbarbaro,项目名称:autoPACK,代码行数:9,代码来源:pandautil.py

示例3: doShoot

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
 def doShoot(self, ccd):
   if(self.fire and self.attempts > 0 and self.gameState == 'PLAY'):
     self.cameraState = 'LOOK'
     self.fire = False
     self.candleThrow.play()
     self.attempts -= 1
     #get from/to points from mouse click
     ## pMouse = base.mouseWatcherNode.getMouse()
     ## pFrom = Point3()
     ## pTo = Point3()
     ## base.camLens.extrude(pMouse, pFrom, pTo)
     
     ## pFrom = render.getRelativePoint(base.cam, pFrom)
     ## pTo = render.getRelativePoint(base.cam, pTo)
     
     # calculate initial velocity
     v = self.pTo - self.pFrom
     ratio = v.length() / 40
     v.normalize()
     v *= 70.0 * ratio
     torqueOffset = random.random() * 10
     
     #create bullet
     shape = BulletSphereShape(0.5)
     shape01 = BulletSphereShape(0.5)
     shape02 = BulletSphereShape(0.5)
     shape03 = BulletSphereShape(0.5)
     body = BulletRigidBodyNode('Candle')
     bodyNP = self.worldNP.attachNewNode(body)
     bodyNP.node().addShape(shape, TransformState.makePos(Point3(0,0,0)))
     bodyNP.node().addShape(shape01, TransformState.makePos(Point3(0,0.5,-0.5)))
     bodyNP.node().addShape(shape02,TransformState.makePos(Point3(0,1,-1)))
     bodyNP.node().addShape(shape03,TransformState.makePos(Point3(0,1.5,-1.5)))
     bodyNP.node().setMass(100)
     bodyNP.node().setFriction(1.0)
     bodyNP.node().setLinearVelocity(v)
     bodyNP.node().applyTorque(v*torqueOffset)
     bodyNP.setPos(self.pFrom)
     bodyNP.setCollideMask(BitMask32.allOn())
     
     visNP = loader.loadModel('models/projectile.X')
     visNP.setScale(0.7)
     visNP.clearModelNodes()
     visNP.reparentTo(bodyNP)
     
     #self.bird = bodyNP.node()
     
     if ccd:
         bodyNP.node().setCcdMotionThreshold(1e-7)
         bodyNP.node().setCcdSweptSphereRadius(0.5)
         
     self.world.attachRigidBody(bodyNP.node())
     
     #remove the bullet again after 1 sec
     self.bullets = bodyNP
     taskMgr.doMethodLater(5, self.removeBullet, 'removeBullet', extraArgs=[bodyNP], 
                           appendTask = True)
开发者ID:MarcusKhoo,项目名称:CandlesVsSnowmen,代码行数:59,代码来源:CandlesVsSnowmen.py

示例4: setup

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
  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())

    # Box
    shape = BulletBoxShape(Vec3(0.5, 0.5, 0.5))

    np = self.worldNP.attachNewNode(BulletRigidBodyNode('Box'))
    np.node().setMass(1.0)
    np.node().addShape(shape)
    np.node().addShape(shape, TransformState.makePos(Point3(0, 1, 0)))
    np.node().setDeactivationEnabled(False)
    np.setPos(2, 0, 4)
    np.setCollideMask(BitMask32.allOn())

    self.world.attachRigidBody(np.node())

    visualNP = loader.loadModel('models/box.egg')
    visualNP.reparentTo(np)

    self.box = np.node()

    # Sphere
    shape = BulletSphereShape(0.6)

    np = self.worldNP.attachNewNode(BulletRigidBodyNode('Sphere'))
    np.node().setMass(1.0)
    np.node().addShape(shape)
    np.node().addShape(shape, TransformState.makePos(Point3(0, 1, 0)))
    np.setPos(-2, 0, 4)
    np.setCollideMask(BitMask32.allOn())

    self.world.attachRigidBody(np.node())

    self.sphere = np.node()
开发者ID:Changuito,项目名称:juan_example,代码行数:54,代码来源:08_Contacts.py

示例5: raycast

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
 def raycast(self):
   # Raycast for closest hit
   tsFrom = TransformState.makePos(Point3(0,0,0))
   tsTo = TransformState.makePos(Point3(10,0,0))
   shape = BulletSphereShape(0.5)
   penetration = 1.0
   result = self.world.sweepTestClosest(shape, tsFrom, tsTo, penetration)
   if result.hasHit():
       torque = Vec3(10,0,0)
       force = Vec3(0,0,100)
       
       ## for hit in result.getHits():
           ## hit.getNode().applyTorque(torque)
           ## hit.getNode().applyCentralForce(force)
       result.getNode().applyTorque(torque)
       result.getNode().applyCentralForce(force)
开发者ID:MarcusKhoo,项目名称:CandlesVsSnowmen,代码行数:18,代码来源:CandlesVsSnowmen.py

示例6: __init__

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
    def __init__(self, world, attach, name = '', position = Vec3(0,0,0), orientation = Vec3(0,0,0), 
            turretPitch = 0): 

        #Constant Relevant Instatiation Parameters
        self._tankSize = Vec3(1, 1.5, .5) # Actually a half-size
        self._tankSideLength = max(self._tankSize)
        friction = .3
        tankMass = 800.0

        # Rewrite constructor to include these?
        self._maxVel = 4
        self._maxRotVel = 1
        self._maxThrusterAccel = 5000
        self._breakForce = 1000
        turretRelPos = (0, 0, 0) #Relative to tank
       
        self._shape = BulletBoxShape(Vec3(1,1.5,.5)) #chassis
        self._transformState = TransformState.makePos(Point3(0, 0, 0)) #offset 
        DynamicWorldObject.__init__(self, world, attach, name, position, self._shape, orientation, Vec3(0,0,0), mass = tankMass)   #Initial velocity must be 0
        self.__createVehicle(self._tankWorld.getPhysics())

        self._collisionCounter = 0
        self._taskTimer = 0
        self._nodePath.node().setFriction(friction)		
        self._nodePath.setPos(position)
        # Set up turret nodepath
        # (Nodepaths are how objects are managed in Panda3d)
 
        self.onTask = 0

        # Make collide mask (What collides with what)
        self._nodePath.setCollideMask(0xFFFF0000)
        #self._nodePath.setCollideMask(BitMask32.allOff())

        self.movementPoint = Point3(10,10,0)
开发者ID:ursulawolz,项目名称:tanCS,代码行数:37,代码来源:Tank.py

示例7: setupVehicle

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
    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
        np = loader.loadModel('models/yugo/yugotireR.egg')
        np.reparentTo(main.worldNP)
        self.addWheel(Point3( 0.70 * scale,  1.05 * scale, 0.3), True, np)

        # Left front wheel
        np = loader.loadModel('models/yugo/yugotireL.egg')
        np.reparentTo(main.worldNP)
        self.addWheel(Point3(-0.70 * scale,  1.05 * scale, 0.3), True, np)

        # Right rear wheel
        np = loader.loadModel('models/yugo/yugotireR.egg')
        np.reparentTo(main.worldNP)
        self.addWheel(Point3( 0.70 * scale, -1.05 * scale, 0.3), False, np)

        # Left rear wheel
        np = loader.loadModel('models/yugo/yugotireL.egg')
        np.reparentTo(main.worldNP)
        self.addWheel(Point3(-0.70 * scale, -1.05 * scale, 0.3), False, np)
开发者ID:genusgant,项目名称:CS594-ThrottleThunder-GameClient,代码行数:61,代码来源:Vehicle.py

示例8: __init__

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
 def  __init__(self,info):
   
   # animation base setup
   self.character_info_ = info   
   size = Vec3(info.width, AnimationActor.DEFAULT_WIDTH , info.height)
   AnimatableObject.__init__(self,info.name,size,info.mass)    
   self.animation_root_np_.setPos(Vec3(0,0,0))
   
       # constraints
   self.left_constraint_ = None
   self.right_constraint_ = None
   self.selected_constraint_ = None
   
   # removing default shapes from rigid body
   shapes = self.node().getShapes()
   for shape in shapes:
     self.node().removeShape(shape)
   
   # adding capsule shape
   radius = 0.5*size.getX()
   height = size.getZ() - 2.0*radius  # height of cylindrical part only
   height = height if height >= 0 else 0.0
   bullet_shape = BulletCapsuleShape(radius, height, ZUp)
   bullet_shape.setMargin(GameObject.DEFAULT_COLLISION_MARGIN)
   self.node().addShape(bullet_shape,TransformState.makePos(Vec3(0,0,0.5*size.getZ()))) # box bottom center coincident with the origin
   self.node().setMass(self.character_info_.mass)
   self.node().setLinearFactor((1,1,1)) 
   self.node().setAngularFactor((0,0,0)) 
   self.setCollideMask(CollisionMasks.NO_COLLISION)    
   
   #  setting bounding volume
   min = LPoint3(-0.5*size.getX(),-0.5*size.getY(),0)
   max = LPoint3(0.5*size.getX(),0.5*size.getY(),size.getZ())
   self.node().setBoundsType(BoundingVolume.BT_box)    
   self.node().setBounds(BoundingBox(min,max))
   
   # setting origin ghost nodes
   rel_pos = Vec3(-GameObject.ORIGIN_XOFFSET,0,info.height/2)
   self.left_origin_gn_ = self.attachNewNode(BulletGhostNode(self.getName() + '-left-origin'))
   self.left_origin_gn_.node().addShape(BulletSphereShape(GameObject.ORIGIN_SPHERE_RADIUS),TransformState.makePosHpr(rel_pos,Vec3.zero()))
   self.left_origin_gn_.node().setIntoCollideMask(CollisionMasks.ACTION_TRIGGER_0 if not self.isFacingRight() else CollisionMasks.NO_COLLISION)
   
   rel_pos = Vec3(GameObject.ORIGIN_XOFFSET,0,info.height/2)
   self.right_origin_gn_ = self.attachNewNode(BulletGhostNode(self.getName() + '-right-origin'))
   self.right_origin_gn_.node().addShape(BulletSphereShape(GameObject.ORIGIN_SPHERE_RADIUS),TransformState.makePosHpr(rel_pos,Vec3.zero()))
   self.right_origin_gn_.node().setIntoCollideMask(CollisionMasks.ACTION_TRIGGER_0 if self.isFacingRight() else CollisionMasks.NO_COLLISION)
   
   # character status
   self.state_data_ = CharacterStateData()
   
   # state machine
   self.sm_ = StateMachine()     
   
   # motion commander
   self.motion_commander_ = MotionCommander(self)
   
   # set id
   self.setObjectID(self.getName())
开发者ID:jrgnicho,项目名称:platformer_games_project,代码行数:60,代码来源:character_base.py

示例9: addMultiSphereGhost

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
 def addMultiSphereGhost(self,rads,centT,**kw):
     inodenp = self.worldNP.attachNewNode(BulletGhostNode("Sphere"))
     for radc, posc in zip(rads, centT):
         shape = BulletSphereShape(radc)
         inodenp.node().addShape(shape, TransformState.makePos(Point3(posc[0],posc[1],posc[2])))#
     self.setRB(inodenp,**kw)
     inodenp.setCollideMask(BitMask32.allOn())    
     self.world.attachRigidBody(inodenp.node())
     return inodenp     
开发者ID:brettbarbaro,项目名称:autoPACK,代码行数:11,代码来源:pandautil.py

示例10: addRBSphere

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
def addRBSphere(world,pos, worldNP):
    shape = BulletSphereShape(0.6)
    inodenp = worldNP.attachNewNode(BulletRigidBodyNode("Sphere"))
    inodenp.node().setMass(0.0)
#    inodenp.node().addShape(shape)
    inodenp.node().addShape(shape, TransformState.makePos(pos))
#        spherenp.setPos(-2, 0, 4)
    inodenp.setCollideMask(BitMask32.allOn())
    world.attachRigidBody(inodenp.node())
    return inodenp.node()
开发者ID:brettbarbaro,项目名称:autoPACK,代码行数:12,代码来源:setupPanda.py

示例11: createHShapedRigidBody

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
 def createHShapedRigidBody(self,name,side_length):
   
   visual = loader.loadModel(RESOURCES_DIR + '/models/box.egg')
   visual.setTexture(loader.loadTexture(RESOURCES_DIR + '/models/limba.jpg'))
   bounds = visual.getTightBounds()
   extents = Vec3(bounds[1] - bounds[0])
   scale_factor = 1/max([extents.getX(),extents.getY(),extents.getZ()])
   #visual.setScale(side_length*scale_factor,side_length*scale_factor,side_length*scale_factor)
   
   half_side_length = 0.5 * side_length/4
   box_size = Vec3(half_side_length,half_side_length,half_side_length)
   rigid_body = NodePath(BulletRigidBodyNode(name))
   
   transforms = [
                 TransformState.makePos(Vec3(0.5*side_length + 3*half_side_length,0,half_side_length)),    # bottom 
                 TransformState.makePos(Vec3(0.5*side_length + 3*half_side_length,0,3*half_side_length)),  # center 1
                 TransformState.makePos(Vec3(0.5*side_length + 3*half_side_length,0,5*half_side_length)) , # center 2
                 TransformState.makePos(Vec3(0.5*side_length + 3*half_side_length,0,7*half_side_length)) , # top
                 TransformState.makePos(Vec3(0.5*side_length + -3*half_side_length,0,half_side_length)) ,  # bottom
                 TransformState.makePos(Vec3(0.5*side_length + -3*half_side_length,0,3*half_side_length)), # center 1
                 TransformState.makePos(Vec3(0.5*side_length + -3*half_side_length,0,5*half_side_length)), # center 2
                 TransformState.makePos(Vec3(0.5*side_length + -3*half_side_length,0,7*half_side_length)), # top 
                 TransformState.makePos(Vec3(0.5*side_length + -half_side_length,0,4*half_side_length)),   # left
                 TransformState.makePos(Vec3(0.5*side_length + half_side_length,0,4*half_side_length))     # right
                 ]
   
   count = 0
   for t in transforms:
     rigid_body.node().addShape(BulletBoxShape(box_size),t)
     vnp = visual.instanceUnderNode(rigid_body,'box-visual' + str(count))
     vnp.setTransform(t)      
     vnp.setScale(2*half_side_length*scale_factor,
                  2*half_side_length*scale_factor,
                  2*half_side_length*scale_factor)
     vnp.setTexture(loader.loadTexture(RESOURCES_DIR + '/models/limba.jpg'))
     count+=1
     
   rigid_body.node().setMass(1)
   rigid_body.node().setLinearFactor((1,0,1))
   rigid_body.node().setAngularFactor((0,0,0))
   rigid_body.node().setIntoCollideMask(BitMask32.allOn())
   
   return rigid_body
开发者ID:jrgnicho,项目名称:platformer_games_project,代码行数:45,代码来源:test_hinge_constraint.py

示例12: addRBCube

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
def addRBCube(world,pos, worldNP):
    shape = BulletBoxShape(Vec3(12.5, 12.5, 12.5))
    inodenp = worldNP.attachNewNode(BulletRigidBodyNode("Box"))
    inodenp.node().setMass(1.0)
#    inodenp.node().addShape(shape)
    inodenp.node().addShape(shape, TransformState.makePos(pos))
#        spherenp.setPos(-2, 0, 4)
    inodenp.setCollideMask(BitMask32.allOn())
    world.attachRigidBody(inodenp.node())
    return inodenp.node()    
开发者ID:brettbarbaro,项目名称:autoPACK,代码行数:12,代码来源:setupPanda.py

示例13: addMultiSphereRB

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
 def addMultiSphereRB(self,rads,centT,**kw):
     inodenp = self.worldNP.attachNewNode(BulletRigidBodyNode("Sphere"))
     inodenp.node().setMass(1.0)
     for radc, posc in zip(rads, centT):
         shape = BulletSphereShape(radc)#if radis the same can use the same shape for each node
         inodenp.node().addShape(shape, TransformState.makePos(Point3(posc[0],posc[1],posc[2])))#
     self.setRB(inodenp,**kw)
     inodenp.setCollideMask(BitMask32.allOn())    
     self.world.attachRigidBody(inodenp.node())
     return inodenp
开发者ID:brettbarbaro,项目名称:autoPACK,代码行数:12,代码来源:pandautil.py

示例14: __init__

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
    def __init__(self, tempworld, bulletWorld, type, playerId):
        self.world = tempworld
        self.speed = 0
        self.acceleration = 1.5
        self.brakes = .7
        self.min_speed = 0
        self.max_speed = 150
        self.reverse_speed = 20
        self.reverse_limit = -40
        self.armor = 100
        self.health = 100
        self.a_timer_start = time.time()
        self.a_timer_end = time.time()
        self.power_ups = [0, 0, 0]
        self.playerId = playerId

        if type == 0:
            self.actor = Actor("models/batmobile-chassis")
            self.actor.setScale(0.7)
            carRadius = 3
        elif type == 1:
            self.actor = Actor("models/policecarpainted", {})
            self.actor.setScale(0.30)
            self.actor.setH(180)  # elif type == 2:
        # self.actor = loader.loadModel("knucklehead.egg")
        #     self.tex = loader.loadTexture("knucklehead.jpg")
        #     self.actor.setTexture(self.car_tex, 1)


        shape = BulletBoxShape(Vec3(1.0, 1.5, 0.4))
        ts = TransformState.makePos(Point3(0, 0, 0.6))

        self.chassisNP = render.attachNewNode(BulletRigidBodyNode('Vehicle'))
        self.chassisNP.node().addShape(shape, ts)
        self.chassisNP.setPos(50 * random.random(), 50 * random.random(), 1)
        self.chassisNP.setH(180)
        self.chassisNP.node().setMass(800.0)
        self.chassisNP.node().setDeactivationEnabled(False)

        bulletWorld.attachRigidBody(self.chassisNP.node())

        self.actor.reparentTo(self.chassisNP)
        self.actor.setH(180)

        # Vehicle
        self.vehicle = BulletVehicle(bulletWorld, self.chassisNP.node())
        self.vehicle.setCoordinateSystem(ZUp)
        bulletWorld.attachVehicle(self.vehicle)

        for fb, y in (("F", 1.1), ("B", -1.1)):
            for side, x in (("R", 0.75), ("L", -0.75)):
                np = loader.loadModel("models/tire%s.egg" % side)
                np.reparentTo(render)
                isFront = fb == "F"
                self.addWheel(Point3(x, y, 0.55), isFront, np)
开发者ID:genusgant,项目名称:CS594-ThrottleThunder-GameClient,代码行数:57,代码来源:Character.py

示例15: setupVehicle

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePos [as 别名]
    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)

        # Left front wheel
        np = loader.loadModel('models/batmobile-wheel-left.egg')
        np.reparentTo(render)
        self.addWheel(Point3(-1, 1.1, .7), True, np)

        # Right rear wheel
        np = loader.loadModel('models/batmobile-wheel-right.egg')
        np.reparentTo(render)
        self.addWheel(Point3(1, -2, .7), False, np)

        # Left rear wheel
        np = loader.loadModel('models/batmobile-wheel-left.egg')
        np.reparentTo(render)
        self.addWheel(Point3(-1, -2, .7), False, np)
开发者ID:Lixinli,项目名称:dd-team,代码行数:57,代码来源:Vehicle.py


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