コード例 #1
0
        public virtual XmlNode SaveNode(XmlDocument doc, string name, UUID id, IControlNode node)
        {
            XmlNode      nodeElement = doc.CreateElement("Node", Namespace);
            XmlAttribute nameAttr    = doc.CreateAttribute(_prefix, "Name", Namespace);
            XmlAttribute xAttr       = doc.CreateAttribute(_prefix, "X", Namespace);
            XmlAttribute yAttr       = doc.CreateAttribute(_prefix, "Y", Namespace);
            XmlAttribute zAttr       = doc.CreateAttribute(_prefix, "Z", Namespace);
            XmlAttribute colourAttr  = doc.CreateAttribute("Colour", Namespace);

            Vector3 pos = Vector3.Subtract(Control.GetNode(node.ID).Pos, Control.HostPrim.Pos);

            nameAttr.Value   = node.Name;
            xAttr.Value      = pos.X.ToString();
            yAttr.Value      = pos.Y.ToString();
            zAttr.Value      = pos.Z.ToString();
            colourAttr.Value = node.Colour.IsKnownColor ? node.Colour.Name : node.Colour.ToArgb().ToString();

            nodeElement.Attributes.Append(nameAttr);
            nodeElement.Attributes.Append(xAttr);
            nodeElement.Attributes.Append(yAttr);
            nodeElement.Attributes.Append(zAttr);
            nodeElement.Attributes.Append(colourAttr);

            return(nodeElement);
        }
コード例 #2
0
        /// <summary>
        /// Sets the current index for use in route traversal
        /// </summary>
        /// <param name="valueWaypoint">Interface to modify</param>
        /// <param name="controlSection">Current control section will be set by calculation</param>
        internal static void CalculateCurrentIndex(IValueSmoothWaypoint valueWaypoint, out CurveControlSection controlSection)
        {
            IControlNode[] controlNodes = new IControlNode[valueWaypoint.nodes.Length];
            for (int i = 0; i < valueWaypoint.nodes.Length; i++)
            {
                controlNodes[i] = ControlNode.CreateNode(i, valueWaypoint.nodes[i], Quaternion.identity, valueWaypoint.curveScales[i]);
            }
            CurveControlSection[] controlSections = CurveControlArgs.GetComputedAndSlicedSections(new CurveControlArgs(controlNodes, true));
            controlSection = controlSections[valueWaypoint.minIndex];

            float routeTime = (valueWaypoint.minIndex + valueWaypoint.current) / controlSections.Length;

            valueWaypoint.currentIndex = (int)(controlSections.Length * routeTime);
        }
コード例 #3
0
        public override XmlNode SaveNode(XmlDocument doc, string name, UUID id, IControlNode node)
        {
            XmlNode n    = base.SaveNode(doc, name, id, node);
            XmlNode newN = doc.CreateElement(node.Parameters.Get <bool>(SandboxControl.IsEP) ? "EP" : "Router", Namespace);

            foreach (XmlAttribute attr in n.Attributes)
            {
                XmlAttribute newAttr = doc.CreateAttribute(attr.Prefix, attr.LocalName, attr.NamespaceURI);
                newAttr.Value = attr.Value;
                newN.Attributes.Append(newAttr);
            }
            foreach (XmlNode child in n.ChildNodes)
            {
                newN.AppendChild(child);
            }
            return(newN);
        }
コード例 #4
0
        protected override IControlNode MakeNode(string name, Parameters parameters, Vector3 position = default(Vector3), Color colour = default(Color))
        {
            Logger.Debug("Creating node '" + name + "'.");
            UUID         ownerID = parameters.Get <UUID>(Control.OwnerID);
            bool         isEP    = parameters.Get <bool>(SandboxControl.IsEP);
            INode        n       = Model.AddNode(name, parameters, position, colour);
            IControlNode node    = null;

            if (isEP)
            {
                node = new SandboxControlEP(n, position, this, ControlConfig, Permissions);
            }
            else
            {
                node = new SandboxControlRouter(n, position, this, Permissions);
            }
            Logger.Info("Created node '" + name + "'.");

            return(RecordNode(node));
        }
コード例 #5
0
        /// <summary>
        /// Draws scene view handles
        /// </summary>
        protected override void OnSceneGUI()
        {
            base.OnSceneGUI();
            IValueSmoothWaypoint valueSmoothWaypoint = m_MemberTarget.valueControl as IValueSmoothWaypoint;

            ValueWaypointEditorUtils.SelectionHandles(valueSmoothWaypoint, target, transform, m_ReorderableSmoothWaypoint.index);

            Color color = Handles.color;

            Handles.color = Color.green;

            if (valueSmoothWaypoint.selectionType != SelectionType.None)
            {
                IControlNode[] controlNodes = new IControlNode[valueSmoothWaypoint.nodes.Length];
                for (int i = 0; i < valueSmoothWaypoint.nodes.Length; i++)
                {
                    controlNodes[i] = ControlNode.CreateNode(i, valueSmoothWaypoint.nodes[i], Quaternion.identity, valueSmoothWaypoint.curveScales[i]);
                }

                var   controlSections = CurveControlArgs.GetComputedAndSlicedSections(new CurveControlArgs(controlNodes, true));
                float lineWidth       = 2;
                for (int i = 0; i < controlSections.Length; i++)
                {
                    var item = controlSections[i];
                    Handles.DrawBezier(item.p0.position,
                                       item.p1.position,
                                       item.q0.position,
                                       item.q1.position,
                                       Handles.color,
                                       null,
                                       lineWidth);
                }

                m_ReorderableSmoothWaypoint.SceneViewDrawSelected(valueSmoothWaypoint, Color.yellow);
                m_ReorderableSmoothWaypoint.SceneViewCreateWaypoint(valueSmoothWaypoint);
            }

            Handles.color = color;
        }
コード例 #6
0
        public virtual XmlNode SaveNode(XmlDocument doc, string name, UUID id, IControlNode node)
        {
            XmlNode nodeElement = doc.CreateElement("Node", Namespace);
            XmlAttribute nameAttr = doc.CreateAttribute(_prefix, "Name", Namespace);
            XmlAttribute xAttr = doc.CreateAttribute(_prefix, "X", Namespace);
            XmlAttribute yAttr = doc.CreateAttribute(_prefix, "Y", Namespace);
            XmlAttribute zAttr = doc.CreateAttribute(_prefix, "Z", Namespace);
            XmlAttribute colourAttr = doc.CreateAttribute("Colour", Namespace);

            Vector3 pos = Vector3.Subtract(Control.GetNode(node.ID).Pos, Control.HostPrim.Pos);

            nameAttr.Value = node.Name;
            xAttr.Value = pos.X.ToString();
            yAttr.Value = pos.Y.ToString();
            zAttr.Value = pos.Z.ToString();
            colourAttr.Value = node.Colour.IsKnownColor ? node.Colour.Name : node.Colour.ToArgb().ToString();

            nodeElement.Attributes.Append(nameAttr);
            nodeElement.Attributes.Append(xAttr);
            nodeElement.Attributes.Append(yAttr);
            nodeElement.Attributes.Append(zAttr);
            nodeElement.Attributes.Append(colourAttr);

            return nodeElement;
        }