Exemplo n.º 1
0
def test_rotate_axis():
    _new()

    with cmdx.DagModifier() as mod:
        a = mod.create_node("transform", name="a")
        b = mod.create_node("transform", name="b", parent=a)
        c = mod.create_node("transform", name="c", parent=b)

        mod.set_attr(a["rotateAxisZ"], cmdx.radians(45))
        mod.set_attr(b["rotateAxisZ"], cmdx.radians(-45))
        mod.set_attr(c["rotateAxisZ"], cmdx.radians(-45))
        mod.set_attr(a["ty"], 3.0)
        mod.set_attr(b["tx"], 1.0)
        mod.set_attr(c["tx"], 1.0)

    cmds.select(str(a), str(b), str(c))
    ri.assign_group()

    # Give them some droop
    group = cmdx.ls(type="rdGroup")[0]
    group["driveStiffness"] = 0.01

    # We've got a bridge-like shape
    #
    #   b      c
    #   .-----.
    #  /       \
    # . a       \
    #
    cmdx.min_time(1)
    cmdx.max_time(50)
    ri.record_markers()

    assert_almost_equals(b["rz"].read(time=50), cmdx.radians(-48.0), 1)
Exemplo n.º 2
0
def test_rotate_pivot():
    _new()

    with cmdx.DagModifier() as mod:
        a = mod.create_node("transform", name="a")
        b = mod.create_node("transform", name="b", parent=a)
        c = mod.create_node("transform", name="c", parent=b)

        mod.set_attr(a["ty"], 3.0)
        mod.set_attr(b["tx"], 1.0)
        mod.set_attr(c["tx"], 1.0)

    cmds.select(str(a), str(b), str(c))
    ri.assign_group()

    # Give them some droop
    group = cmdx.ls(type="rdGroup")[0]
    group["driveStiffness"] = 0.01

    cmdx.max_time(100)
    ri.record_markers()

    # We've got a dick-like shape
    #
    # a
    # .----. b
    #       \
    #        . c
    #        |
    #        |
    #
    assert_almost_equals(b["rz"].read(time=cmdx.max_time()),
                         cmdx.radians(-50.0), 1)
Exemplo n.º 3
0
def test_negative_uniform_scale():
    _new()

    with cmdx.DagModifier() as mod:
        a = mod.create_node("transform", name="a")
        b = mod.create_node("transform", name="b", parent=a)
        c = mod.create_node("transform", name="c", parent=b)

        mod.set_attr(a["scale"], -2.0)
        mod.set_attr(a["ty"], 3.0)
        mod.set_attr(b["tx"], 1.0)
        mod.set_attr(c["tx"], 1.0)

    cmds.select(str(a), str(b), str(c))
    ri.assign_group()

    # Give them some droop
    group = cmdx.ls(type="rdGroup")[0]
    group["driveStiffness"] = 0.01

    cmdx.min_time(1)
    cmdx.max_time(50)

    ri.record_markers()

    cmdx.current_time(50)
    assert_almost_equals(b["rz"].read(), cmdx.radians(31.0), 1)
Exemplo n.º 4
0
def test_record_from_not_start_frame():
    _new()

    with cmdx.DagModifier() as mod:
        a = mod.create_node("transform", name="a")
        b = mod.create_node("transform", name="b", parent=a)
        c = mod.create_node("transform", name="c", parent=b)

        mod.set_attr(a["rz"], cmdx.radians(45))
        mod.set_attr(b["rz"], cmdx.radians(-45))
        mod.set_attr(c["rz"], cmdx.radians(-45))
        mod.set_attr(a["ty"], 3.0)
        mod.set_attr(b["tx"], 1.0)
        mod.set_attr(c["tx"], 1.0)

    cmds.select(str(a), str(b), str(c))
    ri.assign_group()

    # Give them some droop
    group = cmdx.ls(type="rdGroup")[0]
    group["driveStiffness"] = 0.01

    # We've got a bridge-like shape
    #
    #   b      c
    #   .-----.
    #  /       \
    # . a       \
    #
    cmdx.min_time(1)
    cmdx.max_time(50)

    _step(c, 25)

    ri.record_markers()

    # We didn't break the start frame
    cmdx.current_time(1)
    assert_almost_equals(b["rz"].read(), cmdx.radians(-45.0), 1)

    # And the final frame looks ok
    cmdx.current_time(50)
    assert_almost_equals(b["rz"].read(), cmdx.radians(-93.0), 1)
Exemplo n.º 5
0
def test_joint_orient():
    _new()

    with cmdx.DagModifier() as mod:
        a = mod.create_node("joint", name="a")
        b = mod.create_node("joint", name="b", parent=a)
        c = mod.create_node("joint", name="c", parent=b)
        tip = mod.create_node("joint", name="tip", parent=c)

        mod.set_attr(a["jointOrientZ"], cmdx.radians(45))
        mod.set_attr(b["jointOrientZ"], cmdx.radians(-45))
        mod.set_attr(c["jointOrientZ"], cmdx.radians(-45))
        mod.set_attr(a["ty"], 3.0)
        mod.set_attr(b["tx"], 5.0)
        mod.set_attr(c["tx"], 5.0)
        mod.set_attr(tip["tx"], 5.0)

    cmds.select(str(a), str(b), str(c))
    ri.assign_group()

    # Give them some droop
    group = cmdx.ls(type="rdGroup")[0]
    group["driveStiffness"] = 0.01

    # We've got a bridge-like shape
    #
    #   b      c
    #   .-----.
    #  /       \
    # . a       \
    #
    cmdx.min_time(1)
    cmdx.max_time(25)
    ri.record_markers(**{"markersIgnoreJoints": False})

    assert_almost_equals(b["rz"].read(time=25), cmdx.radians(-13.0), 1)
Exemplo n.º 6
0
def test_negative_non_uniform_scale2():
    # A more special case, based on Roy's rig
    _new()

    with cmdx.DagModifier() as mod:
        a = mod.create_node("transform", name="a")
        b = mod.create_node("transform", name="b", parent=a)
        c = mod.create_node("transform", name="c", parent=b)

        mod.set_attr(a["tx"], 0.028)
        mod.set_attr(a["ty"], 5.762)
        mod.set_attr(a["tz"], 1.024)

        mod.set_attr(b["scaleZ"], -1.0)
        mod.set_attr(b["tx"], -0.19)
        mod.set_attr(b["ty"], 0.942)
        mod.set_attr(b["tz"], -0.334)
        mod.set_attr(b["rx"], cmdx.radians(86.831))
        mod.set_attr(b["ry"], cmdx.radians(15.163))
        mod.set_attr(b["rz"], cmdx.radians(100.711))

        mod.set_attr(c["scaleZ"], -1.0)
        mod.set_attr(c["tx"], -1.306)
        mod.set_attr(c["ty"], -0.327)
        mod.set_attr(c["tz"], 3.804)
        mod.set_attr(c["rx"], cmdx.radians(-79.561))
        mod.set_attr(c["ry"], cmdx.radians(61.743))
        mod.set_attr(c["rz"], cmdx.radians(9.128))

    cmds.select(str(a), str(b), str(c))
    ri.assign_group()

    # Give them some droop
    group = cmdx.ls(type="rdGroup")[0]
    group["driveStiffness"] = 0.01

    cmdx.min_time(1)
    cmdx.max_time(40)

    ri.record_markers()

    cmdx.current_time(40)
    assert_almost_equals(c["rx", cmdx.Degrees].read(), -76.638, 1)
    assert_almost_equals(c["ry", cmdx.Degrees].read(), 63.653, 1)
    assert_almost_equals(c["rz", cmdx.Degrees].read(), -8.884, 1)