Sign in to follow this  
eXXXile

Terrain: Polygon area definition and drawing

Recommended Posts

Hello people

I have a terrain and I want to be able to show areas over it. Each area will be defined by an array of 2D points that form a polygon. I want somehow this polygon to be projected to the terrain. What are my options? I don't really know if the polygon will be textured of filled with some pattern (the 2nd option though would be preferable). I saw something about texture splatting but this should be restricted only in the area of the polygon and I don't know how to do it.

Any hint would be much appreciated.

Share this post


Link to post
Share on other sites
[quote name='eXXXile' timestamp='1297857626' post='4774926']
Hello people

I have a terrain and I want to be able to show areas over it. Each area will be defined by an array of 2D points that form a polygon. I want somehow this polygon to be projected to the terrain. What are my options? I don't really know if the polygon will be textured of filled with some pattern (the 2nd option though would be preferable). I saw something about texture splatting but this should be restricted only in the area of the polygon and I don't know how to do it.

Any hint would be much appreciated.[/quote]You may want to look into Projective Texturing. Alternatively, you can probably set each of the vertices of your polygon to the "ground height" of your terrain (I am assuming that you're using a heightmap for your terrain) and then simply draw your polygon with Z-testing (D3DRS_ZENABLE) disabled.

Share this post


Link to post
Share on other sites
Thanx for taking time to help me

The terrain is created by some special GIS file (u may consider it a kind of height map), and I have made utility that returns height at specific x,z position using interpolation and stuff.
The z-test-disable approach result is not satisfactory, especially when someone rotates the terrain around to inspect it. It looks like a sheet thrown over the mountains. I suppose that it would look better if I had a way to convert the polygon to a large number of triangles so it would fit more correctly over the terrain morphology. Has direct3d a way to do it or do I have to do it myself?

Now, about Projective Texturing... I may have to deal with machines that don't have very advanced graphics abilities, so I'm hesitant to use shaders. Is it necessary to use shaders for this technique, and If no, are there any samples that do PT with fixed function pipeline? And I suppose u suggest that I create [u]dynamically[/u] a texture with the shape of the polygon area I want to show on terrain and somehow project it from above?

I tried to follow the mathematical approach (ie to find where the polygon intersects with the terrain grid and make the area to be a separate mesh but I have very hard time to find the indices of the triangles)
Another solution I thought (but don't know how to implement it) is, to create a copy of the terrain and somehow scissor-out the portion that does not intersect with the desired polygon area. Is there any technique to mask somehow a mesh u are drawing?

I really appreciate your time and effort to help me

Share this post


Link to post
Share on other sites

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