Ejemplo n.º 1
0
 private void MoveAxis(MoveArgs args)
 {
     if (AxisEdit)
     {
         currentSelected?.SendMessage("MoveAxis", args, SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 2
0
 private void Update()
 {
     OVRInput.Update();
     if (lhGripState && rhGripState && editSelected)
     {
         Vector3 rh      = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RHand);
         Vector3 lh      = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LHand);
         Vector3 newAxis = rh - lh;
         if (AxisEdit)
         {
             Vector3 AxisDelta = newAxis - axis;
             if (AxisDelta.magnitude > AxisSensitivity)
             {
                 MoveArgs args = new MoveArgs();
                 args.rotate = Quaternion.FromToRotation(axis, newAxis);
                 args.scale  = newAxis.magnitude / axis.magnitude;
                 MoveAxis(args);
                 axis = newAxis;
             }
         }
         else
         {
             AxisEdit = true;
             axis     = newAxis;
         }
     }
 }
Ejemplo n.º 3
0
        /// https://answers.unity.com/questions/14170/scaling-an-object-from-a-different-center.html
        public override void MoveAxis(MoveArgs args)
        {
            if (args.translate != Vector3.zero)
            {
                transform.Translate(args.translate, Space.World);
            }
            args.rotate.ToAngleAxis(out float angle, out Vector3 axis);
            transform.RotateAround(args.pos, axis, angle);
            Vector3 A  = transform.localPosition;
            Vector3 B  = transform.parent.InverseTransformPoint(args.pos);
            Vector3 C  = A - B;
            float   RS = args.scale;
            Vector3 FP = B + C * RS;

            if (FP.magnitude < float.MaxValue)
            {
                transform.localScale    = transform.localScale * RS;
                transform.localPosition = FP;
                for (int i = 0; i < transform.childCount; i++)
                {
                    Transform T = transform.GetChild(i);
                    if (T.GetComponent <Datapoint>() != null)
                    {
                        T.localScale /= RS;
                    }
                }
            }
            changed = true;
        }
Ejemplo n.º 4
0
 public override void Translate(MoveArgs args)
 {
     if (BlockMove)
     {
         transform.Translate(args.translate, Space.World);
     }
 }
Ejemplo n.º 5
0
 public override void VertexMove(MoveArgs data)
 {
     if (!BlockMove)
     {
         ShapeMoveVertex(data);
     }
 }
Ejemplo n.º 6
0
        public override void UnSelected(SelectionTypes button)
        {
            thisRenderer.material = mainMat;
            if (button != SelectionTypes.BROADCAST)
            {
                MoveArgs args = new MoveArgs();
                switch (AppState.instance.editSession.mode)
                {
                case EditSession.EditMode.None:
                    break;

                case EditSession.EditMode.SnapAnchor:
                    LayerMask       layerMask    = UnityLayers.POINT;
                    List <Collider> hitColliders = Physics.OverlapBox(transform.position, transform.TransformVector(Vector3.one / 2), Quaternion.identity, layerMask).ToList().FindAll(item => item.transform.position != transform.position);
                    if (hitColliders.Count > 0)
                    {
                        args.oldPos    = transform.position;
                        args.pos       = hitColliders.First <Collider>().transform.position;
                        args.id        = GetId();
                        args.translate = args.pos - args.oldPos;
                        SendMessageUpwards("Translate", args, SendMessageOptions.DontRequireReceiver);
                    }
                    break;

                case EditSession.EditMode.SnapGrid:
                    args.oldPos    = transform.position;
                    args.pos       = transform.position.Round(AppState.instance.map.transform.TransformVector(Vector3.one * (AppState.instance.project.ContainsKey("GridScale") && AppState.instance.project.GridScale != 0 ? AppState.instance.project.GridScale :  1f)).magnitude);;
                    args.id        = GetId();
                    args.translate = args.pos - transform.position;
                    SendMessageUpwards("Translate", args, SendMessageOptions.DontRequireReceiver);
                    break;
                }
            }
            transform.parent.SendMessageUpwards("UnSelected", button, SendMessageOptions.DontRequireReceiver);
        }
Ejemplo n.º 7
0
 public override void MoveTo(MoveArgs args)
 {
     if (selected)
     {
         SendMessageUpwards("Translate", args, SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 8
0
 public override void VertexMove(MoveArgs data)
 {
     if (VertexTable.Contains(new VertexLookup()
     {
         Id = data.id
     }))
     {
         VertexLookup vdata = VertexTable.Find(item => item.Id == data.id);
         foreach (VertexLookup vLookup in VertexTable)
         {
             if (vLookup.Line && vLookup.Line.vStart == vdata.Vertex)
             {
                 vLookup.Line.MoveStart(data.pos);
             }
             if (vLookup.Line && vLookup.Line.vEnd == vdata.Vertex)
             {
                 vLookup.Line.MoveEnd(data.pos);
             }
         }
         curve.Vector3(GetVertexPositions(), Lr);
         if (label)
         {
             label.position = _labelPosition();
         }
     }
     curve.Vector3(GetVertexPositions(), Lr);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// This is called by the parent to action the move
        /// </summary>
        /// <param name="args"></param>
        // https://answers.unity.com/questions/14170/scaling-an-object-from-a-different-center.html
        public void MoveAxisAction(MoveArgs args)
        {
            if (args.translate != null)
            {
                transform.Translate(args.translate, Space.World);
            }
            args.rotate.ToAngleAxis(out float angle, out Vector3 axis);
            transform.RotateAround(args.pos, axis, angle);
            Vector3 A  = transform.localPosition;
            Vector3 B  = transform.parent.InverseTransformPoint(args.pos);
            Vector3 C  = A - B;
            float   RS = args.scale;
            Vector3 FP = B + C * RS;

            if (FP.magnitude < float.MaxValue)
            {
                transform.localScale    = transform.localScale * RS;
                transform.localPosition = FP;
                for (int i = 0; i < transform.childCount; i++)
                {
                    Transform T = transform.GetChild(i);
                    if (T.GetComponent <LineSegment>() != null)
                    {
                        Vector3 local = T.localScale;
                        local       /= RS;
                        local.z      = T.localScale.z;
                        T.localScale = local;
                    }
                    else
                    {
                        T.localScale /= RS;
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public override void Translate(MoveArgs args)
 {
     if (args.translate != Vector3.zero)
     {
         transform.Translate(args.translate, Space.World);
     }
     changed = true;
 }
Ejemplo n.º 11
0
 private void moveTo(Vector3 to)
 {
     if (!AxisEdit)
     {
         MoveArgs args = new MoveArgs();
         args.translate = to - from;
         currentSelected?.SendMessage("MoveTo", args, SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 12
0
 void Update()
 {
     if (_appState.editSession.IsActive() && (_newFeature != null))
     {
         MoveArgs args = new MoveArgs();
         args.pos = _markerShape.transform.position;
         _lastVertex.ForEach(dp => dp.MoveTo(args));
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Move a vertex of the polygon and recreate the mesh
        /// </summary>
        /// <param name="data">MoveArgs</param>
        public void ShapeMoveVertex(MoveArgs data)
        {
            Mesh mesh = Shape.GetComponent <MeshFilter>().mesh;

            Vector3[] vertices = mesh.vertices;
            vertices[VertexTable.Find(item => item.Id == data.id).pVertex] = Shape.transform.InverseTransformPoint(data.pos);
            mesh.vertices = vertices;
            mesh.uv       = BuildUVs(vertices);
            mesh.RecalculateBounds();
            mesh.RecalculateNormals();
        }
Ejemplo n.º 14
0
 public override void Translate(MoveArgs args)
 {
     foreach (GameObject mesh in meshes)
     {
         if (args.translate != Vector3.zero)
         {
             transform.Translate(args.translate, Space.World);
         }
         changed = true;
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 ///  Sent by the parent entity to request this market to move as part of an entity move
 /// </summary>
 /// <param name="argsin">MoveArgs</param>
 void TranslateHandle(MoveArgs argsin)
 {
     if (argsin.id == GetId())
     {
         MoveArgs argsout = new MoveArgs();
         argsout.oldPos = transform.position;
         transform.Translate(argsin.translate, Space.World);
         argsout.id  = GetId();
         argsout.pos = transform.position;
         SendMessageUpwards("VertexMove", argsout, SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 16
0
 public override void Translate(MoveArgs args)
 {
     if (!BlockMove)
     {
         gameObject.BroadcastMessage("TranslateHandle", args, SendMessageOptions.DontRequireReceiver);
     }
     else
     {
         args.id = GetId();
         transform.parent.SendMessage("Translate", args, SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 17
0
 public override void MoveTo(MoveArgs args)
 {
     if (args.translate != Vector3.zero)
     {
         args.id = GetId();
         transform.parent.SendMessage("Translate", args, SendMessageOptions.DontRequireReceiver);
     }
     else if (args.pos != Vector3.zero && args.pos != transform.position)
     {
         args.id        = GetId();
         args.translate = args.pos - transform.position;
         transform.parent.SendMessage("Translate", args, SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 18
0
 public void Translate(MoveArgs args)
 {
     if (args.translate != Vector3.zero)
     {
         gameObject.transform.Translate(args.translate);
     }
     if (args.rotate != Quaternion.identity)
     {
         gameObject.transform.rotation = gameObject.transform.rotation * args.rotate;
     }
     if (args.scale != 0.0f)
     {
         gameObject.transform.localScale = gameObject.transform.localScale * args.scale;
     }
 }
Ejemplo n.º 19
0
        // https://answers.unity.com/questions/14170/scaling-an-object-from-a-different-center.html
        public override void MoveAxis(MoveArgs args)
        {
            if (args.translate != null)
            {
                Shape.transform.Translate(args.translate, Space.World);
            }
            args.rotate.ToAngleAxis(out float angle, out Vector3 axis);
            Shape.transform.RotateAround(args.pos, axis, angle);
            Vector3 A  = Shape.transform.localPosition;
            Vector3 B  = transform.InverseTransformPoint(args.pos);
            Vector3 C  = A - B;
            float   RS = args.scale;
            Vector3 FP = B + C * RS;

            if (FP.magnitude < float.MaxValue)
            {
                Shape.transform.localScale    = Shape.transform.localScale * RS;
                Shape.transform.localPosition = FP;
            }
        }
Ejemplo n.º 20
0
        // https://answers.unity.com/questions/14170/scaling-an-object-from-a-different-center.html
        public override void MoveAxis(MoveArgs args)
        {
            transform.parent.GetComponent <IVirgisEntity>().MoveAxis(args);
            transform.GetComponentsInChildren <Dataline>().ToList <Dataline>().ForEach(line => line.MoveAxisAction(args));
            if (args.translate != null)
            {
                Shape.transform.Translate(args.translate, Space.World);
            }
            args.rotate.ToAngleAxis(out float angle, out Vector3 axis);
            Shape.transform.RotateAround(args.pos, axis, angle);
            Vector3 A  = Shape.transform.localPosition;
            Vector3 B  = transform.InverseTransformPoint(args.pos);
            Vector3 C  = A - B;
            float   RS = args.scale;
            Vector3 FP = B + C * RS;

            if (FP.magnitude < float.MaxValue)
            {
                Shape.transform.localScale    = Shape.transform.localScale * RS;
                Shape.transform.localPosition = FP;
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Move a vertex of the polygon and recreate the mesh
        /// </summary>
        /// <param name="data">MoveArgs</param>
        public void ShapeMoveVertex(MoveArgs data)
        {
            Mesh         mesh = Shape.GetComponent <MeshFilter>().mesh;
            MeshCollider mc   = Shape.GetComponent <MeshCollider>();
            MeshRenderer mr   = Shape.GetComponent <MeshRenderer>();
            Material     mat  = mr.material;

            Destroy(mc);
            mc = Shape.AddComponent <MeshCollider>();
            Vector3[] vertices = mesh.vertices;
            vertices[VertexTable.Find(item => item.Id == data.id).pVertex] = Shape.transform.InverseTransformPoint(data.pos);
            mesh.vertices = vertices;
            mesh.uv       = BuildUVs(vertices);
            mesh.RecalculateBounds();
            mesh.RecalculateNormals();
            try {
                Physics.BakeMesh(mesh.GetInstanceID(), false);
                mc.sharedMesh = mesh;
            } catch (Exception e) {
                Debug.Log(e.ToString());
            }
            mat.SetVector("_Tiling", new Vector2(scaleX / _tiling_size, scaleY / _tiling_size));
        }
Ejemplo n.º 22
0
 public override void MoveTo(MoveArgs args)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 23
0
 public override void MoveAxis(MoveArgs args)
 {
     changed = true;
     Dataline[] dataFeatures = gameObject.GetComponentsInChildren <Dataline>();
     dataFeatures.ToList <Dataline>().Find(item => args.id == item.GetId()).MoveAxisAction(args);
 }
Ejemplo n.º 24
0
 public override void MoveAxis(MoveArgs args)
 {
     args.pos = transform.position;
     transform.parent.SendMessageUpwards("MoveAxis", args, SendMessageOptions.DontRequireReceiver);
 }
Ejemplo n.º 25
0
 public override void Translate(MoveArgs args)
 {
 }
Ejemplo n.º 26
0
 public override void MoveAxis(MoveArgs args)
 {
     args.pos = transform.position;
     transform.parent.GetComponent <IVirgisEntity>().MoveAxis(args);
 }
Ejemplo n.º 27
0
 public void Add(MoveArgs args)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 28
0
 public override void MoveAxis(MoveArgs args)
 {
     args.id = GetId();
     transform.parent.GetComponent <IVirgisEntity>().MoveAxis(args);
 }
Ejemplo n.º 29
0
 public override void Translate(MoveArgs args)
 {
     gameObject.BroadcastMessage("TranslateHandle", args, SendMessageOptions.DontRequireReceiver);
     changed = true;
 }
Ejemplo n.º 30
0
 public override void MoveAxis(MoveArgs args)
 {
 }