Esempio n. 1
0
 public virtual void StartDragging(GameObject target)
 {
     if (IsDraggable)
     {
         //StartDragging(HydraController.Instance.GetHand(m_hand));
         if (!HydraController.Instance.IsHandDragging(m_hand))
         {
             //Clone instrument here
             if (IsCloneable)
             {
                 BaseAttachment attach = UIFactory.CreateGhostDragger(this);
                 attach.StartDragging(HydraController.Instance.GetHand(m_hand));
             }
             else
             {
                 if (IsDragging)
                 {
                     StopDragging();
                 }
                 SetIsDragging(true);
                 Undock();
                 FixedJoint joint = gameObject.AddComponent <FixedJoint>();
                 joint.connectedBody   = target.GetComponent <Rigidbody>();
                 rigidbody.isKinematic = false;
                 HydraController.Instance.SetHandDragging(m_hand, this);
             }
         }
     }
 }
Esempio n. 2
0
    /*
     * Check if we're inside an object
     */
    protected void CheckForObjectCollision()
    {
        m_heldObject = HydraController.Instance.HandTarget(m_hand, ProximityType.INSTRUMENT_INTERIOR, m_mode);

        if (m_heldObject != null)
        {
            BaseAttachment attach = m_heldObject.GetComponent <BaseAttachment>();

            if (attach != null)
            {
                if (attach.respondsToToolMode(m_mode))
                {
                    //m_gestureState = GestureState.INTERIOR;
                    m_attachment    = attach;
                    m_toolHandState = BaseTool.HandState.HOLDING;
                    m_attachment.SetToolMode(m_mode);
                    m_attachment.SetActiveHand(m_hand);

                    if (mode == ToolMode.IDLE)
                    {
                        m_attachment.StartHover();
                    }
                }
            }
        }
    }
    public override bool AddDockableAttachment(BaseAttachment attach)
    {
        if (base.AddDockableAttachment(attach))
        {
            //attach.rigidbody.velocity = Vector3.zero;
            attach.rigidbody.isKinematic = true;

            InstrumentAttachment instrument = attach as InstrumentAttachment;
            attach.SetToolmodeResponse(new BaseTool.ToolMode[] {
                BaseTool.ToolMode.PRIMARY,
                BaseTool.ToolMode.GRABBING
            });
            instrument.EnableControls();
            instrument.SetCloneable(false);

            GameObject volumetric = UIFactory.CreateVolumetricCylinder();
            volumetric.transform.position = new Vector3(attach.transform.position.x, m_volumetricYOffset, attach.transform.position.z);
            volumetric.transform.parent   = transform;

            iTween.ColorTo(volumetric, iTween.Hash("color", new Color(1.0f, 1.0f, 1.0f, 0.2f), "time", 0.8f));
            m_volumetrics[instrument] = volumetric;

            PlaceObjects();
            //iTween.MoveTo(attach.gameObject, iTween.Hash("position", transform.localPosition, "uselocal", true ));
            return(true);
        }
        return(false);
    }
Esempio n. 4
0
    void Awake()
    {
        m_attach                 = GetComponent <BaseAttachment>();
        m_frameComponents        = new List <GameObject>();
        m_outlineFrameComponents = new List <GameObject>();
        m_gridColumns            = new List <GameObject>();
        m_gridRows               = new List <GameObject>();

        for (int i = 0; i < m_guiPanels.childCount; i++)
        {
            m_frameComponents.Add(m_guiPanels.GetChild(i).gameObject);
        }

        for (int i = 0; i < m_selectGuiPanels.childCount; i++)
        {
            m_outlineFrameComponents.Add(m_selectGuiPanels.GetChild(i).gameObject);
        }

        m_lastWidth  = m_frameWidth;
        m_lastHeight = m_frameHeight;

        if (m_hasGrid)
        {
            CreateGrid(m_numGridRows, m_numGridColumns);
        }

        if (m_label != null)
        {
            SetLabel(m_sliderLabel);
            m_label.transform.localPosition = m_frameOffset * 2.0f;
        }
    }
Esempio n. 5
0
    public GameObject GetClosestObjectInList(List <GameObject> targetList, GameObject target, BaseTool.ToolMode mode)
    {
        float      closestDistance = -1.0f;
        GameObject closestObject   = null;

        if (targetList != null && target != null)
        {
            foreach (GameObject obj in targetList)
            {
                if (obj != null)
                {
                    float dist = Vector3.Distance(obj.transform.position, target.transform.position);
                    if (dist < closestDistance || closestDistance < 0)
                    {
                        BaseAttachment attach = obj.GetComponent <BaseAttachment>();

                        if (attach != null)
                        {
                            if (attach.respondsToToolMode(mode))
                            {
                                closestDistance = dist;
                                closestObject   = obj;
                            }
                        }
                    }
                }
            }
        }

        return(closestObject);
    }
    /*
     * Creates a training point at a position or transform location
     */
    //public RBFTrainingAttachment CreateTrainingPoint(){
    //    RBFTrainingAttachment training = UI.UIFactory.CreateRBFSphereTraining();
    //    training.owner = this;
    //    training.transform.position = transform.position;
    //    training.transform.localScale = transform.localScale;
    //    training.transform.parent = transform;

    //    foreach(RBFPlugAttachment plug in m_plugs)
    //        training.StorePlugValue(plug);

    //    m_trainingPoints.Add(training);
    //    ResetRBF();
    //    return training;
    //}

    public override bool AddDockableAttachment(BaseAttachment attach)
    {
        if (base.AddDockableAttachment(attach))
        {
            attach.rigidbody.isKinematic = true;

            RBFTrainingAttachment rbfAttach = attach as RBFTrainingAttachment;
            rbfAttach.owner = this;
            rbfAttach.SetToolmodeResponse(new BaseTool.ToolMode[] {
                BaseTool.ToolMode.PRIMARY,
                BaseTool.ToolMode.GRABBING
            });
            rbfAttach.SetCloneable(false);
            rbfAttach.SetIsDraggable(true);
            rbfAttach.SetIsDockable(true);

            foreach (RBFPlugAttachment plug in m_plugs)
            {
                rbfAttach.StorePlugValue(plug);
            }

            SetSelectedtraining(rbfAttach);
            return(true);
        }
        return(false);
    }
Esempio n. 7
0
 public override void RemoveDockableAttachment(BaseAttachment attach)
 {
     base.RemoveDockableAttachment(attach);
     attach.rigidbody.isKinematic = false;
     CalculateDisplayedItems();
     PlaceObjects();
 }
Esempio n. 8
0
 public virtual void Undock()
 {
     if (m_dockedInto != null)
     {
         m_dockedInto.RemoveDockableAttachment(this);
         m_dockedInto = null;
     }
 }
 public void InstrumentControlsAreVisible(BaseAttachment attach)
 {
     if (m_activeAttachment != null && attach != m_activeAttachment)
     {
         m_activeAttachment.HideControls();
     }
     m_activeAttachment = attach;
 }
Esempio n. 10
0
 public virtual void RemoveDockableAttachment(BaseAttachment attach)
 {
     while (m_childDockables.Contains(attach))
     {
         m_childDockables.Remove(attach);
     }
     attach.transform.parent = null;
 }
Esempio n. 11
0
 public void SetHandDragging(BaseTool.ToolHand hand, BaseAttachment target)
 {
     if (hand == BaseTool.ToolHand.LEFT)
     {
         m_leftHandDragTarget = target;
     }
     m_rightHandDragTarget = target;
 }
Esempio n. 12
0
 public virtual bool IsInDockingRange(BaseAttachment attach, float range)
 {
     if (attach == null)
     {
         return(false);
     }
     return((Vector3.Distance(transform.position, attach.transform.position) < range) ? true : false);
 }
Esempio n. 13
0
 /*
  * Dockable object modifiers
  */
 public virtual void DockInto(BaseAttachment attach)
 {
     attach.AddDockableAttachment(this);
     m_dockedInto     = attach;
     m_dockedIntoLast = attach;
     if (IsDraggable)
     {
         SetIsDragging(false);
     }
 }
 public ClipCubeHolder FindAttachmentHolder(BaseAttachment attach)
 {
     foreach (ClipCubeHolder holder in m_cubeHolders)
     {
         if (holder.attach == attach)
         {
             return(holder);
         }
     }
     return(null);
 }
    public override void RemoveDockableAttachment(BaseAttachment attach)
    {
        base.RemoveDockableAttachment(attach);
        attach.transform.parent = null;
        ClipCubeHolder holder = FindAttachmentHolder(attach);

        if (holder != null)
        {
            holder.attach = null;
        }
    }
Esempio n. 16
0
        protected HttpResponseMessage GetDownloadResponse(string root, BaseAttachment attachment)
        {
            var response   = new HttpResponseMessage(HttpStatusCode.OK);
            var filePath   = Path.Combine(root, attachment.FileName);
            var fileStream = new FileStream(filePath, FileMode.Open);

            response.Content = new StreamContent(fileStream);
            response.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/octet-stream");
            response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = attachment.OriginalFileName;
            return(response);
        }
    public override void RemoveDockableAttachment(BaseAttachment attach)
    {
        base.RemoveDockableAttachment(attach);
        attach.SetToolmodeResponse(new BaseTool.ToolMode[] {
            BaseTool.ToolMode.GRABBING
        });

        Destroy(m_volumetrics[attach]);

        attach.DisableControls();
        attach.rigidbody.isKinematic = false;
        PlaceObjects();
    }
Esempio n. 18
0
    public override bool AddDockableAttachment(BaseAttachment attach)
    {
        SliderAttachment slider = attach as SliderAttachment;

        slider.SetCloneable(false);
        slider.SetIsDraggable(true);
        slider.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.GRABBING });
        slider.DockInto(m_paramscroller);

        //iTween.MoveTo(slider.gameObject, iTween.Hash("position", transform.position, "time", 0.5f, "islocal", true));
        //iTween.RotateTo(slider.gameObject, iTween.Hash("rotation", transform.rotation, "time", 0.5f));

        return(true);
    }
Esempio n. 19
0
    /*
     * Tool exit state
     */
    public override void TransitionOut()
    {
        if (m_attachment != null)
        {
            LeavingProximity();
            if (HydraController.Instance.IsHandDragging(m_hand))
            {
                HydraController.Instance.GetHandDragging(m_hand).StopDragging();
            }
            m_attachment.Gesture_Exit();
        }

        m_heldObject = null;
        m_attachment = null;
    }
    public override void RemoveDockableAttachment(BaseAttachment attach)
    {
        base.RemoveDockableAttachment(attach);

        RBFTrainingAttachment rbfAttach = attach as RBFTrainingAttachment;

        rbfAttach.SetToolmodeResponse(new BaseTool.ToolMode[] {
            BaseTool.ToolMode.GRABBING
        });

        foreach (RBFPlugAttachment plug in m_plugs)
        {
            rbfAttach.RemovePlugValue(plug);
        }

        attach.rigidbody.isKinematic = false;
    }
 public override bool AddDockableAttachment(BaseAttachment attach)
 {
     if (base.AddDockableAttachment(attach))
     {
         ClipCubeHolder holder = FindClosestHolder(attach.transform.position);
         if (holder.attach == null)
         {
             attach.SetCloneable(false);
             holder.attach           = attach;
             attach.transform.parent = holder.placeholder;
             iTween.MoveTo(attach.gameObject, iTween.Hash("position", Vector3.zero, "islocal", true, "time", 0.5f));
             attach.transform.rotation = holder.placeholder.rotation;
             return(true);
         }
     }
     return(false);
 }
Esempio n. 22
0
    public override bool AddDockableAttachment(BaseAttachment attach)
    {
        if (base.AddDockableAttachment(attach))
        {
            CalculateDisplayedItems();

            attach.transform.parent = m_controlHolder.transform;
            //attach.transform.localPosition = new Vector3(0.0f, m_childDockables.Count * attach.interiorTrigger.GetSize().y, 0.0f);
            attach.transform.localRotation = Quaternion.identity;
            attach.transform.localScale    = new Vector3(m_itemScale, m_itemScale, m_itemScale);
            m_lastAttachHeight             = attach.interiorTrigger.GetSize().y + m_itemSpacing;
            m_lastAttachWidth = attach.interiorTrigger.GetSize().x;
            PlaceObjects();
            UpdateColliders(new Vector3(m_lastAttachWidth * 0.5f, (m_upperVisibleBounds - m_lowerVisibleBounds) * 0.5f, 0.0f), new Vector3(m_lastAttachWidth, m_upperVisibleBounds - m_lowerVisibleBounds, m_collisionDepth));
            return(true);
        }
        return(false);
    }
Esempio n. 23
0
    public virtual void DockIntoClosest()
    {
        GameObject[]   docks            = GameObject.FindGameObjectsWithTag("ParentIsADock");
        BaseAttachment closestValidDock = null;
        float          closestDist      = 0.0f;

        foreach (GameObject dockTag in docks)
        {
            BaseAttachment dockAttach = dockTag.transform.parent.GetComponent <BaseAttachment>();

            if (dockAttach.DockAcceptsType(this.GetType()))
            {
                if (closestValidDock == null)
                {
                    closestDist      = Vector3.Distance(dockAttach.transform.position, transform.position);
                    closestValidDock = dockAttach;
                }
                float dist = Vector3.Distance(dockAttach.transform.position, transform.position);
                if (dist < closestDist)
                {
                    closestValidDock = dockAttach;
                    closestDist      = dist;
                }
            }
        }

        if (closestValidDock != null)
        {
            if (IsInDockingRange(closestValidDock, closestValidDock.dockingRange))
            {
                DockInto(closestValidDock);
            }
            else
            {
                Floating();
            }
        }
        else
        {
            Floating();
        }
    }
Esempio n. 24
0
    /*
     * Dock modifiers
     */
    public virtual bool AddDockableAttachment(BaseAttachment attach)
    {
        if (m_childDockables == null)
        {
            m_childDockables = new List <BaseAttachment>();
        }

        if (DockAcceptsType(attach.GetType()))
        {
            m_childDockables.Add(attach);
            attach.transform.parent = transform;

            return(true);
        }
        else
        {
            Debug.LogError(this + " can't dock with a " + attach.GetType());
        }
        return(false);
    }
Esempio n. 25
0
        public static BaseAttachment CreateGhostDragger(BaseAttachment attach)
        {
            BaseAttachment ghostAttach = null;

            if (attach.GetType() == typeof(SliderAttachment))
            {
                SliderAttachment slider = attach as SliderAttachment;
                ghostAttach = UIFactory.CreateSlider(slider.musicRef, UIFrame.AnchorLocation.BOTTOM_LEFT);
            }
            else if (attach.GetType() == typeof(ClipButtonAttachment))
            {
                ClipButtonAttachment clipButton = attach as ClipButtonAttachment;
                ghostAttach = UIFactory.CreateClipButton(clipButton.musicRef, UIFrame.AnchorLocation.BOTTOM_LEFT);
            }
            else if (attach.GetType() == typeof(ClipCubeAttachment))
            {
                ClipCubeAttachment cubeButton = attach as ClipCubeAttachment;
                ghostAttach = UIFactory.CreateClipCube(cubeButton.musicRef);
            }
            else if (attach.GetType() == typeof(InstrumentAttachment))
            {
                InstrumentAttachment instrument = attach as InstrumentAttachment;
                ghostAttach = UIFactory.CreateInstrument(instrument.musicRef);
            }
            else if (attach.GetType() == typeof(RBFTrainingSpawnerAttachment))
            {
                ghostAttach = UIFactory.CreateRBFSphereTraining();
            }

            ghostAttach.transform.parent     = attach.transform;
            ghostAttach.transform.position   = attach.transform.position;
            ghostAttach.transform.localScale = attach.transform.localScale;
            ghostAttach.transform.parent     = null;
            ghostAttach.SetTransient(true);
            ghostAttach.SetCloneable(false);

            return(ghostAttach);
        }
 public void SetParentAttachment(BaseAttachment attachment)
 {
     m_ParentAttachment = attachment;
 }
Esempio n. 27
0
 public override void RemoveDockableAttachment(BaseAttachment attach)
 {
     base.RemoveDockableAttachment(attach);
     m_paramscroller.RemoveDockableAttachment(attach);
 }