本文整理汇总了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);
}
示例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 ();
}
示例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 ();
}
示例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 ();
}