ofxTuio

Hello,

I finished a first version of a TUIO Client class for OF. It uses ofxOSC so it’s really easy to use. Right now I only tested it in xCode on Mac but it should work cross plattform (because of ofxOSC). You can download it at:
http://addons.openframeworks.cc/projects/show/ofxtuio

It also includes an example. I recommend to test it with tuio simulator. get it here:
http://reactable.iua.upf.edu/?software

See a video here:
http://vimeo.com/1990755

If you find any bugs please tell me. Furthermore you can also improve things in general if you want to since I am pretty new to c++ and programing in general.

For future releases I plan to add 3D tuio support.

Cheers

moka

awesome! will try this out asap…

Wow awesome!

I’m glad you got it working! Did you end up using any of the c++ reactivision client?

I’ll be sure to check this out VERY soon. Will you be including an event system so we know when fingers/objects are down/up/moved?

Thanks!
I actually used the processing and c++ classes from reactivision as reference. I also plan to add events. If anybody else wants to add things just gor for it because I need to wrap my head around it first.

What would be the best way to implement events? Maybe Using poco?

BTW: I made small changes to the curent version. download it here:
http://addons.openframeworks.cc/projects/show/ofxtuio

Hi moka

The way to go to implement events, is poco, with a particular pattern to hide the implementation details from the users, you can take a look at ofxMailUtils, to see how it’s organized. The trickiest part is the forward declaration of the listener and manager in the .h file for the class that generates the events (in my case ofxMailUtils.h)

Also if you can wait, I have a python tool to generate the code for the events, it’s not yet working for the very last implementation, but it should be easy to modify. I’ll post when it’s complete.

that sounds great arturo! I have time, right now I don’t need any events. I only need cursor positions right now since it will only be used for some tracking. I will take a look at your src code anyways. And please let me know when your tool is done!

Is #include “Poco/BasicEvent.h” what I need?
http://www.appinf.com/poco/wiki/tiki-in-…-page=Event

yes, that and delegates, but if you just use them directly, the syntax to register an application to the events will be fairly complicated.

okay thanks, I will see if I can figgure out a way how to implement the events as easy as possible. if I understand you correctly you would write a class that contains all the poco stuff (like the ofxPop3EventListener in your ofxMailUtils).

Yes, you should have an events folder in your addon, and there a .h file that contains a listener, a manager and perhaps another class for the parameters of the event.

The listener is the class you inherit to be able to receive the events from your app.

The manager implements the addListener, removeListener and notify methods that manage all the poco related stuff. You can have different methods for this: don’t remember the tuio events but can be something like:
addNewObjectListener, addObjectRotatedListener…

Then for your addon I suppose you will only need to register listeners to one instance (there are no separate controls to which you need to register listeners independently) so you can create a global instance of the manager, that should be called something like ofxTuioEvents so you can register listeners by calling

  
ofxTuioEvents.addListener(this);  

Take a look at ofMouseEvents.h, I think is the most similar to what you need

If you have any problems just post when you have something done, and i’ll try to help.

Thank you very much arturo!

Just some more general things:

I plan to implement

moved, down and up events.

Isn’t a cursor always down if it is alive? and up if it gets removed/dies? Does anybody know how other Tuio clients do it?

moka:

Well yes it’s always down if it’s alive, but you usually need to know when it was first down. So a down event would be when it’s first down, just lick when a mouse is first pressed. Then move (or update) would be where it is after the initial down and up would be an event sent when it’s no longer alive.

You can see where we send events in the AS3 flash TUIO classes I posted in your other thread. We also dispatch events for rollover, rollout. I’m not sure how all that translates to C++.

okay, here is what I did so far:

I rewrote ofMouseEvents just for testing and added it to simple app like that:

  
class testApp : public ofSimpleApp, public ofxTuioEventListener{...}  

Then in setup I added it to the events manager like that:

  
ofxTuioEvents.addListener(this);  

that works so far. is that the way you wanted to implement it? I am actually really confused about how to progress from there and if this is the way I should be doing it.

PS: I also added a video so you don’t need to download it if you just want to see what this is about:
http://vimeo.com/1990755

Yes that should be. Now if you want to register to different events individually, you have to create the methods for them, like:

addDownListener
addUpListener

Then when that events happen in your tuio class you need to call ofxTuioEvents.notify(this)

If you want to upload what you have by now, i’ll take a look.

THanks again arturo. I added some notifications in the ofxTuioClient.h and I at least get the notifications. Anyways they don’t seem to be “blob specific” right now.

I uploaded the source for you on my googleCode account. Check it out here:
http://code.google.com/p/mokacode/downloads/list

I commented the parts where I send any notifications so you can find it easier.

Thanks in advance for your help!

that seems ok to me. The only thing, change the names of the methods in the listener to tuioMoved, tuioUp and tuioDown. Up, down and moved are pretty generic and can be problematic. And some methods like addupListener to addUpListener: note the capital U in Up, and sorry for being so picky :slight_smile:

If you want the events to be blob specific, I suppose every blob has its id. Take a look at the events in ofxMidiIn (in the addons site). There i’m using a map to store a different poco BasicEvent for each midi controller id. This should be more or less the same.

ofxTuio 0.2

I uploaded a new version of ofxTuio which fixed some bugs and added events. Thanks to arturo who helped me to understand how poco events work!

Download:
http://addons.openframeworks.cc/project-…-es/ofxtuio

I could not test if the events work correctly when you move multiple objects at once but for my understanding they should!

Please suggest any improvements and report bugs!

Thanks!

Hi moka,

Am trying out your ofxTUIO addon…but i do not have poco. I’m compiling your example with VS2008 and was wondering how to install poco such that it works with my current OF0.05FAT. There are a few poco-OF installations floating around on the forum but I do not know which ones I should be using. Any brief instructions would be appreciated.

Hi Progen,

I am actually using a newer version of OF which allready includes poco. I am on a mac though.

I am using this version:
http://www.openframeworks.cc/files/0057-…-thPoco.zip

Its a preview to of 0.6 and compiled for xcode. I don’t know if there is a windows version out there allready.

sorry pc is trailing the mac…

here is a poco version with no apps (just an empty example) –

http://www.openframeworks.cc/files/of-p-…-noApps.zip

I’m trying to make a full CB and VS 2008 as soon as I can –

take care!
zach