コード例 #1
0
        private void OnDisconnectButtonPressed(object sender, ControllerInteractionEventArgs e)
        {
            grabber.ForceRelease();
            GetComponent <VRTK_InteractableObject>().enabled = false;
            GetComponent <MeshRenderer>().enabled            = false;
            GetComponent <Collider>().enabled = false;

            DisconnectBranchFromJunction();

            sourceCord = MergeJunction();
            sourceCord.AllowBranching(false);

            Plug disconnectedPlug = CreatePlug();

            if (branchNode.Cord.StartNode.Equals(branchNode.transform))
            {
                branchNode.Cord.Connect(disconnectedPlug.CordAttachPoint, branchNode.Cord.EndNode);
            }
            else
            {
                branchNode.Cord.Connect(branchNode.Cord.StartNode, disconnectedPlug.CordAttachPoint);
            }

            grabber.ForceGrab(disconnectedPlug.GetComponent <VRTK_InteractableObject>(), () =>
            {
                disconnectedPlug.EnableSnapping();
                sourceCord.AllowBranching(true);
                Destroy(this.gameObject);
            });
        }
コード例 #2
0
ファイル: Plug.cs プロジェクト: lane-s/ComposeVR
        private void OnGrabbed(object sender, InteractableObjectEventArgs e)
        {
            GetComponent <VRTK_TransformFollow>().gameObjectToFollow = null;

            if (DestinationEndpoint == null)
            {
                PlugTransform.SetParent(null);
                StartCoroutine(SnapToController());
            }

            connectedCord.AllowBranching(false);
        }
コード例 #3
0
        /// <summary>
        /// Splits the cord so that this cord contains the points before splitPoint and splitCord contains the points after splitPoint
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="splitPointIndex"></param>
        /// <param name="splitCord"></param>
        /// <returns></returns>
        public CordJunction SplitByBranchHandle(BranchHandle handle, int splitPointIndex, Cord splitCord)
        {
            //Get the points after the splitPoint and assign them to the splitCord
            List <Vector3> splitPath = new List <Vector3>();

            for (int i = splitPointIndex; i < path.Count; i++)
            {
                splitPath.Add(path[i]);
            }

            splitCord.Color = Color;
            splitCord.Flow  = Flow;
            splitCord.Connect(handle.transform, B);
            if (B.GetComponent <BranchHandle>() != null)
            {
                B.GetComponent <BranchHandle>().ReplaceCord(this, splitCord);
            }

            splitCord.Path = splitPath;
            splitCord.AllowBranching(true);

            int combinedPathLength = path.Count;

            //Exclude the points in the splitCord from this cord
            for (int i = 0; i < combinedPathLength - splitPointIndex; i++)
            {
                path.RemoveAt(path.Count - 1);
            }
            B = handle.transform;

            branchHandles.Remove(handle);
            CreateBranchHandles(handle.TrackedController);
            UpdateBoundingBox();

            CordNode JunctionA = new CordNode(this, handle.transform);
            CordNode JunctionB = new CordNode(splitCord, handle.transform);

            return(new CordJunction(JunctionA, JunctionB, Flow));
        }