示例#1
0
        public override sealed void ControllerStart()
        {
            base.ControllerStart();

            // Set default configuration if needed
            if (model.configuration == null)
            {
                model.configuration = BasicHelpers.FindScriptableObject <PuppetConfiguration>(HPTK.core.defaultConfAssets);
            }

            if (model.configuration == null)
            {
                Debug.LogError("Any PuppetConfiguration found in PuppetModel or HPTK.core.defaultConfAssets. The module cannot continue");
                return;
            }

            // Start parts and bones recursively
            PartStart(model.part);

            // Start bones
            model.bones.ForEach(b => BoneStart(b, model.part.root));
            model.bones.ForEach(b => LateBoneStart(b));

            model.view.onPhysicsReady.Invoke();

            model.ready = true;
        }
示例#2
0
            public void SetSlaveActive(bool active)
            {
                if (active)
                {
                    // Teleport
                    model.slave.wrist.transformRef.position = model.master.wrist.transformRef.position;
                    model.slave.wrist.transformRef.rotation = model.master.wrist.transformRef.rotation;

                    // Physics
                    PhysHelpers.SetHandPhysics(model, active);

                    // Module
                    HandPhysicsHandler handPhysics = BasicHelpers.FindHandler <HandPhysicsHandler>(model.relatedHandlers.ToArray());
                    handPhysics.viewModel.isActive = active;
                }
                else
                {
                    // Module
                    HandPhysicsHandler handPhysics = BasicHelpers.FindHandler <HandPhysicsHandler>(model.relatedHandlers.ToArray());
                    handPhysics.viewModel.isActive = active;

                    // Physics
                    PhysHelpers.SetHandPhysics(model, active);
                }

                // Visuals
                model.slave.skinnedMR.enabled = active;
            }
示例#3
0
        public override sealed void Awake()
        {
            base.Awake();

            if (!bone)
            {
                bone = GetComponent <BoneModel>();
            }
            if (!bone)
            {
                bone = BasicHelpers.GetComponentInParents <BoneModel>(transform);
            }

            if (!bone.points.Contains(this))
            {
                bone.points.Add(this);
            }
            if (bone.transform == transform)
            {
                bone.point = this;
            }
            if (!bone.point)
            {
                bone.point = this;
            }
        }
示例#4
0
        public void BasicPublishedContent3Test()
        {
            var appCtx = ApplicationContext.EnsureContext(
                new DatabaseContext(Mock.Of <IDatabaseFactory>(), Mock.Of <ILogger>(), new SqlSyntaxProviders(new[] { Mock.Of <ISqlSyntaxProvider>() })),
                new ServiceContext(),
                CacheHelper.CreateDisabledCacheHelper(),
                new ProfilingLogger(
                    Mock.Of <ILogger>(),
                    Mock.Of <IProfiler>()), true);

            var ctx = UmbracoContext.EnsureContext(
                Mock.Of <HttpContextBase>(),
                appCtx,
                new Mock <WebSecurity>(null, null).Object,
                Mock.Of <IUmbracoSettingsSection>(),
                Enumerable.Empty <IUrlProvider>(), true);

            var test_name = "test";

            //using a helper that I made to setup common fields
            var mockContent = BasicHelpers.GetPublishedContentMock(test_name);

            //setup umbracohelper.assignedcontentitem by setting the publishedcontent request of the umbracocontext
            ctx.PublishedContentRequest = new PublishedContentRequest(new Uri("http://test.com"), ctx.RoutingContext,
                                                                      Mock.Of <IWebRoutingSection>(section => section.UrlProviderMode == UrlProviderMode.AutoLegacy.ToString()),
                                                                      s => new string[] { })
            {
                PublishedContent = mockContent.Object
            };

            var res   = new BasicTestSurfaceController().BasicPublishedContentAction();
            var model = res.Model as string;

            Assert.AreEqual(test_name, model);
        }
示例#5
0
 void UpdateMasterBoneRot(MasterBoneModel masterBone, AbstractTsf inputData, float maxSpeed)
 {
     if (inputData.space == Space.World)
     {
         if (maxSpeed > 0.0f)
         {
             masterBone.transformRef.localRotation = BasicHelpers.ClampQuaternion(masterBone.transformRef.localRotation, Quaternion.Inverse(masterBone.transformRef.parent.rotation) * inputData.rotation, maxSpeed * Time.deltaTime);
         }
         else
         {
             masterBone.transformRef.rotation = inputData.rotation;
         }
     }
     else
     {
         if (maxSpeed > 0.0f)
         {
             masterBone.transformRef.localRotation = BasicHelpers.ClampQuaternion(masterBone.transformRef.localRotation, inputData.rotation, maxSpeed * Time.deltaTime);
         }
         else
         {
             masterBone.transformRef.localRotation = inputData.rotation;
         }
     }
 }
示例#6
0
        public static float ConstrainTurretRotation(float?minRotation, float?maxRotation, float currentRotation, float targetRotation, float maxSpeed)
        {
            if (minRotation != null && maxRotation != null)
            {
                if (targetRotation < minRotation)
                {
                    targetRotation = minRotation.Value;
                }
                if (targetRotation > maxRotation)
                {
                    targetRotation = maxRotation.Value;
                }
            }

            currentRotation = BasicHelpers.NormalizeAngle(currentRotation);
            targetRotation  = BasicHelpers.NormalizeAngle(targetRotation);

            var shortestDistance = BasicHelpers.NormalizeAngle(
                targetRotation - currentRotation + MathHelper.Pi) - MathHelper.Pi;

            if (shortestDistance < 0)
            {
                return(currentRotation + Math.Max(shortestDistance, -maxSpeed));
            }

            return(currentRotation + Math.Min(shortestDistance, maxSpeed));
        }
示例#7
0
        void UpdateBoneTsfRot(ReprModel repr, Transform applyToThis, AbstractTsf inputData, float maxSpeed, Transform referenceTsf, Transform replicatedTsf)
        {
            AvatarController avatarCtrl = repr.point.bone.part.body.avatar.controller;

            Quaternion desiredWorldRot;

            if (inputData.space == Space.World)
            {
                desiredWorldRot = inputData.rotation;
            }
            else
            {
                desiredWorldRot = avatarCtrl.GetWorldFromLocalRotation(inputData.rotation, repr);
            }

            if (referenceTsf && replicatedTsf)
            {
                Quaternion relRot = Quaternion.Inverse(referenceTsf.rotation) * desiredWorldRot;
                desiredWorldRot = replicatedTsf.rotation * relRot;
            }

            if (maxSpeed > 0.0f)
            {
                applyToThis.rotation = BasicHelpers.ClampQuaternion(applyToThis.rotation, desiredWorldRot, maxSpeed * Time.deltaTime);
            }
            else
            {
                applyToThis.rotation = desiredWorldRot;
            }
        }
示例#8
0
        public Dictionary <string, string> GetLocaleDataAll()
        {
            Dictionary <string, string> keyValuePairData = new Dictionary <string, string>();

            using (var reader = new StreamReader(this.GetFileDataFrom_csv))
            {
                bool isThisFirstHeaderRow = true;

                while (!reader.EndOfStream)
                {
                    //Read header
                    if (isThisFirstHeaderRow)
                    {
                        var line_header = reader.ReadLine();
                        isThisFirstHeaderRow = false;
                        continue;
                    }

                    //Read rows below header
                    var      line      = reader.ReadLine();
                    string[] key_value = BasicHelpers._SplitCSV(line);//line.Split(',');

                    //Save Header as key and row value as value in dictionary
                    keyValuePairData.Add(BasicHelpers._TrimQuotesFromString(key_value[0]), BasicHelpers._TrimQuotesFromString(key_value[1]));
                }
            }

            return(keyValuePairData);
        }
示例#9
0
        public KeyValuePair <string, string> GetValueBy_LocaleCode(string languageCode)
        {
            using (var reader = new StreamReader(this.GetFileDataFrom_csv))
            {
                bool isThisFirstHeaderRow = true;

                while (!reader.EndOfStream)
                {
                    //Read header
                    if (isThisFirstHeaderRow)
                    {
                        isThisFirstHeaderRow = false;
                        continue;
                    }

                    //Read rows below header
                    var      line      = reader.ReadLine();
                    string[] key_value = BasicHelpers._SplitCSV(line);//line.Split(',');

                    //Check if iso3166 1 alpha 2 matches
                    if (key_value[0] == languageCode)
                    {
                        var kvp = new KeyValuePair <string, string>(BasicHelpers._TrimQuotesFromString(key_value[0]), BasicHelpers._TrimQuotesFromString(key_value[1]));
                        return(kvp);
                    }
                }
            }

            throw new Exception($@"ZR in GetValueBy_LocaleCode(string languageCode): could not find languageCode with key of {languageCode}");
        }
        public void HelperDynamicContentMediaTest()
        {
            var ctx = UmbracoUnitTestHelper.GetUmbracoContext();

            var contentName = "contentName";
            var mediaName   = "mediaName";
            var contentId   = 20;
            var mediaId     = 30;

            //create content items to be returned
            var mediaItem   = BasicHelpers.GetPublishedContentMock(name: mediaName, id: mediaId);
            var contentItem = BasicHelpers.GetPublishedContentMock(name: contentName, id: contentId);

            //we create a mock of the dynamic query, which is used internally by the Umbraco helper
            var mockedDynamicQuery = new Mock <IDynamicPublishedContentQuery>();

            mockedDynamicQuery.Setup(s => s.Content(contentId)).Returns(contentItem.Object);
            mockedDynamicQuery.Setup(s => s.Media(mediaId)).Returns(mediaItem.Object);

            //give our dynamic query mock to the longer version of the UmbracoHelper constructor
            var helper = UmbracoUnitTestHelper.GetUmbracoHelper(ctx, dynamicQuery: mockedDynamicQuery.Object);

            var controller = new BasicTestSurfaceController(ctx, helper);
            var res        = controller.BasicDynamicContentMediaAction(contentId, mediaId);
            var model      = res.Model as Tuple <string, string>;

            Assert.AreEqual(contentItem.Object.Name, model.Item1);
            Assert.AreEqual(mediaItem.Object.Name, model.Item2);
        }
示例#11
0
        public override void ControllerStart()
        {
            base.ControllerStart();

            // Set default configuration if needed
            if (model.configuration == null)
            {
                model.configuration = BasicHelpers.FindScriptableObject <GestureDetectionConfiguration>(HPTK.core.defaultConfAssets);
            }

            if (model.configuration == null)
            {
                Debug.LogError("Any GestureDetectionConfiguration found in GestureDetectionModel or HPTK.core.defaultConfAssets. The module cannot continue");
                gameObject.SetActive(false);
                return;
            }

            // Init gestures
            InitHandGesture(model.grasp);
            InitHandGesture(model.fist);
            model.extra.ForEach(g => InitHandGesture(g));

            InitFingerGestureGroup(model.thumb, model.hand.thumb);
            InitFingerGestureGroup(model.index, model.hand.index);
            InitFingerGestureGroup(model.middle, model.hand.middle);
            InitFingerGestureGroup(model.ring, model.hand.ring);
            InitFingerGestureGroup(model.pinky, model.hand.pinky);
        }
示例#12
0
        protected override void UpdateInternal(GameTime time)
        {
            var turretRotation = BasicHelpers.NormalizeAngle(TankHelper.ConstrainTurretRotation(
                                                                 null, null,
                                                                 Components["turret"].Rotation + Rotation,
                                                                 InputState.LookDirection,
                                                                 1.5f * (float)time.ElapsedGameTime.TotalSeconds
                                                                 ) - Rotation);

            //Network optimization - check if turret rotation changed without accounting for object rotation
            var uncorrected = BasicHelpers.NormalizeAngle(TankHelper.ConstrainTurretRotation(
                                                              null, null,
                                                              _uncorrectedRot,
                                                              InputState.LookDirection,
                                                              1.5f * (float)time.ElapsedGameTime.TotalSeconds
                                                              ));

            _uncorrectedRot = uncorrected;
            ComponentGroups["turret"].Rotation = turretRotation;

            if (Authoritative && MathHelper.Distance(_lastStateChangeRotation, uncorrected) > 0.05)
            {
                RaiseStateChangeEvent(a => a.Write(turretRotation));
                _lastStateChangeRotation = uncorrected;
            }
            Animations["death_explosion"].Mask = ColorMask;
            base.UpdateInternal(time);
        }
示例#13
0
        public void Test_BasicHelpers_GetCsvHeaderNames()
        {
            // arrange
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            DataServiceForCsvFile dataServiceForCsvFile = new DataServiceForCsvFile(this.FolderPath_CountryData);


            // act
            string[] result           = BasicHelpers.GetCsvHeaderNames(Path.Combine(this.FolderPath_CountryData + "/FromGitHub/datasets/country-codes/", "country-codes.csv"));//dataServiceForCsvFile.Reader_GitHubUser_Datasets.GetCsvHeaderNames();
            string   headerName_first = result[0];
            string   headerName_last  = result[result.Length - 1];


            // assert
            Assert.IsTrue(headerName_first == "FIFA");
            Assert.IsTrue(headerName_last == "EDGAR");



            stopwatch.Stop();
            string timeElpsed = stopwatch.Elapsed.ToString();
        }
        private static void DetectQuadrant4(int sumVectorX, int sumVectorY, ref GradientDirection resultDirection)
        {
            if (sumVectorX < 0 && sumVectorY > 0)
            {
                int absSumVectorX = BasicHelpers.FastAbs(sumVectorX);

                if (sumVectorY > absSumVectorX)
                {
                    if (absSumVectorX * 2 < sumVectorY)
                    {
                        resultDirection = GradientDirection.vertical;
                    }
                    else
                    {
                        resultDirection = GradientDirection.askewFall;
                    }
                }
                else
                {
                    if (absSumVectorX < sumVectorY * 2)
                    {
                        resultDirection = GradientDirection.horizontal;
                    }
                    else
                    {
                        resultDirection = GradientDirection.askewFall;
                    }
                }
            }
        }
示例#15
0
    void SetupGhostObjects()
    {
        // CustomHand > Objects > Ghost
        ghostRootObject      = BasicHelpers.InstantiateEmptyChild(objects);
        ghostRootObject.name = "Ghost." + handType.ToString();

        // Move it to avoid overlay
        ghostRootObject.transform.position += new Vector3(0.0f, 0.4f, 0.0f);

        // CustomHand > Objects > Ghost > (content)
        Transform handRoot;

        if (wristOffset)
        {
            handRoot = wristOffset;
        }
        else
        {
            handRoot = wrist;
        }

        ghostWrist = Instantiate(handRoot.gameObject, ghostRootObject.transform.position, ghostRootObject.transform.rotation);
        ghostWrist.transform.parent = ghostRootObject.transform;
        ghostWrist.transform.name   = "Wrist";

        // Set SkinnedMR material to ghost material

        /*
         * SkinnedMeshRenderer ghostSMR = ghostWrist.GetComponent<SkinnedMeshRenderer>();
         * ghostSMR.material = ghostMat;
         */
    }
示例#16
0
    // 1. Wrist tiene SMR
    // 2. Offset tiene rb y joint
    // 3. wristBone.transformRef apunta a Wrist

    void SetupSlaveObjects()
    {
        // CustomHand > Objects > Slave
        slaveRootObject      = BasicHelpers.InstantiateEmptyChild(objects);
        slaveRootObject.name = "Slave." + handType.ToString();

        // Move it to avoid overlay
        slaveRootObject.transform.position += new Vector3(0.0f, 0.2f, 0.0f);

        // CustomHand > Objects > Slave > (content)
        Transform handRoot;

        if (wristOffset)
        {
            handRoot = wristOffset;
        }
        else
        {
            handRoot = wrist;
        }

        slaveWrist = Instantiate(handRoot.gameObject, slaveRootObject.transform.position, slaveRootObject.transform.rotation);
        slaveWrist.transform.parent = slaveRootObject.transform;
        slaveWrist.transform.name   = "Wrist";

        // Set SkinnedMR material to salve material

        /*
         * SkinnedMeshRenderer slaveSMR = slaveWrist.GetComponent<SkinnedMeshRenderer>();
         * slaveSMR.material = slaveMat;
         */
    }
示例#17
0
文件: HPTK.cs 项目: jorgejgnz/HPTK
        public void AddAvatar(AvatarController avatar)
        {
            this._avatars.Add(avatar);

            avatar.ControllerStart();

            if (applyThisLayerToAvatars != "")
            {
                int layer = LayerMask.NameToLayer(applyThisLayerToAvatars);
                if (layer >= 0)
                {
                    foreach (BodyModel body in avatar.model.bodies)
                    {
                        BoneModel rootBone = body.root.root;

                        foreach (KeyValuePair <string, ReprModel> entry in rootBone.point.reprs)
                        {
                            BasicHelpers.ApplyLayerRecursively(entry.Value.transformRef, layer);
                        }
                    }
                }
            }

            onAvatarEntered.Invoke(avatar.model.view);
        }
示例#18
0
        private void Start()
        {
            model.proxyHand.relatedHandlers.Add(this);

            slaveBones = AvatarHelpers.GetSlaveHandBones(model.proxyHand.slave);

            // Set default configuration if needed
            if (model.asset == null)
            {
                model.asset = BasicHelpers.FindScriptableObject <HandPhysicsConfigurationAsset>(core.model.defaultConfAssets);
            }

            // Make configuration editable
            model.configuration = new HandPhysicsConfiguration(model.asset.configuration);

            for (int i = 0; i < slaveBones.Length; i++)
            {
                if (slaveBones[i].colliderRef)
                {
                    // Ignore palm-finger collisions
                    Physics.IgnoreCollision((model.proxyHand.slave.wrist as SlaveBoneModel).colliderRef, slaveBones[i].colliderRef, true);
                }

                if (slaveBones[i].jointRef)
                {
                    // Get initial connected body local rotations and conn anchors
                    if (slaveBones[i].jointRef.connectedBody != null)
                    {
                        slaveBones[i].initialConnectedBodyLocalRotation     = slaveBones[i].jointRef.connectedBody.transform.localRotation;
                        slaveBones[i].initialConnectedAnchor                = slaveBones[i].jointRef.connectedAnchor;
                        slaveBones[i].jointRef.autoConfigureConnectedAnchor = false;
                    }
                    else
                    {
                        slaveBones[i].initialConnectedBodyLocalRotation = slaveBones[i].jointRef.transform.rotation;
                    }

                    // Set initial joint configurations
                    if (slaveBones[i] == model.proxyHand.slave.wrist)
                    {
                        PhysHelpers.SetSlaveBoneConfiguration(slaveBones[i].jointRef, model.configuration.wrist);
                    }
                    else if (slaveBones[i].isSpecial)
                    {
                        PhysHelpers.SetSlaveBoneConfiguration(slaveBones[i].jointRef, model.configuration.specials);
                    }
                    else
                    {
                        PhysHelpers.SetSlaveBoneConfiguration(slaveBones[i].jointRef, model.configuration.fingers);
                    }

                    // Initial built-in velocity clamps
                    slaveBones[i].rigidbodyRef.maxDepenetrationVelocity = model.configuration.fingers.maxLinearVelocity;
                    slaveBones[i].rigidbodyRef.maxAngularVelocity       = model.configuration.fingers.maxAngularVelocity;
                }
            }
        }
示例#19
0
        public void SetHandPhysics(HandModel hand, bool enabled)
        {
            PuppetView view = BasicHelpers.FindFirst <HPTKView, PuppetView>(hand.view.registry);

            if (view)
            {
                view.SetPhysics(enabled);
            }
        }
        private static int PixelDiff_Custom(Pixel p1, Pixel p2)
        {
            int result = 0;

            result += BasicHelpers.FastAbs(p1.CR - p2.CR);
            result += BasicHelpers.FastAbs(p1.CG - p2.CG);
            result += BasicHelpers.FastAbs(p1.CB - p2.CB);
            return(result);
        }
示例#21
0
            public void SetMasterActive(bool active)
            {
                // Module
                InputHandler input = BasicHelpers.FindHandler <InputHandler>(model.relatedHandlers.ToArray());

                input.viewModel.isActive = active;

                // Visuals
                model.master.skinnedMR.enabled = active;
            }
示例#22
0
        public override sealed void Awake()
        {
            base.Awake();

            if (!transformRef)
            {
                transformRef = transform;
            }
            if (!meshRenderer)
            {
                meshRenderer = GetComponent <MeshRenderer>();
            }
            if (!skinnedMeshRenderer)
            {
                skinnedMeshRenderer = GetComponent <SkinnedMeshRenderer>();
            }
            if (!lineRenderer)
            {
                lineRenderer = GetComponent <LineRenderer>();
            }

            if (!point)
            {
                point = GetComponent <PointModel>();
            }
            if (!point)
            {
                point = BasicHelpers.GetComponentInParents <PointModel>(transform);
            }

            if (!point)
            {
                Debug.LogError("ReprModel " + transform.name + " has no point!");
                return;
            }
            else if (!point.reprs.ContainsValue(this))
            {
                if (key == null || key == "")
                {
                    key = FindKey();
                }

                if (key != null && key != "")
                {
                    if (!point.reprs.ContainsKey(key))
                    {
                        point.reprs.Add(key, this);
                    }
                    else
                    {
                        key = null;
                    }
                }
            }
        }
示例#23
0
        public override sealed void UpdateExtension(TargetConstraint t)
        {
            // Linear limit
            t.joint.xMotion = ConfigurableJointMotion.Locked;
            t.joint.yMotion = ConfigurableJointMotion.Locked;
            t.joint.zMotion = ConfigurableJointMotion.Limited;

            limitSpring.spring        = spring;
            limitSpring.damper        = damper;
            t.joint.linearLimitSpring = limitSpring;

            worldLimitStart = t.connectedAnchor.position - t.GetJointAxisWorldRotation() * Vector3.forward * limit.limit;
            worldLimitEnd   = t.connectedAnchor.position + t.GetJointAxisWorldRotation() * Vector3.forward * limit.limit;

            if (showLimitedAxis)
            {
                Debug.DrawLine(worldLimitStart, worldLimitEnd, Color.black);
            }

            // Threshold detection
            if (detectThreshold)
            {
                if (togglingThresholdDetectionIn <= 0.0f)
                {
                    closestToLine = BasicHelpers.NearestPointOnFiniteLine(worldLimitStart, worldLimitEnd, t.anchor.position);

                    if (inverted)
                    {
                        positionLerp = Vector3.Distance(worldLimitStart, closestToLine) / (limit.limit * 2.0f);
                    }
                    else
                    {
                        positionLerp = Vector3.Distance(worldLimitEnd, closestToLine) / (limit.limit * 2.0f);
                    }

                    if (positionLerp > threshold && thresholdState != ThresholdState.Over)
                    {
                        togglingThresholdDetectionIn = minTimeBetweenDetections;
                        thresholdState = ThresholdState.Over;
                        onOverThreshold.Invoke();
                    }
                    else if (positionLerp < threshold && thresholdState != ThresholdState.Under)
                    {
                        togglingThresholdDetectionIn = minTimeBetweenDetections;
                        thresholdState = ThresholdState.Under;
                        onUnderThreshold.Invoke();
                    }
                }
                else
                {
                    togglingThresholdDetectionIn -= Time.deltaTime;
                }
            }
        }
示例#24
0
        //public string[] GetCsvHeaderNames()
        //{
        //    string[] arrHeaders = new string[] { };

        //    using (var reader = new StreamReader(this._FilePath_csv_countryCodes))
        //    {
        //        //while (!reader.EndOfStream)
        //        //{
        //            var lineHeader = reader.ReadLine();
        //            arrHeaders = BasicHelpers._SplitCSV(lineHeader);
        //        //}
        //    }

        //    return arrHeaders;
        //}

        public Dictionary <string, string> GetDataBy_ISO3166_1_Alpha_3(string ISO3166_1_Alpha_3)
        {
            Dictionary <string, string> resultDictionary = new Dictionary <string, string>();

            using (var reader = new StreamReader(this.FilePath_csv_countryCodes))
            {
                bool     isThisFirstHeaderRow = true;
                string[] arrHeaders           = new string[] { };

                int indexISO3166_1_Alpha_3 = 0;

                while (!reader.EndOfStream)
                {
                    //Read header
                    if (isThisFirstHeaderRow)
                    {
                        string lineHeader = reader.ReadLine();
                        arrHeaders = BasicHelpers._SplitCSV(lineHeader); //lineHeader.Split(',');

                        for (int i = 0; i < arrHeaders.Length; i++)
                        {
                            if (arrHeaders[i] == "ISO3166-1-Alpha-3")
                            {
                                indexISO3166_1_Alpha_3 = i;
                                break;
                            }
                            if (i == arrHeaders.Length - 1)
                            {
                                throw new Exception($@"ZR in GetDataBy_ISO3166_1_Alpha_3(string ISO3166_1_Alpha_3), there is no header with name ISO3166_1_Alpha_3");
                            }
                        }

                        isThisFirstHeaderRow = false;
                        continue;
                    }

                    //Read rows below header
                    var      line   = reader.ReadLine();
                    string[] values = BasicHelpers._SplitCSV(line);//line.Split(',');

                    //Save Header as key and row value as value in dictionary
                    if (values[indexISO3166_1_Alpha_3] == ISO3166_1_Alpha_3)
                    {
                        for (int i = 0; i < values.Length; i++)
                        {
                            string valueCleanedStr = BasicHelpers._TrimQuotesFromString(values[i]);
                            resultDictionary.Add(arrHeaders[i], valueCleanedStr);
                        }
                    }
                }
            }

            return(resultDictionary);
        }
示例#25
0
    bool HandModelIsValid(Transform wrist)
    {
        for (int i = 0; i < wrist.childCount; i++)
        {
            if (!BasicHelpers.IsCleanBranch(wrist.GetChild(i)))
            {
                return(false);
            }
        }

        return(true);
    }
示例#26
0
        //**********************
        //CONSTRUCTOR
        //**********************
        public DataServiceForCsvFile(string folderPath_CountryData)
        {
            BasicHelpers.CheckIfFolderPathExits(folderPath_CountryData);
            this._FolderPath_CountryData = folderPath_CountryData;


            //Data readers
            this.Reader_GitHubUser_Datasets          = new Reader_GitHubUser_Datasets($@"{this._FolderPath_CountryData}FromGitHub\datasets\country-codes\country-codes.csv");
            this.Reader_GitHubUser_Umpirsky_Country  = new Reader_GitHubUser_Umpirsky_Country($@"{this._FolderPath_CountryData}FromGitHub\umpirsky\country-list\", "it_IT");
            this.Reader_GitHubUser_Umpirsky_Language = new Reader_GitHubUser_Umpirsky_Language($@"{this._FolderPath_CountryData}FromGitHub\umpirsky\language-list\", "it_IT");
            this.Reader_GitHubUser_Umpirsky_Locale   = new Reader_GitHubUser_Umpirsky_Locale($@"{this._FolderPath_CountryData}FromGitHub\umpirsky\locale-list\", "it_IT");
        }
示例#27
0
        public void BasicGetPropertyTest()
        {
            var appCtx = ApplicationContext.EnsureContext(
                new DatabaseContext(Mock.Of <IDatabaseFactory>(), Mock.Of <ILogger>(), new SqlSyntaxProviders(new[] { Mock.Of <ISqlSyntaxProvider>() })),
                new ServiceContext(),
                CacheHelper.CreateDisabledCacheHelper(),
                new ProfilingLogger(
                    Mock.Of <ILogger>(),
                    Mock.Of <IProfiler>()), true);

            var ctx = UmbracoContext.EnsureContext(
                Mock.Of <HttpContextBase>(),
                appCtx,
                new Mock <WebSecurity>(null, null).Object,
                Mock.Of <IUmbracoSettingsSection>(),
                Enumerable.Empty <IUrlProvider>(), true);

            string propertyName = "testProp";
            string propValue    = "testValue";

            var propertyMock = new Mock <IPublishedProperty>();

            propertyMock.Setup(s => s.Value).Returns(propValue);

            var contentId = 2;
            //get a mocked IPublishedContent
            var contentMock = BasicHelpers.GetPublishedContentMock();

            contentMock.Setup(s => s.GetProperty(propertyName)).Returns(propertyMock.Object);

            var mockedTypedQuery = new Mock <ITypedPublishedContentQuery>();

            mockedTypedQuery.Setup(s => s.TypedContent(contentId)).Returns(contentMock.Object);

            //give our dynamic query mock to the longer version of the UmbracoHelper constructor
            var helper = new UmbracoHelper(ctx,
                                           Mock.Of <IPublishedContent>(),
                                           mockedTypedQuery.Object,
                                           Mock.Of <IDynamicPublishedContentQuery>(),
                                           Mock.Of <ITagQuery>(),
                                           Mock.Of <IDataTypeService>(),
                                           new UrlProvider(ctx, Mock.Of <IWebRoutingSection>(section => section.UrlProviderMode == UrlProviderMode.Auto.ToString()), new[] { Mock.Of <IUrlProvider>() }),
                                           Mock.Of <ICultureDictionary>(),
                                           Mock.Of <IUmbracoComponentRenderer>(),
                                           new MembershipHelper(ctx, Mock.Of <MembershipProvider>(), Mock.Of <RoleProvider>()));

            var controller = new BasicTestSurfaceController(ctx, helper);
            var res        = controller.BasicGetPropertyAction(contentId, propertyName);
            var model      = (string)res.Model;

            Assert.AreEqual(propValue, model);
        }
示例#28
0
        public void BasicDynamicContentMediaTest()
        {
            var appCtx = ApplicationContext.EnsureContext(
                new DatabaseContext(Mock.Of <IDatabaseFactory>(), Mock.Of <ILogger>(), new SqlSyntaxProviders(new[] { Mock.Of <ISqlSyntaxProvider>() })),
                new ServiceContext(),
                CacheHelper.CreateDisabledCacheHelper(),
                new ProfilingLogger(
                    Mock.Of <ILogger>(),
                    Mock.Of <IProfiler>()), true);

            var ctx = UmbracoContext.EnsureContext(
                Mock.Of <HttpContextBase>(),
                appCtx,
                new Mock <WebSecurity>(null, null).Object,
                Mock.Of <IUmbracoSettingsSection>(),
                Enumerable.Empty <IUrlProvider>(), true);

            var contentName = "contentName";
            var mediaName   = "mediaName";
            var contentId   = 20;
            var mediaId     = 30;

            //create content items to be returned
            var mediaItem   = BasicHelpers.GetPublishedContentMock(name: mediaName, id: mediaId);
            var contentItem = BasicHelpers.GetPublishedContentMock(name: contentName, id: contentId);

            //we create a mock of the dynamic query, which is used internally by the Umbraco helper
            var mockedDynamicQuery = new Mock <IDynamicPublishedContentQuery>();

            mockedDynamicQuery.Setup(s => s.Content(contentId)).Returns(contentItem.Object);
            mockedDynamicQuery.Setup(s => s.Media(mediaId)).Returns(mediaItem.Object);

            //give our dynamic query mock to the longer version of the UmbracoHelper constructor
            var helper = new UmbracoHelper(ctx,
                                           Mock.Of <IPublishedContent>(),
                                           Mock.Of <ITypedPublishedContentQuery>(),
                                           mockedDynamicQuery.Object,
                                           Mock.Of <ITagQuery>(),
                                           Mock.Of <IDataTypeService>(),
                                           new UrlProvider(ctx, Mock.Of <IWebRoutingSection>(section => section.UrlProviderMode == UrlProviderMode.Auto.ToString()), new[] { Mock.Of <IUrlProvider>() }),
                                           Mock.Of <ICultureDictionary>(),
                                           Mock.Of <IUmbracoComponentRenderer>(),
                                           new MembershipHelper(ctx, Mock.Of <MembershipProvider>(), Mock.Of <RoleProvider>()));

            var controller = new BasicTestSurfaceController(ctx, helper);
            var res        = controller.BasicDynamicContentMediaAction(contentId, mediaId);
            var model      = res.Model as Tuple <string, string>;

            Assert.AreEqual(contentItem.Object.Name, model.Item1);
            Assert.AreEqual(mediaItem.Object.Name, model.Item2);
        }
示例#29
0
    public void Setup()
    {
        // Check errors
        if (!AllSystemsNominal())
        {
            return;
        }

        // Set hand pose to open
        BasicHelpers.SetLocalRotForHierarchy(wrist, Vector3.zero);

        // CustomHand
        mainRoot      = new GameObject();
        mainRoot.name = "CustomHand." + handType.ToString();
        mainRoot.transform.position = wrist.position + new Vector3(0.0f, 0.0f, 0.1f);

        // CustomHand > Objects
        objects      = BasicHelpers.InstantiateEmptyChild(mainRoot);
        objects.name = "Objects." + handType.ToString();

        // CustomHand > [Modules]
        modules      = BasicHelpers.InstantiateEmptyChild(mainRoot);
        modules.name = "[Modules]";

        // Get sibilng index for index and thumb
        indexSiblingIndex = indexRootBone.GetSiblingIndex();
        thumbSiblingIndex = thumbRootBone.GetSiblingIndex();

        // Initialize phModel, masterhandModel and slaveHandModel
        SetupProxyHandModule();

        // Initialize masterWrist and slaveWrist
        SetupMasterObjects();
        SetupSlaveObjects();
        SetupGhostObjects();

        // Setup HPTK models
        SetupMasterHandModel(masterHandModel, masterWrist.transform, masterWristOffset);
        SetupSlaveHandModel(slaveHandModel, slaveWrist.transform); // Depends on phModel.master for automatic rig mapping
        SetupGhostHandModel(ghostHandModel, ghostWrist.transform);

        // Setup special points, triggers, ray (and colliders, rbs and joints if needed)
        FixHand(phModel.master, handType, masterWristOffset);
        FixHand(phModel.slave, handType, null);
        FixHand(phModel.ghost, handType, null);

        // Add lines
        AddLines(phModel.master, Color.blue);
        AddLines(phModel.slave, Color.black);
        AddLines(phModel.ghost, Color.white);
    }
示例#30
0
        public override sealed void FingerLerpUpdate()
        {
            base.FingerLerpUpdate();

            // Lerp
            minDist            = conf.minPalmRelDistance * hand.totalScale;
            maxDist            = conf.maxPalmRelDistance * hand.totalScale;
            nearestPointToLine = BasicHelpers.NearestPointOnFiniteLine(hand.palmExterior.transformRef.position, hand.palmInterior.transformRef.position, finger.tip.transformRef.position);
            dist  = Vector3.Distance(nearestPointToLine, finger.tip.transformRef.position);
            _lerp = 1.0f - Mathf.InverseLerp(minDist, maxDist, dist);

            // Intention
            _providesIntention = false;
        }