Beispiel #1
0
    //public static bool GetNeighbourIndexIn(int fromIndex, int fromTriIndex, int toIndex, out int result, MirrorAxis shiftedOnAxis)
    //{
    //    CubeRepresentation cube = new CubeRepresentation(toIndex);
    //    cube.MirrorRepresentation(shiftedOnAxis);
    //    return GetNeighbourIndexIn(fromIndex, fromTriIndex, cube.CubeIndex, out result);
    //}


    public static int RotateIndex(int triangulationIndex, MirrorAxis axis)
    {
        CubeRepresentation cube = new CubeRepresentation(triangulationIndex);

        cube.MirrorRepresentation(axis);
        return(cube.CubeIndex);
    }
Beispiel #2
0
        static void Main(string[] args)
        {
            //Get an IMirror to move the motor
            IMirror mirror = ClassFactory.CreateIMirror();

            //Loop through commands
            String quit = "n";

            do
            {
                //Get the axis
                Console.Write("Axis: (X)");
                String axisStr = Console.ReadLine();

                if (axisStr == String.Empty)
                {
                    axisStr = "X";
                }

                //Get the power
                Console.Write("Power: (25)");
                String powerStr = Console.ReadLine();

                if (powerStr == String.Empty)
                {
                    powerStr = "25";
                }

                //Get the degrees
                Console.Write("Degrees: (90)");
                String degStr = Console.ReadLine();

                if (degStr == String.Empty)
                {
                    degStr = "90";
                }

                //Move the Mirror
                MirrorAxis axis    = (MirrorAxis)Enum.Parse(typeof(MirrorAxis), axisStr);
                Int32      power   = Int32.Parse(powerStr);
                Int32      degrees = Int32.Parse(degStr);

                mirror.Move(axis, degrees);

                //Get the char to quit
                Console.Write("Quit: (n)");
                quit = Console.ReadLine();

                if (quit == String.Empty)
                {
                    quit = "n";
                }

                Console.WriteLine();
            }while (quit != "y");

            //Dispose of the Mirror
            mirror.Dispose();
        }
    private static void MirrorBoard(MirrorAxis axis)
    {
        if (BoardBeingPlaced.GetComponentsInChildren <CircuitBoard>().Length > 1)
        {
            return;
        }                                                                                    // everything will be screwed up if we have a board with other boards attached to it

        List <Transform> childcomponents = new List <Transform>();

        for (int i = 0; i < BoardBeingPlaced.transform.childCount; i++)
        {
            childcomponents.Add(BoardBeingPlaced.transform.GetChild(i));
        }

        foreach (Transform child in childcomponents)
        {
            if (axis == MirrorAxis.x)
            {
                float Xcenter            = (CircuitBoardBeingPlaced.x * 0.3f) / 2;
                float DistanceFromCenter = Mathf.Abs(Xcenter - child.localPosition.x);
                float NewX = child.localPosition.x;

                if (child.transform.localPosition.x > Xcenter)
                {
                    NewX = Xcenter - DistanceFromCenter;
                }
                else if (child.transform.localPosition.x < Xcenter)
                {
                    NewX = Xcenter + DistanceFromCenter;
                }

                child.transform.localPosition = new Vector3(NewX, child.transform.localPosition.y, child.transform.localPosition.z);
                Quaternion oldrot = child.transform.localRotation;
                child.transform.localRotation = new Quaternion(-oldrot.x, oldrot.y, oldrot.z, -oldrot.w); // this is my first time really using quaternions. I have absolutely no idea how this works, I found it on google
            }
            else
            {
                float Zcenter            = (CircuitBoardBeingPlaced.z * 0.3f) / 2;
                float DistanceFromCenter = Mathf.Abs(Zcenter - child.localPosition.z);
                float NewZ = child.localPosition.z;

                if (child.transform.localPosition.z > Zcenter)
                {
                    NewZ = Zcenter - DistanceFromCenter;
                }
                else if (child.transform.localPosition.z < Zcenter)
                {
                    NewZ = Zcenter + DistanceFromCenter;
                }

                child.transform.localPosition = new Vector3(child.transform.localPosition.x, child.transform.localPosition.y, NewZ);
                Quaternion oldrot = child.transform.localRotation;
                child.transform.localRotation     = new Quaternion(oldrot.x, oldrot.y, -oldrot.z, -oldrot.w);
                child.transform.localEulerAngles += new Vector3(180, 0, 180); // why is the previous effect always off by 180 on two axes? I don't f*****g know! Quaternions!!!!!!!!
            }

            StuffRotater.RedrawCircuitGeometryOf(BoardBeingPlaced);
        }
    }
Beispiel #4
0
 public void MirrorRepresentation(MirrorAxis axis)
 {
     if (axis == MirrorAxis.X)
     {
         Swap(RotateOnX);
     }
     else if (axis == MirrorAxis.Y)
     {
         Swap(RotateOnY);
     }
     else
     {
         Swap(RotateOnZ);
     }
 }
Beispiel #5
0
 public static int RotateCornerIndexOnAxis(int cornerIndex, MirrorAxis axis)
 {
     if (axis == MirrorAxis.X)
     {
         return(CubeRepresentation.RotateOnX(cornerIndex));
     }
     else if (axis == MirrorAxis.Y)
     {
         return(CubeRepresentation.RotateOnY(cornerIndex));
     }
     else
     {
         return(CubeRepresentation.RotateOnZ(cornerIndex));
     }
 }
        /// <summary>
        /// MoveMirror moves the specified mirror by the input
        /// amount of steps.
        /// </summary>
        /// <param name="type">The Type of Button that was clicked</param>
        /// <param name="step">The amount that the Mirror should be moved</param>
        /// <returns>Boolean TRUE if the mirror was moved, FALSE otherwise</returns>
        private Boolean MoveMirror(UpDown2D.ButtonType type, Int32 step)
        {
            //Declare a variable to return
            Boolean rtn = false;

            //Set the cursor appropriately
            Mouse.OverrideCursor = Cursors.Wait;

            //If the mirror still isn't created, show an error.
            //Otherwise, move the mirror.
            if (this._mirror == null)
            {
                this._eventAggregator.GetEvent <ErrorMessageEvent>().Publish(Strings.HardwareNotDetected);
            }
            else
            {
                //Save the SecondsPerStep value in the NewSpectrumInfo
                this.NewSpectrumInfo.SecondsPerStep = this._mirror.SecondsPerStep;

                //Translate the ButtonType into a MirrorAxis
                MirrorAxis axis = MirrorAxis.X;

                if (type == UpDown2D.ButtonType.Up || type == UpDown2D.ButtonType.Down)
                {
                    axis = MirrorAxis.Y;
                }

                //Try to move the mirror
                try
                {
                    //Call the Move Method
                    this._mirror.Move(axis, step);

                    //Set the return value to True to indicate success
                    rtn = true;
                }
                catch (System.Exception e)
                {
                    MessageBox.Show(e.Message, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            //Reset the Cursor
            Mouse.OverrideCursor = Cursors.Arrow;

            //Return the result
            return(rtn);
        }
Beispiel #7
0
 public static IEnumerable <int> RotateValuesOnAxis(IEnumerable <int> @is, MirrorAxis axis)
 {
     System.Func <int, int> f;
     if (axis == MirrorAxis.X)
     {
         f = CubeRepresentation.RotateOnX;
     }
     else if (axis == MirrorAxis.Y)
     {
         f = CubeRepresentation.RotateOnY;
     }
     else
     {
         f = CubeRepresentation.RotateOnZ;
     }
     return(@is.Select(f));
 }
Beispiel #8
0
        public HVRHandPose CreateFullHandPose(MirrorAxis axis, Transform transformOverride = null)
        {
            var hand = CreateHandPose(transformOverride);

            //var handMirror = hand.Mirror(axis, transform);
            var handMirror = Mirror(axis);

            var left  = IsLeft ? hand : handMirror;
            var right = IsLeft ? handMirror : hand;

            var handPose = ScriptableObject.CreateInstance <HVRHandPose>();

            handPose.SnappedLeft = Side == HVRHandSide.Left;
            handPose.LeftHand    = left;
            handPose.RightHand   = right;
            return(handPose);
        }
Beispiel #9
0
        public HVRHandPose CreateFullHandPoseWorld(MirrorAxis axis)
        {
            var hand = CreateHandPose();

            hand.Position = transform.position;
            hand.Rotation = transform.rotation;

            //var handMirror = hand.Mirror(axis, transform);
            var handMirror = Mirror(axis);

            var left  = IsLeft ? hand : handMirror;
            var right = IsLeft ? handMirror : hand;

            var handPose = ScriptableObject.CreateInstance <HVRHandPose>();

            handPose.SnappedLeft = Side == HVRHandSide.Left;
            handPose.LeftHand    = left;
            handPose.RightHand   = right;
            return(handPose);
        }
Beispiel #10
0
    public static int RotateEdgeIndexOn(int edgeIndex, MirrorAxis axis)
    {
        int result = edgeIndex;

        if (axis == MirrorAxis.X)
        {
            if (edgeIndex == 1 || edgeIndex == 5)
            {
                result = edgeIndex + 2;
            }
            else if (edgeIndex == 10)
            {
                result = 11;
            }
            else if (edgeIndex == 9)
            {
                result = 8;
            }
            else if (edgeIndex == 3 || edgeIndex == 7)
            {
                result = edgeIndex - 2;
            }
            else if (edgeIndex == 11)
            {
                result = 10;
            }
            else if (edgeIndex == 8)
            {
                result = 9;
            }
        }
        else if (axis == MirrorAxis.Y)
        {
            if (edgeIndex >= 0 && edgeIndex < 4)
            {
                result = edgeIndex + 4;
            }
            else if (edgeIndex < 8)
            {
                result = edgeIndex - 4;
            }
        }
        else
        {
            if (edgeIndex == 2 || edgeIndex == 6)
            {
                result = edgeIndex - 2;
            }
            else if (edgeIndex == 11)
            {
                result = 8;
            }
            else if (edgeIndex == 10)
            {
                result = 9;
            }
            else if (edgeIndex == 0 || edgeIndex == 4)
            {
                result = edgeIndex + 2;
            }
            else if (edgeIndex == 8)
            {
                result = 11;
            }
            else if (edgeIndex == 9)
            {
                result = 10;
            }
        }
        return(result);
    }
Beispiel #11
0
 public static Vector2Int RotateEdgeOn(int edge1, int edge2, MirrorAxis axis)
 {
     return(new Vector2Int(RotateEdgeIndexOn(edge1, axis), RotateEdgeIndexOn(edge2, axis)));
 }
Beispiel #12
0
 public static Vector2Int RotateEdgeOn(Vector2Int edge, MirrorAxis axis)
 {
     return(new Vector2Int(RotateEdgeIndexOn(edge.x, axis), RotateEdgeIndexOn(edge.y, axis)));
 }
Beispiel #13
0
        public HVRHandPoseData Mirror(MirrorAxis handMirrorAxis, Transform transformOverride = null)
        {
            var t = transformOverride ?? transform;

            var clone = new HVRHandPoseData();

            clone.Position = t.localPosition;

            Vector3 direction;

            switch (handMirrorAxis)
            {
            case MirrorAxis.X:
                clone.Position.x *= -1f;
                direction         = Vector3.right;
                break;

            case MirrorAxis.Y:
                clone.Position.y *= -1;
                direction         = Vector3.up;
                break;

            case MirrorAxis.Z:
                clone.Position.z *= -1;
                direction         = Vector3.forward;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(handMirrorAxis), handMirrorAxis, null);
            }

            Vector3 forward;
            Vector3 up;

            if (t.parent != null)
            {
                forward = t.parent.InverseTransformDirection(t.forward);
                up      = t.parent.InverseTransformDirection(t.up);
            }
            else
            {
                forward = t.forward;
                up      = t.up;
            }

            var mirror   = Vector3.Reflect(forward, direction);
            var upMirror = Vector3.Reflect(up, direction);

            clone.Rotation = Quaternion.LookRotation(mirror, upMirror);

            HVRJointMirrorSetting thumbOverride = null;
            HVRJointMirrorSetting indexMirror   = null;
            HVRJointMirrorSetting middleMirror  = null;
            HVRJointMirrorSetting ringMirror    = null;
            HVRJointMirrorSetting pinkyMirror   = null;

            if (MirrorSettings)
            {
                thumbOverride = MirrorSettings.UseThumbSetting ? MirrorSettings.ThumbSetting : MirrorSettings.AllSetting;
                indexMirror   = MirrorSettings.UseIndexSetting ? MirrorSettings.IndexSetting : MirrorSettings.AllSetting;
                middleMirror  = MirrorSettings.UseMiddleSetting ? MirrorSettings.MiddleSetting : MirrorSettings.AllSetting;
                ringMirror    = MirrorSettings.UseRingSetting ? MirrorSettings.RingSetting : MirrorSettings.AllSetting;
                pinkyMirror   = MirrorSettings.UsePinkySetting ? MirrorSettings.PinkySetting : MirrorSettings.AllSetting;
            }


            if (Thumb != null)
            {
                clone.Thumb = MirrorFinger(Thumb, thumbOverride, MirrorSettings?.ThumbSettings);
            }

            if (Index != null)
            {
                clone.Index = MirrorFinger(Index, indexMirror, MirrorSettings?.IndexSettings);
            }

            if (Middle != null)
            {
                clone.Middle = MirrorFinger(Middle, middleMirror, MirrorSettings?.MiddleSettings);
            }

            if (Ring != null)
            {
                clone.Ring = MirrorFinger(Ring, ringMirror, MirrorSettings?.RingSettings);
            }

            if (Pinky != null)
            {
                clone.Pinky = MirrorFinger(Pinky, pinkyMirror, MirrorSettings?.PinkySettings);
            }

            return(clone);
        }