示例#1
0
        public void TruncateRayForInvalidPosition_Test()
        {
            var ray    = new AcousticRay(new Vector3(0, 0, 0), new Vector3(1, 5, 7));
            var newRay = ray.TruncateRay(5, new Vector3(1, 5, 7));

            Assert.IsTrue(newRay.Source == new Vector3(0, 0, 0) && newRay.MicrophonePosition == new Vector3(1, 5f, 7));
            Assert.IsTrue(newRay.CollisionPoints.Count == 0 && newRay.AcousticMaterials.Count == 0);
        }
示例#2
0
        public void TruncateRayUsualCase_Test()
        {
            var ray = new AcousticRay(new Vector3(0, 0, 0), new Vector3(1, 5, 7));

            ray.CollisionPoints.Add(new Vector3(1, 5, 3));
            ray.CollisionPoints.Add(new Vector3(1, 2, 6));
            ray.CollisionPoints.Add(new Vector3(1, 5, 16));
            ray.CollisionPoints.Add(new Vector3(1, 2, 20));

            var gameObject = new GameObject();

            gameObject.AddComponent <AcousticMaterial>();
            ray.AcousticMaterials.Add(gameObject.GetComponent <AcousticMaterial>());
            ray.AcousticMaterials.Add(gameObject.GetComponent <AcousticMaterial>());
            ray.AcousticMaterials.Add(gameObject.GetComponent <AcousticMaterial>());
            ray.AcousticMaterials.Add(gameObject.GetComponent <AcousticMaterial>());

            var microphonePos = new Vector3(1, 5.02f, 16);
            var newRay        = ray.TruncateRay(3, microphonePos);

            Assert.IsTrue(newRay.Source == new Vector3(0, 0, 0) && newRay.MicrophonePosition == new Vector3(1, 5.02f, 16));
            Assert.IsTrue(newRay.CollisionPoints.Count == 3 && newRay.AcousticMaterials.Count == 3);
        }