コード例 #1
0
        public VPacket(IPacket packet, IVNode from, IVNode to, IVLink link, IPrimFactory primFactory, IAsynchQueue queue, View view)
            : base(primFactory, from.Pos, packet.Name, packet.Colour, packet.Selected, packet.Parameters)
        {
            Prim.Editable = false;
            _packet       = packet;
            _from         = from;
            _to           = to;
            _link         = link;
            _step         = 0;
            _view         = view;
            Selected      = packet.Selected;
            Configure();

            _deleteListener = id => Dropped("Visualisation layer dropped " + Name + ".");

            _from.OnWorldMove += (id, oldPos, newPos) => Reconfigure();
            _to.OnWorldMove   += (id, oldPos, newPos) => Reconfigure();
            _from.OnAPIMove   += (id, oldPos, newPos) => Reconfigure();
            _to.OnAPIMove     += (id, oldPos, newPos) => Reconfigure();


            link.OnWeightChanged += (id, weight) => Reconfigure();
            link.OnWorldDelete   += _deleteListener;
            link.OnSystemDelete  += _deleteListener;

            //_tickListener = () => queue.QueueWorkItem(state => UpdatePosition());
            _tickListener = () => queue.QWork("Move Packet", () => UpdatePosition());
            view.OnTick  += _tickListener;
        }
コード例 #2
0
ファイル: VLink.cs プロジェクト: JohnMcCaffery/RoutingIsland
        internal static Quaternion GetRotatation(IVNode from, IVNode to)
        {
            Vector3 vector = Vector3.Normalize(Vector3.Subtract(from.Pos, to.Pos));
            Vector3 cross  = Vector3.Cross(vector, ZAxis);
            float   angle  = (float)Math.Acos(Vector3.Dot(vector, ZAxis));

            return(Quaternion.CreateFromAxisAngle(cross, angle * -1f));
        }
コード例 #3
0
ファイル: VLink.cs プロジェクト: JohnMcCaffery/RoutingIsland
        public VLink(IPrimFactory primFactory, IVNode from, IVNode to, float weight = default(float), Parameters parameters = null, bool bidirectional = true)
            : base(primFactory, GetPos(from.Pos, to.Pos), "Link between " + from.Name + " and " + to.Name, Color.White, 0d, parameters)
        {
            From = from;
            To = to;
            IsBidirectional = bidirectional;
            Parameters = parameters == null ? new Parameters() : parameters;

            Weight = weight;

            from.OnWorldMove += (id, oldPos, newPos) => LengthChanged(oldPos, To.Pos);
            to.OnWorldMove += (id, oldPos, newPos) => LengthChanged(From.Pos, oldPos);
            from.OnAPIMove += (id, oldPos, newPos) => LengthChanged(oldPos, To.Pos);
            to.OnAPIMove += (id, oldPos, newPos) => LengthChanged(From.Pos, oldPos);

            Position();
        }
コード例 #4
0
ファイル: VLink.cs プロジェクト: JohnMcCaffery/RoutingIsland
        public VLink(IPrimFactory primFactory, IVNode from, IVNode to, float weight = default(float), Parameters parameters = null, bool bidirectional = true)
            : base(primFactory, GetPos(from.Pos, to.Pos), "Link between " + from.Name + " and " + to.Name, Color.White, 0d, parameters)
        {
            From            = from;
            To              = to;
            IsBidirectional = bidirectional;
            Parameters      = parameters == null ? new Parameters() : parameters;

            Weight = weight;

            from.OnWorldMove += (id, oldPos, newPos) => LengthChanged(oldPos, To.Pos);
            to.OnWorldMove   += (id, oldPos, newPos) => LengthChanged(From.Pos, oldPos);
            from.OnAPIMove   += (id, oldPos, newPos) => LengthChanged(oldPos, To.Pos);
            to.OnAPIMove     += (id, oldPos, newPos) => LengthChanged(From.Pos, oldPos);

            Position();
        }
コード例 #5
0
ファイル: VLink.cs プロジェクト: JohnMcCaffery/RoutingIsland
        internal static Vector3 GetScale(IVNode from, IVNode to, bool distanceWeight, float weight, float length)
        {
            float width = MinWidth;

            if (!distanceWeight)
            {
                float weightInverse = 1f - (weight > 1f ? 1f : weight);
                float widthRange    = (MaxWidth - MinWidth) / 1;
                float zeroedWidth   = weightInverse * widthRange;
                width = MinWidth + zeroedWidth;
            }

            if (width < MinWidth)
            {
                width = MinWidth;
            }
            else if (width > MaxWidth)
            {
                width = MaxWidth;
            }

            return(new Vector3(width, width, length));
        }
コード例 #6
0
        public VPacket(IPacket packet, IVNode from, IVNode to, IVLink link, IPrimFactory primFactory, IAsynchQueue queue, View view)
            : base(primFactory, from.Pos, packet.Name, packet.Colour, packet.Selected, packet.Parameters)
        {
            Prim.Editable = false;
            _packet = packet;
            _from = from;
            _to = to;
            _link = link;
            _step = 0;
            _view = view;
            Selected = packet.Selected;
            Configure();

            _deleteListener = id => Dropped("Visualisation layer dropped " + Name + ".");

            _from.OnWorldMove += (id, oldPos, newPos) => Reconfigure();
            _to.OnWorldMove += (id, oldPos, newPos) => Reconfigure();
            _from.OnAPIMove += (id, oldPos, newPos) => Reconfigure();
            _to.OnAPIMove += (id, oldPos, newPos) => Reconfigure();

            link.OnWeightChanged += (id, weight) => Reconfigure();
            link.OnWorldDelete += _deleteListener;
            link.OnSystemDelete += _deleteListener;

            //_tickListener = () => queue.QueueWorkItem(state => UpdatePosition());
            _tickListener = () => queue.QWork("Move Packet", () => UpdatePosition());
            view.OnTick += _tickListener;
        }
コード例 #7
0
ファイル: VLink.cs プロジェクト: JohnMcCaffery/RoutingIsland
        internal static Vector3 GetScale(IVNode from, IVNode to, bool distanceWeight, float weight, float length)
        {
            float width = MinWidth;

            if (!distanceWeight) {
                float weightInverse = 1f - (weight > 1f ? 1f : weight);
                float widthRange = (MaxWidth - MinWidth) / 1;
                float zeroedWidth = weightInverse * widthRange;
                width = MinWidth + zeroedWidth;
            }

            if (width < MinWidth)
                width = MinWidth;
            else if (width > MaxWidth)
                width = MaxWidth;

            return new Vector3(width, width, length);
        }
コード例 #8
0
ファイル: VLink.cs プロジェクト: JohnMcCaffery/RoutingIsland
 internal static Quaternion GetRotatation(IVNode from, IVNode to)
 {
     Vector3 vector = Vector3.Normalize(Vector3.Subtract(from.Pos, to.Pos));
     Vector3 cross = Vector3.Cross(vector, ZAxis);
     float angle = (float)Math.Acos(Vector3.Dot(vector, ZAxis));
     return Quaternion.CreateFromAxisAngle(cross, angle * -1f);
 }