Esempio n. 1
0
            /// <summary>
            /// Create a visible line connecting the frozen anchor to the spongy anchor.
            /// </summary>
            /// <param name="id">The anchor id of the frozen and spongy anchors.</param>
            /// <param name="frozen">The frozen anchor.</param>
            /// <param name="spongy">The spongy anchor.</param>
            /// <returns></returns>
            public IdPair <AnchorId, ConnectingLine> CreateDisplacement(AnchorId id, FrozenAnchorVisual frozen, SpongyAnchorVisual spongy)
            {
                var newLine = ConnectingLine.Create(spongy.transform.parent,
                                                    frozen.transform,
                                                    spongy.transform,
                                                    0.01f, Color.red);

                return(new IdPair <AnchorId, ConnectingLine>()
                {
                    id = id,
                    target = newLine
                });
            }
Esempio n. 2
0
            /// <summary>
            /// Look up the frozen anchor endpoints and connect them with a line.
            /// </summary>
            /// <param name="edge">Pair of anchor ids.</param>
            /// <param name="resource">The resource to create.</param>
            /// <returns></returns>
            public bool CreateFrozenEdge(AnchorEdge edge, out IdPair <AnchorEdge, ConnectingLine> resource)
            {
                var anchorId1 = edge.anchorId1;
                var anchorId2 = edge.anchorId2;

                var frozenAnchor1Idx = FindInSortedList(anchorId1, frozenResources, frozenAnchorVisualComparer);
                var frozenAnchor2Idx = FindInSortedList(anchorId2, frozenResources, frozenAnchorVisualComparer);

                if (frozenAnchor1Idx < 0 || frozenAnchor2Idx < 0)
                {
                    resource = new IdPair <AnchorEdge, ConnectingLine>()
                    {
                        id = edge, target = null
                    };
                    return(false);
                }
                var frozenAnchor1 = frozenResources[frozenAnchor1Idx];
                var frozenAnchor2 = frozenResources[frozenAnchor2Idx];

                Transform parent1      = frozenAnchor1.target.transform.parent;
                Transform parent2      = frozenAnchor2.target.transform.parent;
                bool      sameFragment = parent1 == parent2;
                Color     color        = Color.blue;
                float     width        = 0.002f;
                Transform parent       = parent1;

                if (!sameFragment)
                {
                    color = Color.yellow;
                    width = 0.004f;
                }

                var edgeVisual = ConnectingLine.Create(parent,
                                                       frozenAnchor1.target.transform, frozenAnchor2.target.transform,
                                                       width, color);

                resource = new IdPair <AnchorEdge, ConnectingLine>()
                {
                    id     = edge,
                    target = edgeVisual
                };
                return(true);
            }