コード例 #1
0
        public void Test_Pick()
        {
            var node1 = new Node ("Node1");
            var col1 = new CollisionObject ();
            col1.Shape = new BoxShape (1, 1, 1);
            node1.Attach (col1);

            var node2 = new Node ("Node2");
            var col2 = new CollisionObject ();
            col2.Shape = new BoxShape (1, 1, 1);
            node2.Attach (col2);

            var wld = new World ();
            wld.AddChild (node1);
            wld.AddChild (node2);

            node1.Translate (1, 0, 0);
            node2.Translate (-1, 0, 0);

            wld.CollisionUpdate ();

            Assert.AreEqual (null, wld.Pick (new Vector3 (3, -10, 0), new Vector3 (3, 10, 0)));
            Assert.AreEqual (node1, wld.Pick (new Vector3 (2, -10, 0), new Vector3 (2, 10, 0)));
            Assert.AreEqual (node1, wld.Pick (new Vector3 (1, -10, 0), new Vector3 (1, 10, 0)));
            Assert.AreEqual (node1, wld.Pick (new Vector3 (0, -10, 0), new Vector3 (0, 10, 0)));
            Assert.AreEqual (node2, wld.Pick (new Vector3 (-1, -10, 0), new Vector3 (-1, 10, 0)));
            Assert.AreEqual (node2, wld.Pick (new Vector3 (-2, -10, 0), new Vector3 (-2, 10, 0)));
            Assert.AreEqual (null, wld.Pick (new Vector3 (-3, -10, 0), new Vector3 (-3, 10, 0)));
        }