Пример #1
0
def recurse_hierarchy(op, parentID):
    global depth
    global globalID

    # print "{} parent: {}".format(depth, parentID)
    myID = parentID

    if isinstance(op, c4dchar.CAJointObject):

        globalID += 1
        myID = globalID

        if myID == 0:  # if root, add offset pos
            pos = op.GetMl().off
            anim_desc["Frames"][-1].append(.5)
            anim_desc["Frames"][-1].append(round(pos.x, 5))
            anim_desc["Frames"][-1].append(round(pos.y, 5))
            anim_desc["Frames"][-1].append(round(pos.z, 5))

        # only add quaternions
        rot = c4dutils.MatrixToHPB(op.GetMl())
        q = c4d.Quaternion()
        q.SetHPB(rot)
        anim_desc["Frames"][-1].append(round(q.w, 5))
        anim_desc["Frames"][-1].append(round(q.v.x, 5))
        anim_desc["Frames"][-1].append(round(q.v.y, 5))
        anim_desc["Frames"][-1].append(round(q.v.z, 5))

    for child in op.GetChildren():
        depth += 1
        recurse_hierarchy(child, myID)
        depth -= 1
def GetGlobalRotation(obj):
    return utils.MatrixToHPB(obj.GetMg())
def GetGlobalRotation(obj):  # Get object's global rotation
    return u.MatrixToHPB(obj.GetMg())
def main():
    print(utils.MatrixToHPB(op.GetMg()))
Пример #5
0
def GetGlobalRotation(obj):
    """
    Returns the global rotation of obj
    """
    return utils.MatrixToHPB(obj.GetMg())
def recurse_hierarchy(op, parentID):
    global depth
    global globalID

    # print "{} parent: {}".format(depth, parentID)
    myID = parentID

    if isinstance(op, c4dchar.CAJointObject):

        globalID += 1
        myID = globalID

        pos = op.GetMl().off
        rot = c4dutils.MatrixToHPB(op.GetMl())

        body_desc["Skeleton"]["Joints"].append({
            "ID": myID,
            "Name": op.GetName(),
            "Type": "none",
            "Parent": parentID,
            "AttachX": round(pos.x, 5),
            "AttachY": round(pos.y, 5),
            "AttachZ": round(pos.z, 5),
            "AttachThetaX": round(rot.x, 5),
            "AttachThetaY": round(rot.y, 5),
            "AttachThetaZ": round(rot.z, 5),
            "LimLow0": -1.000000,
            "LimHigh0": 1.000000,
            "LimLow1": -1.000000,
            "LimHigh1": 1.000000,
            "LimLow2": -1.000000,
            "LimHigh2": 1.000000,
            "TorqueLim": 200,
            "IsEndEffector": 0,
            "DiffWeight": 1
        })
        body_desc["Skeleton"]["BodyDefs"].append({
            "ID": myID,
            "Name": op.GetName(),
            "Shape": "sphere",
            "Mass": 6.0,
            "ColGroup": 1,
            "EnableFallContact": 1,
            "AttachX": 0,
            "AttachY": 0,
            "AttachZ": 0,
            "AttachThetaX": 0,
            "AttachThetaY": 0,
            "AttachThetaZ": 0,
            "Param0": 10,
            "Param1": 10,
            "Param2": 10
        })
        body_desc["Skeleton"]["DrawShapeDefs"].append({
            "ID": myID,
            "Name": op.GetName(),
            "Shape": "sphere",
            "ParentJoint": myID,
            "AttachX": 0,
            "AttachY": 0,
            "AttachZ": 0,
            "AttachThetaX": 0,
            "AttachThetaY": 0,
            "AttachThetaZ": 0,
            "Param0": 10,
            "Param1": 10,
            "Param2": 10,
            "ColorR": 0.4706,
            "ColorG": 0.549,
            "ColorB": 0.6863,
            "ColorA": 1
        })
        # print "{} {} {} {}".format(depth, op.GetName(), myID, parentID)

    for child in op.GetChildren():
        depth += 1
        recurse_hierarchy(child, myID)
        depth -= 1