Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mouse Gestures  (Read 1042 times)
0 Members and 1 Guest are viewing this topic.
Offline smallporgies

Junior Newbie





« Posted 2013-08-18 18:51:20 »

Hi all!
Does anyone have any experience with coding mouse gestures in Java? I'm think of something along the lines of what you see in Lionhead Studio's Black & White where you can have a reasonably complex shape recognised at any size in any position in the screen. Brief googling doesn't reveal anything much so hopefully someone here has a homebrew they'd like to share or anything at all in the way of advice about writing something like this myself? Thanks in advance!
Offline Several Kilo-Bytes

Senior Member


Medals: 11



« Reply #1 - Posted 2013-08-18 19:34:20 »

How complex are the shapes? Some people recognize simple motions in 4 or 8 directions, convert it to a string, then use a regular expression or state machine to recognize certain sequences. ("LULULURD" matches "(LU)+RD") Handwriting recognition is similar type of problem. Many of those libraries use machine learning and use many different factors. There are open source Java libraries for simple gestures recognition and hand writing recognition.

There are medium level complexity algorithms which may be good enough if the shapes all follow a similar pattern or are constrained some how.

Search link

There is also a java.awt.dnd.MouseDragGestureRecognizer class but this is the first time I've seen it.
Offline smallporgies

Junior Newbie





« Reply #2 - Posted 2013-08-18 21:17:58 »

Hm, I was after something that could do curves but I suppose that in terms of recognising that an 8 directional implementation could do the trick. I'll also need to check relative lengths of each of the motions in the gesture.

https://www.google.co.uk/search?q=black+and+white+miracle+gestures&tbm=isch

Most of those search results bring up the same thing, which appears to be 4 directional only. I'll take a look at the code and see if I can 'upgrade' it to 8 directional - Thanks!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Several Kilo-Bytes

Senior Member


Medals: 11



« Reply #3 - Posted 2013-08-18 22:01:22 »

Those gestures will definitely work with the simple method, but you could get false positives and you would need to make sure everything was really different according to the algorithm. Those gestures all have long strokes, so you could use the 8 direction with filtering to ignore very short deviations so jittering would not turn a square into a circle. Or use some other filtering so "88889888" was transformed to "88888888". (See numpad keys.) If you wanted the star to work only if it self-intersected at the correct points I know some techniques, but it's probably overkill.

I also forgot to mention you could try radial menus as an alternative, but that does not seem to be what you wanted.

Let us know how it works, there does not seem to be much online for in game gestures (as opposed non-twitchy to applications like web browsers.)
Offline Jeremy
« Reply #4 - Posted 2013-08-18 22:10:43 »

I've honestly never tried this before, but maybe this is an idea worth mentioning.

You could have the user create a series of points as they attempted to invoke a gesture. Record these points.

Your gestures could be complex geometry shapes. Essentially what you would do is you would construct the area of that gesture using an Area object and a series of Shapes, then take that Area object, and copy it.

Take the copy, scale it down, place it over the original and subtract from the original. Then you have a shape that outlines this gesture with a thickness proportional to however much you scaled the copy.

Now you can see if the user's points are contained by the gesture. Ofcourse, the problem is scaling the gesture shape properly. I haven't quite figured out how you would scale it...

Anyway, just an idea. I've never done this before.

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline smallporgies

Junior Newbie





« Reply #5 - Posted 2013-08-18 22:49:46 »

Thanks for the great ideas guys!
I guess at this point I should elaborate on what I'm trying to do here, which is using mouse gestures for side-scrolling melee combat, and Black and White was the best example of mouse gestures in a game that came to mind. My reason for this is to try and keep the combat more skill based (as in, the human player's prowess) as opposed to being level/gear based which I figure could make for an interesting multiplayer scenario or even as a single player campaign - also it is theoretically more immersive. It's very much a WIP so I'm trying the gestures as a proof of concept... If it doesn't work I'll try something else but that is for another thread.
In any case, sounds like there's definitely some scope here for experimentation and maybe a chance to make an open source complex-gestures library of some sort while I'm at it Wink
If there are any further ideas or interesting links do post them here! I'll go away and see what I can come up with.
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #6 - Posted 2013-08-19 04:43:32 »

Having never attempted anything even remotely like this, I'd go with something like:

- express each target gesture as a sequence of joining angles, and relative line distances (so the overall scale of what is drawn doesn't matter).
- record the points as a path
- apply a flatten filter to the recorded path
- compare the relative line distances and joining angles of the flattened path to each of your target gestures, applying some kind of fuzzy fitness algorithm.
- tune the parameters of the path flattening, the fitness algorithm, and the design of your gestures until it works to your satisfaction.

Though as I said, I've no experience in the matter, so this approach could be completely wrong.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline philfrei
« Reply #7 - Posted 2013-08-19 05:58:13 »

Maybe this won't be an issue, but depending on how you collect the points (assuming use of a MouseMotionListener) and process them, it may become useful to timestamp the input data.

I ended up doing this when using the MouseMotionListener to control a Theremin (vertical for tone/volume, horizontal for pitch).

It depends on how "real time" your gesture interpreter has to be.

Just a thought.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline jonjava
« Reply #8 - Posted 2013-08-19 06:30:23 »

This isn't a java specific question so don't let that limit your searches. One technique I'm familiar with, which is straightforward and great for shape recognition, is by chaining balls together that move in 8 directions. You can vary the frequency of the balls and the radius of balls and/or zoom in/out the whole mesh to get the amount of accuracy you need.

Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #9 - Posted 2013-08-19 09:37:20 »

http://depts.washington.edu/aimgroup/proj/dollar/
See the links for $N, $P, etc. I found that it works ok if the gesture is similar to a pattern, otherwise tends to have false positives.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline smallporgies

Junior Newbie





« Reply #10 - Posted 2013-08-19 14:01:39 »

Thanks for the link Nate, I'll check it out.
It sounds like there are a few techniques out there - really depends on what sort of gestures need to be recognised. It may not be a one-fits-all solution if I want to keep it super efficient (kinda necessary for live combat). I'll try to find the time over the next few nights to mock something up and post it here!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (20 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (57 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!