Advertisement Jump to content
Sign in to follow this  

picking my terrain

This topic is 4908 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 ive got a terrain implememted using Geomipmapping and in dx (right now its not using index and/or vertex buffer) my terrain can be scaled (its x,y and z) now my question is how can i perform picking on my terrain in dx? i want to get the coordinates or what area in the terrain is selected (just like in RTS) so that i can do my pathfinding and treat it as that of 2D thanks

Share this post

Link to post
Share on other sites
Hi there Yuppies, How are you doing?
Well Direct3D helps you a bit with situations like this

[The problem]
"how can i perform picking on my terrain in dx?"

[Possible Solution]
This is how I would go about it and maybe the general idea will help you get yours correct...

Refer to this post for Spaces theory.

This means that the mouse coordinates that you will recieve most of the time will be in Screen space, you will need to transform these coordinates to World space and then with a simple test you can see what section the mouse coordinates fall in.

1) Transform mouse coordinates into World Space using a Inverse ViewProjection Matrix.
Usefull functions/methods:
D3DXVec3Transform Function
D3DXVec3Unproject Function

2) Check where on your terrain these coordinates are and set the range which you can select, maybe the tile on which the point falls. (I am sure you can get values of a tile in your terrain.)

3) With a simple boolean test. Set the tile's property to selected or any entities on this tile.

I hope this helps a bit,
Stay cool.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!