using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VisiMath;
using VisimBox;

namespace VisimBuilder
{
    //todo : uniform scaling, visual difference from the position gizmo

    class ScaleGizmo : MoveGizmo
    {
        public bool UniformScale = true;
        
        public ScaleGizmo(MainBuilderForm boss)
            : base(boss)
        {
            InLocalCoords = true;
        }
        
        public override void MyMove(float dist, VisiMath.Vector3 origo)
        {
            if (Boss.SelectedNode.Trans == null)
                return;

            Vector3 movement;

                switch ((MoveGizmoSelected)SelectedPart)
                {
                    case MoveGizmoSelected.XArrow:
                        if (UniformScale)
                            movement = new Vector3(dist * origo.X);
                        else
                            movement = new Vector3(dist * origo.X, 0, 0);
                        break;
                    case MoveGizmoSelected.YArrow:
                        if (UniformScale)
                            movement = new Vector3(dist * origo.Y);
                        else
                            movement = new Vector3(0, dist * origo.Y, 0);
                        break;
                    case MoveGizmoSelected.ZArrow:
                        if (UniformScale)
                            movement = new Vector3(dist * origo.Z);
                        else                            
                            movement = new Vector3(0, 0, dist * origo.Z);
                        break;
                    default:
                        return;
                }
            Boss.SelectedNode.Trans.Scale = Boss.SelectedNode.Trans.Scale + movement;
            Boss.SceneChanged = true;

            VisimBox.Physics.StaticCollision sc = Boss.SelectedNode as VisimBox.Physics.StaticCollision;
            if (sc != null)
            {
                if (Boss.Settings.StaticColUpdate)
                {
                    VisimEngine.Instance.MainScene.PhysScene.UpdateStaticCol(sc);
                }
                else Boss.StaticCollisionInvalid = true;
            }
        }
    }
}
