Ortho - mouse hotspot displacement

Hi, this is my first post here, so please be gentle if I break some of the rules :wink:



Test setup: I have two orthogonal quads on the screen, one is ‘mouse’ and one is just ‘generic quad’.

For the sake of the test, I’ve positioned generic quad on the center of the screen (400,300), set my mouse hotspot to 0,32 (upper-left) and tried to click on left lower corner of the quad with logging points. When precisely (as much as I can) clicking on the lower left generic quad corner, mouse local translation reports that I’ve clicked few pixels over, ie. (405, 306). Finding 400,300 click position was just those few pixels below the quad, as seen on the screenshot.

Link - the pic is 1280x1024, don’t want to clutter the post

The second anomaly I’ve noticed is that I cannot move mouse to the window title bar. There’s around 20-25 pixels between mouse hotspot and window title.

I’ve runned jmetest AbsoluteMouseTest, and that big cursor moves to the upper-left, but coordinates report 50,549.



I’m using AbsoluteMouse implementation registered at InputHandler, all tests are run on 800x600, windowed.

Platform is Ubuntu Dapper dist (as you can see in the screenshot).

Graphic drivers are Mesa blah blah…



AlphaState wasn’t set on the mouse quad for the sake of the test.



Help, please?



Also, if I may say and ask, this cube is part of inventory grid, and when testing on which cube I’ve clicked I use my own ortho math code. Is there a way to do it better/faster using some part of collision testing mechanism (or something else) from JMonkey I’m not aware of?



Thanks in advance, sorry for long first question.

Using photoshop to measure, it looks like it is off approximately 16 pixels in both the x and y directions.  Perhaps your hotspot settings are not doing what you think they are?  (either because of poor programming on your side or a bug in jme…)  Can you provide a short test showing the behavior?

Ouch… that pun about my skills did hurt a bit :smiley:



Down to the bussiness, I’ve stripped the problem source of other dependencies and tried to build test with as little source classes as possible. They’re packed in .zip file, residing here. I’ve packed sources and two dependency images, runnable class is called org.pleasantnightmare.poorprogrammingtest.InventoryTest. Only library dependency is JME nightbuild.



Just to mention, in original code, I use my own ConsoleGame, which doesn’t do camera look with mouse. Those sources extend SimpleGame so sphere will fly around as you move the mouse, nevertheless, explained behaviour exists in this test also. Try to get to the bottom of window title with cursor either, its impossible.



Thanks in advance.



P.S. Don’t punch me too hard if I managed to mess something stupid :smiley:

It wasn't meant as a pun, more of a "i'm not sure which side the problem lies on."  :)  We've had plenty of bugs found (most of them fixed I hope) in jME to date!  I'll have a look at your example shortly.  Thanks for taking the time to put it together.

Here's your problem, your hotspot offset is an offset from the origin of the quad that represents your mouse.  Quads have their origin at the center of the quad, so instead of a hotspot at 0,32 you really want one at -16,16:


mouse.setHotSpotOffset(new Vector3f(-16.0f, 16.0f, 0.0f));

deus_ex_machina said:

Ouch... that pun about my skills did hurt a bit :D


Don't take it personally....as programmers we are the flaws in the system.  A machine will do exactly what it is designed to do, it's just a matter of whether we as software (and hardware) developers realize what that is. ;)

@renanse, oh, I though offset was taken from texture root. Couldn't find example in jme test sources.

Sorry for making you go through my code for such stupid flaw… I guess the same solution applies to the fact that mouse wouldn't go to the top screen edge.





@darkfrog I was just kidding, it didn't hurt me at all, nah nah nah naaah naaah… :smiley: :smiley:

I really am too much of a joking person for a programmer :wink:

Au contrare. :wink:



To be a good programmer one must be able to laugh at himself and his own stupidity from time to time otherwise you end up eventually throwing yourself out a window.  :stuck_out_tongue: