Monthly Archives: June 2011
- Access to raw data streams.
- The capability to track the skeleton image of one or two people moving.
- Advanced audio capabilities.
- Audio processing capabilities.
- Sample code and documentation
- Easy installation.
These are the keyfeatures of the new kinect sdk for windows. Microsoft released the beta version a few day ago. You can download the sdk and find amazing demos here.
I think this makes kinect support in the next XNA version much more likely.
An inkcanvas can be serialized so that you have a byte array to send over a network.
For the client, in this case the canvas someone draws on, you create a TcpClient.
Fortunately this is handled by the .Net framework for you.
TcpClient client = new TcpClient(“192.168.0.1”, 42000);
Next you create a MemoryStream to save your StrokeCollection on the inkCanvas to. The Networkstream doesn’t support this. But you can send the byte array without problems.
MemoryStream memstream = new MemoryStream();
Get the Networkstream form the TcpClient.
NetworkStream netstream = client.GetStream();
In a real application you should put this in a separate thread, but for this example let us simply assume this is running in the Window with the inkCanvas. This saves the inkCanvas Stroke Collection to the memory as a byte array.
The byte array can be send to the networkstream and with that to the TcpServer on the other end of the connection.
netstream.Write(memstream.GetBuffer(), 0, memstream.GetBuffer().Length);
Some cleaning up and the client is complete.
Please note that you need to at least catch some exceptions before using this in any real application. #
The server looks pretty much the same.
Create the Server in the form of a TcpListener. The framework handles this for you.
TcpListener server = new TcpListener(42000);
Start the server. server.Start();
Tell the server to Accept a waiting connection from a TcpClient and save this client. This will freeze the Thread till a connection is established. So better put this in some other thread that is dedicated to communication.
TcpClient client = server.AcceptTcpClient();
Grab the Networkstream the client is writing to.
NetworkStream netstream = client.GetStream();
Fortunately the StrokeCollection Class has a constructor that take a stream as parameter. StrokeCollection p = new StrokeCollection(netstream) ;
The usual cleanup.
And don’t forget to pass the information somewhere. If you are sure, that nothing will happen with the object you can save the Clone(). But it is more secure to make a copy of the data for the gui. Otherwise you might get into troubles with the next update.
this.inkCanvas1.Strokes = p.Clone();
My videocard stopped working last week. So my first solution to this problem was to switch back to the onboard vga card. Problem with that is, that it cannot display the Windows Phone 7 emulator. So i cannot test or screenshot anything for the tutorial series.
I bought a new (cheap) PCIe videocard to solve this. Sadly it did not work and after some searching the web i found out, that my chipset, the old 915GV, does not support PCIe videocards. The only thing working in the PCIe slot is a special DVI Adapter extension for the onboard card.
What i am trying to say is, it might take a few days till i can update the tutorial again. Sorry about the delay.
If you have big levels and/or a huge amount of 3d models you have to render you will find that the game gets slower and slower.
Before you try to optimize the draw codes, please use a profiler to make sure, that the problem is not somewhere else. Maybe the update logic is the problem?
You have some ways to tackle the problem:
- optimize everything in your draw code and shaders
- tell the user to buy a better computer
- remove objects
- lower the quality of models
Or you could scale the quality with the power of the computer displaying them.
To do so in a quick (and a bit dirty) way go to your class that holds the model and decides which model is to render (might be only one there without a LoD system or damage system).
- Add a second and third model.
- Make low poly versions of your model. One really low and one somewhere around the quality you can life with.
- Load these lower versions of the model in your class
- Add some code to check the distance to the camera
- Now simply make some if statements:
- If(distance >500.0f) do nothing
- If(distance > 300.0f) draw(lowest_quality_model)
- If(distance > 100.0f) draw(average_quality_model)
- else draw (high_quality_model)
- Play around till the numbers make sense in your game.
- You might also add a condition that a slow running game never renders the highest_quality_model
- As my LoD system not only draws the model but the shadows too i could use the lowest quality model to draw the shadow.
- I also added a condition that the game fist tries to stop drawing shadows and than lowers the quality of models even further till the point where only the lowest poly models really close to the camera a drawn and the rest is ignored.
- Be carefull with drastic measures. It is not always good to lower the overall quality of models just because the game missed one or two frames somewhere. The problem might not be the draw code at all.
Hope this helps you.