private void DeHighlightFrames_Editor(Gesture g)
        {
            // De-highlight frame on grids
            Model3DGroup modelGroup_3D = (Model3DGroup)HotspotCellsModelVisual3D_Hit_Visualizer.Content;

            CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)] = new Model3DGroup();
        }
Esempio n. 2
0
 /// <summary>
 /// De-highlight frames on visualizer grids
 /// </summary>
 /// <param name="g">Gesture</param>
 private void DeHighlightFrames_Visualizer(Gesture g)
 {
     //Model3DGroup modelGroup_3D = (Model3DGroup)HotspotCellsModelVisual3D_Hit_Visualizer.Content; //this seems to be unused
     CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)]    = new Model3DGroup(); //TODO: maybe there is a bug here and wanted to use modelGroup_3D instead?
     CollisionHighlights_Front.Children[GestureCollection.IndexOf(g)] = new Model3DGroup(); //TODO: maybe reuse the "new Model3DGroup()" instead of creating 3 of those?
     CollisionHighlights_Side.Children[GestureCollection.IndexOf(g)]  = new Model3DGroup();
 }
Esempio n. 3
0
        /// <summary>
        /// Highlight frames on visualizer grids
        /// </summary>
        /// <param name="g">Gesture</param>
        /// <param name="fs">Gesture Frames</param>
        private void HighlightFrames_Visualizer(Gesture g, List <GestureFrame> fs)
        {
            Model3DGroup modelGroup = GetHighlightModel3D(g, fs);

            CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)]    = modelGroup;
            CollisionHighlights_Front.Children[GestureCollection.IndexOf(g)] = modelGroup;
            CollisionHighlights_Side.Children[GestureCollection.IndexOf(g)]  = modelGroup;
        }
        private void AddNewFrameButton_Click(object sender, RoutedEventArgs e)
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            // Add the frame to the Gesture object
            g.Frames.Add(MakeNewGestureFrame());
            // Extend CollisionTimes to keep track of collisions
            CollisionTimes[GestureCollection.IndexOf(g)].Add(new DateTime());
            // Select the newly added frame on the timeline
            FramesListBox.SelectedIndex = FramesListBox.Items.Count - 1;
            SyncEditorGrids();
        }
Esempio n. 5
0
        /// <summary>
        /// Undo changes done to gesture (or if it was a new one discard it)
        /// </summary>
        public void DiscardGesture()
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            if (ExGesture == null)                                           // If the gesture is a new gesture...
            {
                GestureCollection.Remove(g);                                 //...remove it from the Gesture Collection
            }
            else                                                             // else if the gesture is an existing gesture being edited...
            {
                GestureCollection[GestureCollection.IndexOf(g)] = ExGesture; //...restore it to its initial state
            }
            CloseEditor();
        }
Esempio n. 6
0
        public void AddNewFrame()
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            if (g == null)
            {
                return;
            }

            g.Frames.Add(MakeNewGestureFrame());                              // Add the frame to the Gesture object
            CollisionTimes[GestureCollection.IndexOf(g)].Add(new DateTime()); // Extend CollisionTimes to keep track of collisions
            FramesListBox.SelectedIndex = FramesListBox.Items.Count - 1;      // Select the newly added frame on the timeline

            SyncEditorGrids();
        }
Esempio n. 7
0
        public void DiscardGesture(object parameter)
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            // If the gesture is a new gesture, remove that m**********r from the Gesture Collection
            if (ExGesture == null)
            {
                GestureCollection.Remove(g);
            }
            // If the gesture is an existing gesture being edited, restore the m**********r to its initial state
            else
            {
                GestureCollection[GestureCollection.IndexOf(g)] = ExGesture;
            }
            // Go go go
            KillEditor();
        }
        private void HighlightFrames_Visualizer(Gesture g, List <GestureFrame> fs)
        {
            Model3DGroup modelGroup = new Model3DGroup();
            // Create material
            SolidColorBrush materialBrush = new SolidColorBrush()
            {
                Color   = Colors.White,
                Opacity = 0.3
            };
            EmissiveMaterial material = new EmissiveMaterial(materialBrush);

            foreach (GestureFrame f in fs)
            {
                foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                {
                    int fcIndex = Array.IndexOf(f.FrontCells, fc);
                    foreach (GestureFrameCell sc in f.SideCells.Where(
                                 sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                    {
                        // Init mesh
                        MeshBuilder meshBuilder = new MeshBuilder(false, false);
                        // Make cube and add to mesh
                        double  y          = (fc.LeftCM + fc.RightCM) / 2;
                        double  z          = (fc.TopCM + fc.BottomCM) / 2;
                        double  x          = (sc.LeftCM + sc.RightCM) / 2;
                        Point3D cubeCenter = new Point3D(x, y, z);
                        meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                        // Create and freeze mesh
                        var mesh = meshBuilder.ToMesh(true);
                        // Create models
                        modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                    }
                }
            }
            CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)]    = modelGroup;
            CollisionHighlights_Front.Children[GestureCollection.IndexOf(g)] = modelGroup;
            CollisionHighlights_Side.Children[GestureCollection.IndexOf(g)]  = modelGroup;
        }
Esempio n. 9
0
        public void Play(object parameter)
        {
            CollisionTimes            = new List <List <DateTime> >();
            CollisionStates           = new List <JointCollisionStates[]>();
            CollisionHighlights_3D    = new Model3DGroup();
            CollisionHighlights_Front = new Model3DGroup();
            CollisionHighlights_Side  = new Model3DGroup();
            foreach (Gesture g in GestureCollection)
            {
                CollisionTimes.Add(new List <DateTime>());
                foreach (GestureFrame f in g.Frames)
                {
                    CollisionTimes.Last().Add(new DateTime());
                }
                CollisionStates.Add(new JointCollisionStates[2] {
                    JointCollisionStates.OutThere, JointCollisionStates.OutThere
                });
                CollisionHighlights_3D.Children.Add(new Model3DGroup());
                CollisionHighlights_Front.Children.Add(new Model3DGroup());
                CollisionHighlights_Side.Children.Add(new Model3DGroup());
            }
            HotspotCellsModelVisual3D_Hit_Visualizer.Content = CollisionHighlights_3D;
            // Mark gesture cells in 3D Grid
            Model3DGroup modelGroup = new Model3DGroup();

            foreach (Gesture g in GestureCollection)
            {
                foreach (GestureFrame f in g.Frames)
                {
                    // Create material
                    SolidColorBrush materialBrush = new SolidColorBrush()
                    {
                        Color   = Visualizer_GestureColors[GestureCollection.IndexOf(g) % Visualizer_GestureColors.Length].Color,
                        Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.6
                    };
                    DiffuseMaterial material = new DiffuseMaterial(materialBrush);
                    foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                    {
                        int fcIndex = Array.IndexOf(f.FrontCells, fc);
                        foreach (GestureFrameCell sc in f.SideCells.Where(
                                     sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                        {
                            // Init mesh
                            MeshBuilder meshBuilder = new MeshBuilder(false, false);
                            // Make cube and add to mesh
                            double  y          = (fc.LeftCM + fc.RightCM) / 2;
                            double  z          = (fc.TopCM + fc.BottomCM) / 2;
                            double  x          = (sc.LeftCM + sc.RightCM) / 2;
                            Point3D cubeCenter = new Point3D(x, y, z);
                            meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                            // Create and freeze mesh
                            var mesh = meshBuilder.ToMesh(true);
                            // Create models
                            modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                        }
                    }
                }
                HotspotCellsModelVisual3D_Visualizer.Content = modelGroup;
            }
            // Show visualizer
            TheEditor.Visibility     = Visibility.Hidden;
            TheVisualizer.Visibility = Visibility.Visible;
            EditorOverlay.Visibility = Visibility.Hidden;
            // Hide Manager
            ManagerOverlay.Visibility = Visibility.Visible;
            // Enable Kinect
            if (kinect != null)
            {
                kinect.SkeletonStream.Enable();
                kinect.SkeletonFrameReady += SkeletonFrameReady_Draw3D_Visualizer;
                kinect.SkeletonFrameReady += SkeletonFrameReady_Detect_Visualizer;
                kinect.Start();
            }
            // Kill keyboard control
            EventLogic.RemoveRoutedEventHandlers(ViewPort3D_Visualizer.CameraController, HelixToolkit.Wpf.CameraController.KeyDownEvent);
        }
Esempio n. 10
0
        /// <summary>
        /// Sync 3D Viewport with grids
        /// </summary>
        private void SyncEditorGrids_3D(Gesture g) //TODO: split into smaller methods
        {
            // Init 3D stuff
            Model3DGroup modelGroup = new Model3DGroup();

            foreach (GestureFrame f in g.Frames)
            {
                // Create material
                SolidColorBrush materialBrush = new SolidColorBrush()
                {
                    Color   = Colors.DarkSlateBlue,
                    Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.8
                };
                DiffuseMaterial material = new DiffuseMaterial(materialBrush);

                foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                {
                    int fcIndex = Array.IndexOf(f.FrontCells, fc);
                    foreach (GestureFrameCell sc in f.SideCells.Where(
                                 sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                    {
                        // Init mesh
                        MeshBuilder meshBuilder = new MeshBuilder(false, false);
                        // Make cube and add to mesh
                        double  y          = (fc.LeftCM + fc.RightCM) / 2;
                        double  z          = (fc.TopCM + fc.BottomCM) / 2;
                        double  x          = (sc.LeftCM + sc.RightCM) / 2;
                        Point3D cubeCenter = new Point3D(x, y, z);
                        meshBuilder.AddBox(cubeCenter, 15, 15, 15);

                        // Create and freeze mesh
                        var mesh = meshBuilder.ToMesh(true);

                        // Create model
                        modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                    }
                }
            }

            // Suggest other gestures too
            foreach (Gesture gg in GestureCollection)
            {
                foreach (GestureFrame f in gg.Frames)
                {
                    // Create material
                    SolidColorBrush materialBrush = new SolidColorBrush()
                    {
                        Color   = Visualizer_GestureColors[GestureCollection.IndexOf(gg) % Visualizer_GestureColors.Length].Color,
                        Opacity = ((double)(gg.Frames.IndexOf(f) + 1) / (double)gg.Frames.Count) * 0.09
                    };
                    DiffuseMaterial material = new DiffuseMaterial(materialBrush);

                    foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                    {
                        int fcIndex = Array.IndexOf(f.FrontCells, fc);
                        foreach (GestureFrameCell sc in f.SideCells.Where(
                                     sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                        {
                            // Init mesh
                            MeshBuilder meshBuilder = new MeshBuilder(false, false);

                            // Make cube and add to mesh
                            double  y          = (fc.LeftCM + fc.RightCM) / 2;
                            double  z          = (fc.TopCM + fc.BottomCM) / 2;
                            double  x          = (sc.LeftCM + sc.RightCM) / 2;
                            Point3D cubeCenter = new Point3D(x, y, z);
                            meshBuilder.AddBox(cubeCenter, 15, 15, 15);

                            // Create and freeze mesh
                            var mesh = meshBuilder.ToMesh(true);

                            // Create model
                            modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                        }
                    }
                }
            }

            HotspotCellsModelVisual3D_Editor.Content = modelGroup;
        }
Esempio n. 11
0
        public void ShowVisualizer() //TODO: make method smaller (refactor into multiple methods)
        {
            CollisionTimes            = new List <List <DateTime> >();
            CollisionStates           = new List <JointCollisionStates[]>();
            CollisionHighlights_3D    = new Model3DGroup();
            CollisionHighlights_Front = new Model3DGroup();
            CollisionHighlights_Side  = new Model3DGroup();

            foreach (Gesture g in GestureCollection)
            {
                CollisionTimes.Add(new List <DateTime>());
                foreach (GestureFrame f in g.Frames)
                {
                    CollisionTimes.Last().Add(new DateTime());
                }
                CollisionStates.Add(new JointCollisionStates[2] {
                    JointCollisionStates.OutThere, JointCollisionStates.OutThere
                });
                CollisionHighlights_3D.Children.Add(new Model3DGroup());
                CollisionHighlights_Front.Children.Add(new Model3DGroup());
                CollisionHighlights_Side.Children.Add(new Model3DGroup());
            }

            HotspotCellsModelVisual3D_Hit_Visualizer.Content = CollisionHighlights_3D;

            // Mark gesture cells in 3D Grid
            Model3DGroup modelGroup = new Model3DGroup();

            foreach (Gesture g in GestureCollection)
            {
                foreach (GestureFrame f in g.Frames)
                {
                    // Create material
                    SolidColorBrush materialBrush = new SolidColorBrush()
                    {
                        Color   = Visualizer_GestureColors[GestureCollection.IndexOf(g) % Visualizer_GestureColors.Length].Color,
                        Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.6
                    };
                    DiffuseMaterial material = new DiffuseMaterial(materialBrush);

                    foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                    {
                        int fcIndex = Array.IndexOf(f.FrontCells, fc);
                        foreach (GestureFrameCell sc in f.SideCells.Where(
                                     sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                        {
                            // Init mesh
                            MeshBuilder meshBuilder = new MeshBuilder(false, false);
                            // Make cube and add to mesh
                            double  y          = (fc.LeftCM + fc.RightCM) / 2;
                            double  z          = (fc.TopCM + fc.BottomCM) / 2;
                            double  x          = (sc.LeftCM + sc.RightCM) / 2;
                            Point3D cubeCenter = new Point3D(x, y, z);
                            meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                            // Create and freeze mesh
                            var mesh = meshBuilder.ToMesh(true);
                            // Create models
                            modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                        }
                    }
                }
                HotspotCellsModelVisual3D_Visualizer.Content = modelGroup;
            }

            VisualizerVisible = true;

            EnableKinect_Visualizer();
            DisableKeyboardControl_Visualizer(); //we don't want to consume emulated keyboard events
        }
 private void SyncEditorGrids()
 {
     try {
         Gesture g = (Gesture)TheWorkspace.DataContext;
         // Enable/disable rows on SideViewGrid according to selection on FrontViewGrid
         GestureFrame       sf  = (GestureFrame)FramesListBox.SelectedItem;
         GestureFrameCell[] fcs = (GestureFrameCell[])FVGrid.ItemsSource;
         GestureFrameCell[] scs = (GestureFrameCell[])SVGrid.ItemsSource;
         // 'If' overcomes FVGrid_SelectionChanged firing before everything else and syncing SVGrid to a different Frame's FVGrid
         if (Object.ReferenceEquals(sf.FrontCells, fcs) && Object.ReferenceEquals(sf.SideCells, scs))
         {
             IList      frontViewGrid_selectedCells = (IList)FVGrid.SelectedItems;
             List <int> frontViewGrid_selectedRows  = new List <int>();
             foreach (GestureFrameCell c in frontViewGrid_selectedCells)
             {
                 frontViewGrid_selectedRows.Add((int)(c.IndexInFrame / 20));
             }
             for (int i = 0; i < 400; i++)
             {
                 ListBoxItem sideViewGridItemContainer = (ListBoxItem)SVGrid.ItemContainerGenerator.ContainerFromIndex(i);
                 if (frontViewGrid_selectedRows.Contains((int)(i / 20)))
                 {
                     sideViewGridItemContainer.IsEnabled = true;
                 }
                 else
                 {
                     sideViewGridItemContainer.IsEnabled = false;
                     GestureFrame f = (GestureFrame)SVGrid.DataContext;
                     f.SideCells[i].IsHotspot = false;
                 }
             }
         }
         // Put hints for the current gesture's existing hotspots below both 2D grids
         FVHints.Children.Clear();
         SVHints.Children.Clear();
         for (int i = 0; i < 400; i++)
         {
             FVHints.Children.Add(new Border()
             {
                 Background = Brushes.Transparent, BorderBrush = Brushes.Transparent
             });
             SVHints.Children.Add(new Border()
             {
                 Background = Brushes.Transparent, BorderBrush = Brushes.Transparent
             });
         }
         foreach (GestureFrame f in g.Frames)
         {
             foreach (GestureFrameCell c in f.FrontCells.Where(c => c.IsHotspot))
             {
                 Border b = (Border)FVHints.Children[c.IndexInFrame];
                 b.Background = new SolidColorBrush()
                 {
                     Color = Colors.SlateBlue, Opacity = 0.2
                 };
             }
             foreach (GestureFrameCell c in f.SideCells.Where(c => c.IsHotspot))
             {
                 Border b = (Border)SVHints.Children[c.IndexInFrame];
                 b.Background = new SolidColorBrush()
                 {
                     Color = Colors.SlateBlue, Opacity = 0.2
                 };
             }
         }
         // Also sync 3D Viewport with grids
         // Init 3D stuff
         Model3DGroup modelGroup = new Model3DGroup();
         foreach (GestureFrame f in g.Frames)
         {
             // Create material
             SolidColorBrush materialBrush = new SolidColorBrush()
             {
                 Color   = Colors.DarkSlateBlue,
                 Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.8
             };
             DiffuseMaterial material = new DiffuseMaterial(materialBrush);
             foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
             {
                 int fcIndex = Array.IndexOf(f.FrontCells, fc);
                 foreach (GestureFrameCell sc in f.SideCells.Where(
                              sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                 {
                     // Init mesh
                     MeshBuilder meshBuilder = new MeshBuilder(false, false);
                     // Make cube and add to mesh
                     double  y          = (fc.LeftCM + fc.RightCM) / 2;
                     double  z          = (fc.TopCM + fc.BottomCM) / 2;
                     double  x          = (sc.LeftCM + sc.RightCM) / 2;
                     Point3D cubeCenter = new Point3D(x, y, z);
                     meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                     // Create and freeze mesh
                     var mesh = meshBuilder.ToMesh(true);
                     // Create model
                     modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                 }
             }
         }
         // Suggest other gestures too
         foreach (Gesture gg in GestureCollection)
         {
             foreach (GestureFrame f in gg.Frames)
             {
                 // Create material
                 SolidColorBrush materialBrush = new SolidColorBrush()
                 {
                     Color   = Visualizer_GestureColors[GestureCollection.IndexOf(gg) % Visualizer_GestureColors.Length].Color,
                     Opacity = ((double)(gg.Frames.IndexOf(f) + 1) / (double)gg.Frames.Count) * 0.09
                 };
                 DiffuseMaterial material = new DiffuseMaterial(materialBrush);
                 foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                 {
                     int fcIndex = Array.IndexOf(f.FrontCells, fc);
                     foreach (GestureFrameCell sc in f.SideCells.Where(
                                  sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                     {
                         // Init mesh
                         MeshBuilder meshBuilder = new MeshBuilder(false, false);
                         // Make cube and add to mesh
                         double  y          = (fc.LeftCM + fc.RightCM) / 2;
                         double  z          = (fc.TopCM + fc.BottomCM) / 2;
                         double  x          = (sc.LeftCM + sc.RightCM) / 2;
                         Point3D cubeCenter = new Point3D(x, y, z);
                         meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                         // Create and freeze mesh
                         var mesh = meshBuilder.ToMesh(true);
                         // Create model
                         modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                     }
                 }
             }
         }
         HotspotCellsModelVisual3D_Editor.Content = modelGroup;
     }
     catch (NullReferenceException) { return; }
 }