Jump to content
  • Advertisement


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


DirectX with Spheres

This topic is 6091 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

I''m programming a 3D version of Risk, based around a globe of the world. Has anyone got any hints on how to read which country the user has clicked on. I''m really stuck, so any help at all would be great! Cheers.

Share this post

Link to post
Share on other sites
Two ideas...

1. Under normal circumstances, render everything with your nice detailed texture, but if the user clicks, turn off lighting, etc. and render your scene to a texture render target using a texture that has simple colored regions for your countries. If you set up your viewport, matrices, and target correctly, you can actually render only the click point and reading that small texture can be very fast. The color at that point is the country. Turn on lighting, etc. set the target back to the back buffer, and keep rendering.

2. The first way uses the card to do alot of processing for you. The other way is to find which polygon on your sphere you clicked on using the approach from the picking sample in the SDK. Once you have the triangles, you have the texture coordinates. Find the actual intersection point within the triangle, interpolate the texture coordinates for that point, and use that as a look up into a table of countries. That table is probably a bitmap that looks alot like your world texture but lacking detail like bumps, etc.

Both of these let you easily support accurate picks, even on the very edges of countries with rough borders. Assuming your sphere has a fairly low poly count, both should be fast.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!