示例#1
0
 // Use this for initialization
 void Start()
 {
     _handDraggable = GetComponent <HandDraggable>();
     _handDraggable.StartedDragging += HandDraggableOnStartedDragging;
     _handDraggable.StoppedDragging += HandDraggableOnStoppedDragging;
     _rigidbody = GetComponent <Rigidbody>();
 }
示例#2
0
    private void Start()
    {
        /* Adding components using code, simply because it's more friendly to version control */
        handDraggable = gameObject.AddComponent <HandDraggable>();
        handDraggable.RotationMode = HandDraggable.RotationModeEnum.LockObjectRotation;
        GetComponent <TwoHandManipulatable>().enabled = false;

        ModelClipPlaneCtrl = ModelClipPlane.GetComponentInChildren <ModelClippingPlaneControl>();
        // Turn off the clipping plane on start
        DefaultModelMaterial.DisableKeyword("CLIPPING_ON");
        DefaultModelTransparentMaterial.DisableKeyword("CLIPPING_ON");
        DataVisualizationMaterial.DisableKeyword("CLIPPING_ON");

        LayersSection.SetActive(false);
        AnimationSubmenu.SetActive(false);

        RefreshUserInterface();
        InitializeAddButtons();

        // This sets proper state of buttons and components like handDraggable
        ClickChangeTransformationState(TransformationState.None);

        // Animation speed slider
        SliderAnimationSpeed.GetComponent <SliderGestureControl>().OnUpdateEvent.AddListener(
            delegate {
            AnimationSpeed = SliderAnimationSpeed.GetComponent <SliderGestureControl>().SliderValue;
        }
            );
    }
示例#3
0
    protected virtual void clone()
    {
        if (shouldSpawn)
        {
            //Copying Controller...
            GameObject prefabObjectClone = GameObject.Instantiate(gameObject);
            Vector3    cam     = Camera.main.transform.forward.normalized;
            Vector3    current = gameObject.transform.position;
            prefabObjectClone.transform.position = new Vector3(current.x + (cam.x * .05f), current.y + (cam.y * .05f), current.z + (cam.z * .05f));
            Vector3 globalScale = gameObject.transform.lossyScale;
            prefabObjectClone.transform.localScale = new Vector3(globalScale.x * 1.35f, globalScale.y * 1.35f, globalScale.z * 1.35f);
            prefabObjectClone.transform.rotation   = gameObject.transform.rotation;
            EditModeController edit = prefabObjectClone.GetComponent <EditModeController>();
            edit.scaleModeTriggered = true;
            Transform dupButton = prefabObjectClone.transform.Find("BillBoard/ttpContainer/Duplicate Button");
            dupButton.parent = null;
            Destroy(dupButton.gameObject);
            Destroy(prefabObjectClone.GetComponent <SpawnBehaviourScript>());

            HandDraggable hd = prefabObjectClone.AddComponent <HandDraggable>();
            hd.enabled           = true;
            hd.RotationMode      = HandDraggable.RotationModeEnum.OrientTowardUserAndKeepUpright;
            hd.IsDraggingEnabled = true;
        }
    }
 private void Start()
 {
     originalLocalPosition          = transform.localPosition;
     originalLocalRotation          = transform.localRotation;
     handDraggable                  = GetComponent <HandDraggable>();
     handDraggable.StartedDragging += HandDraggable_StartedDragging;
     handDraggable.StoppedDragging += HandDraggable_StoppedDragging;
 }
示例#5
0
    private HandDraggable handDraggable;       //HandDraggable scipt

    /// <summary>
    /// Instantiate private vars
    /// </summary>
    private void Awake()
    {
        activeHUD        = false;
        dismissMessage   = "\n Say 'Stop Recording' or tap to close.";
        recordingMessage = "Recording... Tap on tag to stop. \n";
        priorText        = "";
        handDraggable    = this.gameObject.GetComponent <HandDraggable>();
    }
示例#6
0
    // Use this for initialization
    void Start()
    {
        handDraggable = this.GetComponent <HandDraggable>();
        handDraggable.StartedDragging += OnDraggingStarted;
        handDraggable.StoppedDragging += OnDraggingStopped;

        body = GetComponent <Rigidbody>();
    }
    // Use this for initialization
    void Start()
    {
        drag  = GameObject.Find(dragObjectName).GetComponent <HandDraggable>();
        scale = GameObject.Find(scaleObjectName).GetComponent <ExtendedManipulation>();

        drag.SetDragging(false);
        scale.SetScaling(false);
    }
示例#8
0
    // Use this for initialization
    void Start()
    {
        hd    = GetComponent <HandDraggable> ();
        rBody = GetComponent <Rigidbody> ();

        hd.StoppedDragging += StopDrag;
        hd.StartedDragging += StartDrag;
    }
 private void Start()
 {
     if (ObjectToScale)
     {
         InitialScale  = ObjectToScale.transform.localScale;
         handDraggable = ObjectToScale.GetComponent <HandDraggable>();
         handRotatable = ObjectToScale.GetComponent <HandRotatable>();
     }
 }
示例#10
0
        IEnumerator DispatchMixerEvent(List <GameObject> gameObjects)
        {
            isWaiting = true; // don't dispatch any more until we're done here (prevents repeat dispatches)

            yield return(new WaitForSeconds(1));

            // after selecting specific ids, should still be a count of two
            if (gameObjects
                .Where(x =>
                       x.gameObject.GetComponent <CloudComponent>().cId == "5bb31f90023eb3359042462e" || // aluminum chips
                       x.gameObject.GetComponent <CloudComponent>().cId == "5bb31f99023eb3359042462f")   // iron oxide powder
                .ToList().Count == 2)
            {
                // load in the thermite
                GameObject gameObject = (GameObject)Instantiate(
                    Resources.Load("Bottles/Mesh/Bottle 01", typeof(GameObject)),
                    centre,
                    new Quaternion(0, 0, 0, 1),
                    GameObject.Find("/SceneContent/CloudObjects").transform);

                gameObject.layer = 8; // layer 8 = cloudobjects layer
                gameObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);

                gameObject.name = "Thermite";
                gameObject.AddComponent <ObjectPopupName>(); // show name on focus

                // add various props from the cloudobject that aren't already present
                CloudComponent cloudComponent = gameObject.AddComponent <CloudComponent>();
                cloudComponent.cId          = "5bb425bccc7ed83ee3cfbd8d"; // these values will eventually be from the db
                cloudComponent.cSignificant = true;

                // components required for picking up the object
                HandDraggable draggable = gameObject.AddComponent <HandDraggable>();
                draggable.StartedDragging += () => GameObject.Find("/SceneContent/CloudSession")
                                             .GetComponent <CloudSessionManager>()
                                             .HandleUserSelfGrab(gameObject);
                draggable.StoppedDragging += () => GameObject.Find("/SceneContent/CloudSession")
                                             .GetComponent <CloudSessionManager>()
                                             .HandleUserSelfDrop(gameObject);

                gameObject.AddComponent <Rigidbody>();
                gameObject.AddComponent <BoxCollider>();

                // log the transform event
                TransformEvent transformEvent = this.gameObject.GetComponent <TransformEvent>();
                transformEvent.Trigger(gameObject, gameObjects);

                gameObjects.ForEach(obj =>
                {
                    // remove the objects to replace them with the thermite
                    Destroy(obj);
                });

                isWaiting = false;
            }
        }
    //private bool isDraggable = false;

    // Use this for initialization
    void Start()
    {
        handDraggable = widget.GetComponent <HandDraggable>();

        // Dragging is off by default
        handDraggable.enabled = false;

        // When finished dragging, handDraggable should be disabled
        handDraggable.StoppedDragging += stopDragging;
    }
    void Start()
    {
        clipPlaneQuadBbox       = GetComponent <BoundingBoxRig>();
        HandTranslation         = GetComponent <HandDraggable>();
        HandTranslation.enabled = false;

        ButtonClippingPlaneTranslation.gameObject.SetActive(false);
        ButtonClippingPlaneRotation.gameObject.SetActive(false);
        clipPlaneQuadBbox.Deactivate();
    }
示例#13
0
        public void Import()
        {
            if (!string.IsNullOrEmpty(scenarioID))
            {
                Transform cloudObjParent = GameObject.Find("/SceneContent/CloudObjects").transform;
                WWW       ep             = new WWW(string.Format(apiEndpoint, scenarioID));
                while (!ep.isDone)
                {
                    ;
                }

                if (!string.IsNullOrEmpty(ep.text))
                {
                    CloudScenarioResponse res = JsonConvert.DeserializeObject <CloudScenarioResponse>(ep.text);

                    foreach (CloudObject obj in res.scenario.objects)
                    {
                        UnityMainThreadDispatcher.Instance().Enqueue(() =>
                        {
                            GameObject gameObject = (GameObject)Instantiate(
                                Resources.Load(obj.path, typeof(GameObject)),
                                new Vector3(obj.x, obj.y, obj.z),
                                new Quaternion(obj.pitch, obj.yaw, obj.roll, 1),
                                GameObject.Find("/SceneContent/CloudObjects").transform);

                            gameObject.layer = 8; // layer 8 = cloudobjects layer
                            gameObject.transform.localScale = new Vector3(obj.scale_x, obj.scale_y, obj.scale_z);

                            gameObject.name = obj.name;
                            gameObject.AddComponent <ObjectPopupName>(); // show name on focus

                            // add various props from the cloudobject that aren't already present
                            CloudComponent cloudComponent = gameObject.AddComponent <CloudComponent>();
                            cloudComponent.cId            = obj.id;
                            cloudComponent.cSignificant   = obj.significant;

                            // components required for picking up the object
                            HandDraggable draggable    = gameObject.AddComponent <HandDraggable>();
                            draggable.StartedDragging += () => GameObject.Find("/SceneContent/CloudSession")
                                                         .GetComponent <CloudSessionManager>()
                                                         .HandleUserSelfGrab(gameObject);
                            draggable.StoppedDragging += () => GameObject.Find("/SceneContent/CloudSession")
                                                         .GetComponent <CloudSessionManager>()
                                                         .HandleUserSelfDrop(gameObject);

                            gameObject.AddComponent <Rigidbody>();
                            gameObject.AddComponent <BoxCollider>();

                            // perception logging
                            gameObject.AddComponent <PerceptionEvent>();
                        });
                    }
                }
            }
        }
示例#14
0
        private void Start()
        {
            HubManager.Instance.OnSendTransform += HubManagerOnSendTransform;

            _handDraggable = GetComponent <HandDraggable>();
            _handDraggable.StartedDragging += HandDraggableOnStartedDragging;
            _handDraggable.StoppedDragging += HandDraggableOnStoppedDragging;

            _sendTransformCoroutine   = StartCoroutine(SendTransformCoroutine());
            _updateTransformCoroutine = StartCoroutine(UpdateTransformCoroutine());
        }
示例#15
0
    private void Start()
    {
        wid     = widgetobj.GetComponent <DataWidget>();
        handler = widgetparent.GetComponent <DataWidgetHandler>();

        handDraggable = widgetobj.GetComponent <HandDraggable>();

        // Dragging is off by default
        handDraggable.enabled = isDraggable;

        // When finished dragging, handDraggable should be disabled
        handDraggable.StoppedDragging += StopDragging;
    }
示例#16
0
    private void OnWorldAnchorStoreLoaded(WorldAnchorStore store)
    {
        var persistentGameObject = GameObject.Find("persistentGameObject");
        persistentGameObjectScript persistentScript = persistentGameObject.GetComponent <persistentGameObjectScript>();

        if (persistentScript.loadWorldAnchors)
        {
            Debug.Log("LOADING WORLD ANCHORS");
            var ids = store.GetAllIds();

            foreach (var id in ids)
            {
                char[]   delimiterChars = { ':' };
                string[] anchorInfo     = id.ToString().Split(delimiterChars);
                Debug.Log("<color=yellow>Anchor ID:" + anchorInfo[0] + " Lossy Scale: " + anchorInfo[1] + " Creation Time: " + anchorInfo[2]);

                ModelController mc        = ModelController.Instance;
                int             integerID = Convert.ToInt32(anchorInfo[0]);
                try
                {
                    GameObject            go  = mc.GetPrefabWithId(integerID);
                    BaseVentanaController bvc = go.GetComponent <BaseVentanaController>();
                    if (bvc)
                    {
                        bvc.OnVumarkFound();
                        bvc.VentanaID = integerID;
                    }
                    HandDraggable hd = go.AddComponent <HandDraggable>();
                    hd.enabled           = false;
                    hd.RotationMode      = HandDraggable.RotationModeEnum.OrientTowardUserAndKeepUpright;
                    hd.IsDraggingEnabled = true;

                    float scaleVal = float.Parse(anchorInfo[1], CultureInfo.InvariantCulture.NumberFormat);

                    go.transform.localScale = new Vector3(scaleVal, scaleVal, scaleVal);
                    store.Load(id, go);
                }
                catch (Exception ex)
                {
                    Debug.Log("[Anchor Loader] " + ex.Message);
                }
            }
        }
        else
        {
            store.Clear();
            Debug.Log("World Anchor Store CLEARED");
        }
    }
示例#17
0
        void Awake()
        {
            if (movable)
            {
                HandDraggable dragComp = gameObject.AddComponent <HandDraggable>();
                dragComp.StartedDragging  += StartDrag;
                dragComp.StoppedDragging  += StopDrag;
                dragComp.RotationMode      = rotationMode;
                dragComp.IsDraggingEnabled = true;

                HoloToolkit.Unity.InputModule.Cursor c = FindObjectOfType <HoloToolkit.Unity.InputModule.Cursor>();
                dragComp.hackedCursorReference = c.transform;

                WorldErrors.Print("Created Hand-draggable");
            }
        }
示例#18
0
    void Start()
    {
        Collider collider = GetComponentInChildren <Collider>();

        if (collider == null)
        {
            gameObject.AddComponent <BoxCollider>();
        }

        handDraggable = gameObject.GetComponentInParent <HandDraggable>();
        if (handDraggable)
        {
            handDraggable.StartedDragging += HandDraggable_StartedDragging;
            handDraggable.StoppedDragging += HandDraggable_StoppedDragging;
        }
    }
示例#19
0
    // Use this for initialization
    void Start()
    {
        source = gameObject.GetComponent <AudioSource>();
        // initialize to regular mode, with tap to place controls inactive
        moreButtons.gameObject.SetActive(true);
        deleteDone.gameObject.SetActive(false);
        scaleHandles.gameObject.SetActive(false);

        handDraggable = gameObject.GetComponent <HandDraggable>();

        if (handDraggable != null)
        {
            handDraggable.StoppedDragging += HandDraggable_StoppedDragging;
            handDraggable.StartedDragging += HandDraggable_StartedDragging;
        }
    }
示例#20
0
 public override void Render(StringBuilder sb)
 {
     AddProperty("rotate", Vector3.ToString(Rotate));
     AddProperty("center", Vector3.ToString(Center));
     AddProperty("clingtocamera", ClingToCamera);
     AddProperty("activetransform", ActiveTransform);
     AddProperty("presentation", Presentation);
     AddProperty("presentationangle", PresentationAngle);
     AddProperty("presentationspeed", PresentationSpeed);
     AddProperty("kinetic", Kinetic);
     AddProperty("bounciness", Bounciness);
     AddProperty("applytoparent", ApplyToParent.ToSlamString());
     AddProperty("handdraggable", HandDraggable.ToSlamString());
     AddProperty("updatable", Updatable.ToSlamString());
     base.Render(sb);
 }
示例#21
0
    void Start()
    {
        handDraggableComponent = gameObject.AddComponent <HandDraggable>();
        handDraggableComponent.OnDraggingUpdate += HandDraggableComponent_OnDraggingUpdate;
        handDraggableComponent.StartedDragging  += HandDraggableComponent_StartedDragging;
        handDraggableComponent.StoppedDragging  += HandDraggableComponent_StoppedDragging;

        handDraggableComponent.RotationMode = HandDraggable.RotationModeEnum.OrientTowardUserAndKeepUpright;

        originalPosition = transform.localPosition;
        mapObject        = GameObject.Find(GameObjectNamesHolder.NAME_MAP_COLLIDER);
        boxCollider      = GetComponentInChildren <BoxCollider>(); // children and this object

        initializeBoundsObject();

        layerToAvoidRaycast = GameObjectNamesHolder.LAYER_OBJECT_BEING_PLACED;
        HoloToolkit.Unity.Utils.SetLayerRecursively(gameObject, layerToAvoidRaycast);
    }
    private void Awake()
    {
        if (line == null)
        {
            line = GetComponent <LineRenderer>();
        }
        line.positionCount = 2;

        interpolatorComponent = GetComponentInParent <Interpolator>();
        interpolatorComponent.InterpolationDone += InterpolationDone;
        parentTransform = interpolatorComponent.gameObject.transform;

        handDraggableComponent  = GetComponent <HandDraggable>();
        tableTitleTextComponent = GetComponentInChildren <Text>();
        handDraggableComponent.OnDraggingUpdate += HandDraggableComponent_OnDraggingUpdate;
        hideButtonComponent.OnButtonClicked     += DraggableInfoTable_OnButtonClicked;
        TableHolderHasGazeFeedback = false;
        isAtStart = true;
    }
    void Start()
    {
        isRecognizing = true;
        VuforiaBehaviour.Instance.enabled = false;
        keyboardRecognitionManager        = GetComponent <KeyboardRecognitionManager>();
        tutorialVideo = tutorialPanel.GetComponent <VideoPlayer>();
        handDraggable = mainContent.GetComponent <HandDraggable>();


        mainMenu.SetActive(false);
        tutorialPanel.SetActive(false);
        mainContent.SetActive(false);

        // Start listening to tap gesture
        gestureRecognizer              = new GestureRecognizer();
        gestureRecognizer.TappedEvent += (source, tapCount, headRay) => { StartCoroutine(OnTap(headRay)); };
        gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap);
        gestureRecognizer.StartCapturingGestures();
    }
    ///<summary>
    ///WorldAnchorManager.Instance.AttachAnchor returns a string that can be used for Debugging.
    ///This function will first search to see if there is a stored anchor that is associated
    ///With this.gameObject.name. If so, it attaches that anchor to the game object.
    ///If not, it creates a new anchor associated with this.gameObject.name and attaches it.
    ///Listeners for the HandDraggable script are also added, to detach and reattach anchors
    ///At the new location when dragging starts and ends respectively.
    /// </summary>
    void Awake()
    {
        string temp1 = WorldAnchorManager.Instance.AttachAnchor(this.gameObject);

        Debug.Log("Added initial anchor: " + temp1);

        HandDraggable handDraggable = this.gameObject.GetComponent <HandDraggable>();

        handDraggable.StartedDragging += () =>
        {
            // Removing anchor temporarily when dragging starts
            WorldAnchorManager.Instance.RemoveAnchor(this.gameObject);
        };
        handDraggable.StoppedDragging += () =>
        {
            // Adding back with the same name when dragging ends
            string temp2 = WorldAnchorManager.Instance.AttachAnchor(this.gameObject);
            Debug.Log("Dragging ended. Added anchor " + temp2);
        };
    }
示例#25
0
 private void Awake()
 {
     boundingBoxRig = GetComponent <BoundingBoxRig>();
     handDraggable  = GetComponent <HandDraggable>();
     solverHandler  = GetComponent <SolverHandler>();
 }
        void HandleUserUpdate(object sender, ChildChangedEventArgs args)
        {
            // remote user performed some activity, like moving or grabbing
            if (args.DatabaseError != null)
            {
                Debug.LogError(args.DatabaseError.Message);
                return;
            }

            if (args.Snapshot.Key != userName__NO_TOUCH)
            {
                UnityMainThreadDispatcher.Instance().Enqueue(() =>
                {
                    GameObject player         = playerObjects.Where(x => x.name == args.Snapshot.Key).First();
                    player.transform.position = new Vector3(
                        float.Parse(args.Snapshot.Child("pos_x").Value.ToString()),
                        float.Parse(args.Snapshot.Child("pos_y").Value.ToString()),
                        float.Parse(args.Snapshot.Child("pos_z").Value.ToString()));

                    player.transform.rotation = new Quaternion(
                        float.Parse(args.Snapshot.Child("quat_x").Value.ToString()),
                        float.Parse(args.Snapshot.Child("quat_y").Value.ToString()),
                        float.Parse(args.Snapshot.Child("quat_z").Value.ToString()),
                        float.Parse(args.Snapshot.Child("quat_w").Value.ToString()));

                    if (args.Snapshot.HasChild("inventory"))
                    {
                        List <CloudComponent> cloudComponents = FindObjectsOfType <CloudComponent>()
                                                                .Where(x => x.cId == args.Snapshot.Child("inventory").Child("cid").Value.ToString()).ToList();

                        if (cloudComponents.Count == 1)
                        {
                            GameObject grabbed  = cloudComponents.First().gameObject;
                            Rigidbody rigidBody = grabbed.GetComponent <Rigidbody>();
                            if (rigidBody != null)
                            {
                                Destroy(rigidBody);                    // remove dragged rigid body to prevent gravity
                            }
                            HandDraggable handDraggable = grabbed.GetComponent <HandDraggable>();
                            if (handDraggable != null)
                            {
                                Destroy(handDraggable);                        // remove dragability to prevent snatching
                            }
                            CloudPlayerDragging playerDragging = grabbed.GetComponent <CloudPlayerDragging>();
                            if (playerDragging == null)
                            {
                                grabbed.AddComponent <CloudPlayerDragging>();                        // add empty component to use in querying
                            }
                            // update the dragged object's position
                            grabbed.transform.position = new Vector3(
                                float.Parse(args.Snapshot.Child("inventory").Child("pos_x").Value.ToString()),
                                float.Parse(args.Snapshot.Child("inventory").Child("pos_y").Value.ToString()),
                                float.Parse(args.Snapshot.Child("inventory").Child("pos_z").Value.ToString()));

                            grabbed.transform.rotation = new Quaternion(
                                float.Parse(args.Snapshot.Child("inventory").Child("quat_x").Value.ToString()),
                                float.Parse(args.Snapshot.Child("inventory").Child("quat_y").Value.ToString()),
                                float.Parse(args.Snapshot.Child("inventory").Child("quat_z").Value.ToString()),
                                float.Parse(args.Snapshot.Child("inventory").Child("quat_w").Value.ToString()));

                            // listen for delete events, so we can re-apply the rigidbody
                            EventHandler <ChildChangedEventArgs> onInvDelete = null; // set to null first, so it can be used to unsub inside the delegate
                            onInvDelete = delegate(object senderInv, ChildChangedEventArgs argsInv)
                            {
                                if (argsInv.Snapshot.Key == "inventory")
                                {
                                    // inventory was removed (item was dropped)
                                    if (grabbed.GetComponent <Rigidbody>() == null)
                                    {
                                        grabbed.AddComponent <Rigidbody>();
                                    }
                                    if (grabbed.GetComponent <HandDraggable>() == null)
                                    {
                                        grabbed.AddComponent <HandDraggable>();
                                    }
                                    if (grabbed.GetComponent <CloudPlayerDragging>() != null)
                                    {
                                        Destroy(grabbed.GetComponent <CloudPlayerDragging>());
                                    }

                                    refUsers.Child(args.Snapshot.Key).ChildRemoved -= onInvDelete; // remove handler
                                }
                            };

                            refUsers.Child(args.Snapshot.Key).ChildRemoved += onInvDelete;
                        }
                        else
                        {
                            Debug.LogWarning(string.Format("HandleUserRemoteGrab returned {0} results, when it was expecting 1", cloudComponents.Count));
                        }
                    }
                });
            }
        }
示例#27
0
 private void Awake()
 {
     handDraggable = gameObject.transform.parent.transform.gameObject.GetComponentInParent <HandDraggable>();
 }
示例#28
0
 void Start()
 {
     _faceTarget    = GetComponent <FaceTarget>();
     _handDraggable = GetComponent <HandDraggable>();
     _handDraggable.IsDraggingEnabled = false;
 }
 void Start()
 {
     handdrag = box.Target.GetComponent <HandDraggable>();
 }
示例#30
0
 // Use this for initialization
 void Start()
 {
     script = GetComponent <HandDraggable>();
     rb     = GetComponent <Rigidbody>();
 }