Esempio n. 1
0
 /// <summary>
 /// Debug function to modify min bound of rotation mapping
 /// </summary>
 /// <param name="bounds"></param>
 /// <param name="change"></param>
 private void ModifyHandRotationBoundsMin(BoundaryValue bounds, float change)
 {
     if (bounds != null)
     {
         bounds.ModifyMin(change);
     }
 }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            GenerateSeedsMethod generateSeedsMethod = (GenerateSeedsMethod)selectRand.SelectedIndex;
            BoundaryValue       boundaryValue       = (BoundaryValue)selectBound.SelectedIndex;

            int[] parameters = null;
            switch (generateSeedsMethod)
            {
            case GenerateSeedsMethod.Evenly:
                parameters = new int[2] {
                    int.Parse(textBoxX.Text), int.Parse(textBoxY.Text)
                };
                break;

            case GenerateSeedsMethod.RandomR:
                parameters = new int[1] {
                    int.Parse(textBoxR.Text)
                };
                break;

            case GenerateSeedsMethod.ClickMethod:
            case GenerateSeedsMethod.Random:
            default:
                break;
            }

            simulation.GenerateSeeds(int.Parse(textBoxWidth.Text), int.Parse(textBoxHeight.Text), generateSeedsMethod, boundaryValue, int.Parse(textBoxAmount.Text), parameters);
        }
        private void InsertBoundaryValueView(BoundaryValue bounds, string label)
        {
            EditorGUIUtility.labelWidth = 70;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(label, GUILayout.MaxWidth((float)_handGUIWidth / 5));
            Undo.RecordObject(_dexmoController, "Change bounds");
            float min = EditorGUILayout.FloatField("Min", bounds.Min,
                                                   GUILayout.MaxWidth((float)2 * _handGUIWidth / 5));
            float max = EditorGUILayout.FloatField("Max", bounds.Max,
                                                   GUILayout.MaxWidth((float)2 * _handGUIWidth / 5));

            min        = Mathf.Clamp01(min);
            max        = Mathf.Clamp01(max);
            bounds.Min = min;
            bounds.Max = max;
            //EditorGUILayout.LabelField(label,
            //    GUILayout.MaxWidth((float)_handGUIWidth * 4 / 20));
            //EditorGUILayout.LabelField("Min",
            //    GUILayout.MaxWidth((float)_handGUIWidth * 4 / 20));
            //bounds.Min = EditorGUILayout.Slider(bounds.Min, 0, 1,
            //    GUILayout.MaxWidth((float)4 * _handGUIWidth / 20));
            //EditorGUILayout.LabelField("Max",
            //    GUILayout.MaxWidth((float)_handGUIWidth * 4 / 20));
            //bounds.Max = EditorGUILayout.Slider(bounds.Max, 0, 1,
            //    GUILayout.MaxWidth((float)4 * _handGUIWidth / 20));
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 4
0
        public void CreateNewMap(int w, int h, BoundaryValue boundaryValue)
        {
            this.w             = w;
            this.h             = h;
            this.boundaryValue = boundaryValue;

            mapTemp = CreateMap(w, h);
            Commit();
        }
Esempio n. 5
0
 /// <summary>
 /// convert baoundary value to gateway
 /// </summary>
 /// <param name="boundaryValue"></param>
 /// <param name="runtimeBoundaryValue"></param>
 /// <param name="field"></param>
 private void ConvertBoundaryToGateway(BoundaryValue boundaryValue, BoundaryValue runtimeBoundaryValue, DBField field)
 {
     if (boundaryValue.Type != RangeType.RangeNoVal && !boundaryValue.Discard)
     {
         if (ValueInGatewayFormat)
         {
             boundaryValue.Value.Value = runtimeBoundaryValue.Value.Value;
         }
         else
         {
             boundaryValue.Value.Value = GatewayAdapter.StorageConvertor.ConvertMgValueToGateway(field, runtimeBoundaryValue.Value.Value);
         }
     }
 }
Esempio n. 6
0
        public void GenerateSeeds(int width, int height, GenerateSeedsMethod method, BoundaryValue boundaryValue, int amount, int[] parameters)
        {
            this.width  = (width += 2);
            this.height = (height += 2);

            mapController.CreateNewMap(width, height, boundaryValue);
            mapControllerSec.CreateNewMap(width, height, boundaryValue);

            seedsController.GenerateSeeds(width, height, method, amount, parameters);

            foreach (var seed in seedsController.GetSeeds())
            {
                mapController.SetPixesl(seed.x, seed.y, seed.myColor);
            }
            mapController.Commit();
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hasBoundary"></param>
        /// <param name="IsMaxEqualsMin"></param>
        /// <param name="expVal"></param>
        /// <returns></returns>
        BoundaryValue BuildBoundaryValue(bool hasBoundary, bool IsMaxEqualsMin, GuiExpressionEvaluator.ExpVal expVal, char wildCharFiller, bool shouldDiscard)
        {
            BoundaryValue boundaryValue = new BoundaryValue();

            boundaryValue.Type = ComputeRangeType(hasBoundary, IsMaxEqualsMin);
            if (hasBoundary)
            {
                boundaryValue.Value = GetFieldValue(expVal, wildCharFiller);

                if (shouldDiscard)
                {
                    boundaryValue.Discard = true;
                }
            }

            return(boundaryValue);
        }
Esempio n. 8
0
        /// <summary>
        /// init the boundary
        /// </summary>
        /// <param name="boundaryValue"></param>
        /// <param name="storageAttribute"></param>
        /// <param name="discard"></param>
        /// <param name="value"></param>
        private void InitBoundary(BoundaryValue boundaryValue, StorageAttribute storageAttribute, bool discard, string value, int length, char filler)
        {
            if (discard)
            {
                boundaryValue.Type         = RangeType.RangeNoVal;
                boundaryValue.Value.IsNull = true;
            }
            else
            {
                if (value == null)
                {
                    boundaryValue.Value.IsNull = true;
                }
                else
                {
                    if (storageAttribute == StorageAttribute.ALPHA ||
                        storageAttribute == StorageAttribute.UNICODE)
                    {
                        if (IsLocate)
                        {
                            boundaryValue.Value.Value = DisplayConvertor.StringValueToMgValue(value, storageAttribute, filler, length);
                        }
                        else
                        {
                            boundaryValue.Value.Value = value;
                        }

                        boundaryValue.Value.Value = StrUtil.SearchAndReplaceWildChars((string)boundaryValue.Value.Value, length, filler);
                    }
                    else
                    {
                        boundaryValue.Value.Value = DisplayConvertor.StringValueToMgValue(value, storageAttribute, filler, length);
                    }
                }

                boundaryValue.Type = RangeType.RangeParam;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Keyboard shortcuts for debug purpose.
        /// </summary>
        private void KeyboardCommandToDexmo()
        {
            if (LibdexmoClientController == null || !LibdexmoClientController.Connected)
            {
                return;
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                SwitchHandPositionAndAttitudeReference();
            }

            if (Input.GetKeyDown(KeyCode.R))
            {
                foreach (UnityHandController handController in _handControllers)
                {
                    if (handController.Active)
                    {
                        int assignedId = handController.DeviceInfo.AssignedId;
                        ImpedanceControlStopAllFingers(assignedId);
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.U))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.I))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.J))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.K))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.T))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.Y))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.G))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.H))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    int n = 5;
                    for (int i = 0; i < n; i++)
                    {
                        BoundaryValue bounds = handRep.HandRotationBounds.Fingers[i].BendRotationBounds;
                        bounds.RestoreToDefault();
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.Alpha9))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    int n = 5;
                    for (int i = 0; i < n; i++)
                    {
                        BoundaryValue bounds = handRep.HandRotationBounds.Fingers[i].BendRotationBounds;
                        bounds.RestoreToDefault();
                    }
                }
            }
        }