Sign in to follow this  

User click on window : where is it in 3D space ?

This topic is 4199 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, I'm currently programming a chess game (with C# and MDX). I managed to make the camera moving smoothly around the chessboard using spherical coordinates, but I don't know how to detect where user clicked. If a user clicks somewhere on screen, I need to know on which cell he clicked. And I don't have any clue how to do it... Collision ? Computing knowing the camera position ? I really don't have a clue. I guess a lot of maths are behind that problem so I'm just asking here. screenshot : http://xboxemul.free.fr/screen.jpg sourcecode : http://xboxemul.free.fr/esieaChess.zip Regards.

Share this post


Link to post
Share on other sites
You need to send a ray from the point that the user clicked along the view point of the camera. I believe this is called picking, which would be a good keyword for you to [google]

If you cannot find the resources yourself, post back here and I will give you some sample code.

Share this post


Link to post
Share on other sites
Thank you for the tip, I googled "Picking DirectX" and I came across that page.

http://www.thehazymind.com/archives/2005/10/tutorial_9_picking_objects_fro.htm

In fact there's a picking demo in the DX SDK but it's a C++ sample and the code is pretty unclear (everything is in a big cpp file...). Well I guess I have to work around this now. Thanks a lot.

Share this post


Link to post
Share on other sites

This topic is 4199 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this