public string AddGroupEmail()
        {
            StringBuilder members = new StringBuilder();

            _powershellScript = SkeletonMapper.MapObjectToSkeleton(
                new AddNewGroupEmail()
            {
                GroupName   = this.DomainModel.EmailName,
                GroupEmail  = this.DomainModel.EmployeeEmail,
                DisplayName = this.DomainModel.EmailName,
                MangedBy    = this.DomainModel.EmployeeEmail,
                Members     = "members",
            }, forJavaScript: true);
            if (DomainModel != null && GroupMember.Count > 0)
            {
                int i = 0;
                foreach (var item in GroupMember)
                {
                    // members.Append((Expression<Func<GroupMembersModel, string>>)(x => x.MemberEmail));
                    members.Append(this.GroupMember[i].MemberEmail).Append(',');

                    i++;
                }
                // members.Remove(members.Length - 3, 3);//remove last ,
                // members.Remove(0, 2);// First tow chars,

                this._powershellScript = this._powershellScript.Replace("$('#members').val()", members.ToString());
            }
            return(_powershellScript);
        }
 public string AddNewAccount()
 {
     _powershellScript = SkeletonMapper.MapObjectToSkeleton(
         new AddNewAccount()
     {
         Department      = this.Requester.EmployeeDepartment,
         Company         = this.DomainModel.ContractorCompany,
         ExpireDate      = this.DomainModel.DateTo.ToString(),
         FirstName       = this.DomainModel.ContractorFirstName,
         FamilyName      = this.DomainModel.ContractorLastName,
         JobTitle        = this.DomainModel.ContractorJobTitle,
         ManagerUsername = this.Requester.Email,
         Password        = this.DomainModel.Password,
         Project         = this.DomainModel.ContractorProject,
         SAMAccount      = this.DomainModel.UserName,
         IsTrainee       = this.DomainModel.IsForTrainee.ToString()
     }, forJavaScript: false);
     return(_powershellScript);
 }
        private void CreateSkeletonMapper()
        {
            // Create an empty skeleton mapper that can map bone transforms between the dude and
            // the marine model.
            _skeletonMapper = new SkeletonMapper(_dudeMeshNode.SkeletonPose, _marineMeshNode.SkeletonPose);

            // A skeleton mapper manages a collection of bone mappers, that map individual bones.
            // Without the bone mappers, the SkeletonMapper does nothing.
            // Setting up the right bone mappers is not trivial if the skeletons are very different.
            //
            // Here are a few tips:
            //
            // Display the skeletons of both models (as in the BindPoseSample.cs).
            // Compare the bones of the skeletons and find out which bones and which bone chains should
            // map to which bones or bone chains of the other model.
            //
            // Use a DirectBoneMapper for the first bones in the pelvis. Set MapAbsoluteTransforms to
            // false and set MapTranslations to true to map translations (hip swing). If the models
            // have different size then adapt ScaleAToB manually to scale the mapped translations.
            //
            // ChainBoneMappers can be used to map single bones or bone chains. In the case below
            // several spine bones of the dude are mapped to a single spine bone of the marine.
            //
            // Chain bone mappers need a start and end bone (which is excluded and only defines the
            // end of the chain). Therefore, use DirectBoneMappers for end bones (hands, feet, head).
            //
            // If the arm bind poses are very different (e.g. a bind pose with horizontal arms vs a bind
            // pose with lowered arms), you must use ChainBoneMappers for the upper arm and lower arm
            // bones.
            //
            // Experiment until you find a good mapping. In some cases it is necessary to define one
            // bone mapping to map from the first to the second skeleton and use a different bone mapping
            // to map in the reverse direction. Set BoneMapper.Direction if a specific bone mapper
            // instance should only be used for a specific mapping direction.

            _skeletonMapper.BoneMappers.Add(
                new DirectBoneMapper(1, 1)
            {
                MapAbsoluteTransforms = false,
                MapTranslations       = true,
                ScaleAToB             = 1f,
            });


            // Spine:
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(3, 6, 2, 3));

            // Clavicle
            _skeletonMapper.BoneMappers.Add(new DirectBoneMapper(12, 6)
            {
                MapAbsoluteTransforms = false, MapTranslations = false,
            });
            _skeletonMapper.BoneMappers.Add(new DirectBoneMapper(31, 12)
            {
                MapAbsoluteTransforms = false, MapTranslations = false,
            });

            // Left Leg
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(50, 51, 16, 17));
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(51, 52, 17, 18));
            _skeletonMapper.BoneMappers.Add(new DirectBoneMapper(52, 18)
            {
                MapAbsoluteTransforms = false, MapTranslations = false,
            });

            // Right Leg
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(54, 55, 21, 22));
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(55, 56, 22, 23));
            _skeletonMapper.BoneMappers.Add(new DirectBoneMapper(56, 23)
            {
                MapAbsoluteTransforms = false, MapTranslations = false,
            });

            // Left Arm
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(13, 14, 7, 8));
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(14, 15, 8, 9));
            _skeletonMapper.BoneMappers.Add(new DirectBoneMapper(15, 9)
            {
                MapTranslations = false,
            });

            // Right Arm
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(32, 33, 12, 13));
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(33, 34, 13, 14));
            _skeletonMapper.BoneMappers.Add(new DirectBoneMapper(34, 14)
            {
                MapTranslations = false,
            });

            // Neck, Head
            _skeletonMapper.BoneMappers.Add(new ChainBoneMapper(6, 7, 3, 4));
            _skeletonMapper.BoneMappers.Add(new DirectBoneMapper(7, 4)
            {
                MapAbsoluteTransforms = true, MapTranslations = false,
            });
        }
Esempio n. 4
0
        private void InitializeSkeletonMappers()
        {
            // Create a SkeletonMapper for each model.
            // In this sample, the models on the screen should act like a mirror for the players'
            // movements. Therefore, we mirror the skeletons, e.g. the right Kinect arm controls left
            // model arm.

            //
            // ----- SkeletonMapper for the Dude model.
            //
            _skeletonMapperA = new SkeletonMapper(_kinectWrapper.SkeletonPoseA, _meshNodeA.SkeletonPose);
            var ks = _kinectWrapper.SkeletonPoseA.Skeleton;
            var ms = _meshNodeA.SkeletonPose.Skeleton;

            // So far _skeletonMapperA does nothing. We have to configure how bones or bone chains
            // from the Kinect skeleton should map to the Dude skeleton. This is done using
            // BoneMappers:
            // A DirectBoneMapper transfers the rotation and scale of a single bone.
            _skeletonMapperA.BoneMappers.Add(new DirectBoneMapper(ks.GetIndex("HipCenter"), ms.GetIndex("Root"))
            {
                MapTranslations = true,
                ScaleAToB       = 1f, // TODO: Make this scale factor configurable.
            });

            // An UpperBackBoneMapper is a special bone mapper that is specifically designed for
            // spine bones. It uses the spine, neck and shoulders to compute the rotation of the spine
            // bone. This rotations is transferred to the Dude's "Spine" bone.
            // (An UpperBackBoneMapper does not transfer bone translations.)
            _skeletonMapperA.BoneMappers.Add(new UpperBackBoneMapper(
                                                 ks.GetIndex("Spine"), ks.GetIndex("ShoulderCenter"), ks.GetIndex("ShoulderLeft"), ks.GetIndex("ShoulderRight"),
                                                 ms.GetIndex("Spine"), ms.GetIndex("Neck"), ms.GetIndex("R_UpperArm"), ms.GetIndex("L_UpperArm")));

            // A ChainBoneMapper transfers the rotation of a bone chain. In this case, it rotates
            // the Dude's "R_UpperArm" bone. It makes sure that the direction from the Dude's
            // "R_Forearm" bone origin to the "R_UpperArm" origin is parallel, to the direction
            // "ElbowLeft" to "ShoulderLeft" of the Kinect skeleton.
            // (An ChainBoneMapper does not transfer bone translations.)
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ShoulderLeft"), ks.GetIndex("ElbowLeft"), ms.GetIndex("R_UpperArm"), ms.GetIndex("R_Forearm")));

            // And so on...
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ShoulderRight"), ks.GetIndex("ElbowRight"), ms.GetIndex("L_UpperArm"), ms.GetIndex("L_Forearm")));
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ElbowLeft"), ks.GetIndex("WristLeft"), ms.GetIndex("R_Forearm"), ms.GetIndex("R_Hand")));
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ElbowRight"), ks.GetIndex("WristRight"), ms.GetIndex("L_Forearm"), ms.GetIndex("L_Hand")));
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("HipLeft"), ks.GetIndex("KneeLeft"), ms.GetIndex("R_Thigh"), ms.GetIndex("R_Knee")));
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("HipRight"), ks.GetIndex("KneeRight"), ms.GetIndex("L_Thigh1"), ms.GetIndex("L_Knee2")));
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("KneeLeft"), ks.GetIndex("AnkleLeft"), ms.GetIndex("R_Knee"), ms.GetIndex("R_Ankle")));
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("KneeRight"), ks.GetIndex("AnkleRight"), ms.GetIndex("L_Knee2"), ms.GetIndex("L_Ankle1")));
            _skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ShoulderCenter"), ks.GetIndex("Head"), ms.GetIndex("Neck"), ms.GetIndex("Head")));

            // We could also try to map the hand bones - but the Kinect input for the hands jitters a lot.
            // It looks better if we do not animate the hands.
            //_skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("WristLeft"), ks.GetIndex("HandLeft"), ms.GetIndex("R_Hand"), ms.GetIndex("R_Middle1")));
            //_skeletonMapperA.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("WristRight"), ks.GetIndex("HandRight"), ms.GetIndex("L_Hand"), ms.GetIndex("L_Middle1")));

            //
            // ----- SkeletonMapper for the Marine model.
            //
            // (Same as for the Dude - only different bone names.)
            _skeletonMapperB = new SkeletonMapper(_kinectWrapper.SkeletonPoseB, _meshNodeB.SkeletonPose);
            ks = _kinectWrapper.SkeletonPoseB.Skeleton;
            ms = _meshNodeB.SkeletonPose.Skeleton;
            _skeletonMapperB.BoneMappers.Add(new DirectBoneMapper(ks.GetIndex("HipCenter"), ms.GetIndex("Spine_0"))
            {
                MapTranslations = true,
                ScaleAToB       = 1f, // TODO: Make this scale factor configurable.
            });
            _skeletonMapperB.BoneMappers.Add(new UpperBackBoneMapper(
                                                 ks.GetIndex("Spine"), ks.GetIndex("ShoulderCenter"), ks.GetIndex("ShoulderLeft"), ks.GetIndex("ShoulderRight"),
                                                 ms.GetIndex("Spine1"), ms.GetIndex("Neck"), ms.GetIndex("R_Arm"), ms.GetIndex("L_Arm")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ShoulderLeft"), ks.GetIndex("ElbowLeft"), ms.GetIndex("R_Arm"), ms.GetIndex("R_Elbow")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ShoulderRight"), ks.GetIndex("ElbowRight"), ms.GetIndex("L_Arm"), ms.GetIndex("L_Elbow")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ElbowLeft"), ks.GetIndex("WristLeft"), ms.GetIndex("R_Elbow"), ms.GetIndex("R_Hand")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ElbowRight"), ks.GetIndex("WristRight"), ms.GetIndex("L_Elbow"), ms.GetIndex("L_Hand")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("HipLeft"), ks.GetIndex("KneeLeft"), ms.GetIndex("R_Hip"), ms.GetIndex("R_Knee")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("HipRight"), ks.GetIndex("KneeRight"), ms.GetIndex("L_Hip"), ms.GetIndex("L_Knee")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("KneeLeft"), ks.GetIndex("AnkleLeft"), ms.GetIndex("R_Knee"), ms.GetIndex("R_Ankle")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("KneeRight"), ks.GetIndex("AnkleRight"), ms.GetIndex("L_Knee"), ms.GetIndex("L_Ankle")));
            _skeletonMapperB.BoneMappers.Add(new ChainBoneMapper(ks.GetIndex("ShoulderCenter"), ks.GetIndex("Head"), ms.GetIndex("Neck"), ms.GetIndex("Head")));
        }