Top Banner
Advanced Kinect Tricks
12

Advanced Kinect Tricks. Shapes Game Goal is to demonstrate how to create a simple game that uses Kinect audio and skeletal tracking information The game.

Dec 14, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Slide 1

Advanced Kinect Tricks Slide 2 Shapes Game Goal is to demonstrate how to create a simple game that uses Kinect audio and skeletal tracking information The game displays the tracked skeleton of the players and shapes (circles, triangles, stars, and so on) falling from the sky. Players can move their limbs to make shapes change direction or even explode, and speak commands such as "make bigger"/"make smaller" to increase/decrease the size of the shapes or "show yellow stars" to change the color and type of falling shapes. Slide 3 Demo Slide 4 How does it work? App.xaml Declaration of application level resources. App.xaml.cs Interaction logic behind app.xaml. FallingShapes.cs Shape rendering, physics, and hit-testing logic. MainWindow.xaml Declaration of layout within main application window. MainWindow.xaml.cs NUI initialization, player skeleton tracking, and main game logic. Recognizer.cs Speech verb definition and speech event recognition. Slide 5 Step 1 (Register for Events) Kinect.Initialize( RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor ) Kinect.SkeletonFrameReady += new EventHandler (SkeletonsReady); speechRecognizer = SpeechRecognizer.Create(); speechRecognizer.Start(new KinectAudioSource()); speechRecognizer.SaidSomething += new EventHandler (recognizer_SaidS omething); Slide 6 Process Events Process skeleton data MainWindow.xaml.cs Method: void SkeletonsReady(object sender, SkeletonFrameReadyEventArgs e) Update the joint data positions Process speech MainWindow.xaml.cs Method: void recognizer_SaidSomething(object sender, speechRecognizer.SaidSomethingEventArgs e) Match it with the speech vocabulary and get the command Slide 7 Translate the speech command to a list of operations for the falling objects For ex. the speech commands reset will get translated to: SetPolies(PolyType.All); SetDropRate(dropRate); SetGravity(dropGravity); SetSize(dropSize); SetShapesColor(Color.FromRgb(0, 0, 0), true); Slide 8 How do you find out a hit? Any guess? Slide 9 How do you find out a hit? Convert joints data into bones/segments data (a bone is a segment that connects two joints) Now, we can maintain a dictionary of {bone, } Update the segment's position and compute a smoothed velocity for the circle or the endpoints of the segment based on the time it took to move from the last position to the current one. The velocity is in pixels per second. Slide 10 How do you find out a hit? Lets see FailingShapes.cs class FallingThings public bool Hit(Segment seg, ref Point ptHitCenter, ref double lineHitLocation) if hit, the center point on the segment being hit is returned, along with the spot on the line from 0 to 1 if a line segment was hit. Slide 11 Bouncing off after a hit Lets see FailingShapes.cs class FallingThings public void BounceOff(double x1, double y1, double otherSize, double fXv, double fYv) Slide 12 The useful code that you can reuse SpeechRecognizer.cs We have already covered it in lab3 Finding out a hit between the skeleton and an object The bouncing off effect.