Integrate TUIO based Input
by Michael Savarese · in Torque Game Builder · 09/25/2009 (1:22 am) · 5 replies
I am looking to integrate the TUIO based multi-touch input for a project into the game engine and am new to the code side of TGB. Where should I start looking or does anyone have suggestions for how to achieve this?
Basically what I need is to be able to have an object listenfor events which is already written in TUIO c++ classes but need to be able to send a script event when that touch event is received.
Basically what I need is to be able to have an object listenfor events which is already written in TUIO c++ classes but need to be able to send a script event when that touch event is received.
#2
I'll be writing a rough one-player tennis game tomorrow. If that goes well, I'll post a resource on what I did.
If anybody is curious as to why you'd want this, take a look at this video:
01/24/2010 (7:11 am)
Yes! I did it! I've integrated the C++ TUIO source into TGB and now have a multi-touch input device talking to TGB! I ended up making a TuioEvent and I only have the t2dSceneWindow working with it right now, but that's good enough for my purposes.I'll be writing a rough one-player tennis game tomorrow. If that goes well, I'll post a resource on what I did.
If anybody is curious as to why you'd want this, take a look at this video:
#3
I'll eventually be using the ReacTIVision image processor since it supports fidicials (the weird amoeba-like shapes on the pucks in the video above).
01/25/2010 (4:43 am)
I made a quick demo app in TGB. In the upper-left is the image processor "Community Core Vision". In the lower-right is the quick demo. It's just a ball bouncing around, and then the multi-touch adds more balls to bounce against.I'll eventually be using the ReacTIVision image processor since it supports fidicials (the weird amoeba-like shapes on the pucks in the video above).
#4
01/25/2010 (4:45 am)
And as an idea of how hard this is to work with:function sceneWindow2D::onTuioCursorAdd( %this, %id, %x, %y )
{
%pos = sceneWindow2D.getWorldPoint( %x, %y );
$BALL[%id] = new t2dStaticSprite() {
scenegraph = BulletballScene;
imageMap = "puzzleGem_5ImageMap";
frame = "0";
canSaveDynamicFields = "1";
size = "6.250 6.250";
Layer = "6";
CollisionActiveReceive = "1";
CollisionCircleScale = "0.75";
CollisionDetectionMode = "CIRCLE";
CollisionResponseMode = "BOUNCE";
CollisionCircleSuperscribed = "0";
Immovable = "1";
position = %pos;
};
}
function sceneWindow2D::onTuioCursorUpdate( %this, %id, %x, %y )
{
%pos = sceneWindow2D.getWorldPoint( %x, %y );
$BALL[%id].setPosition( %pos );
}
function sceneWindow2D::onTuioCursorRemove( %this, %id, %x, %y )
{
$BALL[%id] = 0;
}
Associate William Lee Sims
Machine Code Games
I've got a rough outline of what I'd do, but it's going to be a pain.
First I was going to modify the GuiEvent (in gui/core/guiTypes.h) to have an ID (associated with the TUIO ids). This would require a change in the InputEvent class (platform/event.h). Finally, I was going to add a device much like the DInputDevice in platformWin32/winDInputDevice.h that would be a TUIOInputDevice which builds the InputEvent.
Now comes the ENORMOUS PAIN. I was planning on passing the TUIO ID to the scripts as the last parameter. I would just assume that a "0" was the real mouse while any other ID would be from the TUIO.
Like I said... this is just a rough outline of where I would start. I'm sure there's much more complication than I'm anticipating.
Good Luck!