当前位置: 首页>>代码示例>>C#>>正文


C# World.Distance方法代码示例

本文整理汇总了C#中World.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# World.Distance方法的具体用法?C# World.Distance怎么用?C# World.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.Distance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_Distance

        public void Test_Distance()
        {
            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 (0, 0, 0);
            node2.Translate (0, 0, 0);
            Assert.AreEqual (0, wld.Distance (node1, node2));

            node1.Translate (0, 0, 0);
            node2.Translate (10, 0, 0);
            Assert.AreEqual (8, wld.Distance (node1, node2), 0.01f);

            node1.Rotate (0, 0, 0, 0);
            node2.Rotate (45, 0, 0, 1);
            Assert.AreEqual (7.6f, wld.Distance (node1, node2), 0.01f);

            node1.Detach (col1);
            node2.Detach (col2);
            Assert.AreEqual (Single.NaN, wld.Distance (node1, node2), 0.01f);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:32,代码来源:TestCollisionAnalyze.cs

示例2: Test_Distance_Box_to_Box

        public void Test_Distance_Box_to_Box()
        {
            var node1 = new Node ("Node1");

            var col1 = new CollisionObject ();
            col1.Shape = new BoxShape (1, 1, 1);
            col1.SetOffset (0, 0, 0);

            node1.Attach (col1);

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

            node2.Attach (col2);

            node1.Translate (0, 0, 0);
            node2.Translate (10, 0, 0);

            // 10*√2

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

            wld.CollisionUpdate ();

            Assert.AreEqual(10*1.4142f - 2*1.4142f, wld.Distance (node1, node2), 0.05f);

            wld.Destroy ();
        }
开发者ID:weimingtom,项目名称:erica,代码行数:32,代码来源:TestDistance.cs

示例3: Test_Distance_Invalid_Objects

        public void Test_Distance_Invalid_Objects()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");

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

            wld.CollisionUpdate ();

            var d = wld.Distance (node1, node2);
            Assert.AreEqual (Single.NaN, d);

            wld.Destroy ();
        }
开发者ID:weimingtom,项目名称:erica,代码行数:16,代码来源:TestDistance.cs

示例4: Test_Distance_Overlapped_Objects

        public void Test_Distance_Overlapped_Objects()
        {
            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);

            wld.CollisionUpdate ();

            node2.Translation = new Vector3 (3, 0, 0);
            node2.Rotation = new Quaternion (45, 0, 0, 1);

            var d = wld.Distance (node1, node2);
            Assert.AreEqual (3 - 1 - 1 * 1.4142f, d, 0.5f);

            node2.Translation = new Vector3 (2.1f, 0, 0);

            d = wld.Distance (node1, node2);
            Assert.AreEqual (0, d);

            node2.Translation = new Vector3 (0, 0, 0);

            d = wld.Distance (node1, node2);
            Assert.AreEqual (0, d);

            wld.Destroy ();
        }
开发者ID:weimingtom,项目名称:erica,代码行数:39,代码来源:TestDistance.cs


注:本文中的World.Distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。