Пример #1
0
        public static void Group(TransformNode node1, TransformNode node2)
        {
            TransformNode groupNode = new TransformNode("Group");

            node1.SetParent(groupNode);
            node2.SetParent(groupNode);
        }
Пример #2
0
        public override string Process(string[] arguments)
        {
            string output = "";

            if (arguments.Length == 3)
            {
                TransformNode childNode  = TransformNode.Find(arguments[1]) as TransformNode;
                TransformNode parentNode = TransformNode.Find(arguments[2]) as TransformNode;

                if (childNode != null && parentNode != null)
                {
                    if (childNode.FindNode(parentNode.Name) == null)
                    {
                        childNode.SetParent(parentNode);
                    }
                    else
                    {
                        output = "Cannot parent a node to one of its children";
                    }
                }
                else
                {
                    output = "Parenting failed - could not find parent or child node";
                }
            }
            else
            {
                output = "You must specify two nodes";
            }

            return(output);
        }
Пример #3
0
        public override string Process(string[] arguments)
        {
            string output = "";

            Console.WriteLine();

            if (arguments.Length == 2)
            {
                TransformNode node = TransformNode.Find(arguments[1]) as TransformNode;
                if (node != null)
                {
                    node.ShowTree();
                }
                else
                {
                    output = "Invalid node specified: " + arguments[1];
                }
            }
            else
            {
                TransformNode.ShowAll();
            }

            return(output);
        }
Пример #4
0
 public ShapeNode(string name)
 {
     this.transformNode = new TransformNode(name);
     this.transformNode.SetShape(this);
     this.name = this.transformNode.ToString() + "Shape";
     shapes.Add(this);
 }
Пример #5
0
        public override string Process(string[] arguments)
        {
            string output = "";

            if (arguments.Length == 3)
            {
                Node node = TransformNode.Find(arguments[1]);
                if (node != null)
                {
                    if (TransformNode.Find(arguments[2]) == null)
                    {
                        node.Name = arguments[2];
                    }
                    else
                    {
                        output = "The target name already exists: " + arguments[2];
                    }
                }
                else
                {
                    output = "Could not find the specified node: " + arguments[1];
                }
            }
            else
            {
                output = "You must specify the old name and the new name";
            }

            return(output);
        }
Пример #6
0
        static void Main(string[] args)
        {
            TransformNode sphereNode = new GeometryNode("sphere").TransformNode;
            TransformNode lightNode  = new LightNode("spotLight").TransformNode;

            TransformNode.Group(lightNode, sphereNode);
            TransformNode.ShowAll();

            while (!CommandManager.Done)
            {
                Console.Write(":");
                CommandManager.ProcessCommand(Console.ReadLine());
            }
        }
Пример #7
0
        public TransformNode(string name)
        {
            string validatedName = name;
            int    counter       = 2;

            while (TransformNode.Find(validatedName) != null)
            {
                validatedName = name + counter.ToString();
                counter++;
            }

            children  = new List <TransformNode>();
            this.name = validatedName;
            rootNodes.Add(this);
        }
Пример #8
0
        public override string Process(string[] arguments)
        {
            string output = "";

            if (arguments.Length == 3)
            {
                TransformNode node1 = TransformNode.Find(arguments[1]) as TransformNode;
                TransformNode node2 = TransformNode.Find(arguments[2]) as TransformNode;

                if (node1 != null && node2 != null)
                {
                    TransformNode.Group(node1, node2);
                }
                else
                {
                    output = "One or both nodes are invalid";
                }
            }
            else if (arguments.Length == 2)
            {
                TransformNode node1 = TransformNode.Find(arguments[1]) as TransformNode;

                if (node1 != null)
                {
                    TransformNode.Group(node1);
                }
                else
                {
                    output = "Invalid node";
                }
            }
            else
            {
                output = "You must specify one or two nodes in order to group";
            }

            return(output);
        }
Пример #9
0
        public override string Process(string[] arguments)
        {
            string output = "";

            if (arguments.Length == 2)
            {
                TransformNode node = TransformNode.Find(arguments[1]) as TransformNode;
                if (node != null)
                {
                    node.RemoveNode();
                }
                else
                {
                    output = "Node not found: " + arguments[1];
                }
            }
            else
            {
                output = "You must enter the name of a single node to remove";
            }

            return(output);
        }
Пример #10
0
        public override string Process(string[] arguments)
        {
            string output = "";

            if (arguments.Length == 2)
            {
                TransformNode node = TransformNode.Find(arguments[1]) as TransformNode;
                if (node != null)
                {
                    node.SetParent(null);
                }
                else
                {
                    output = "Could not find specified node";
                }
            }
            else
            {
                output = "You must specify a single node";
            }

            return(output);
        }
Пример #11
0
        public void SetParent(TransformNode parent)
        {
            // Remove from old containing list
            if (this.parent == null)
            {
                rootNodes.Remove(this);
            }
            else
            {
                this.parent.children.Remove(this);
            }

            // Assign new parent
            this.parent = parent;

            if (parent == null)
            {
                rootNodes.Add(this);
            }
            else
            {
                parent.children.Add(this);
            }
        }