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


Python TransformState.makeHpr方法代码示例

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


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

示例1: create_colliders

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeHpr [as 别名]
def create_colliders(root, pose_rig, joints_config):
    for node, parent in pose_rig.exposed_joints:
        if node.getName() not in joints_config:
            continue

        joint_config = joints_config[node.getName()]
        if "joints" not in joint_config:
            continue

        joints = joint_config["joints"]
        if len(joints) == 0:
            continue

        mass = joint_config["mass"] if "mass" in joint_config else 1

        box_rb = BulletRigidBodyNode(node.getName())
        box_rb.setMass(1.0)
        # box_rb.setLinearDamping(0.2)
        # box_rb.setAngularDamping(0.9)
        # box_rb.setFriction(1.0)
        # box_rb.setAnisotropicFriction(1.0)
        # box_rb.setRestitution(0.0)

        for joint in joints:
            child_node, child_parent = next(
                (child_node, child_parent)
                for child_node, child_parent in pose_rig.exposed_joints
                if child_node.getName() == joint
            )

            pos = child_node.getPos(child_parent)
            width = pos.length() / 2.0
            scale = Vec3(3, width, 3)

            shape = BulletBoxShape(scale)

            quat = Quat()
            lookAt(quat, child_node.getPos(child_parent), Vec3.up())
            if len(joints) > 1:
                transform = TransformState.makePosHpr(child_node.getPos(child_parent) / 2.0, quat.getHpr())
            else:
                transform = TransformState.makeHpr(quat.getHpr())

            box_rb.addShape(shape, transform)

        box_np = root.attachNewNode(box_rb)

        if len(joints) > 1:
            pos = node.getPos(pose_rig.actor)
            hpr = node.getHpr(pose_rig.actor)
            box_np.setPosHpr(root, pos, hpr)
        else:
            box_np.setPos(child_parent, child_node.getPos(child_parent) / 2.0)
            box_np.lookAt(child_parent, child_node.getPos(child_parent))

        yield box_np
开发者ID:BarkingMouseStudio,项目名称:python-experiments,代码行数:58,代码来源:physics_utils.py

示例2: __setupConstraints__

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeHpr [as 别名]
 def __setupConstraints__(self,actor_rigid_body_np):
   
   self.__cleanupConstraints__()
   
   self.left_constraint_ = BulletGenericConstraint(self.node(),
                                                   actor_rigid_body_np.node(),
                                                   TransformState.makeIdentity(),
                                                   TransformState.makeHpr(Vec3(180,0,0)),False)
   
   self.right_constraint_ = BulletGenericConstraint(self.node(),
                                                    actor_rigid_body_np.node(),
                                                    TransformState.makeIdentity(),
                                                    TransformState.makeIdentity(),False)
   
   self.left_constraint_.setEnabled(False)
   self.right_constraint_.setEnabled(False)
   for axis in range(0,6):
     self.left_constraint_.setParam(BulletGenericConstraint.CP_cfm,0,axis)
     self.right_constraint_.setParam(BulletGenericConstraint.CP_cfm,0,axis)
开发者ID:jrgnicho,项目名称:platformer_games_project,代码行数:21,代码来源:character_base.py

示例3: __init__

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeHpr [as 别名]
    def __init__(self,cubeMapPath=None):
        yawOff=198
        self.sphere = loader.loadModel("InvertSphereBlend.egg")
        # self.sphere = loader.loadModel("InvertedSphere.egg")
        # Load a sphere with a radius of 1 unit and the faces directed inward.

        self.sphere.setTexGen(TextureStage.getDefault(),
                              TexGenAttrib.MWorldPosition)
        self.sphere.setTexProjector(TextureStage.getDefault(), render,
                                    self.sphere)
        self.sphere.setTexTransform(TextureStage.getDefault(),
                                    TransformState.makeHpr(VBase3(yawOff, 0, 0)))

        # Create some 3D texture coordinates on the sphere. For more info on this, check the Panda3D manual.
        self.sphere.setPos((0,0,0))
        self.sphere.setTexPos(TextureStage.getDefault(), 0, 0, 0)
        self.sphere.setTexScale(TextureStage.getDefault(), 1)

        # tex = loader.loadCubeMap(cubeMapPath)
        if cubeMapPath is None:
            cubeMapPath=renamer()
        tex = loader.loadCubeMap(cubeMapPath)
        self.sphere.setTexture(tex)
        # Load the cube map and apply it to the sphere.

        self.sphere.setLightOff()
        # Tell the sphere to ignore the lighting.

        self.sphere.setScale(10)

        # Increase the scale of the sphere so it will be larger than the scene.
        print self.sphere.getHpr()
        print self.sphere.getPos()
        self.sphere.reparentTo(render)


        # Reparent the sphere to render so you can see it.
        # result = self.sphere.writeBamFile(cubeMapPath.split('_#.tga')[0]+'.bam')
        print '/'.join(cubeMapPath.split('/')[:-1])+'.bam'
        base.saveCubeMap('streetscene_cube_#.jpg', size=512)
        result = self.sphere.writeBamFile('/'.join(cubeMapPath.split('/')[:-1])+'.bam')
        # Save out the bam file.
        print(result)
开发者ID:pvnkmrksk,项目名称:world,代码行数:45,代码来源:boxGen.py

示例4: createConstraints

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeHpr [as 别名]
 def createConstraints(self,bodyA,bodyB):
   
   left_constraint = BulletGenericConstraint(bodyA,bodyB,TransformState.makeIdentity(),TransformState.makeHpr(Vec3(180,0,0)),False)
   right_constraint = BulletGenericConstraint(bodyA,bodyB,TransformState.makeIdentity(),TransformState.makeIdentity(),False)
   left_constraint.setEnabled(False)
   right_constraint.setEnabled(False)
   return (right_constraint,left_constraint)
开发者ID:jrgnicho,项目名称:platformer_games_project,代码行数:9,代码来源:test_hinge_constraint.py


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