def test_boxshape_shift(): S0 = BoxShape() args = Vec3(1, 2, 3) S1 = BoxShape([args]) pos = Vec3(10, 20, 30) quat = Quat(1, 1, 0, 0) quat.normalize() ones = Vec3(1, 1, 1) T = TransformState.makePosQuatScale(pos, quat, ones) S0.shift(pos=pos, quat=quat) S1.shift(pos=pos, quat=quat) S1.shift(pos=pos, quat=quat) assert S0[1] == T assert S1[1] == T.compose(T)
def test_boxshape_transform(): args = Vec3(1, 2, 3) S0 = BoxShape([args]) scale = Vec3(5, 6, 7) pos = Vec3(10, 20, 30) quat = Quat(1, 1, 0, 0) quat.normalize() ones = Vec3(1, 1, 1) rbso = RBSO("rbso") rbso.set_scale(scale) rbso.set_pos(pos) rbso.set_quat(quat) S0.transform(rbso) T = TransformState.makePosQuatScale(pos, quat, ones) assert S0[0][0] == Vec3(*imap(mul, args, scale)) assert S0[1] == T
def test_apply_prop_read_prop_SSO(): sso = SSO("foo") other = SSO("other") other.setPos(100, 200, 300) other.setHpr(23, 20, 100) other.setScale(6, 2, 9) prop0 = { "name": "testname", "pos": Point3(1, 2, 3), "quat": Quat(2**0.5, 2**0.5, 0, 0), "scale": Vec3(10, 9, 8), } sso.setName(prop0["name"]) sso.setPos(prop0["pos"]) sso.setQuat(prop0["quat"]) sso.setScale(prop0["scale"]) assert prop0 == sso.read_prop() oprop = sso.read_prop(other=other) sso.wrtReparentTo(other) assert sso.read_prop() == oprop