コード例 #1
0
 /// <summary>
 /// Get a scene or create it (And add it in the scene list)
 /// </summary>
 /// <param name="idAnimation"></param>
 /// <returns></returns>
 protected KineapScene GetOrCreateScene(int idAnimation, ModelType modelType)
 {
     KineapScene matchingSkeleton = sceneList.Where(animTmp => animTmp.SceneId == idAnimation)
                         .FirstOrDefault();
     Scene matchingScene = null;
     if (matchingSkeleton == null)
     {
         matchingScene = new Scene();
         matchingSkeleton = new KineapScene(idAnimation, matchingScene);
         matchingSkeleton.ModelType = modelType;
         this.sceneList.Add(matchingSkeleton);
     }
     else
         matchingScene = matchingSkeleton.Scene;
     return matchingSkeleton;
 }
コード例 #2
0
 public NewMcKineapAnimationWindowViewModel(KineapScene kineapScene)
 {
     mcKineapAnimationName = "McKineap Animation";
     mcKineapAnimationNumber = GetLastMcKineapAnimationIndex();
     this.kineapScene = kineapScene;
 }
コード例 #3
0
        /// <summary>
        /// Allows to merge a kinect recorded scene with a leap motion recorded scene
        /// </summary>
        /// <param name="sceneKinect">The recorded Kinect Scene</param>
        /// <param name="sceneLeapMotion">The recorded LeapMotion Scene</param>
        /// <param name="handDirection">The direction of the hand, 1 is for the right direction and 2 for the left</param>
        public static Scene MergeBodyAndHand(ref KineapScene[] kineapSceneBucket)
        {
            Scene generatedScene = new Scene();

            Scene kinectScene = kineapSceneBucket[0].Scene;
            KineapScene leftHandLeapMotionScene = kineapSceneBucket[1];
            KineapScene rightHandLeapMotionScene = kineapSceneBucket[2];
            string kinectHandfulLeft = KinectConverter.GetNodeIdName(Microsoft.Kinect.JointType.HandLeft);
            string kinectHandfulRight = KinectConverter.GetNodeIdName(Microsoft.Kinect.JointType.HandRight);

            Scene onlyAvailableLeapMotion = null;
            string kinectJointToMergeName = null;
            if (leftHandLeapMotionScene == null ^ rightHandLeapMotionScene == null)
            {
                if (leftHandLeapMotionScene != null)
                {
                    onlyAvailableLeapMotion = leftHandLeapMotionScene.Scene;
                    kinectJointToMergeName = kinectHandfulLeft;
                }
                else
                {
                    onlyAvailableLeapMotion = rightHandLeapMotionScene.Scene;
                    kinectJointToMergeName = kinectHandfulRight;
                }
            }

            if (kinectScene == null)
                throw (new ArgumentException("A skeleton should be at least present", "value"));
            else if (leftHandLeapMotionScene == null && rightHandLeapMotionScene == null)
                throw (new ArgumentException("One hand should be at least available", "value"));

            MergeBehaviour mergeBehaviour = new MergeBehaviour();
            mergeBehaviour.childrenCopy = true;
            if (onlyAvailableLeapMotion != null) //if only one hand
            {
                generatedScene.RootNode = AssimpAnimFormatMerger.MergeNodeStructure(
                    kinectScene.RootNode, kinectJointToMergeName,
                    onlyAvailableLeapMotion.RootNode, onlyAvailableLeapMotion.RootNode.Children[0].Name,
                    ref mergeBehaviour
                );
                generatedScene.Animations.Add(AssimpAnimFormatMerger.MergeAnimations(kinectScene.Animations[0], onlyAvailableLeapMotion.Animations[0]));
                //We dont need the root nodeAnim anymore from the leap motion, we will only merge the children
                ExcludeNodeAnimation(generatedScene.Animations[0], onlyAvailableLeapMotion.RootNode.Name);
            }
            else // If both hands are presents
            {
                generatedScene.RootNode = AssimpAnimFormatMerger.MergeNodeStructure(
                    kinectScene.RootNode, kinectHandfulLeft,
                    leftHandLeapMotionScene.Scene.RootNode, leftHandLeapMotionScene.Scene.RootNode.Children[0].Name,
                    ref mergeBehaviour
                );
                generatedScene.Animations.Add(AssimpAnimFormatMerger.MergeAnimations(kinectScene.Animations[0], leftHandLeapMotionScene.Scene.Animations[0]));
                ExcludeNodeAnimation(generatedScene.Animations[0], leftHandLeapMotionScene.Scene.RootNode.Name);

                //We dont want to make copy that time, because we already did it
                mergeBehaviour.copyTreeNode1 = false;
                mergeBehaviour.copyTreeNode2 = true;
                AssimpAnimFormatMerger.MergeNodeStructure(
                    generatedScene.RootNode, kinectHandfulRight,
                    rightHandLeapMotionScene.Scene.RootNode, rightHandLeapMotionScene.Scene.RootNode.Children[0].Name,
                    ref mergeBehaviour
                );
                AssimpUtil.CopyAnimationInto(rightHandLeapMotionScene.Scene.Animations[0], generatedScene.Animations[0]);
                ExcludeNodeAnimation(generatedScene.Animations[0], rightHandLeapMotionScene.Scene.RootNode.Name);
            }

            return generatedScene;
        }
コード例 #4
0
ファイル: Project.cs プロジェクト: loic-lavergne/mckineap
 /// <summary>
 /// Load a captured Model3D From Kinect or LeapMotion
 /// </summary>
 /// <param name="name">The name of the Model3D file</param>
 /// <param name="scene">The Assimp Scene of the captured Model3D.</param>
 public void LoadCapturedModel3D(string name, KineapScene kineapScene)
 {
     Mckineap.Models.Engine3D.Model3D model3D = Mckineap.Models.Engine3D.Model3D.ConstructAsCapturedModel(name, kineapScene);
     model3D.Serialize();
     Load(model3D);
 }
コード例 #5
0
 public NewCaptureWindowViewModel(KineapScene kineapScene)
 {
     this.kineapScene = kineapScene;
     captureNumber = GetLastCaptureIndex();
     captureName = "Capture";
 }
コード例 #6
0
ファイル: Model3D.cs プロジェクト: loic-lavergne/mckineap
        /// <summary>
        /// Constructs a Model3D captured with Kinect or LeapMotion.<br />
        /// Creates a Model3D file in the models Workspace.
        /// </summary>
        /// <param name="name">The name of the captured Model3D.</param>
        /// <param name="scene">Assimp Scene</param>
        /// <returns></returns>
        public static Model3D ConstructAsCapturedModel(string name, KineapScene kineapScene)
        {
            if (Session.CurrentSession.HasCurrentProject())
            {
                string path = System.IO.Path.Combine(Session.CurrentSession.CurrentProject.GetCategoryPath("models"), name + ".mkmdl");
                File.Create(path);
                return new Model3D(path, kineapScene);
            }

            return null;
        }
コード例 #7
0
ファイル: Model3D.cs プロジェクト: loic-lavergne/mckineap
        public Model3D(string fullpath, KineapScene kineapScene)
            : base(fullpath) //: this (fullpath, kineapScene.Scene)
        {
            this.scene = kineapScene.Scene;
            this.kineapScene = kineapScene;
            /*
            if (Name.Contains(".mkmdl"))
            {
                int start = Name.IndexOf(".mkmdl");
                Name = Name.Remove(start, 6);
            }
            */
            bones = new Collection<Bone>();
            joints = new Collection<Joint>();
            content = new Model3DGroup();

            isInitialized = false;
            if (scene != null && scene.HasAnimations)
            {
                hasAnimation = true;
                animation = new Animation(scene.Animations[0]);
            }
            else
            {
                hasAnimation = false;
                animation = null;
            }

            Initialize();
        }
コード例 #8
0
 private void PromptMcKineapAnimationName(KineapScene kineapScene)
 {
     NewMcKineapAnimationWindow window = new NewMcKineapAnimationWindow(new NewMcKineapAnimationWindowViewModel(kineapScene));
     window.Owner = Application.Current.MainWindow;
     window.ShowDialog();
 }