Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Dirk Gregorius

Screen 2 World

This topic is 5473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, for my application I need to transform window coordinates that I get from a double-click into the window into world coordinates. I only need the x and y coordinate, I use orthographic projection and the modelview matrix does nothing ( = identity ). This is what I do: // After a double click I get the corresponding window // coordinates passed in function like this void OnDblClick(long x, long y) { // 1.) Transform from the windows coordsystem to opengl y = WINDOWSHEIGHT - y; // 2.) Do the invert viewport transform x = 2*x/WINDOWWIDTH - 1; y = 2*y/WINDOWHEIGHT -1; // 3.) Do the invert projection transform Matrix4 mtx; glGetFloatv(GL_PROJECTION_MATRIX, &mtx); mtx.Invert(); Vector4 v(x, y, 0.0f, 1.0f); vtx = mtx*v; } // End Something seems not work. Do I need the transform from windows coords to opengl coords like in step 1? After the transfrom vtx.w ist no more 1.0f. So so I need to divide by w? Finally, is there a better way? Any help is greatly appreciated! -Dirk }

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
gluUnProject()

Share this post


Link to post
Share on other sites
(Sorry for hijacking, but I have some questions that fit here )

Would this be better than using picking to find objects? Anyone know the relative speeds?

Share this post


Link to post
Share on other sites
Hey

Yeah I searched for this a while back because I had similar questions. The Opengl method of picking is like twice as slow(if my memory is correct, maybe bit slower) as when using a ray trace method.

I will try finding same article

Share this post


Link to post
Share on other sites
I found the post

http://www.gamedev.net/community/forums/topic.asp?topic_id=193977

down the bottom there is a post of someone that did a test on his machine comparing different ways of doing picking.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!