private void updatemove(Ray mouseary)
        {
            MouseState mouseState = Mouse.GetState();
            if (!lockedaxis)
            {
                if (mouseState.RightButton == ButtonState.Pressed)
                    ma.UpdateData();
                else
                {
                    if (activeObject.Length != 0)
                    {
                        axis = ma.UpdateData(mouseary);
                        if (axis != Axis.none && mouseState.LeftButton == ButtonState.Pressed)
                        {
                            lockedaxis = true;
                            mymouse = true;
                        }
                        else
                            mymouse = false;
                    }
                }
            }

            if (currentaction == null)
            {
                Vector3 transl = ma.transform.Translation;
                if (activeObject.Length != 0 && mouseState.LeftButton == ButtonState.Pressed && axis != Axis.none)
                {
                    //begin
                    lockedaxis = true;
                    //Vector3 transl = ma.transform.Translation;
                    currentaction = new Actions.DragPivotObject(activeObject, axis, new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), transl));
                    if (activeObject.Length == 1)
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    else
                        GameEngine.renderController.setRelative(threezeros);
                }
                else
                    if (activeObject.Length == 0)
                        GameEngine.renderController.setRelative(null);
                    else if (activeObject.Length == 1)
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    else GameEngine.renderController.setRelative(threezeros);
            }
            else
            {
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Released)
                {
                    //continue
                    lockedaxis = true;
                    Vector3 transl = ma.transform.Translation;
                    currentaction.UpdateAction(new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), transl));
                    ma.SetTransformMatrix(activeObject.middleMarix);

                    Vector3 difference = (Vector3)currentaction.ActionResult;
                    GameEngine.renderController.setRelative(new string[] { difference.X.ToString(), difference.Y.ToString(), difference.Z.ToString() });

                    return;
                }
                if (mouseState.LeftButton == ButtonState.Released && mouseState.RightButton == ButtonState.Released)
                {
                    //stop
                    lockedaxis = false;
                    if(currentaction.Valid())
                        editor.actions.AddNewAction(currentaction);
                    currentaction = null;
                    axis = Axis.none;

                    if (activeObject.Length == 1)
                    {
                        Vector3 transl = ma.transform.Translation;
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    }
                    else
                        GameEngine.renderController.setRelative(threezeros);

                    return;
                }
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Pressed)
                {
                    //abort
                    currentaction.CancelAction(this.editor);

                    ma.SetTransformMatrix(activeObject.middleMarix);
                    Vector3 transl = ma.transform.Translation;
                    if (activeObject.Length == 1)
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    else
                        GameEngine.renderController.setRelative(threezeros);

                    lockedaxis = false;
                    currentaction = null;
                    axis = Axis.none;
                    return;
                }

            }
        }
        private void updaterotatesame(Ray mouseary)
        {
            MouseState mouseState = Mouse.GetState();
            if (!lockedaxis)
            {
                if (mouseState.RightButton == ButtonState.Pressed)
                    rc.UpdateData();
                else
                {
                    if (activeObject.Length != 0)
                    {
                        axis = rc.UpdateData(mouseary);
                        if (axis != Axis.none && mouseState.LeftButton == ButtonState.Pressed)
                        {
                            lockedaxis = true;
                            mymouse = true;
                        }
                        else
                        {
                            mymouse = false;
                            if (activeObject.Length == 1)
                            {
                                Quaternion q;
                                Vector3 v, vs;

                                activeObject[0].transform.Decompose(out vs, out q, out v);
                                GameEngine.renderController.setRotationSame(new string[] { q.X.ToString(), q.Y.ToString(), q.Z.ToString(), q.W.ToString() });
                            }
                            else
                                GameEngine.renderController.setRotationSame(new string[] { "0", "0", "0", "1" });
                        }
                    }
                    else GameEngine.renderController.setRelative(null);
                }
            }

            if (currentaction == null)
            {
                if (mouseState.LeftButton == ButtonState.Pressed && axis != Axis.none)
                {
                    //begin
                    lockedaxis = true;
                    currentaction = new Actions.RotateSamePivotAction(activeObject, axis, new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), rc.transform.Translation));
                    Quaternion res = (Quaternion)currentaction.ActionResult;

                    GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                }

            }
            else
            {
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Released)
                {
                    //continue
                    lockedaxis = true;
                    currentaction.UpdateAction(new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), rc.transform.Translation));
                    // ma.SetTransformMatrix(activeObject.transform.TranslationMatrix());
                    rc.SetTransformMatrix(activeObject.middleMarix);
                    Quaternion res = (Quaternion)currentaction.ActionResult;
                    GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                    return;
                }
                if (mouseState.LeftButton == ButtonState.Released && mouseState.RightButton == ButtonState.Released)
                {
                    //stop
                    lockedaxis = false;
                    if (currentaction.Valid())
                        editor.actions.AddNewAction(currentaction);
                    if (activeObject.Length == 1)
                    {
                        Quaternion res = (Quaternion)currentaction.ActionResult;
                        GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                    }

                    currentaction = null;
                    axis = Axis.none;
                    return;
                }
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Pressed)
                {
                    //abort
                    currentaction.CancelAction(this.editor);

                    rc.SetTransformMatrix(activeObject.middleMarix);
                    lockedaxis = false;
                    if (activeObject.Length == 1)
                    {
                        Quaternion res = (Quaternion)currentaction.ActionResult;
                        GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                    }
                    currentaction = null;
                    axis = Axis.none;
                    return;
                }
            }
        }
        public void SwitchState(TransformManagerState newstate)
        {
            if (newstate != currentState)
            {
                mymouse = false;
                lockedaxis = false;
                axis = Axis.none;
                if (currentaction != null)
                {
                    currentaction.CancelAction(this.editor);
                    ma.SetTransformMatrix(activeObject.middleMarix);
                    lockedaxis = false;
                    currentaction = null;
                    axis = Axis.none;
                }
                switch (newstate)
                {
                    case TransformManagerState.move:
                        {
                            if (activeObject.Length != 0)
                                ma.SetTransformMatrix(activeObject.middleMarix);

                            Vector3 transl = ma.transform.Translation;
                            if (activeObject.Length == 1)
                                GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                            else
                                GameEngine.renderController.setRelative(threezeros);
                        }break;
                    case TransformManagerState.rotatelocal:
                    case TransformManagerState.rotatesame:
                        {
                            if (activeObject.Length != 0)
                                rc.SetTransformMatrix(activeObject.middleMarix);
                        }break;
                }
                currentState = newstate;
            }
        }