示例#1
0
        /// <summary>
        /// Create all necessary resources.
        /// </summary>
        private void SetupManipulation()
        {
            TakeDownManipulation();
            if (userOriented)
            {
                boundingBox = owner.gameObject.AddComponent <BoundingBox>();

                boundingBox.HideElementsInInspector = false;
                boundingBox.BoundingBoxActivation   = BoundingBox.BoundingBoxActivationType.ActivateByProximityAndPointer;
                boundingBox.RotateStarted.AddListener(BeginManipulation);
                boundingBox.RotateStopped.AddListener(FinishManipulation);
                boundingBox.ScaleStarted.AddListener(BeginManipulation);
                boundingBox.ScaleStopped.AddListener(FinishManipulation);
                float maxScaleFactor = 8.0f;
                float minScaleFactor = 0.2f;
                MinMaxScaleConstraint scaleHandler = owner.GetComponent <MinMaxScaleConstraint>();
                if (scaleHandler == null)
                {
                    scaleHandler = owner.gameObject.AddComponent <MinMaxScaleConstraint>();
                }
                scaleHandler.RelativeToInitialState = true;
                scaleHandler.ScaleMaximum           = maxScaleFactor;
                scaleHandler.ScaleMinimum           = minScaleFactor;
            }

            manipulationHandler = owner.gameObject.AddComponent <ManipulationHandler>();
            manipulationHandler.OneHandRotationModeFar  = ManipulationHandler.RotateInOneHandType.MaintainOriginalRotation;
            manipulationHandler.OneHandRotationModeNear = ManipulationHandler.RotateInOneHandType.MaintainOriginalRotation;
            manipulationHandler.ConstraintOnRotation    = Toolkit.Utilities.RotationConstraintType.None;

            manipulationHandler.OnManipulationStarted.AddListener(BeginManipulation);
            manipulationHandler.OnManipulationEnded.AddListener(FinishManipulation);

            nearGrabbable = owner.gameObject.AddComponent <NearInteractionGrabbable>();
        }
示例#2
0
        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            GameObject instance = ResourceManager.Instance.NetworkInstantiate(prefab, transform.position, transform.rotation);

            handler = instance.GetComponentInChildren <ManipulationHandler>();
            handler.OnPointerDown(eventData);
        }
示例#3
0
        // Start Up
        private void Awake()
        {
            // MRTK components to add
            manipHandler = gameObject.AddComponent <ManipulationHandler>();
            manipHandler.TwoHandedManipulationType = ManipulationHandler.TwoHandedManipulation.MoveRotate;

            // Other components
            codeBlockSnap = gameObject.AddComponent <CodeBlockSnap>();
            snapColliders = GetComponentInChildren <SnapColliderGroup>();

            // Setup
            SetMyBlockInternalArg();
            CodeBlockManager.instance.RegisterCodeBlock(this);

            // ArgListManager set up
            codeBlockArgumentList = gameObject.AddComponent <CodeBlockArgumentList>();
            codeBlockArgumentList.SetUp(this);

            if (GetComponent <ManipulationLogger>() == null)
            {
                gameObject.AddComponent <ManipulationLogger>();
            }

            UpdateText();
        }
示例#4
0
        /// <summary>
        /// Unsubscribes from manipulation events.
        /// </summary>
        private void OnDisable()
        {
            if (objectManipulator != null)
            {
                objectManipulator.OnManipulationStarted.RemoveListener(OnManipulationStarted);
                objectManipulator.OnManipulationEnded.RemoveListener(OnManipulationEnded);

                objectManipulator = null;
            }

            if (manipulationHandler != null)
            {
                manipulationHandler.OnManipulationStarted.RemoveListener(OnManipulationStarted);
                manipulationHandler.OnManipulationEnded.RemoveListener(OnManipulationEnded);

                manipulationHandler = null;
            }

            if (dockedPosition != null)
            {
                dockedPosition.DockedObject = null;
                dockedPosition = null;
            }

            overlappingPositions.Clear();
        }
        private void SetUpMoveableInvisibleKuri()
        {
            Transform           kuri_t       = transform.GetChild(1);
            ManipulationHandler manipHandler = gameObject.AddComponent <ManipulationHandler>();

            //manipHandler.TwoHandedManipulationType = ManipulationHandler.TwoHandedManipulation.MoveRotate;
            TurnOffMeshRenderers(kuri_t);
        }
示例#6
0
 private void Awake()
 {
     myCodeBlock         = GetComponent <CodeBlock>();
     manipulationHandler = GetComponent <ManipulationHandler>();
     manipulationHandler.OnManipulationStarted.AddListener(OnManipulationStart);
     manipulationHandler.OnManipulationEnded.AddListener(OnManipulationEnd);
     mySnapColliders = GetComponentInChildren <SnapColliderGroup>();
 }
示例#7
0
 private void Awake()
 {
     manipulationHandler = GetComponent <ManipulationHandler>();
     manipulationHandler.OnManipulationStarted.AddListener(OnManipulationStart);
     manipulationHandler.OnManipulationEnded.AddListener(OnManipulationEnd);
     snapColliderGroup = gameObject.GetComponentInChildrenOnlyDepthOne <SnapColliderGroup>();
     ResetCBS();
 }
示例#8
0
 private void Awake()
 {
     _handler         = GetComponent <ManipulationHandler>();
     _transformTarget = _handler.HostTransform;
     _handler.OnManipulationStarted.AddListener(OnManipulationStart);
     _handler.OnManipulationEnded.AddListener(OnManipulationEnd);
     StoreTargets();
 }
示例#9
0
 private void Awake()
 {
     startingPosition    = transform.position;
     renderer            = GetComponent <MeshRenderer>();
     manipulationHandler = GetComponent <ManipulationHandler>();
     manipulationHandler.OnManipulationStarted.AddListener(StartedMotion);
     manipulationHandler.OnManipulationEnded.AddListener(StoppedMotion);
     blockStillInMenu = true;
 }
示例#10
0
 // Start is called before the first frame update
 void Start()
 {
     isRemovable           = true;
     isActuallyManipulable = false;
     manip         = GetComponentInChildren <ManipulationHandler>();
     manip.enabled = false;
     Cross         = GetComponentsInChildren <Image>()[1];
     CrossBtn      = GetComponentInChildren <Button>();
     CrossBtn.onClick.AddListener(MeasureManager.Instance.RemoveLastPoint);
     Cross.enabled = CrossBtn.enabled = true;
 }
        private void Awake()
        {
            realtimeTransform   = GetComponent <RealtimeTransform>();
            objectManipulator   = GetComponent <ObjectManipulator>();
            manipulationHandler = GetComponent <ManipulationHandler>();
            rigidbody           = GetComponent <Rigidbody>();

            startPosition = transform.localPosition;
            startRotation = transform.localRotation;
            startScale    = transform.localScale;
        }
示例#12
0
 void Start()
 {
     manipHandler = GetComponent <ManipulationHandler>();
     if (manipHandler != null)
     {
         manipHandler.OnManipulationStarted.AddListener(LogManipulationStart);
     }
     pressButton = GetComponent <PressableButtonHoloLens2>();
     if (pressButton != null)
     {
         pressButton.ButtonPressed.AddListener(LogManipulationStartButtonPress);
     }
 }
示例#13
0
        private void Awake()
        {
            realtimeTransform   = GetComponent <RealtimeTransform>();
            objectManipulator   = GetComponent <ObjectManipulator>();
            manipulationHandler = GetComponent <ManipulationHandler>();
            rigidbody           = GetComponent <Rigidbody>();

            startPosition = transform.localPosition;
            startRotation = transform.localRotation;
            startScale    = transform.localScale;

            if (shouldExtrapolateIfRigidbody && rigidbody != null)
            {
                realtimeTransform.extrapolation = true;
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////
        /// UNITY OVERRIDES
        ////////////////////////////////////////////////////////////////////////////////////////////////


        private void Start()
        {
            if (TargetObject != null)
            {
                m_objectEnabled = TargetObject.activeInHierarchy;
            }

            // Get Offset vector
            m_targetObjectOffset = gameObject.transform.position - TargetObject.transform.position;

            // Setup callbacks
            m_manipulationHandler = gameObject.GetComponent <ManipulationHandler>();
            m_manipulationHandler.OnManipulationStarted.AddListener(MRTK_OnManipulationStarted);
            m_manipulationHandler.OnManipulationEnded.AddListener(MRTK_OnManipulationEnded);
            m_manipulationHandler.OnHoverEntered.AddListener(MRTK_OnHoverEntered);
            m_manipulationHandler.OnHoverExited.AddListener(MRTK_OnHoverExited);
        }
示例#15
0
        /// <summary>
        ///     初期化処理を実施します
        /// </summary>
        private void OnEnable()
        {
            if (isInitialized)
            {
                return;
            }

            isInitialized        = true;
            manipulationHandler  = GetComponent <ManipulationHandler>();
            interactionGrabbable = GetComponent <NearInteractionGrabbable>();
            handInteractionHint  = GetComponentInChildren <HandInteractionHint>();
            arrowAnimate         = GetComponentInChildren <ArrowAnimate>();
            toolTip = GetComponentInChildren <ToolTip>();
            systemKeyboardInputHelper = GetComponentInChildren <SystemKeyboardInputHelper>();
            pos1 = handInteractionHint.transform.GetChild(1).transform.position;
            pos2 = handInteractionHint.transform.GetChild(2).transform.position;
        }
    void CoordinateEditPopUpPressed(NetworkOutput output, GameObject parentButton, GameObject CoordianteButton)
    {
        EditColorChange(parentButton);
        if (parentButton.GetComponent <ManipulationHandler>() != null)
        {
            Destroy(parentButton.GetComponent <ManipulationHandler>());
            Destroy(parentButton.GetComponent <NearInteractionGrabbable>());
        }
        else
        {
            parentButton.AddComponent(typeof(NearInteractionGrabbable));
            ManipulationHandler manipulationHander = parentButton.AddComponent(typeof(ManipulationHandler)) as ManipulationHandler;
            manipulationHander.OneHandRotationModeNear = ManipulationHandler.RotateInOneHandType.FaceAwayFromUser;
            manipulationHander.OneHandRotationModeFar  = ManipulationHandler.RotateInOneHandType.FaceAwayFromUser;

            manipulationHander.OnManipulationEnded.AddListener((ManipulationEventData test) => { updateCoordinate(output, parentButton, CoordianteButton); });
        }
    }
示例#17
0
 void Start()
 {
     manipHandler   = GetComponent <ManipulationHandler>();
     loggingManager = LoggingManager.instance;
     if (manipHandler != null)
     {
         manipHandler.OnManipulationStarted.AddListener(LogManipulationStart);
         manipHandler.OnManipulationEnded.AddListener(StopLogging);
     }
     pressButton = GetComponent <PressableButtonHoloLens2>();
     if (pressButton != null)
     {
         pressButton.ButtonPressed.AddListener(LogManipulationStart);
         pressButton.ButtonReleased.AddListener(StopLogging);
     }
     interactable = GetComponent <Interactable>();
     if (interactable != null)
     {
         // handled by `OnStateChange`
     }
 }
示例#18
0
        /// <summary>
        /// Subscribes to manipulation events.
        /// </summary>
        private void OnEnable()
        {
            objectManipulator = gameObject.GetComponent <ObjectManipulator>();
            if (objectManipulator != null)
            {
                objectManipulator.OnManipulationStarted.AddListener(OnManipulationStarted);
                objectManipulator.OnManipulationEnded.AddListener(OnManipulationEnded);
            }
            else
            {
                manipulationHandler = gameObject.GetComponent <ManipulationHandler>();
                if (manipulationHandler != null)
                {
                    manipulationHandler.OnManipulationStarted.AddListener(OnManipulationStarted);
                    manipulationHandler.OnManipulationEnded.AddListener(OnManipulationEnded);
                }
            }

            Assert.IsTrue(objectManipulator != null || manipulationHandler != null,
                          "A Dockable object must have either an ObjectManipulator or a ManipulationHandler component.");

            Assert.IsNotNull(gameObject.GetComponent <Collider>(), "A Dockable object must have a Collider component.");
        }
    protected override void Awake()
    {
        base.Awake();
        _mainCamera = Camera.main;

        _offsetOnPullToCamera = GalaxyExplorerManager.ForcePullToCamFixedDistance;

        _manipulationHandler = ManipulationHandler ? ManipulationHandler : GetComponentInChildren <ManipulationHandler>();
        Debug.Assert(_manipulationHandler != null, "Force Solver failed to find a manipulation handler");
        _attractionCollider = AttractionCollider ? AttractionCollider : GetComponentInChildren <Collider>();
        Debug.Assert(_attractionCollider != null, "Force Solver failed to find a attraction collider");

        _manipulationHandler.OnManipulationEnded.AddListener(OnManipulationEnd);

        if (ControllerTracker == null)
        {
            Debug.LogWarning(gameObject.name + " ForceSolver no controller tracker transform supplied will instantiate locally");
            var controllerTrackerObject = new GameObject(gameObject.name + " ForceSolver autogenerated controller tracker");
            ControllerTracker = controllerTrackerObject.AddComponent <ControllerTransformTracker>();
        }

        ControllerTracker.AllTrackingLost += OnControllersLost;
    }
示例#20
0
 private void AddMRTKComponents()
 {
     manipHandler = gameObject.AddComponent <ManipulationHandler>();
     manipHandler.TwoHandedManipulationType = ManipulationHandler.TwoHandedManipulation.MoveRotate;
 }
示例#21
0
 private void OnEnable()
 {
     manipulationHandler = GetComponent <ManipulationHandler>();
     manipulationHandler.OnManipulationStarted.AddListener(StartedMotion);
     manipulationHandler.OnManipulationEnded.AddListener(StoppedMotion);
 }
示例#22
0
        public IEnumerator CursorContextMove()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            // The cube needs to be moved from under the gaze cursor before we add the manipulation handler.
            // Because the cube is under the gaze cursor from the beginning, it gets a focus gained event
            // in Setup(). When we show the right hand, we get a focus lost event from the gaze pointer. 
            // This messes with the CursorContextManipulationHandler hoverCount, as it decrements without
            // ever having incremented. To avoid this, we move the cube out of focus before we add the
            // ManipulationHandler and CursorContextManipulationHandler.
            cube.transform.localPosition = new Vector3(0, -2, 2);
            yield return new WaitForFixedUpdate();
            yield return null;

            ManipulationHandler manipulationHandler = cube.AddComponent<ManipulationHandler>();
            CursorContextManipulationHandler cursorContextManipulationHandler = cube.AddComponent<CursorContextManipulationHandler>();
            yield return new WaitForFixedUpdate();
            yield return null;

            // Move cube back to original position (described above)
            cube.transform.localPosition = new Vector3(0, 0, 2);
            yield return new WaitForFixedUpdate();
            yield return null;

            // Show right hand on object
            var rightHand = new TestHand(Handedness.Right);
            Vector3 rightPos = new Vector3(0.05f, 0, 1.5f);
            yield return rightHand.Show(rightPos);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.None);

            // Pinch right hand
            yield return rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.MoveCross);

            // Show left hand on object
            var leftHand = new TestHand(Handedness.Left);
            Vector3 leftPos = new Vector3(-0.05f, 0, 1.5f);
            yield return rightHand.Hide();
            yield return leftHand.Show(leftPos);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.None);

            // Pinch left hand
            yield return leftHand.SetGesture(ArticulatedHandPose.GestureId.Pinch);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.MoveCross);

            // Show both hands on object
            yield return rightHand.SetGesture(ArticulatedHandPose.GestureId.Open);
            yield return rightHand.Show(rightPos);
            yield return leftHand.SetGesture(ArticulatedHandPose.GestureId.Open);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.MoveCross);

            Object.Destroy(cursorContextManipulationHandler);
            Object.Destroy(manipulationHandler);
        }
示例#23
0
 void Start()
 {
     rigidbody = gameObject.GetComponent <Rigidbody>();
     man       = gameObject.GetComponent <ManipulationHandler>();
     man.OnManipulationEnded.AddListener(FallDown);
 }
示例#24
0
 /// <summary>
 /// Clean up all resources.
 /// </summary>
 private void TakeDownManipulation()
 {
     boundingBox         = null;
     manipulationHandler = null;
     nearGrabbable       = null;
 }
示例#25
0
 private void ConfigureMeshManipulationHandler()
 {
     this.meshManipHandler = this.mesh.AddComponent <ManipulationHandler>();
     this.meshManipHandler.OneHandRotationModeFar  = ManipulationHandler.RotateInOneHandType.MaintainOriginalRotation;
     this.meshManipHandler.OneHandRotationModeNear = ManipulationHandler.RotateInOneHandType.MaintainOriginalRotation;
 }
示例#26
0
 /// <summary>
 /// Capture a reference to the manipulation handler
 /// </summary>
 private void Start()
 {
     _manipulationHandler = GetComponent <ManipulationHandler>();
     Debug.Assert(_manipulationHandler != null, "RedirectManipulationTarget requires a ManipulationHandler");
 }
示例#27
0
    public void LoadObject()
    {
        GameObject playspace = this.gameObject;
        GameObject camera    = playspace.transform.Find("Main Camera").gameObject;

        model = new GameObject(model_name);
        model.transform.parent = playspace.transform;
        model.AddComponent <MeshRenderer>();
        model.AddComponent <StepToggle>();


        Vector3 camera_pos = camera.transform.position;
        Vector3 camera_dir = camera.transform.forward;

        model.transform.position   = camera_pos + camera_dir;
        model.transform.position  += new Vector3(0.0f, -0.05f, 0.6f);
        model.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

        AssetBundle.UnloadAllAssetBundles(true);
        var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine("file:///", Application.streamingAssetsPath, model_name));

        if (myLoadedAssetBundle == null)
        {
            Debug.Log("Failed to load AssetBundle!");
            return;
        }
        var fileArray = myLoadedAssetBundle.LoadAllAssets <GameObject>();

        foreach (var obj in fileArray)
        {
            if (obj.name.Contains("step"))
            {
                GameObject step_model = Instantiate(obj);
                step_model.transform.parent = model.transform;
                //get step number to set the right order
                int step_num = int.Parse(string.Join("", obj.name.Substring(obj.name.IndexOf("step")).ToCharArray().Where(Char.IsDigit)));
                step_model.transform.SetSiblingIndex(step_num);
                //AddLines(step_model);
                step_model.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                step_model.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                step_model.transform.GetChild(0).gameObject.AddComponent <StepHighlighter>();
            }
            else if (obj.name.Equals(model_name) || obj.name.Equals(model_name.ToLower()))
            {
                GameObject model_small = Instantiate(obj);
                model_small.transform.parent = camera.transform.GetChild(1).gameObject.transform;
                //AddLines(model_small);
                model_small.transform.localPosition = new Vector3(0f, -6.7f, -0.7f);
                model_small.transform.localRotation = new Quaternion(0.165f, -73.45901f, 31.383f, 0);
                model_small.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);

                float canvas_width = model_small.transform.parent.GetComponent <RectTransform>().rect.width *model_small.transform.parent.GetComponent <RectTransform>().transform.localScale.x;
                float bb_width     = model_small.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().bounds.size.x * 2.25f;

                model_small.transform.localScale = new Vector3(canvas_width / bb_width, canvas_width / bb_width, canvas_width / bb_width);

                RotatingObject ro = model_small.AddComponent <RotatingObject>();
                ro.yAngle = 2;
                ro.speed  = 0.2f;
            }
            else
            {
                //bricks.Add(obj.name, obj);
            }
        }

        // make small model canvas visible
        camera.transform.Find("Canvas").gameObject.SetActive(true);
        // make model picker menu invisible
        playspace.transform.Find("Canvas").gameObject.SetActive(false);

        ConfigSpeechInputHandler();

        // add components to move and scale the model
        ManipulationHandler mh = model.AddComponent <ManipulationHandler>();

        ManipulationHandler.ReleaseBehaviorType ReleaseBehaviorType = ManipulationHandler.ReleaseBehaviorType.KeepVelocity & ManipulationHandler.ReleaseBehaviorType.KeepAngularVelocity;
        mh.ReleaseBehavior = ReleaseBehaviorType;
        model.AddComponent <BoundingBox>();
        Rigidbody modelRigidBody = model.AddComponent <Rigidbody>();

        modelRigidBody.useGravity = false;
        model.AddComponent <NearInteractionGrabbable>();
    }
 void Start()
 {
     handler = GetComponent <ManipulationHandler>();
 }