PDA

View Full Version : How do I convert window coordinates to World Coordinates?



05-22-2004, 09:04 AM
Heya, everyone! its been a while since I posted here (about a year). Anyhow, I'm currently programming an editor for my soon-to-come MMOFPS, and I need a little help!

You start off with a large height map, with small spheres on each vertex. There is an array of vertex structs, each having several values including x, y, and height. (yes, z is depth and not y.)

What I want: When the user clicks a sphere and drags the mouse up or down, the height of the vertex changes respectively.

The Problem: All of the Mouse Event callback functions return just window-relative coordinates. Of course, I need the x and y coordinates related to the vertecies in the world.

05-22-2004, 09:29 AM
gluUnProject is what you want !

Andrewinator
05-23-2004, 04:19 PM
Thanks a bunch, but I sorta need a little more help; You see, I looked it up in the Red Book, put it into my program.... and got errors. I'm still a newbie with OpenGL (and programming in general). The errors were concerning the function parameters - my varibles weren't the types it wanted. (please don't kill me yet, as I siad I'm a newb!) After a great deal of effort, I turned up absolutely nothing. nothing but the previous errors. I even copied the book's example into my program!

What I'd really appreciate is somone who can tell me how to get the world coordinates were the cursor is currentlt using the function gluUnProject. Sorry for being a worthless newb!

Andrewinator <---- Pleads Newbie

dvm
05-24-2004, 12:23 AM
Just stick with the redbook. Copy the variable definitions as well and you should be ok. I've copy pasted the code my self a few times and it all worked fine. If you need, make a new program and type the example from the redbook. This way you'll read and study each line.

Andrewinator
05-24-2004, 08:03 AM
Thanks, I'll do that.

BTW: If my newbiness disgusts you, please keep in mind I'm only 15.