Using TouchInput tutorial?

Hello!



Not sure what forum to place this topic in, but looks like the Android would be the best one.



I want to use JME3 to create an application, controlled by TUIO touches and gestures on a touchtable or a desktop with a touch patch. However, I cannot find any tutorial on how to begin using this kind of input in JME3. There are people on this forum who seem to successfully implement this on desktop but I do not know how they do it. I am fimiliar with all the TUIO technology and have been doing such applications using other platforms, now I want to use JME3 but can’t find the info. Could someone please point me to a tutorial or describe some basics? I just need the direction to go.

Nobody can say anything on that? I just don’t believe that!

So far in android (on the nifty gui side anyway which is where I’ve tested) I just get touch events as mouse clicks…other than that I can’t really help you sorry…but I am a newbie myself :slight_smile:

Yep, but there are also the two-finger gestures… and multiple fingers tracking… Maybe I should ask on the general forum since some people may not be visiting the Android branch of the forum.

mhhh… I was going to RTFM you but I realize there are no tutorials about this…neither there are examples in the test repo…



so here it is, i’ll make a proper wiki page later



TouchInput does not work exactly like the rest of the inputs in JME, that’s a flaw of the original design and it might change after the 3.0 release.



first you have to register the type of event you want to recieve with the inputManager. Basically you have to register all of them :

[java]

inputManager.addMapping(“tap”, new TouchTrigger(TouchInput.ALL));

[/java]

then you have to check for that event in the onTouch :

[java]

inputManager.addListener(new TouchListener() {



public void onTouch(String name, TouchEvent event, float tpf) {



if (event.getType() == TouchEvent.Type.TAP) {

//do TAP stuff

}

if (event.getType() == TouchEvent.Type.SCROLL) {

//do SCROLL stuff

}

if (event.getType() == TouchEvent.Type.DOWN) {

// do DOWN stuff

}

// and so on…

}

},

“tap”);

[/java]

the event object has plenty of convenient information like the x, y of the pointer, the pointer id and so on.

For multi finger gestures, you can detect a down event every time a finger touch the screen, the pointer id will be different if there are multiple fingers.



The only detected gesture is the SCALE gesture you have a SCALE_START, SCALE_MOVE, SCALE_END event type.

I recommend looking into the different event types.



Note that this works with android devices, but it has never been tested on other touch device, because none of us have one.





Also a mouse simulation is implemented and works for single inputs, so you just have to handle it like you would with a mouse.

2 Likes

@nehon



Ok, so, say i want to load photos and display them as 2D pictures, using ortho, controlled with the gestures… So I do like you say, and then, to tie it with JMonekyEngine logic, I have to create a special type of Controller which will check all the touch input data and see if any of the rays, cast from the touches along the Z axis intersect with the textured quads that represent the photos, and if, say, two fingers get into one quad, then I can track their scaling and rotating motion, pivoting on the midpoint between the fingers, right?



And is there any way to make the “clicked” photos to be rendered last (on top) of all?



Touch input is cool, very spectacular installations can be made of it (that’s what I am after), that could benefit JME if presented in galleries! I have been using MT4j previously, but it is based on Processing and has problems with serious 3D.

ho…thanks to give me back the opportunity to RTFM you that’s very appreciated :

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3#tutorials_for_beginners



Those are not questions that can be answered quickly, however going through all the tutorials will definitely.

:smiley: That will suffice, to know that JME suggests it’s usual approach to touch handling also! Thank you, helped me a lot!

@nehon



Finally I have got to this and tried and what you have proposed - does not work. I create the mapping and then add a listener for it like you said, but nothing gets captured. The onTouch() method of the listener does not get executed. Maybe something else has to be enabled? Maybe in settings or something?