Ejemplo n.º 1
0
        public void ShouldThrowWhenChildIsNull2()
        {
            DummySceneNode node = new DummySceneNode();

            node.Children.Add(new DummySceneNode());
            node.Children[0] = null;
        }
Ejemplo n.º 2
0
        public void ClearShouldResetParents()
        {
            DummySceneNode node = new DummySceneNode();

            Assert.AreEqual(0, node.Children.Count);

            node.Children.Clear(); // Test clear on empty collection.

            DummySceneNode nodeA = new DummySceneNode();
            DummySceneNode nodeB = new DummySceneNode();
            DummySceneNode nodeC = new DummySceneNode();

            node.Children.Add(nodeA);
            node.Children.Add(nodeB);
            node.Children.Add(nodeC);

            Assert.AreSame(node, nodeA.Parent);
            Assert.AreSame(node, nodeB.Parent);
            Assert.AreSame(node, nodeC.Parent);

            node.Children.Clear();

            Assert.IsNull(nodeA.Parent);
            Assert.IsNull(nodeB.Parent);
            Assert.IsNull(nodeC.Parent);
        }
Ejemplo n.º 3
0
        public void SwitchingCollection()
        {
            DummySceneNode node  = new DummySceneNode();
            DummySceneNode node2 = new DummySceneNode();

            DummySceneNode nodeA = new DummySceneNode();
            DummySceneNode nodeB = new DummySceneNode();
            DummySceneNode nodeC = new DummySceneNode();

            node.Children.Add(nodeA);
            node.Children.Add(nodeB);
            node.Children.Add(nodeC);

            Assert.AreSame(node, nodeA.Parent);
            Assert.AreSame(node, nodeB.Parent);
            Assert.AreSame(node, nodeC.Parent);

            node.Children.Remove(nodeB);
            node.Children.Remove(nodeC);
            node2.Children.Add(nodeB);
            node2.Children.Add(nodeC);
            Assert.AreEqual(1, node.Children.Count);
            Assert.AreSame(node, nodeA.Parent);
            Assert.AreEqual(2, node2.Children.Count);
            Assert.AreSame(node2, nodeB.Parent);
            Assert.AreSame(node2, nodeC.Parent);
        }
Ejemplo n.º 4
0
        public void ShouldThrowWhenSceneIsAddedToAsChild()
        {
            DefaultScene scene = new DefaultScene();

            DummySceneNode node = new DummySceneNode();

            node.Children.Add(scene);
        }
Ejemplo n.º 5
0
        public void ShouldThrowWhenChildExists()
        {
            DummySceneNode node  = new DummySceneNode();
            DummySceneNode child = new DummySceneNode();

            node.Children.Add(child);
            node.Children.Add(child);
        }
Ejemplo n.º 6
0
        public void ShouldThrowWhenChildExists2()
        {
            DummySceneNode node   = new DummySceneNode();
            DummySceneNode childA = new DummySceneNode();
            DummySceneNode childB = new DummySceneNode();

            node.Children.Add(childA);
            node.Children.Add(childB);
            node.Children[1] = childA;
        }
Ejemplo n.º 7
0
        public void ShoudThrowWhenChildHasParent()
        {
            DummySceneNode node   = new DummySceneNode();
            DummySceneNode node2  = new DummySceneNode();
            DummySceneNode childA = new DummySceneNode();
            DummySceneNode childB = new DummySceneNode();

            node.Children.Add(childA);
            node2.Children.Add(childB);
            node.Children[0] = childB;
        }
Ejemplo n.º 8
0
        public void AddRemoveSingleNode()
        {
            DefaultScene scene = new DefaultScene();

            DummySceneNode node = new DummySceneNode();

            scene.Children.Add(node);

            Assert.AreEqual(1, scene.CollisionDomain.CollisionObjects.Count);
            Assert.AreSame(node, scene.CollisionDomain.CollisionObjects[0].GeometricObject);

            scene.Children.Remove(node);
            Assert.AreEqual(0, scene.CollisionDomain.CollisionObjects.Count);
        }
Ejemplo n.º 9
0
        public void RemoveShouldResetParents()
        {
            DummySceneNode node = new DummySceneNode();

            DummySceneNode child = new DummySceneNode();

            node.Children.Add(child);

            Assert.AreSame(node, child.Parent);

            node.Children.Remove(child);

            Assert.IsNull(child.Parent);
        }
Ejemplo n.º 10
0
        public void AddRemoveTreeOfNodesTest()
        {
            DefaultScene scene = new DefaultScene();

            DummySceneNode nodeA = new DummySceneNode {
                Name = "A"
            };
            DummySceneNode nodeB = new DummySceneNode {
                Name = "B"
            };
            DummySceneNode nodeC = new DummySceneNode {
                Name = "C"
            };
            DummySceneNode nodeD = new DummySceneNode {
                Name = "D"
            };

            nodeA.Children.Add(nodeB);
            nodeA.Children.Add(nodeC);
            nodeB.Children.Add(nodeD);

            // Add a tree of nodes.
            scene.Children.Add(nodeA);

            Assert.AreEqual(4, scene.CollisionDomain.CollisionObjects.Count);
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeA));
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeB));
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeC));
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeD));

            // Add a single node to tree.
            DummySceneNode nodeE = new DummySceneNode();

            nodeD.Children.Add(nodeE);

            Assert.AreEqual(5, scene.CollisionDomain.CollisionObjects.Count);
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeE));

            // Remove a subtree.
            nodeB.Children.Remove(nodeD);

            Assert.AreEqual(3, scene.CollisionDomain.CollisionObjects.Count);
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeA));
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeB));
            Assert.IsNotNull(scene.CollisionDomain.CollisionObjects.Get(nodeC));

            // Remove tree.
            scene.Children.Remove(nodeA);
            Assert.AreEqual(0, scene.CollisionDomain.CollisionObjects.Count);
        }
Ejemplo n.º 11
0
        public void ReplaceChild()
        {
            DummySceneNode node   = new DummySceneNode();
            DummySceneNode childA = new DummySceneNode();
            DummySceneNode childB = new DummySceneNode();

            node.Children.Add(childA);

            Assert.AreEqual(1, node.Children.Count);
            Assert.AreSame(childA, node.Children[0]);

            node.Children[0] = childB;
            Assert.AreEqual(1, node.Children.Count);
            Assert.AreSame(childB, node.Children[0]);
        }
Ejemplo n.º 12
0
        public void ShouldSetParent()
        {
            DummySceneNode node = new DummySceneNode();

            DummySceneNode nodeA = new DummySceneNode();
            DummySceneNode nodeB = new DummySceneNode();
            DummySceneNode nodeC = new DummySceneNode();

            node.Children.Add(nodeA);
            node.Children.Add(nodeB);
            node.Children.Add(nodeC);

            Assert.AreSame(node, nodeA.Parent);
            Assert.AreSame(node, nodeB.Parent);
            Assert.AreSame(node, nodeC.Parent);
        }
Ejemplo n.º 13
0
        public void GetAncestors()
        {
            DummySceneNode nodeA = new DummySceneNode();
            DummySceneNode nodeB = new DummySceneNode();
            DummySceneNode nodeC = new DummySceneNode();
            DummySceneNode nodeD = new DummySceneNode();

            nodeA.Children.Add(nodeB);
            nodeA.Children.Add(nodeC);
            nodeB.Children.Add(nodeD);

            var ancestors = nodeD.GetAncestors().ToArray();

            Assert.AreEqual(2, ancestors.Length);
            Assert.AreSame(nodeB, ancestors[0]);
            Assert.AreSame(nodeA, ancestors[1]);
        }
Ejemplo n.º 14
0
        public void GetDescendantsBreadthFirst()
        {
            DummySceneNode nodeA = new DummySceneNode();
            DummySceneNode nodeB = new DummySceneNode();
            DummySceneNode nodeC = new DummySceneNode();
            DummySceneNode nodeD = new DummySceneNode();

            nodeA.Children.Add(nodeB);
            nodeA.Children.Add(nodeC);
            nodeB.Children.Add(nodeD);

            var descendants = nodeA.GetDescendants(false).ToArray();

            Assert.AreEqual(3, descendants.Length);
            Assert.AreSame(nodeB, descendants[0]);
            Assert.AreSame(nodeC, descendants[1]);
            Assert.AreSame(nodeD, descendants[2]);
        }
Ejemplo n.º 15
0
        public void CheckSequence()
        {
            DummySceneNode node = new DummySceneNode();

            Assert.AreEqual(0, node.Children.Count);

            DummySceneNode nodeA = new DummySceneNode();
            DummySceneNode nodeB = new DummySceneNode();
            DummySceneNode nodeC = new DummySceneNode();

            node.Children.Add(nodeA);
            node.Children.Add(nodeB);
            node.Children.Add(nodeC);

            Assert.AreEqual(3, node.Children.Count);
            Assert.AreSame(nodeA, node.Children[0]);
            Assert.AreSame(nodeB, node.Children[1]);
            Assert.AreSame(nodeC, node.Children[2]);
        }
Ejemplo n.º 16
0
        public void GetAncestorsOfRoot()
        {
            DummySceneNode nodeA = new DummySceneNode();

            Assert.AreEqual(0, nodeA.GetAncestors().Count());
        }
Ejemplo n.º 17
0
        public void GetDescendantsOfLeaf()
        {
            DummySceneNode nodeA = new DummySceneNode();

            Assert.AreEqual(0, nodeA.GetDescendants().Count());
        }
Ejemplo n.º 18
0
        public void ManipulatePoses()
        {
            DummySceneNode nodeA = new DummySceneNode {
                PoseLocal = new Pose(new Vector3(1, 1, 1))
            };
            DummySceneNode nodeB = new DummySceneNode {
                PoseLocal = new Pose(new Vector3(1, 2, -3))
            };
            DummySceneNode nodeC = new DummySceneNode {
                PoseLocal = new Pose(new Vector3(1, 2, 3))
            };
            DummySceneNode nodeD = new DummySceneNode {
                PoseLocal = new Pose(new Vector3(0, 0, -1))
            };

            nodeA.Children.Add(nodeB);
            nodeA.Children.Add(nodeC);
            nodeB.Children.Add(nodeD);

            Assert.AreEqual(new Pose(new Vector3(1, 1, 1)), nodeA.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(1, 2, -3)), nodeB.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(1, 2, 3)), nodeC.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(0, 0, -1)), nodeD.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(1, 1, 1)), nodeA.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(2, 3, -2)), nodeB.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(2, 3, 4)), nodeC.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(2, 3, -3)), nodeD.PoseWorld);

            // Update local pose
            nodeA.PoseLocal = new Pose(new Vector3(2, 0, 0));
            Assert.AreEqual(new Pose(new Vector3(2, 0, 0)), nodeA.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(1, 2, -3)), nodeB.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(1, 2, 3)), nodeC.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(0, 0, -1)), nodeD.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(2, 0, 0)), nodeA.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(3, 2, -3)), nodeB.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(3, 2, 3)), nodeC.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(3, 2, -4)), nodeD.PoseWorld);

            // Update world pose
            nodeB.PoseWorld = new Pose(new Vector3(9, 9, 9));
            Assert.AreEqual(new Pose(new Vector3(2, 0, 0)), nodeA.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(7, 9, 9)), nodeB.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(1, 2, 3)), nodeC.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(0, 0, -1)), nodeD.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(2, 0, 0)), nodeA.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(9, 9, 9)), nodeB.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(3, 2, 3)), nodeC.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(9, 9, 8)), nodeD.PoseWorld);

            // Attach node to different node
            nodeA.Children.Remove(nodeB);
            nodeC.Children.Add(nodeB);
            Assert.AreEqual(new Pose(new Vector3(2, 0, 0)), nodeA.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(1, 2, 3)), nodeC.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(7, 9, 9)), nodeB.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(0, 0, -1)), nodeD.PoseLocal);
            Assert.AreEqual(new Pose(new Vector3(2, 0, 0)), nodeA.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(3, 2, 3)), nodeC.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(10, 11, 12)), nodeB.PoseWorld);
            Assert.AreEqual(new Pose(new Vector3(10, 11, 11)), nodeD.PoseWorld);
        }
Ejemplo n.º 19
0
        public void ShouldThrowWhenChildIsNull()
        {
            DummySceneNode node = new DummySceneNode();

            node.Children.Add(null);
        }
Ejemplo n.º 20
0
        public void ShouldThrowWhenOwnerHasCollection()
        {
            DummySceneNode node = new DummySceneNode();

            new SceneNodeCollection(node);
        }