How to map skeleton to shape in C# - c#

I am trying to write a Tetris game using Kinect. There are two game players. One of the game players will move the blocks and the other will define the shape of the blocks using body positions.
Now, the challenge I am facing is : How do I map the body position to a block?
For example I have this shape given below.
I want to identify it as a 'T' shape block. How do i Do it?\
Here is what I thot:
I will store sample images of all the blocks (total 10) and compare the skeleton image from camera to these stored images and then display the block to which the camera has a match.
However, this is the toughest part. How do I find a match? Even if I have a T shaped sample image, what processing do I do with this skeleton so that It resembles a T shape before the comparison can be done?

I would suggest using a gesture recognition library. Such as:
https://github.com/EvilClosetMonkey/Fizbin.Kinect.Gestures
http://kinecttoolbox.codeplex.com/
You can define the gestures as a static held position -- for example, "Menu" in the Fizbin.Kinect.Gestures library. When the particular gesture is recognized an event is fired and you can then act upon it, by showing the shape you desire.

Related

Unity - How to combine sprites into one

I want to make RPG game using Unity2d with the tile feature to draw the game map.
I created a new class inherited from UnityEngine.Tilemaps.Tile and overrided void GetTileData.
In void GetTileData I determine the sprite to show for each tile according to the tile's neighbors.
See the image below. The source image is input from the inspector. The input is only one image like this below. I don't want to make massive input images caus that totally mess up.
But then I have a problem. When in the game I have to extract certain blocks from the source image and combine them into a new sprite to show onto the map as a tile sprite.
Just want to know, if I have the 4 rectangles known, and want to combine them into a sprite like the image above, how can I do that?
There is no easy way to do what you want in code. Simply use a tilemap with smaller base tiles.

Kinect-WPF Focus on Hover

I am wondering if it is possible to implement an interface similar to Apple's tvOS in WPF with Kinect v2 whereby the hovering of a hand on the screen would focus on the closest button in a grid layout filled with buttons as illustrated in the link below:
https://developer.apple.com/tvos/human-interface-guidelines/images/overview-clear.mp4
https://codepen.io/anon/pen/KvKOzo Mockup illustrating intended interface
If it is possible to implement such an interface, can somebody provide any guidelines, pseudocode or libraries that can help achieve such an interface using WPF and Kinect v2.
You'll need to transform your Skeleton space to a 2d space (color space for instance) and map that space to your WPF view, you'll then have a stream of x and y coordinates of your hand.
Then you can do a AABB collision detection to determine if your hand "touches" the button.
There's some Kinect example projects on:
http://kinectforwindows.codeplex.com/
Controls-Basic-WPF seems like a good starting point.

Monogame - Loading between levels

I'm currently building a 2D platformer using Monogame and I'm having a bit of an issue. The way I have designed my game is that I use an array to draw out the map of tiles, which all have collision, like this:
protected override void LoadContent()
{
map.Generate(new int[,] {
// 0 = no tile drawn
// 3 = tile is drawn
{0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,},
{3,3,3,3,3,3,3,3,3,3,},
{3,3,3,3,3,3,3,3,3,3,},
}, 57); // size
}
However I'm trying to think of a way that allows me to load another array that of course would have tiles placed differently once the player reaches a certain point, for example, using the array in my question, if the player spawns on the left and reaches the last tile on the right.
What would be the simplest way of trying to accomplish this?
Here's a good reference, supplied by Microsoft. This will allow you to examine and breakdown a working version of a 2D platformer.
https://msdn.microsoft.com/en-us/library/dd254916%28v=xnagamestudio.31%29.aspx
In brief, this is what I would expect to implement, regarding a 2D platformer and several levels (not scrolling).
Define the total screens, block size, total blocks to draw on the screen.
Create an array of screen block data.
Set the game screen number to your start screen.
Use that number to reference into the screen block data array and draw the blocks on screen.
The above data could be generated as a binary file and loaded in at start-up, or for ease created as an array of screne block data within your game class.
I'm sure the tutorial I've linked will guide you in the development of your game.

How do I convert a set of lines that are not intersecting into a maintainable polygon (triangle)?

I have an application I'm working on that requires a fair amount of 3D graphics programming. I have a series of lines that create both text and 3D cylindrical holes (see images).
I would like to be able to click and drag the objects in question using my mouse through the X,Y plane (Z constant). My understanding is that in order for the bounding boxes to be setup correctly, I have to have everything in using 3D polygons (triangles). I would like to be able to do collision detection without this conversion. Is this possible? If I must convert, can anyone point me to a piece of code that does this rather painlessly?
You can treat each line segment as a cylinder, and check them for collision.
Here's the math, as well as more alternatives.

Save cube in variable and apply scale/rotate/move OpenTK

I am creating simple 3D editor. I now can draw simple primitives like cube but, I don't know how to save this object to som variable and then copy it to other coordinates. I also don't know how rotate/scale/move this cube and save this new shape to variable. I have seen many tutorials on this topic, but in every one them, guy is moving only camera, not drawn object(cube). So basically I just need tutorial how to save some object to variable, than load this object from variable and draw it many times on different coordinates over scene and apply some transformation to these new objects(move,rotate,scale). I am creating this app in C# and OpenTK
Use the GL.Translate(x,y,z), GL.Rotate(θ,x,y,z) and GL.Scale(sx,sy,sz) functions to move the coordinate system origin, orientation and scaling.
So drawing a cube after the command
GL.Translate(10,10,100);
will draw the cube at the above location. Here is an (clunky) example of this process below:

Categories

Resources