示例#1
0
        private static Color Get(SurfaceNode parentNode, NodeElementArchetype arch)
        {
            if (arch.ValueIndex < 0)
            {
                return(Color.White);
            }

            Color result;
            var   value = parentNode.Values[arch.ValueIndex];

            if (value is Color valueColor)
            {
                result = valueColor;
            }
            else if (value is Vector3 valueVec3)
            {
                result = valueVec3;
            }
            else if (value is Vector4 valueVec4)
            {
                result = valueVec4;
            }
            else
            {
                result = Color.White;
            }

            return(result);
        }
示例#2
0
    void triangulate_solid_surfaces()
    {
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                if (map[x, y] >= FILLED)
                {
                    SurfaceNode n00 = node_map[x + 0, y + 0].upleft;
                    SurfaceNode n01 = node_map[x + 1, y + 0].upleft;
                    SurfaceNode n10 = node_map[x + 0, y + 1].upleft;
                    SurfaceNode n11 = node_map[x + 1, y + 1].upleft;

                    index_vertices(n00, n01, n10, n11);

                    triangles.Add(n10.index);
                    triangles.Add(n11.index);
                    triangles.Add(n01.index);

                    triangles.Add(n00.index);
                    triangles.Add(n10.index);
                    triangles.Add(n01.index);
                }
            }
        }
    }
示例#3
0
 public AddRemoveNodeAction(SurfaceNode node, bool isAdd)
 {
     _surface = node.Surface;
     _context = new ContextHandle(node.Context);
     _nodeId = node.ID;
     _isAdd = isAdd;
 }
        public void LandCallback(Multiplexer.Command cmd)
        {
            stage    = Stage.None;
            scanner  = null;
            NextNode = null;
            Nodes    = null;
            StopTimer.Reset();
            CutoffTimer.Reset();

            switch (cmd)
            {
            case Multiplexer.Command.On:
            case Multiplexer.Command.Resume:
                if (VSL.LandedOrSplashed)
                {
                    CFG.AP1.Off(); break;
                }
                CFG.HF.On(HFlight.Stop);
                set_initial_altitude();
                CFG.AltitudeAboveTerrain = true;
                TriedNodes = new HashSet <SurfaceNode>(new SurfaceNode.Comparer(VSL.Geometry.R));
                break;

            case Multiplexer.Command.Off:
                CFG.VF.On(VFlight.AltitudeControl);
                if (!VSL.LandedOrSplashed)
                {
                    CFG.DesiredAltitude = VSL.Altitude;
                }
                ClearStatus();
                break;
            }
        }
示例#5
0
        private static Vector4 GetValueVector4(SurfaceNode parentNode, NodeElementArchetype archetype)
        {
            Vector4 value = Vector4.Zero;
            var     v     = parentNode.Values[archetype.ValueIndex];

            if (v is Vector2 vec2)
            {
                value = new Vector4(vec2, 0.0f, 0.0f);
            }
            else if (v is Vector3 vec3)
            {
                value = new Vector4(vec3, 0.0f);
            }
            else if (v is Vector4 vec4)
            {
                value = vec4;
            }
            else if (v is Color col)
            {
                value = col;
            }
            else if (v is float f)
            {
                value = new Vector4(f);
            }
            else if (v is int i)
            {
                value = new Vector4(i);
            }

            return(value);
        }
示例#6
0
        private static Vector2 GetValueVector2(SurfaceNode parentNode, NodeElementArchetype archetype)
        {
            Vector2 value = Vector2.Zero;
            var     v     = parentNode.Values[archetype.ValueIndex];

            if (v is Vector2 vec2)
            {
                value = vec2;
            }
            else if (v is Vector3 vec3)
            {
                value = new Vector2(vec3);
            }
            else if (v is Vector4 vec4)
            {
                value = new Vector2(vec4);
            }
            else if (v is Color col)
            {
                value = new Vector2(col.R, col.G);
            }
            else if (v is float f)
            {
                value = new Vector2(f);
            }
            else if (v is int i)
            {
                value = new Vector2(i);
            }

            return(value);
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssetSelect"/> class.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="archetype">The archetype.</param>
        public AssetSelect(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(Utilities.Utils.GetType((ContentDomain)archetype.BoxID), archetype.ActualPosition)
        {
            SelectedID = (Guid)parentNode.Values[archetype.ValueIndex];

            ParentNode = parentNode;
            Archetype  = archetype;
        }
示例#8
0
        /// <inheritdoc />
        public ColorValue(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(Get(parentNode, archetype), archetype.Position.X, archetype.Position.Y)
        {
            ParentNode = parentNode;
            Archetype  = archetype;

            ParentNode.ValuesChanged += OnNodeValuesChanged;
        }
示例#9
0
        /// <inheritdoc />
        public IntegerValue(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(Get(parentNode, archetype), archetype.Position.X, archetype.Position.Y, 50, (int)archetype.ValueMin, (int)archetype.ValueMax, 0.05f)
        {
            ParentNode = parentNode;
            Archetype  = archetype;

            ParentNode.ValuesChanged += OnNodeValuesChanged;
        }
示例#10
0
        public EditNodeConnections(VisjectSurfaceContext context, SurfaceNode node)
        {
            _surface = context.Surface;
            _context = new ContextHandle(context);
            _nodeId  = node.ID;

            CaptureConnections(node, out _before);
        }
示例#11
0
    void triangulate_corner(SurfaceNode n0, SurfaceNode n1, SurfaceNode n2)
    {
        index_vertices(n0, n1, n2);
        //color_edges(n0, n2);

        triangles.Add(n2.index);
        triangles.Add(n1.index);
        triangles.Add(n0.index);
    }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssetSelect"/> class.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="archetype">The archetype.</param>
        public AssetSelect(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(Scripting.TypeUtils.GetType(archetype.Text), archetype.ActualPosition)
        {
            ParentNode = parentNode;
            Archetype  = archetype;

            ParentNode.ValuesChanged += OnNodeValuesChanged;
            OnNodeValuesChanged();
        }
示例#13
0
 /// <inheritdoc />
 public InputBox(SurfaceNode parentNode, NodeElementArchetype archetype)
     : base(parentNode, archetype, archetype.Position)
 {
     // Check if use inlined default value editor
     if (Archetype.ValueIndex != -1)
     {
         ParentNode.ValuesChanged += UpdateDefaultValue;
     }
 }
示例#14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssetSelect"/> class.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="archetype">The archetype.</param>
        public AssetSelect(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(Utilities.Utils.GetType((ContentDomain)archetype.BoxID), archetype.ActualPosition)
        {
            ParentNode = parentNode;
            Archetype  = archetype;

            ParentNode.ValuesChanged += OnNodeValuesChanged;
            OnNodeValuesChanged();
        }
示例#15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ActorSelect"/> class.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="archetype">The archetype.</param>
        public ActorSelect(SurfaceNode parentNode, NodeElementArchetype archetype)
        {
            ParentNode = parentNode;
            Archetype  = archetype;
            Bounds     = new Rectangle(Archetype.ActualPosition, archetype.Size);
            Type       = Scripting.TypeUtils.GetType(archetype.Text);

            ParentNode.ValuesChanged += OnNodeValuesChanged;
            OnNodeValuesChanged();
        }
 void land(SurfaceNode n)
 {
     CFG.Anchor        = n.ToWayPoint();
     CFG.Anchor.Radius = C.NodeTargetRange;
     SetTarget(CFG.Anchor);
     CFG.Nav.OnIfNot(Navigation.Anchor);
     WideCheckAlt = VSL.Geometry.H * (C.StopAtH + 1);
     TCA.SquadConfigAction(cfg => cfg.AP1.XOnIfNot(Autopilot1.Land));
     stage = Stage.Land;
 }
示例#17
0
 /// <inheritdoc />
 public EnumValue(SurfaceNode parentNode, NodeElementArchetype archetype)
     : base(Scripting.TypeUtils.GetType(archetype.Text).Type)
 {
     X          = archetype.ActualPositionX;
     Y          = archetype.ActualPositionY;
     Width      = archetype.Size.X;
     ParentNode = parentNode;
     Archetype  = archetype;
     Value      = (int)ParentNode.Values[Archetype.ValueIndex];
 }
示例#18
0
        /// <summary>
        /// Gets the floating point value from the specified parent node. Handles type casting and components gather.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="arch">The node element archetype.</param>
        /// <param name="customValue">The custom value override (optional).</param>
        /// <returns>The result value.</returns>
        public static float Get(SurfaceNode parentNode, NodeElementArchetype arch, object customValue = null)
        {
            if (arch.ValueIndex < 0 && customValue == null)
            {
                return(0);
            }

            float result;
            var   value = customValue ?? parentNode.Values[arch.ValueIndex];

            // Note: this value box may edit on component of the vector like Vector3.Y, BoxID from Archetype tells which component pick

            if (value is int asInt)
            {
                result = (float)asInt;
            }
            else if (value is float asFloat)
            {
                result = asFloat;
            }
            else if (value is double asDouble)
            {
                result = (float)asDouble;
            }
            else if (value is Vector2 asVector2)
            {
                result = (float)(arch.BoxID == 0 ? asVector2.X : asVector2.Y);
            }
            else if (value is Vector3 asVector3)
            {
                result = (float)(arch.BoxID == 0 ? asVector3.X : arch.BoxID == 1 ? asVector3.Y : asVector3.Z);
            }
            else if (value is Vector4 asVector4)
            {
                result = (float)(arch.BoxID == 0 ? asVector4.X : arch.BoxID == 1 ? asVector4.Y : arch.BoxID == 2 ? asVector4.Z : asVector4.W);
            }
            else if (value is Float2 asFloat2)
            {
                result = (arch.BoxID == 0 ? asFloat2.X : asFloat2.Y);
            }
            else if (value is Float3 asFloat3)
            {
                result = (arch.BoxID == 0 ? asFloat3.X : arch.BoxID == 1 ? asFloat3.Y : asFloat3.Z);
            }
            else if (value is Float4 asFloat4)
            {
                result = (arch.BoxID == 0 ? asFloat4.X : arch.BoxID == 1 ? asFloat4.Y : arch.BoxID == 2 ? asFloat4.Z : asFloat4.W);
            }
            else
            {
                result = 0;
            }

            return(result);
        }
示例#19
0
        /// <summary>
        /// Sets all the values to the given value (eg. all components of the vector).
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="arch">The node element archetype.</param>
        /// <param name="toSet">The value to assign.</param>
        public static void SetAllValues(SurfaceNode parentNode, NodeElementArchetype arch, float toSet)
        {
            if (arch.ValueIndex < 0)
            {
                return;
            }

            var value = parentNode.Values[arch.ValueIndex];

            if (value is int)
            {
                value = (int)toSet;
            }
            else if (value is float)
            {
                value = toSet;
            }
            else if (value is double)
            {
                value = (double)toSet;
            }
            else if (value is Vector2)
            {
                value = new Vector2(toSet);
            }
            else if (value is Vector3)
            {
                value = new Vector3(toSet);
            }
            else if (value is Vector4)
            {
                value = new Vector4(toSet);
            }
            else if (value is Float2)
            {
                value = new Float2(toSet);
            }
            else if (value is Float3)
            {
                value = new Float3(toSet);
            }
            else if (value is Float4)
            {
                value = new Float4(toSet);
            }
            else
            {
                value = 0;
            }

            parentNode.SetValue(arch.ValueIndex, value);
        }
示例#20
0
        /// <inheritdoc />
        public TextBoxView(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(archetype.BoxID == 1, archetype.Position.X, archetype.Position.Y, archetype.Size.X)
        {
            ParentNode = parentNode;
            Archetype  = archetype;

            Size = archetype.Size;
            if (archetype.ValueIndex >= 0)
            {
                Text     = (string)parentNode.Values[archetype.ValueIndex];
                EditEnd += () => ParentNode.SetValue(Archetype.ValueIndex, Text);
            }
        }
 bool scan(int lvl, SurfaceNode start = null, float d = 0)
 {
     if (scanner == null)
     {
         scanner = surface_scanner(lvl, start, d);
     }
     if (scanner.MoveNext())
     {
         return(true);
     }
     scanner = null;
     return(false);
 }
示例#22
0
        /// <summary>
        /// Gets the integer value from the specified parent node. Handles type casting and components gather.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="arch">The node element archetype.</param>
        /// <returns>The result value.</returns>
        public static int Get(SurfaceNode parentNode, NodeElementArchetype arch)
        {
            if (arch.ValueIndex < 0)
            {
                return(0);
            }

            int result;
            var value = parentNode.Values[arch.ValueIndex];

            // Note: this value box may edit on component of the vector like Vector3.Y, BoxID from Archetype tells which component pick

            if (value is int valueInt)
            {
                result = valueInt;
            }
            else if (value is uint valueUint)
            {
                result = (int)valueUint;
            }
            else if (value is long valueLong)
            {
                result = (int)valueLong;
            }
            else if (value is ulong valueUlong)
            {
                result = (int)valueUlong;
            }
            else if (value is float valueFloat)
            {
                result = (int)valueFloat;
            }
            else if (value is Vector2 valueVec2)
            {
                result = (int)(arch.BoxID == 0 ? valueVec2.X : valueVec2.Y);
            }
            else if (value is Vector3 valueVec3)
            {
                result = (int)(arch.BoxID == 0 ? valueVec3.X : arch.BoxID == 1 ? valueVec3.Y : valueVec3.Z);
            }
            else if (value is Vector4 valueVec4)
            {
                result = (int)(arch.BoxID == 0 ? valueVec4.X : arch.BoxID == 1 ? valueVec4.Y : arch.BoxID == 2 ? valueVec4.Z : valueVec4.W);
            }
            else
            {
                result = 0;
            }

            return(result);
        }
 void try_move_to_flattest()
 {
     NextNode = FlattestNode;
     if (NextNode != null &&
         distance_to_node(NextNode) > LND.NodeTargetRange * 2 &&
         NextNode.unevenness > LND.UnevennessThreshold)
     {
         move_next();
     }
     else
     {
         wide_check(LND.WideCheckAltitude);
     }
 }
            public void UpdateUnevenness(SurfaceNode n)
            {
                if (neighbours.Contains(n))
                {
                    return;
                }
                var unev = Mathf.Abs(Vector3.Dot((n.position - position).normalized, up));

                unevenness   += unev;
                n.unevenness += unev;
                neighbours.Add(n);
                n.neighbours.Add(this);
                flat = unevenness < LND.MaxUnevenness;
            }
        /// <inheritdoc />
        public SkeletonNodeSelectElement(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(parentNode, archetype)
        {
            _isAutoSelect = true;

            UpdateComboBox();

            // Select saved value
            _selectedIndices.Clear();
            if (Archetype.ValueIndex != -1)
            {
                _selectedIndices.Add((int)ParentNode.Values[Archetype.ValueIndex]);
            }
        }
示例#26
0
        /// <inheritdoc />
        public TextBoxView(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(archetype.BoxID == 1, archetype.Position.X, archetype.Position.Y, archetype.Size.X)
        {
            ParentNode = parentNode;
            Archetype  = archetype;

            Size = archetype.Size;
            if (archetype.ValueIndex >= 0)
            {
                OnNodeValuesChanged();
                EditEnd += () => ParentNode.SetValue(Archetype.ValueIndex, Text);
                ParentNode.ValuesChanged += OnNodeValuesChanged;
            }
        }
            public void UpdateUnevenness(SurfaceNode n)
            {
                if (neighbours.Contains(n))
                {
                    return;
                }
                var unev = Math.Abs(Pos.Alt - n.Pos.Alt) / Pos.DistanceTo(n.Pos, Body);

                unevenness   += unev;
                n.unevenness += unev;
                neighbours.Add(n);
                n.neighbours.Add(this);
                flat = unevenness < C.MaxUnevenness;
            }
        /// <inheritdoc />
        public SkeletonNodeNameSelectElement(SurfaceNode parentNode, NodeElementArchetype archetype)
            : base(parentNode, archetype)
        {
            _isAutoSelect = true;

            UpdateComboBox();

            // Select saved value
            _selectedIndices.Clear();
            if (Archetype.ValueIndex != -1)
            {
                SelectedNodeName          = (string)ParentNode.Values[Archetype.ValueIndex];
                ParentNode.ValuesChanged += OnNodeValuesChanged;
            }
        }
示例#29
0
    void triangulate_alley(SurfaceNode n0, SurfaceNode n1, SurfaceNode n2, SurfaceNode n3, SurfaceNode n4)
    {
        index_vertices(n0, n1, n2, n3, n4);
        //color_edges(n0, n1, n4);

        triangles.Add(n2.index);
        triangles.Add(n1.index);
        triangles.Add(n0.index);

        triangles.Add(n3.index);
        triangles.Add(n2.index);
        triangles.Add(n0.index);

        triangles.Add(n4.index);
        triangles.Add(n3.index);
        triangles.Add(n0.index);
    }
示例#30
0
        private void CaptureConnections(SurfaceNode node, out BoxHandle[][] boxesConnections)
        {
            var boxes = node.GetBoxes();

            boxesConnections = new BoxHandle[boxes.Count][];
            for (int i = 0; i < boxesConnections.Length; i++)
            {
                var box         = boxes[i];
                var connections = new BoxHandle[box.Connections.Count];
                boxesConnections[i] = connections;
                for (int j = 0; j < connections.Length; j++)
                {
                    var other = box.Connections[j];
                    connections[j] = new BoxHandle(other);
                }
            }
        }
示例#31
0
 public virtual SurfaceNode newSurfaceNode(Part p)
 {
     SurfaceNode newNode = new SurfaceNode();
     newNode.id = p.uid;
     newNode.rad = p.srfAttachNode.position.x;
     newNode.xPos = p.transform.localPosition.x;
     newNode.yPos = p.transform.localPosition.y;
     newNode.zPos = p.transform.localPosition.z;
     newNode.prevFactor = stretchFactor;
     newNode.prevRFactor = radialFactor;
     return newNode;
 }
示例#32
0
        public virtual void updateSurfaceNode(SurfaceNode node, Part p)
        {
            if (node.yPos > 0)
            {
                p.transform.Translate(0f, (stretchFactor / node.prevFactor) * (node.yPos - node.rad) + node.rad - node.yPos, 0f, part.transform);
            }
            else
            {
                p.transform.Translate(0f, (stretchFactor / node.prevFactor) * (node.yPos + node.rad) - node.rad - node.yPos, 0f, part.transform);
            }
            node.prevFactor = stretchFactor;
            node.yPos = p.transform.localPosition.y;

            float radius = Mathf.Sqrt(node.xPos * node.xPos + node.zPos * node.zPos);
            float angle = Mathf.Atan2(node.xPos, node.zPos);
            float newRad = (radialFactor / node.prevRFactor) * (radius - node.rad) + node.rad - radius;
            p.transform.Translate(newRad * Mathf.Sin(angle), 0f, newRad * Mathf.Cos(angle), part.transform);
            node.xPos = p.transform.localPosition.x;
            node.zPos = p.transform.localPosition.z;
            node.prevRFactor = radialFactor;
        }
示例#33
0
    public override void updateSurfaceNode(SurfaceNode node, Part p)
    {
        if (node.yPos > 0)
          p.transform.Translate(0f, (stretchFactor / node.prevFactor) * (node.yPos - node.rad) + node.rad - node.yPos, 0f, part.transform);
        else
          p.transform.Translate(0f, (stretchFactor / node.prevFactor) * (node.yPos + node.rad) - node.rad - node.yPos, 0f, part.transform);

        node.prevFactor = stretchFactor;
        node.yPos = p.transform.localPosition.y;

        float v=node.yPos/(stretchFactor*1.875f)+0.5f;
        float  rf=Mathf.Lerp(radialFactor, topFactor, v);
        float prf=Mathf.Lerp(node.prevRFactor, node.prevTFactor, v);

        float radius = Mathf.Sqrt(node.xPos * node.xPos + node.zPos * node.zPos);
        float angle = Mathf.Atan2(node.xPos, node.zPos);
        float newRad = (rf / prf) * (radius - node.rad) + node.rad - radius;
        p.transform.Translate(newRad * Mathf.Sin(angle), 0f, newRad * Mathf.Cos(angle), part.transform);
        node.xPos = p.transform.localPosition.x;
        node.zPos = p.transform.localPosition.z;
        node.prevRFactor = radialFactor;
        node.prevTFactor = topFactor;
    }