コード例 #1
0
def test_applyOneToMany():
    cubes, mats = getMultiMatrixObjects()
    mmo.applyNodePositions([mats[0]], cubes)

    for cube in cubes:
        cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
        assert(cubeMat == pytest.approx(flattenMat(mats[0])))
コード例 #2
0
def test_applyManyToSame():
    cubes, mats = getMultiMatrixObjects()
    mmo.applyNodePositions(mats, cubes)

    for x in xrange(len(cubes)):
        cubeMat = flattenMat(cubes[x].getMatrix(worldSpace=True))
        assert(cubeMat == pytest.approx(flattenMat(mats[x])))
コード例 #3
0
def test_applyManyToSame():
    cubes, mats = getMultiMatrixObjects()
    mmo.applyNodePositions(mats, cubes)

    for x in xrange(len(cubes)):
        cubeMat = flattenMat(cubes[x].getMatrix(worldSpace=True))
        assert (cubeMat == pytest.approx(flattenMat(mats[x])))
コード例 #4
0
def test_applyOneToMany():
    cubes, mats = getMultiMatrixObjects()
    mmo.applyNodePositions([mats[0]], cubes)

    for cube in cubes:
        cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
        assert (cubeMat == pytest.approx(flattenMat(mats[0])))
コード例 #5
0
def test_applyManyToMore():
    cubes, mats = getMultiMatrixObjects()
    # Failure case.
    with pytest.raises(IndexError):
        mmo.applyNodePositions(mats[2:], cubes)
    # Check that nothing was changed.
    for cube in cubes:
        cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
        assert(cubeMat == pytest.approx(flattenMat(pm.dt.Matrix())))
コード例 #6
0
def test_applyManyToMore():
    cubes, mats = getMultiMatrixObjects()
    # Failure case.
    with pytest.raises(IndexError):
        mmo.applyNodePositions(mats[2:], cubes)
    # Check that nothing was changed.
    for cube in cubes:
        cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
        assert (cubeMat == pytest.approx(flattenMat(pm.dt.Matrix())))
コード例 #7
0
def test_applyManyToLess():
    cubes, mats = getMultiMatrixObjects()
    mmo.applyNodePositions(mats[:3], cubes[:2])

    # Only two cubes changed. Remaining matrices tossed.
    for x in xrange(2):
        cubeMat = flattenMat(cubes[x].getMatrix(worldSpace=True))
        assert(cubeMat == pytest.approx(flattenMat(mats[x])))
    for cube in cubes[2:]:
        cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
        assert(cubeMat == pytest.approx(flattenMat(pm.dt.Matrix())))
コード例 #8
0
def test_applyManyToLess():
    cubes, mats = getMultiMatrixObjects()
    mmo.applyNodePositions(mats[:3], cubes[:2])

    # Only two cubes changed. Remaining matrices tossed.
    for x in xrange(2):
        cubeMat = flattenMat(cubes[x].getMatrix(worldSpace=True))
        assert (cubeMat == pytest.approx(flattenMat(mats[x])))
    for cube in cubes[2:]:
        cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
        assert (cubeMat == pytest.approx(flattenMat(pm.dt.Matrix())))
コード例 #9
0
def test_applyLocked():
    cube, shape = pm.polyCube()
    cube.tx.lock()

    applyMat = pm.dt.Matrix()
    resultMat = pm.dt.Matrix()
    applyMat[3] = (5, 5, 5, 1)
    # Tests partial application of position
    resultMat[3] = (0, 5, 5, 1)
    mmo.applyNodePositions([applyMat], [cube])

    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert (cubeMat == pytest.approx(flattenMat(resultMat)))
コード例 #10
0
def test_applyLocked():
    cube, shape = pm.polyCube()
    cube.tx.lock()


    applyMat = pm.dt.Matrix()
    resultMat = pm.dt.Matrix()
    applyMat[3] = (5, 5, 5, 1)
    # Tests partial application of position
    resultMat[3] = (0, 5, 5, 1)
    mmo.applyNodePositions([applyMat], [cube])

    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(resultMat)))
コード例 #11
0
def test_applyScaledMatrix():
    # applyNodePositions should NOT apply scale.
    cube, shape = pm.polyCube()
    mat = pm.dt.Matrix([[0.5, 0.5, -0.707106781187, 0.0],
                        [-0.292893218813, 1.70710678119, 1.0, 0.0],
                        [1.70710678119, -0.292893218813, 1.0, 0.0],
                        [1.0, 2.0, 3.0, 1.0]])

    # Same matrix, but unscaled
    unscaled = pm.dt.Matrix([[0.5, 0.5, -0.707106781187, 0.0],
                             [-0.146446609407, 0.853553390593, 0.5, 0.0],
                             [0.853553390593, -0.146446609407, 0.5, 0.0],
                             [1.0, 2.0, 3.0, 1.0]])
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert (cubeMat == pytest.approx(flattenMat(unscaled)))
コード例 #12
0
def test_applyScaledMatrix():
    # applyNodePositions should NOT apply scale.
    cube, shape = pm.polyCube()
    mat = pm.dt.Matrix([
        [0.5, 0.5, -0.707106781187, 0.0],
        [-0.292893218813, 1.70710678119, 1.0, 0.0],
        [1.70710678119, -0.292893218813, 1.0, 0.0],
        [1.0, 2.0, 3.0, 1.0]])

    # Same matrix, but unscaled
    unscaled = pm.dt.Matrix([
        [0.5, 0.5, -0.707106781187, 0.0],
        [-0.146446609407, 0.853553390593, 0.5, 0.0],
        [0.853553390593, -0.146446609407, 0.5, 0.0],
        [1.0, 2.0, 3.0, 1.0]])
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(unscaled)))
コード例 #13
0
def test_applyOneMatrix():
    cube, shape = pm.polyCube()

    # Pass through identity matrix
    mat = pm.dt.Matrix()
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(mat)))

    # Reset to identity
    cube.t.set((1, 2, 3))
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(mat)))

    # Arbitrary matrix.
    mat = pm.dt.Matrix([
        [0.664463024389, 0.664463024389, -0.342020143326, 0.0],
        [-0.386220403522, 0.697130037317, 0.604022773555, 0.0],
        [0.639783314196, -0.269255641148, 0.719846310393, 0.0],
        [15.5773616478, 17.4065855678, 15.7988353267, 1.0]])

    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(mat)))
コード例 #14
0
def test_applyOneMatrix():
    cube, shape = pm.polyCube()

    # Pass through identity matrix
    mat = pm.dt.Matrix()
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert (cubeMat == pytest.approx(flattenMat(mat)))

    # Reset to identity
    cube.t.set((1, 2, 3))
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert (cubeMat == pytest.approx(flattenMat(mat)))

    # Arbitrary matrix.
    mat = pm.dt.Matrix([[0.664463024389, 0.664463024389, -0.342020143326, 0.0],
                        [-0.386220403522, 0.697130037317, 0.604022773555, 0.0],
                        [0.639783314196, -0.269255641148, 0.719846310393, 0.0],
                        [15.5773616478, 17.4065855678, 15.7988353267, 1.0]])

    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert (cubeMat == pytest.approx(flattenMat(mat)))