本文整理汇总了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
示例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)
示例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)
示例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)