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


Python Matrix.to_quaternion方法代码示例

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


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

示例1: rotation_from_matrix

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_quaternion [as 别名]
def rotation_from_matrix(m00, m01, m02, m10, m11, m12, m20, m21, m22):
    mat = Matrix()
    mat[0][0] = m00
    mat[0][1] = m01
    mat[0][2] = m02
    mat[1][0] = m10
    mat[1][1] = m11
    mat[1][2] = m12
    mat[2][0] = m20
    mat[2][1] = m21
    mat[2][2] = m22

    return mat.to_quaternion()
开发者ID:Delicode,项目名称:NI-mate-plugins,代码行数:15,代码来源:animation_delicode_ni_mate_tools.py

示例2: _attachpoint_prs_blender

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_quaternion [as 别名]
    def _attachpoint_prs_blender(self, attachpoint):
        pos = self._vec_blender(attachpoint.position)

        rot = Matrix()
        x = self._vec_blender2(attachpoint.zvector)
        y = self._vec_blender2(attachpoint.xvector)
        z = self._vec_blender2(attachpoint.yvector)
        rot[0].xyz = (x[0], y[0], z[0])
        rot[1].xyz = (x[1], y[1], z[1])
        rot[2].xyz = (x[2], y[2], z[2])
        rot = rot.to_quaternion()

        bbmax = Vector(attachpoint.bounding_box_max)
        bbmin = Vector(attachpoint.bounding_box_min)
        sca = bbmax - bbmin
        sca = [sca[0], sca[2], sca[1]]

        return pos, rot, sca
开发者ID:Ryder25,项目名称:Age-of-Mythology,代码行数:20,代码来源:brgfileimporter.py

示例3: computeRoll

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_quaternion [as 别名]
def computeRoll(head, tail, normal, bone=None):
    if normal is None:
        return 0

    p1 = m2b(head)
    p2 = m2b(tail)
    xvec = normal
    pvec = getUnitVector(p2-p1)
    xy = xvec.dot(pvec)
    yvec = getUnitVector(pvec-xy*xvec)
    zvec = getUnitVector(xvec.cross(yvec))
    if zvec is None:
        return 0
    else:
        mat = Matrix((xvec,yvec,zvec))

    checkOrthogonal(mat)
    quat = mat.to_quaternion()
    if abs(quat[0]) < 1e-4:
        return 0
    else:
        roll = math.pi - 2*math.atan(quat[2]/quat[0])

    if roll < -math.pi:
        roll += 2*math.pi
    elif roll > math.pi:
        roll -= 2*math.pi
    return roll

    if bone and bone.name in ["forearm.L", "forearm.R"]:
        print("B  %s" % bone.name)
        print(" H  %.4g %.4g %.4g" % tuple(head))
        print(" T  %.4g %.4g %.4g" % tuple(tail))
        print(" N  %.4g %.4g %.4g" % tuple(normal))
        print(" P  %.4g %.4g %.4g" % tuple(pvec))
        print(" X  %.4g %.4g %.4g" % tuple(xvec))
        print(" Y  %.4g %.4g %.4g" % tuple(yvec))
        print(" Z  %.4g %.4g %.4g" % tuple(zvec))
        print(" Q  %.4g %.4g %.4g %.4g" % tuple(quat))
        print(" R  %.4g" % roll)

    return roll
开发者ID:,项目名称:,代码行数:44,代码来源:

示例4: read

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_quaternion [as 别名]

#.........这里部分代码省略.........

            elif section[1] == self.quatLinearRotationController_tag:
                print("quatLinearRotationController_tag    /!\    No parser defined   /!\ ")
                #parsed_sections[section[2]] =

            elif section[1] == self.quatBezRotationController_tag:
                print("quatBezRotationController_tag    /!\    No parser defined   /!\ ")
                #parsed_sections[section[2]] =

            elif section[1] == self.skinbones_tag:
                print("skinbones_tag    /!\    No parser defined   /!\ ")
                #parsed_sections[section[2]] =

            elif section[1] == self.bones_tag:
                print("bones_tag    /!\    No parser defined   /!\ ")
                #parsed_sections[section[2]] =

            else:
                print("Unknown section tag %d" % section[1] )



        for section in sections:

            if section[1] == self.model_data_tag:
                model_data = parsed_sections[section[2]]
                if model_data[3] == 6:
                    continue
                
                model_id = self.dictionary.get(model_data[2][1], str(model_data[2][1]))
                #model_id = "model-%x" % model_data[2][2]
                geometry = parsed_sections[parsed_sections[model_data[4]][2]]
                topology = parsed_sections[parsed_sections[model_data[4]][3]]
                faces = topology[4]
                verts = geometry[6]
                uvs = geometry[7]
                normals = geometry[8]
                colors = geometry[9]
                weights = geometry[10]
                
                
                rotation_matrix = Matrix((
                  (model_data[2][4][0],model_data[2][4][4],model_data[2][4][8],model_data[2][4][12]),
                  (model_data[2][4][1],model_data[2][4][5],model_data[2][4][9],model_data[2][4][13]),
                  (model_data[2][4][2],model_data[2][4][6],model_data[2][4][10],model_data[2][4][14]),
                  (model_data[2][4][3],model_data[2][4][7],model_data[2][4][11],model_data[2][4][15])))
                #loc, rot, scale = rotation_matrix.decompose()
                rot = rotation_matrix.to_quaternion()
                loc = model_data[2][5]
                
                if model_data[2][6] > 0:
                    obj_parent_data = parsed_sections[model_data[2][6]]
                    if obj_parent_data[0] == 'Model':
                      obj_parent_data = obj_parent_data[2]
                    
                    obj_parent = self.dictionary.get(obj_parent_data[2], str(obj_parent_data[2]))
                else:
                    obj_parent = str(0)
                
                material_names = []
                marerial_indecies = None
                if model_data[3] == 3:
                  mat_group_sec_id = model_data[8]
                  mat_group_sec_data = parsed_sections[mat_group_sec_id]
                  for item in mat_group_sec_data[3]:
                    mat_sec_data = parsed_sections[item]
                    if self.dictionary.get(mat_sec_data[2], None) != None:
                      material_names.append(self.dictionary.get(mat_sec_data[2], None))
                    
                  marerial_indecies = model_data[7]
                
                self.build_model(model_id, verts, uvs, normals, faces, colors, weights, obj_parent, loc, rot, material_names, marerial_indecies)
            elif section[1] == self.object3D_tag:
                object3D_data = parsed_sections[section[2]]
                obj_name = self.dictionary.get(object3D_data[2], str(object3D_data[2]))
                obj_position = object3D_data[6]
                
                obj_rotationMat = Matrix((
                  (object3D_data[5][0],object3D_data[5][4],object3D_data[5][8],object3D_data[5][12]),
                  (object3D_data[5][1],object3D_data[5][5],object3D_data[5][9],object3D_data[5][13]),
                  (object3D_data[5][2],object3D_data[5][6],object3D_data[5][10],object3D_data[5][14]),
                  (object3D_data[5][3],object3D_data[5][7],object3D_data[5][11],object3D_data[5][15])))
                
                #loc, rot, scale = obj_rotationMat.decompose()
                rot = obj_rotationMat.to_quaternion()
                
                loc = object3D_data[6]
                
                if object3D_data[7] > 0:
                    obj_parent_data = parsed_sections[object3D_data[7]]
                    if obj_parent_data[0] == 'Model':
                      obj_parent_data = obj_parent_data[2]
                    
                    obj_parent = self.dictionary.get(obj_parent_data[2], str(obj_parent_data[2]))
                else:
                    obj_parent = str(0)
                    
                self.build_emptyObject(obj_name, loc, rot, obj_parent)
            
        print("Import done")
开发者ID:Last-Bullet-Development,项目名称:payday-model-blender-addon,代码行数:104,代码来源:import_pd2model.py


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