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


Python TransformState.makePosQuatScale方法代码示例

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


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

示例1: build_link

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePosQuatScale [as 别名]
    def build_link(self, node):
        
        (id_bda, ta), (id_bdb, tb) = self.link_building_status[node] 

        bda = self.factory.multiboxes[id_bda]
        bdb = self.factory.multiboxes[id_bdb]
        
        pos =  bda.body.getPosition()
        quat = LQuaternionf(bda.body.getQuaternion())
        mat = TransformState.makePosQuatScale(pos, quat, Vec3(1, 1, 1)).getMat()
        mat = ta.getMat() * mat
        print "ta", ta

        print "absol", TransformState.makeMat(mat)
        mat = LMatrix4f.translateMat(Vec3(0.5, 0, 0)) * mat
        anchor = TransformState.makeMat(mat).getPos() 
        print "absol", TransformState.makeMat(mat)
        
        axis = self.quat_dict[1][1]
        if node.orientation == 1:
            t = LMatrix4f.rotateMat(*self.quat_dict[4]) * mat
        else:
            t = LMatrix4f.rotateMat(*self.quat_dict[2]) * mat
        row = t.getRow(0)
        print "rotation", t.getRow(0), type(t.getRow(0))
        #axis = t.getQuat().getAxis()
        axis = Vec3(row.getX(), row.getY(), row.getZ())
        print "axis",axis
        print "anchor", anchor

        mat = LMatrix4f.translateMat(Vec3(0.5, 0, 0)) * mat
        mat = tb.getInverse().getMat() * mat
        t = TransformState.makeMat(mat)
        posb = t.getPos()
        quatb = t.getQuat()

        bdb.body.setPosition(posb)
        bdb.body.setQuaternion(quatb)

        cs = OdeHingeJoint(self.physics.world, self.physics.servogroup)
        cs.attach(bda.body, bdb.body)
        cs.setAxis(axis)
        cs.setAnchor(anchor)
        
        #add the motor
        cs.setParamFMax(self.satu_cmd)
        cs.setParamFudgeFactor(0.5)
        cs.setParamCFM(11.1111)
        cs.setParamStopCFM(11.1111)
        cs.setParamStopERP(0.444444)
        cs.setParamLoStop(- math.pi * 0.5)
        cs.setParamHiStop(math.pi * 0.5)
        pid = PID()

        self.dof_motors[node] = (cs, pid)
        print "add constraint"
开发者ID:clement91190,项目名称:rp,代码行数:58,代码来源:Creature.py

示例2: make_fixed

# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makePosQuatScale [as 别名]
 def make_fixed(np0, np1, type_=BulletGenericConstraint, cfm=0.01, erp=.99):
     """ Make a joint and return it."""
     t0 = np0.getTop()
     t1 = np1.getTop()
     p0 = np0.getPos(t0)
     p1 = np1.getPos(t1)
     q0 = np0.getQuat(t0)
     q1 = np1.getQuat(t1)
     pivot = Point3((p0 + p1) / 2.)
     disp = Point3((p1 - p0) / 2.)
     pivot_np = t0.attachNewNode("pivot-node")
     pivot_np.setPos(pivot)
     s = Vec3(1, 1, 1)
     q = Quat.identQuat()  # pivot_np.getQuat(t0)  #
     #BP()
     # q0 = pivot_np.getQuat(np0)
     # q1 = pivot_np.getQuat(np1)
     q0i = Quat(q0)
     q1i = Quat(q1)
     #BP()
     q0i.invertInPlace()
     q1i.invertInPlace()
     q0i *= q
     q1i *= q
     #BP()
     ts0 = TransformState.makePosQuatScale(disp, q0i, s)
     ts1 = TransformState.makePosQuatScale(-disp, q1i, s)
     pivot_np.removeNode()
     # Create the joint.
     joint = type_(np0.node(), np1.node(), ts0, ts1, False)
     for ax in xrange(4):
         joint.setAngularLimit(ax, 0, 0)
         joint.setLinearLimit(ax, 0, 0)
     joint.setParam(type_.CPErp, erp)
     joint.setParam(type_.CPCfm, cfm)
     joint.setDebugDrawSize(2)
     return joint
开发者ID:jhamrick,项目名称:scenesim,代码行数:39,代码来源:bulletbase.py


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