Thanks to anyone who stopped by the Unity3d booth at GDC and said howdy to Sandor and I and checked out the multi-touch table: the FishTish.
As promised, the updated uniTUIO scripts have been made available on the xtuio.com site!
They have actually been up for quite some time now, but I ahve been (as usual) either too busy or too lazy to get a post up, so here it is:
Note: they have been pretty much fully redesigned to take advantage of the ‘iPhone Input’ style of touch detection.
What does this mean? Well, the older scripts used a more centralized raycasting and distribution method. There was one main event handler that took each touch point and checked to see if it collided with any registered ‘touchable’ objects. This is a perfectly good design, and it works very well when you have lots and lots of points (in other words, you are only raycasting once per touch per frame)
However, we decided to go away from that and create a fake iPhoneInput class that you can access from the desktop version of Unity.
Well, the most compelling reason was so that we could quickly and easily port iPhone apps to the touch table. Once I had the faux iPhoneInput class that was being populated with TUIO generated touch information, then it was trivial to take a few of the iPhone apps (and most all of the Unity iPhone tutorial projects) and simply drop them in and have them ‘just work’.
In fact, funny story: On the first day of the GDC expo, I had another Unity/iPhone dev come up and he was excited about the FishTish and thought that his app: iPottery would work really well on it. I grabbed the code from him with the intention of dropping in our scripts and installing it as one of the demo apps on the FishTish. Well, that day was quite a long one and I did not have the energy to actually do anything with the script until the next morning. I spent approximates 15 minutes with a totally unfamiliar code base (iPottery scripts are all in JS and the uniTUIO stuff is all in C#, so that also speaks to how simple it is to use them :-) and I had it working no problems. I spent most of my time deleting the onGUI stuff (onGUI doesnt work with uniTUIO, soory!) and adding some guiText/guiTexture based buttons instead.
For the next two days of the expo we showed off iPottery along with all the other demo apps and it worked great!
Ok, enough of my tangent, how does this actually work?
Well, grab the sample project from the link above, there are two scenes, one called ‘basic touch’ and one called ‘buttons’. Buttons actually contains the entirety of ‘basic touch’. (it just has more buttons in it)
Effectively what the new scripts provide is am iPhoneInput class that you can use in your TUIO enabled MT apps just like you would if you were writing an app for your iPhone or iPad. I have provided a dozen or so scripts that show some examples of how to use the iPhoneInput to do things like basic drag/scale/rotate and build buttons using either GUIText/GUITextures or 3d objects.
I havent had time to put together a video yet, but the code is pretty easy. The only thing that you will need is to make sure that you have an active BBiPhoneInputManager script running somewhere in your scene.
I use the BBTouchManagerStarter script to check to see if there is already an input manager and if not then make one. This is good because if you switch scenes, the input manager does not get destroyed. In an actual deployment, you can just instantiate one in your opening scene and be done with i, but during testing when you want to be able to just look at the scene you are in, this can become cumbersome, so I use the BBTouchManagerStarter in all my scenes instead.