public void DisableObjectsExcept(ModelingObject selectedObject)
    {
        foreach (Transform model in this.transform)
        {
            if (model.CompareTag("ModelingObject"))
            {
                ModelingObject currentModelingObject = model.GetComponent <ModelingObject> ();

                if (currentModelingObject != selectedObject)
                {
                    currentModelingObject.DeActivateCollider();
                    currentModelingObject.DarkenColorObject();
                }
            }
            else if (model.CompareTag("Group"))
            {
                Group currentGroup = model.GetComponent <Group> ();

                if (currentGroup != selectedObject.group)
                {
                    currentGroup.DeActivateCollider();
                    currentGroup.DarkenColorObject();
                }
            }
        }
    }
    public void StopMovingObject(ModelingObject movedObject)
    {
        foreach (Transform unit in this.transform)
        {
            if (unit.CompareTag("ModelingObject"))
            {
                ModelingObject currentModelingObject = unit.GetComponent <ModelingObject> ();

                if (currentModelingObject != movedObject)
                {
                    currentModelingObject.StopUseAsPossibleSnap();
                }
            }

            if (unit.CompareTag("Group"))
            {
                if (unit.transform != movedObject.group)
                {
                    foreach (Transform groupElement in unit.transform)
                    {
                        if (groupElement.CompareTag("ModelingObject"))
                        {
                            ModelingObject currentModelingObject = groupElement.GetComponent <ModelingObject> ();

                            if (currentModelingObject != movedObject)
                            {
                                currentModelingObject.StopUseAsPossibleSnap();
                            }
                        }
                    }
                }
            }
        }
    }
 public void AddObjectToGroup(Group group, ModelingObject modelingObject)
 {
     modelingObject.transform.SetParent(group.transform);
     modelingObject.group = group;
     group.objectList.Add(modelingObject);
     group.DrawBoundingBox();
 }
 public void TakeObjectOutOfGroup(Group group, ModelingObject modelingObject)
 {
     modelingObject.transform.SetParent(group.transform.parent);
     modelingObject.group = null;
     group.objectList.Remove(modelingObject);
     group.DrawBoundingBox();
 }
Example #5
0
 public void OpenMainMenu(ModelingObject modelingObject, Selection controller)
 {
     currentModelingObject = modelingObject;
     // let menu always face controller that selected object
     player = controller.transform;
     MainMenu.GetComponent <UIMenu>().ActivateMenu();
 }
Example #6
0
    // Use this for initialization
    void Start()
    {
        if (arrow != null)
        {
            // Hover effect: Scale bigger & change color
            LeanTween.color(arrow, normalColor, 0.06f);

            if (rotationArrow != null)
            {
                LeanTween.color(rotationArrow, normalColor, 0.06f);
            }
        }

        ResetLastPosition();
        connectedModelingObject = connectedObject.GetComponent <ModelingObject>();

        if (arrow != null)
        {
            initialSizeArrow = arrow.transform.localScale;
        }

        if (typeOfHandle == handleType.RotationHandleToggle)
        {
            standardPosBottom = bottomPartSphere.transform.localPosition;
        }
        //initialScale = transform.lossyScale.x;
    }
Example #7
0
 public void ColorGroup(ModelingObject initiater, Color color)
 {
     for (int i = 0; i < objectList.Count; i++)
     {
         if (objectList[i] != initiater)
         {
             objectList[i].ChangeColor(color, false);
         }
     }
 }
Example #8
0
 public void StartScalingGroup(ModelingObject initiater)
 {
     for (int i = 0; i < objectList.Count; i++)
     {
         if (objectList[i] != initiater)
         {
             objectList[i].StartScaling(false);
         }
     }
 }
Example #9
0
 public void ScaleBy(float newScale, ModelingObject initiater)
 {
     for (int i = 0; i < objectList.Count; i++)
     {
         if (objectList[i] != initiater)
         {
             objectList[i].ScaleBy(newScale, false);
         }
     }
 }
 void OnTriggerExit(Collider other)
 {
     if (possibleSnapping != null && parentMoving && other.gameObject.CompareTag("ColliderSphere"))
     {
         if (other.transform.parent.gameObject == possibleSnapping.gameObject)
         {
             other.gameObject.GetComponent <ColliderSphere> ().SnappedToThis = null;
             possibleSnapping = null;
         }
     }
 }
 void OnTriggerEnter(Collider other)
 {
     if (parentMoving && other.gameObject.CompareTag("ColliderSphere"))
     {
         if (other.gameObject.GetComponent <ColliderSphere> ().SnappedToThis == null)
         {
             possibleSnapping = other.transform.parent.GetComponent <ModelingObject>();
             other.gameObject.GetComponent <ColliderSphere> ().SnappedToThis = transform.parent.GetComponent <ModelingObject> ();
         }
     }
 }
Example #12
0
    public void SetLowestObjectOfGroup()
    {
        lowestModObject = objectList [0];

        for (int i = 0; i < objectList.Count; i++)
        {
            if (objectList [i].transform.position.y < lowestModObject.transform.position.y)
            {
                lowestModObject = objectList[i];
            }
        }
    }
Example #13
0
    public void StopMoving(Selection controller, ModelingObject initiater)
    {
        DrawBoundingBox();

        for (int i = 0; i < objectList.Count; i++)
        {
            if (objectList[i] != initiater)
            {
                objectList[i].StopMoving(controller, initiater);
            }
        }
    }
Example #14
0
    public void Move(Vector3 distance, ModelingObject initiater)
    {
        boundingBox.ClearBoundingBox();

        for (int i = 0; i < objectList.Count; i++)
        {
            if (objectList[i] != initiater)
            {
                // apply a similar movement
                objectList[i].MoveModelingObject(distance);
            }
        }
    }
Example #15
0
    public void RotateGroup(ModelingObject initiater, Vector3 angleAxis, float angle)
    {
        // use
        RotationCenter = GetBoundingBoxCenter();

        for (int i = 0; i < objectList.Count; i++)
        {
            if (objectList[i] != initiater)
            {
                //   objectList[i].RotateAround(angleAxis, angle);
            }
        }
    }
Example #16
0
    public void TrashGroup(ModelingObject initiater)
    {
        boundingBox.ClearBoundingBox();

        for (int i = 0; i < objectList.Count; i++)
        {
            if (objectList[i] != initiater)
            {
                objectList[i].TrashObject(false);
            }
        }

        ObjectsManager.Instance.DeleteGroup(this);
    }
Example #17
0
    public void UnFocusGroup(ModelingObject initiater, Selection controller)
    {
        if (!selected)
        {
            focused = false;

            boundingBox.ClearBoundingBox();

            for (int i = 0; i < objectList.Count; i++)
            {
                objectList [i].UnHighlight();
                objectList [i].HideBoundingBox(false);
            }
        }
    }
    public void SaveCurrentState()
    {
        Debug.Log("Save castle");
        String fullPathForSave = filePathSave + "CastleSave" + UserID + "_session" + sessionNumber + "_" + saveNumber + ".xml";

        saveNumber++;

        fs = File.Create(fullPathForSave);
        fs.Dispose();

        // create the string

        //String xmlRepresentation = "<?xml version="1.0" encoding="UTF - 8"?>\n";

        String xmlRepresentation = "";

        xmlRepresentation += "<castle>\n";
        xmlRepresentation += "<userID>" + UserID + "</userID>\n";
        xmlRepresentation += "<session>" + sessionNumber + "</session>\n";
        xmlRepresentation += "<creation>\n";

        foreach (Transform child in ObjectsManager.Instance.transform)
        {
            if (child.CompareTag("ModelingObject"))
            {
                ModelingObject currentModelingobject = child.GetComponent <ModelingObject>();
                xmlRepresentation += CreateObjectXML(currentModelingobject);
            }
            else
            {
                // group
                foreach (Transform groupChild in child)
                {
                    if (groupChild.CompareTag("ModelingObject"))
                    {
                        ModelingObject currentModelingobject = groupChild.GetComponent <ModelingObject> ();
                        xmlRepresentation += CreateObjectXML(currentModelingobject);
                    }
                }
            }
        }
        xmlRepresentation += "</creation>\n";

        xmlRepresentation += "</castle>\n";

        File.AppendAllText(fullPathForSave, xmlRepresentation);
    }
    public void ReachGoal()
    {
        ModelingObject currentObj = selection.currentSelection.GetComponent <ModelingObject> ();

        currentObj.PositionHandles(true);
        currentObj.RotateHandles();
        currentObj.handles.ShowNonUniformScalingHandles();

        if (currentObj.handles.rotationHandlesvisible)
        {
            currentObj.handles.ShowRotationHandles();
        }

        currentObj.DrawConnectingLines();

        moving = false;
    }
    public void MoveCameraCenterToObject()
    {
        moving = true;

        ModelingObject currentObj = selection.currentSelection.GetComponent <ModelingObject> ();

        currentObj.handles.HideRotationHandlesExcept(null);
        currentObj.handles.HideScalingHandlesExcept(null);
        currentObj.connectingLinesHandles.ClearLines();


        // get desired distance based on objet size?
        //desiredDistance = 5f;

        LeanTween.move(target.gameObject, currentObj.GetBoundingBoxCenter(), 0.8f).setEase(LeanTweenType.easeInOutExpo).setOnComplete(ReachGoal);

        // maybe also implement move closer
    }
Example #21
0
    public void FocusGroup(ModelingObject initiater, Selection controller)
    {
        if (!focused)
        {
            focused = true;

            DrawBoundingBox();

            /*
             * for (int i = 0; i < objectList.Count; i++) {
             *      if (objectList[i] != initiater)
             *      {
             *              objectList [i].Highlight ();
             *              objectList [i].ShowBoundingBox (false);
             *      }
             * }*/
        }
    }
    public void DuplicateObject(ModelingObject original, Group group, Vector3 objectPosition)
    {
        //Debug.Log ("before: " + objectPosition);
        //Debug.Log ("after inverse transform point: " + original.transform.InverseTransformPoint (objectPosition));

        if (original.complexObject.transform.childCount == 0)
        {
            createNewObject(original.typeOfObject, null, original, objectPosition, true, group, original.currentColor, null);
        }
        else
        {
            createNewObject(original.typeOfObject, null, original, objectPosition, true, group, original.currentColor, original.complexObject.transform.GetChild(0).gameObject);
        }

        if (group == null)
        {
            DuplicateAnimaton(original.GetBoundingBoxCenter());
        }
    }
    public ModelingObject GetlatestObject()
    {
        int i = 0;

        foreach (Transform model in this.transform)
        {
            if (model.CompareTag("ModelingObject"))
            {
                if (model.GetComponent <ModelingObject>().ObjectID > i)
                {
                    i = model.GetComponent <ModelingObject>().ObjectID;
                }
            }
        }

        ModelingObject m = GameObject.Find("Object " + i).GetComponent <ModelingObject>();

        return(m);
    }
    public void EnableObjects()
    {
        foreach (Transform model in this.transform)
        {
            if (model.CompareTag("ModelingObject"))
            {
                ModelingObject currentModelingObject = model.GetComponent <ModelingObject> ();

                currentModelingObject.ActivateCollider();
                currentModelingObject.NormalColorObject();
            }
            else if (model.CompareTag("Group"))
            {
                Group currentGroup = model.GetComponent <Group> ();

                currentGroup.ActivateCollider();
                currentGroup.NormalColorObject();
            }
        }
    }
 public void InitializeFace(int numberOfVertices)
 {
     vertexBundles        = new VertexBundle[numberOfVertices];
     parentModelingObject = transform.parent.parent.GetComponent <ModelingObject>();
 }
    public void createNewObject(ModelingObject.ObjectType type, Face groundface, ModelingObject original, Vector3 offSet, bool insideStage, Group group, Color color, GameObject complexObject)
    {
        Mesh mesh = new Mesh();

        if (type == ModelingObject.ObjectType.triangle)
        {
            mesh = triangle;
        }
        else if (type == ModelingObject.ObjectType.square)
        {
            mesh = square;
        }
        else if (type == ModelingObject.ObjectType.octagon)
        {
            mesh = octagon;
        }

        GameObject newObject = Instantiate(modelingObject);

        if (insideStage)
        {
            newObject.transform.SetParent(objects);
        }
        else
        {
            newObject.transform.SetParent(library);
        }

        ModelingObject newModelingObject = newObject.GetComponent <ModelingObject>();

        newObject.name             = "Object " + objectIDcount;
        newModelingObject.ObjectID = objectIDcount;
        objectIDcount++;

        newModelingObject.typeOfObject = type;

        newObject.GetComponent <ModelingObject>().Initiate(mesh);

        if (groundface != null)
        {
            newObject.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
            newObject.transform.position         = groundface.center.transform.TransformPoint(groundface.center.coordinates + groundface.normal * 0.4f);
            newObject.transform.localScale       = groundface.transform.parent.parent.transform.localScale;

            newModelingObject.bottomFace.ReplaceFaceOnOtherFace(groundface, new Vector3(0f, 0f, 0f), true);
            newModelingObject.topFace.ReplaceFaceOnOtherFace(groundface, groundface.normal.normalized * 0.1f, false);

            // recalculate centers
            newModelingObject.RecalculateCenters();

            // recalculate normals
            newModelingObject.RecalculateNormals();
        }
        else
        {
            if (insideStage)
            {
                newObject.transform.localScale       = new Vector3(1f, 1f, 1f);
                newObject.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
                newObject.transform.localPosition    = new Vector3(0f, 0f, 0f);
                newObject.transform.localPosition    = offSet;
            }
            else
            {
                newObject.transform.localPosition = offSet;
                newObject.transform.localScale    = new Vector3(0.8f, 0.8f, 0.8f);
            }
        }

        if (original != null)
        {
            // SetVertexBundlePositions(Vector3[] topFaceCoordinates, Vector3[] bottomFaceCoordinates, Vector3 topFaceCenter, Vector3 bottomFaceCenter)

            Vector3[] topFaceCoordinates    = new Vector3[original.topFace.vertexBundles.Length];
            Vector3[] bottomFaceCoordinates = new Vector3[original.bottomFace.vertexBundles.Length];

            for (int i = 0; i < topFaceCoordinates.Length; i++)
            {
                topFaceCoordinates[i] = original.topFace.vertexBundles[i].coordinates;
            }

            for (int i = 0; i < bottomFaceCoordinates.Length; i++)
            {
                bottomFaceCoordinates[i] = original.bottomFace.vertexBundles[i].coordinates;
            }

            newModelingObject.SetVertexBundlePositions(topFaceCoordinates, bottomFaceCoordinates, original.topFace.centerPosition, original.bottomFace.centerPosition);
            newObject.transform.localPosition = offSet;

            newModelingObject.coordinateSystem.transform.localRotation = original.coordinateSystem.transform.localRotation;
        }

        // newModelingObject.CorrectOffset();
        newModelingObject.CalculateBoundingBox();
        newModelingObject.InitiateHandles();

        if (group != null)
        {
            ObjectsManager.Instance.AddObjectToGroup(group, newModelingObject);
            //newObject.transform.position = offSet;
        }

        newModelingObject.ChangeColor(color, false);
        latestModelingObject = newModelingObject;

        if (complexObject != null)
        {
            newModelingObject.InsertObject(complexObject);
        }
    }
Example #27
0
 public void Initialize()
 {
     parentVertexBundle = transform.parent.GetComponent <VertexBundle>();
     parentObject       = transform.parent.parent.parent.parent.GetComponent <ModelingObject>();
     initialized        = true;
 }
Example #28
0
 public void SelectGroup(ModelingObject initiater)
 {
     selected = true;
     DrawBoundingBox();
 }
Example #29
0
 public void DeSelectGroup(ModelingObject initiator, Selection controller)
 {
     selected = false;
     boundingBox.ClearBoundingBox();
     UnFocusGroup(initiator, controller);
 }
Example #30
0
 public void Initialize()
 {
     parentVertexBundle = transform.parent.GetComponent<VertexBundle>();
     parentObject = transform.parent.parent.parent.parent.GetComponent<ModelingObject>();
     initialized = true;
 }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0) && movingHandle)
        {
            currentFocus.GetComponent <handle> ().FinishUsingHandle(this);
            movingHandle   = false;
            triggerPressed = false;
        }

        RaycastHit hit;

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (pointOfCollisionGO != null)
        {
            float distance;
            if (dragPlane.Raycast(ray, out distance))
            {
                pointOfCollisionGO.transform.position = ray.GetPoint(distance);
                //Debug.Log ("point of coll at" + pointOfCollisionGO.transform.position);
            }
        }

        // only change focus is the object is not moved at the moment

        // adjust this for touch

        if (!movingObject && !movingHandle && !scalingObject && !triggerPressed &&
            ((!TouchManager.Instance.touchActive && !Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2)) ||
             (TouchManager.Instance.touchActive)))
        {
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                if (Physics.Raycast(ray, out hit))
                {
                    if (currentSelectionMode == selectionMode.laserpointer)
                    {
                        pointOfCollision = hit.point;
                    }

                    if (currentSelectionMode == selectionMode.laserpointer)
                    {
                        if (hit.rigidbody != null && hit.rigidbody.transform.parent != null)
                        {
                            collisionObject = hit.rigidbody.transform.parent.gameObject;
                        }
                        else
                        {
                            collisionObject = null;
                        }
                    }

                    if (collisionObject != null)
                    {
                        if (currentFocus != collisionObject || recheckFocus)
                        {
                            count++;

                            recheckFocus = false;

                            if (collisionObject.CompareTag("ModelingObject"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <ModelingObject> ().Focus(this);
                            }
                            else if (collisionObject.CompareTag("Handle"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <handle> ().Focus(this);
                            }
                            else if (collisionObject.CompareTag("UiElement") && UiCanvasGroup.Instance.visible)
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <UiElement> ().Focus(this);
                            }
                            else if (!UiCanvasGroup.Instance.visible && collisionObject.CompareTag("TeleportTrigger"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <TeleportationTrigger> ().Focus(this);
                            }
                            else if (collisionObject.CompareTag("SelectionButton"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <ObjectSelecter> ().Focus(this);
                                if (currentFocus.GetComponent <ObjectSelecter> ().connectedObject != null)
                                {
                                    currentFocus.GetComponent <ObjectSelecter> ().connectedObject.Focus(this);
                                }
                            }
                            else if (!UiCanvasGroup.Instance.visible && collisionObject.CompareTag("TeleportPosition"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <TeleportationPosition> ().Focus(this);
                            }
                            else if (!UiCanvasGroup.Instance.visible && collisionObject.CompareTag("Library"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                library.Instance.Focus(this);
                            }
                            else if (collisionObject.CompareTag("HeightControl"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <StageHeightController> ().Focus(this);
                            }
                            else if (collisionObject.CompareTag("DistanceControl"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <StageDistanceController> ().Focus(this);
                            }
                            else if (collisionObject.CompareTag("Stage") && typeOfController == controllerType.mainController)
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <StageFreeMovement> ().Focus(this);
                            }
                            else if (collisionObject.CompareTag("InfoPanel"))
                            {
                                DeFocusCurrent(collisionObject);
                                currentFocus = collisionObject;
                                currentFocus.GetComponent <Infopanel> ().Focus(this);
                            }
                            else
                            {
                                DeFocusCurrent(null);
                            }
                        }
                    }
                    else
                    {
                        if (currentFocus != null && collisionObject == null)
                        {
                            DeFocusCurrent(null);
                            temps = Time.time;
                        }
                    }
                }
                else
                {
                    if (currentFocus != null || (currentSelectionMode == selectionMode.directTouch && collisionObject == null))
                    {
                        DeFocusCurrent(null);
                        temps = Time.time;
                    }
                }
            }
            else
            {
                if (currentFocus != null)
                {
                    DeFocusCurrent(null);
                    temps = Time.time;
                }
            }


            if (currentlyFocusedUiElement != null && currentSelection != null)
            {
                // check which element is hovered and focus right 3d handle
                if (currentlyFocusedUiElement.typeOfThis == NewUielement.typeOfUiElement.YMovement)
                {
                    GameObject chosenHandle = currentSelection.GetComponent <ModelingObject> ().handles.YMovement;
                    DeFocusCurrent(chosenHandle);
                    currentFocus = chosenHandle;
                    currentFocus.GetComponent <handle> ().Focus(this);
                    pointOfCollision = chosenHandle.transform.position;
                }
                else if (currentlyFocusedUiElement.typeOfThis == NewUielement.typeOfUiElement.UniformScale)
                {
                    GameObject chosenHandle = currentSelection.GetComponent <ModelingObject> ().handles.UniformScale.transform.GetChild(0).gameObject;
                    DeFocusCurrent(chosenHandle);
                    currentFocus = chosenHandle;
                    currentFocus.GetComponent <handle> ().Focus(this);
                    pointOfCollision = chosenHandle.transform.position;
                }
                else if (currentlyFocusedUiElement.typeOfThis == NewUielement.typeOfUiElement.ToggleRotation)
                {
                    GameObject chosenHandle = currentSelection.GetComponent <ModelingObject> ().handles.ToggleRotateOnOff;
                    DeFocusCurrent(chosenHandle);
                    currentFocus = chosenHandle;
                    currentFocus.GetComponent <handle> ().Focus(this);
                    pointOfCollision = chosenHandle.transform.position;
                }
                else if (currentlyFocusedUiElement.typeOfThis == NewUielement.typeOfUiElement.RotateX)
                {
                    GameObject chosenHandle = currentSelection.GetComponent <ModelingObject> ().handles.RotateX;
                    DeFocusCurrent(chosenHandle);
                    currentFocus = chosenHandle;
                    currentFocus.GetComponent <handle> ().Focus(this);
                    pointOfCollision = chosenHandle.transform.position;
                }
                else if (currentlyFocusedUiElement.typeOfThis == NewUielement.typeOfUiElement.RotateY)
                {
                    GameObject chosenHandle = currentSelection.GetComponent <ModelingObject> ().handles.RotateY;
                    DeFocusCurrent(chosenHandle);
                    currentFocus = chosenHandle;
                    currentFocus.GetComponent <handle> ().Focus(this);
                    pointOfCollision = chosenHandle.transform.position;
                }
                else if (currentlyFocusedUiElement.typeOfThis == NewUielement.typeOfUiElement.RotateZ)
                {
                    GameObject chosenHandle = currentSelection.GetComponent <ModelingObject> ().handles.RotateZ;
                    DeFocusCurrent(chosenHandle);
                    currentFocus = chosenHandle;
                    currentFocus.GetComponent <handle> ().Focus(this);
                    pointOfCollision = chosenHandle.transform.position;
                }
            }
        }


        if (currentFocus != null)
        {
            if (Input.GetMouseButtonDown(0))
            {
                triggerPressed = true;
                temps          = Time.time;
            }

            if (triggerPressed && (currentFocus.CompareTag("ModelingObject") || currentFocus.CompareTag("TeleportPosition") || currentFocus.CompareTag("Stage") || currentFocus.CompareTag("Library") || currentFocus.CompareTag("DistanceControl") || currentFocus.CompareTag("HeightControl")) && typeOfController == controllerType.mainController)
            {
                if (!movingObject && !groupItemSelection)
                {
                    CreatePointOfCollisionPrefab(Vector3.up);
                    //CreatePointOfCollisionPrefab (Camera.main.transform.forward * (-1f));
                    movingObject = true;

                    if (currentFocus.CompareTag("ModelingObject"))
                    {
                        Logger.Instance.AddLine(Logger.typeOfLog.triggerOnObject);

                        if (currentSelection != null && currentFocus != currentSelection)
                        {
                            //WorldLocalToggle.Instance.Hide ();
                            currentSelection.GetComponent <ModelingObject> ().DeSelect(this);
                        }

                        if (!duplicateMode)
                        {
                            currentFocus.GetComponent <ModelingObject> ().StartMoving(this, currentFocus.GetComponent <ModelingObject> ());

                            if (typeOfController == controllerType.mainController)
                            {
                                //settingsButtonHelp.HideCompletely (false);
                            }
                        }
                        else
                        {
                            if (currentFocus.GetComponent <ModelingObject> ().group == null)
                            {
                                // needs to be local position
                                ObjectCreator.Instance.DuplicateObject(currentFocus.GetComponent <ModelingObject> (), null, currentFocus.transform.localPosition);
                            }
                            else
                            {
                                ObjectCreator.Instance.DuplicateGroup(currentFocus.GetComponent <ModelingObject> ().group, Vector3.zero);
                            }

                            ModelingObject duplicatedObject = ObjectCreator.Instance.latestModelingObject;

                            DeFocusCurrent(duplicatedObject.gameObject);

                            if (currentSelection != null)
                            {
                                currentSelection.GetComponent <ModelingObject> ().DeSelect(this);
                            }

                            currentFocus = duplicatedObject.gameObject;
                            duplicatedObject.Focus(this);
                            duplicatedObject.StartMoving(this, duplicatedObject);
                        }
                    }
                    else if (currentFocus.CompareTag("Library"))
                    {
                        library.Instance.StartMoving(this);
                    }
                    else if (currentFocus.CompareTag("HeightControl"))
                    {
                        currentFocus.GetComponent <StageHeightController> ().StartMoving(this);
                    }
                    else if (currentFocus.CompareTag("DistanceControl"))
                    {
                        currentFocus.GetComponent <StageDistanceController> ().StartMoving(this);
                    }
                }
                else if (currentFocus.CompareTag("Stage"))
                {
                    currentFocus.GetComponent <StageFreeMovement> ().StartMoving(this);
                }
            }
            else if (triggerPressed && (movingHandle || currentFocus.CompareTag("Handle")))
            {
                handle currentHandle = currentFocus.GetComponent <handle> ();

                if (!movingHandle)
                {
                    CreatePointOfCollisionPrefab(Camera.main.transform.forward * (-1f));

                    if (currentHandle.typeOfHandle == handle.handleType.Rotation)
                    {
                        movingHandle = currentHandle.ApplyChanges(pointOfCollisionGO, movingHandle, this);
                    }
                    movingHandle = true;
                }
                else
                {
                    movingHandle = currentHandle.ApplyChanges(pointOfCollisionGO, movingHandle, this);
                }

                //Debug.Log ("point of collisionpos " + pointOfCollisionGO.transform.position);
                //currentHandle.connectedObject.GetComponent<ModelingObject> ().HideBoundingBox ();
                // movingHandle = true;
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            triggerPressed    = false;
            grabbedIconOffset = Vector3.zero;

            if (movingHandle)
            {
                currentFocus.GetComponent <handle> ().FinishUsingHandle(this);
                movingHandle = false;
            }


            if (movingObject && typeOfController == controllerType.mainController)
            {
                //otherController.triggerPressed = false;
                //otherController.movingHandle = false;

                recheckFocus = true;

                if (currentFocus.CompareTag("ModelingObject"))
                {
                    currentFocus.GetComponent <ModelingObject> ().StopMoving(this, currentFocus.GetComponent <ModelingObject> ());

                    if (currentFocus.GetComponent <ModelingObject> ().inTrashArea)
                    {
                        UiCanvasGroup.Instance.CloseMenu(this);
                        currentFocus.GetComponent <ModelingObject> ().TrashObject(true);
                        trashInfopanel.CloseInfoPanel();
                    }
                    else
                    {
                        if (currentSelection != null)
                        {
                            if (currentSelection != currentFocus)
                            {
                                //currentSelection.GetComponent<ModelingObject> ().DeSelect (this);

                                if (currentSettingSelectionMode == settingSelectionMode.alwaysOpen)
                                {
                                    currentFocus.GetComponent <ModelingObject> ().Select(this, uiPositon.position);
                                }
                            }
                            else
                            {
                                UiCanvasGroup.Instance.ShowAgain(uiPositon.position);
                            }
                        }
                        else
                        {
                            if (currentSettingSelectionMode == settingSelectionMode.alwaysOpen)
                            {
                                currentFocus.GetComponent <ModelingObject> ().Select(this, uiPositon.position);
                            }
                        }
                    }
                }
                else if (currentFocus.CompareTag("TeleportPosition"))
                {
                    currentFocus.GetComponent <TeleportationPosition> ().StopMoving(this);
                    Teleportation.Instance.JumpToPos(5);
                }
                else if (currentFocus.CompareTag("Library"))
                {
                    library.Instance.StopMoving(this);
                }
                else if (currentFocus.CompareTag("HeightControl"))
                {
                    currentFocus.GetComponent <StageHeightController> ().StopMoving(this);
                }
                else if (currentFocus.CompareTag("DistanceControl"))
                {
                    currentFocus.GetComponent <StageDistanceController> ().StopMoving(this);
                }
                else if (currentFocus.CompareTag("Stage"))
                {
                    currentFocus.GetComponent <StageFreeMovement> ().StopMoving(this);
                }
            }

            ///Destroy (pointOfCollisionGO);
            if (pointOfCollisionGO != null)
            {
                pointOfCollisionGO.SetActive(false);
            }

            movingObject = false;

            if (currentFocus != null)
            {
                if (currentFocus.CompareTag("ModelingObject"))
                {
                    if (groupItemSelection)
                    {
                        if (currentFocus.GetComponent <ModelingObject> ().group == null)
                        {
                            ObjectsManager.Instance.AddObjectToGroup(ObjectsManager.Instance.currentGroup, currentFocus.GetComponent <ModelingObject> ());
                        }
                        else
                        {
                            if (currentFocus.GetComponent <ModelingObject> ().group != ObjectsManager.Instance.currentGroup)
                            {
                                ObjectsManager.Instance.AddAllObjectsOfGroupToGroup(ObjectsManager.Instance.currentGroup, currentFocus.GetComponent <ModelingObject> ().group);
                            }
                        }
                    }
                }
                else if (currentFocus.CompareTag("SelectionButton"))
                {
                    UiCanvasGroup.Instance.Show();
                    currentFocus.GetComponent <ObjectSelecter> ().Select(this, uiPositon.position);
                }
                else if (currentFocus.CompareTag("Handle"))
                {
                    handle currentHandle = currentFocus.GetComponent <handle> ();
                    currentHandle.ResetLastPosition();
                    currentHandle.UnLock();
                    currentHandle.UnFocus(this);
                    currentHandle.connectedObject.GetComponent <ModelingObject> ().ShowBoundingBox(true);
                }
                else if (currentFocus.CompareTag("UiElement") && UiCanvasGroup.Instance.visible && !movingObject && !movingHandle)
                {
                    if (Time.time - tempsUI > 0.1f)
                    {
                        tempsUI = Time.time;
                        currentFocus.GetComponent <UiElement> ().PerformAction(this);

                        if (currentFocus.GetComponent <UiElement> ().goal != null)
                        {
                            currentFocus.GetComponent <UiElement> ().goal.ActivateMenu();
                        }

                        Logger.Instance.AddLine(Logger.typeOfLog.uiElement);
                    }
                }
                else if (currentFocus.CompareTag("InfoPanel"))
                {
                    currentFocus.GetComponent <Infopanel> ().CloseInfoPanel();
                }
                else if (currentFocus.CompareTag("TeleportTrigger"))
                {
                    Teleportation.Instance.JumpToPos(currentFocus.GetComponent <TeleportationTrigger> ().triggerPos);
                }
            }

            temps = 0;
        }

        if (Input.GetKeyDown(KeyCode.LeftAlt))
        {
            duplicateMode = true;
        }

        if (Input.GetKeyUp(KeyCode.LeftAlt))
        {
            duplicateMode = false;
        }
    }