public void ConstructSnapshot() { // set unique position/rotation/scale transform.position = new Vector3(1, 2, 3); transform.rotation = Quaternion.identity; transform.localScale = new Vector3(4, 5, 6); // construct snapshot double time = NetworkTime.localTime; NTSnapshot snapshot = component.ConstructSnapshot(); Assert.That(snapshot.remoteTimestamp, Is.EqualTo(time).Within(0.01)); Assert.That(snapshot.position, Is.EqualTo(new Vector3(1, 2, 3))); Assert.That(snapshot.rotation, Is.EqualTo(Quaternion.identity)); Assert.That(snapshot.scale, Is.EqualTo(new Vector3(4, 5, 6))); }
public void Interpolate() { NTSnapshot from = new NTSnapshot( 1, 1, new Vector3(1, 1, 1), Quaternion.Euler(new Vector3(0, 0, 0)), new Vector3(3, 3, 3) ); NTSnapshot to = new NTSnapshot( 2, 2, new Vector3(2, 2, 2), Quaternion.Euler(new Vector3(0, 90, 0)), new Vector3(4, 4, 4) ); // interpolate NTSnapshot between = NTSnapshot.Interpolate(from, to, 0.5); // note: timestamp interpolation isn't needed. we don't use it. //Assert.That(between.remoteTimestamp, Is.EqualTo(1.5).Within(Mathf.Epsilon)); //Assert.That(between.localTimestamp, Is.EqualTo(1.5).Within(Mathf.Epsilon)); // check position Assert.That(between.position.x, Is.EqualTo(1.5).Within(Mathf.Epsilon)); Assert.That(between.position.y, Is.EqualTo(1.5).Within(Mathf.Epsilon)); Assert.That(between.position.z, Is.EqualTo(1.5).Within(Mathf.Epsilon)); // check rotation // (epsilon is slightly too small) Assert.That(between.rotation.eulerAngles.x, Is.EqualTo(0).Within(Mathf.Epsilon)); Assert.That(between.rotation.eulerAngles.y, Is.EqualTo(45).Within(0.001)); Assert.That(between.rotation.eulerAngles.z, Is.EqualTo(0).Within(Mathf.Epsilon)); // check scale Assert.That(between.scale.x, Is.EqualTo(3.5).Within(Mathf.Epsilon)); Assert.That(between.scale.y, Is.EqualTo(3.5).Within(Mathf.Epsilon)); Assert.That(between.scale.z, Is.EqualTo(3.5).Within(Mathf.Epsilon)); }
public new void ApplySnapshot(NTSnapshot start, NTSnapshot goal, NTSnapshot interpolated) => base.ApplySnapshot(start, goal, interpolated);