Jump to content
  • Advertisement
Sign in to follow this  

drawing polygons on terrain

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

Hello, I'm trying to find a good way to allow users to draw any polygon on a 3d terrain and fill it with a tranlucent color. i finished the non-terrain part with polygon tesslator, but i have no idea how to approach the terrain version. any suggestion or insight is apperciated thanks,

Share this post


Link to post
Share on other sites
Advertisement
simply store the key points of the selection, and create a poly from them.
also, make sure you break the lines into smaller segments and make em connect with the ground below.

Share this post


Link to post
Share on other sites
Another way I can think of is, if you patch your terrain meshes in NxN chunks
you just select the chunks you hit.

Pass the hit location to the shader via a Uniform (in opengl), also pass the information you need to calculate the tex coordinates


Now in the vertex shader you calculate the texture coordinates of the texture you want to render on top of the terrain.

I basically do this to render decals. You can render several decals in at once using multiple texture units.

Share this post


Link to post
Share on other sites
Well, that is essentially what projective texturing is. Of course, you're making the optimization that you only apply it to certain chunks (good). But I would take things a step further. Figure out what chunks the decal is over, then figure out which "terrain cells" it is over (by terrain cell I mean 2 triangles in the shape of a square) once you know which terrain cells it covers, you can then tesselate the decal so that it is actually a mesh that hugs the ground and is given a small offset above the terrain (to avoid zFighting)

of course, its that last step taht I don't know. But There has to be a way, you could then go and detect which terrain vertices the decal is over, and create vertices at each of those points, (with a y coordinate semi-raised). Add in the vertices at the corners of the decal (you would have to cast a ray down or something to get the y coordinate) Then you would eliminate redundant vertices. You would need to calculate the texture coordinates for each point, and then create the indices.

eh, i'm sure its possible, but i can't say i have the best way, or anything

cheers
-Dan

Share this post


Link to post
Share on other sites
thanks for all the advice, i guess i will have to see which methodolgy suits my need the best.

and this is a side question, i'm a noob so i have alot of questions. but most of them i try to solve myself. Unfornuately i came across another hurdle and i didn't want to start a new thread.

So here is my second question:

i have multiple polygons and they are translucent, when they overlap i notice that they tend to blend the colors, is there a way i can have the polygons translucent and use the color that is nearest to the user when the polygons overlap. I used depth test, but that doesn't draw the overlapping parts. i'm messing with the glbendfunc with no success.

Thanks again

Share this post


Link to post
Share on other sites
There's no "real" way of doing what you want, since transparency is well. transparent. this blending is what happens in real life too :)

Anyway, you could fake it by making sure that the polygon you want to draw is the one closest to the camera, and draw this first. This would override the drawing of the second polygon (at least the part that's behind the first polygon).

Later on, you will understand the need to properly sort translucent object, in order to make the render correctly :)

Cheers!

Share this post


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

  • 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!