Click here to Skip to main content
Click here to Skip to main content

Tagged as

Interactive Water Effect Multitouch

, 1 Feb 2011
Rate this:
Please Sign up or sign in to vote.
Interactive Water Effect Multitouch with Tuio Library

Introduction

I found an excellent article posted in CodeProject: Interactive water effect.

It's pretty good because you can make some wave on a plane by clicking on it with the mouse.

But, I made a multitouch table and I have adapted the program for it. So I share with you my code.

A video example can be found at http://www.youtube.com/watch?v=EkZDBLxMX9U.

Background

The interesting thing (because some of you could say, hmm, why make an article with this) is the library in opensource tuio library (http://www.tuio.org/?cpp).
The tuio library uses UDP to send touch event. For more information about table multitouch, see the example of the implementation of tuio lib C++ in a opengl application.

Using the Code

tuio lib provides a class TuioListener with offer method for touch Event.

The project in msvc is:

projetscreenshot.jpg
In the article, Interactive water effect, the project is an OpenGl program.

To implement the tuiolib, I made a class TuioDemo. This class has a constructor:

TuioDemo(int port)    
 {             
 tuioClient = new TuioClient(port);      
 tuioClient->addTuioListener(this);       
 tuioClient->connect();     
 if (!tuioClient->isConnected()) {          
      }     
 } 

The port is the UDP number for connecting to the software detecting the touch. My TuioDemo extends TuioListener and has to implement the methods:

void addTuioObject(TuioObject *tobj) { }  
void updateTuioObject(TuioObject *tobj) { } 
void removeTuioObject(TuioObject *tobj){ } 
void addTuioCursor(TuioCursor *tcur);
void updateTuioCursor(TuioCursor *tcur);
void removeTuioCursor(TuioCursor *tcur);
        
void refresh(TuioTime frameTime) { }    

The TuioListener is a design pattern: observer.

All methods ***TuiObject are there when the user puts a fiducial marker attached onto physical objects. So it's not interesting for this article.

The other ***TuioCursor is for touch by finger.

void addTuioCursor(TuioCursor *tcur);      When a finger touch the surface
void updateTuioCursor(TuioCursor *tcur);   When a finger move    
void removeTuioCursor(TuioCursor *tcur);   When a finger untouch. 

The TuioCursor gets some great information like: x_pos and y_pos accessible by methods: getX() and getY().

I made another method of TuioDemo:

void showWave(dmFlotte *flotte)
{         
    std::list<TuioCursor*> lstCursor = tuioClient->getTuioCursors();
    std::list<TuioCursor*>::iterator tcur; 
    for (tcur=lstCursor.begin(); tcur!= lstCursor.end(); tcur++) {                   
        flotte->setWave((*tcur)->getX(),-(*tcur)->getY(),  128);
    } 
}

This updates the plane according to all touches made at one time on the multitouch surface.
the flotte variable (in English slang, it's water) describes all perturbation on water. This method is called in the update of openGl:

void display(void)

Points of Interest

I hope this article can help people with the tuio library.

Please let me know if you have a problem.

I'm searching for a job, so tell me if you are interested in employing me. My email address is charles.vidal ( at ) gmail dot com.

History

  • 1st February, 2011: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

zebulon75018
Software Developer (Senior) http://www.cmb-soft.com/
France France
No Biography provided

Comments and Discussions

 
Generalvery cool Pinmemberwoposmail20-Aug-12 0:37 
good,thanks for share Roll eyes | :rolleyes:
GeneralMy vote of 5 Pinmembermanoj kumar choubey26-Feb-12 21:13 
GeneralN o expected output PinmemberPrafullaVedante1-Feb-11 19:37 
GeneralRe: N o expected output PinmemberGPUToaster2-Feb-11 0:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 1 Feb 2011
Article Copyright 2011 by zebulon75018
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid