Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Inverting Y Axis for Screen coordinates?

Author
Message
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 10th Apr 2007 12:59 Edited at: 10th Apr 2007 13:01
This is really annoying me

Is there anyway to change the screen coordinates so instead of being like this:



They are like this?



Edit: Would i be best just using a function every time saying Invert Y Coord (Y)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Apr 2007 14:26
There is no command to do this, you would have to do it yourself.
wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 10th Apr 2007 18:58
This will do it, just put it into a function.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 10th Apr 2007 20:08
...you just subtract the y coordinate from the screen height...

mousey = SCREEN HEIGHT() - MOUSEY()

eg:

screen height = 200, mouse y = 10, inverted = 200 - 10 = 190.

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 11th Apr 2007 00:12
Okay, i'll probably try to get used to it as it is, as if i just invert all the y coordinates i'll probably run in to troubles later on
wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 11th Apr 2007 01:06
I had this handy already when you asked. I know the following will be more information than you wanted. Just wanted to show you why I flip the y coordinates.

I use this as a function to draw heightmaps on the screen to make real time changes to matrix heights.

A matrix coordinates are flipped up side down when viewed from the top. So I can use this to draw normally on a bitmap and have the matrix respond accordingly. This allows me to actually draw a heightmap precisely the way I want and see the results.

I can even paste a map to the screen and trace it. When I'm done I take the resulting heightmap and make a advanced terrain out of it.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 11th Apr 2007 02:28
Ill say it again...

inverted y = screen height - mouse y

...really...its not hard.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Apr 2007 09:38
What you need to do is invert the Y values in the For..Next loop when you transfer them to the matrix - not before.

Leave the 2D X/Y co-ordinate system as it is - as you suggest, if you change it, you'll have problems later...

Refer to the following snippet which does more or less the thing you are after. It textures a matrix with a single image and the For..Next loop has to place the top left corner tile of the image in the bottom left corner of the matrix.



TDK_Man

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 16th Apr 2007 12:31
Okay thank you very much, sorry for late reply

Login to post a reply

Server time is: 2024-11-25 19:28:39
Your offset time is: 2024-11-25 19:28:39