Jump to content
  • Advertisement
Sign in to follow this  
Jiia

Highlighting polygons

This topic is 4895 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've hit sort of a wall in my project. It's a tiny, unimportant wall, but I can't get over it. In my terrain editor, I need to impliment material-painting. The materials will be assigned to equally spaced quads. So basically the game engine just does a cell-lookup to determine the material type of any given coordinate. The materials are just used for game physics (do arrows stick or bounce, etc) and sound effects. Anyway, I'm having trouble in the editor displaying which quads are assigned to which material. What I plan to do is highlight the polygons that belong to the paint brush material. I have no idea how to do this. I've tried simply drawing a transparent lit-quad as a stand-alone render in every single cell, but there are too many to show in some situations, and the framerate has dropped to 6 [smile] I could construct a new index buffer every time the artist paints the material. Would this be the best choice? Or are there any ways to hide existing polygons from rendering without changing the number of polygons in the index buffer? So I could have a solid buffer, but exclude certain faces from rendering in some way? Here's a snapshot. It makes what I'm doing more clear. The 3x3 area is just the brush: Since this is for my editor, I don't mind using hacks, as long as they aren't too crazy. Any opinions will be greatly praised. [Edited by - Jiia on May 27, 2005 7:18:31 AM]

Share this post


Link to post
Share on other sites
Advertisement
Reuse vertex position vertex buffers and index buffers that you already have (for rendering the things as they are). Use an additional 'selection' buffer which could be for example rgba color buffer for an extra 'selection' pass. For unselected polygons, set the rgba to (0, 0, 0, 0) and something else, maybe (1, 1, 0.5, 0.5), for those polygons that are selected. You only need to update the rgba values when they change, and only those rgba values that do change.

You can also combine the normal rendering and selection highlight into a single shader / pass.

Share this post


Link to post
Share on other sites
Using vertex colors wouldn't work correctly if each triangle shares vertices with other triangles, would it? I'm not sure how else I can specify colors per triangle? Or do you mean to avoid using an index buffer and just give each triangle it's own 3 vertices?

Sorry if I'm not catching on. I appreciate the help.

Share this post


Link to post
Share on other sites
Indeed shared vertices will not work. So you may need a version of vertex position buffer that duplicates the positions for each corner. You need four corners for each quad, not three corners for each triangle, so you can still share a little.

Share this post


Link to post
Share on other sites
Hmm. So you don't think it would be easier to restructure an index buffer when materials are painted? If I use vertex colors, I'll have to construct a special vertex buffer to paint these. Where as I could recycle my base terrain vertex buffer if I just use the index buffer. Either way I have to lock the video data. It is in system memory, though.

Your method does allow only changing the data that actually changes, though. Hmm. I'll have to think about this some more.
Thanks for the idea [smile]

Share this post


Link to post
Share on other sites
Looking nice Jiia! Sorry I can't really suggest anything for your highlighted grid that would escape having to duplicate the vertices, sorry. Hope you don't mind but I was wondering how you displayed that grid across your terrain;I need to do something similar (well the same actually) but am a bit stumped how to go about it.

Thanks,

Matt

Share this post


Link to post
Share on other sites
Quote:
Original post by mattm
Looking nice Jiia! Sorry I can't really suggest anything for your highlighted grid that would escape having to duplicate the vertices, sorry. Hope you don't mind but I was wondering how you displayed that grid across your terrain;I need to do something similar (well the same actually) but am a bit stumped how to go about it.


I turned the near and far planes up to prevent z-fighting, then rendered line strips through the vertices. Each vertex being a point in the line strip primtive. Segments (quad to quad) are rendered together, but each axis line on the grid is rendered seperately. You could choose to do that however you want, though.

Let me know if you need more specifics.
Thanks for the compliment. Here's a snap with less editor things in the way:
Free Image Hosting at www.ImageShack.us

Share this post


Link to post
Share on other sites
What spacing do you currently use between the vertices when constructing your triangles and which API are you using? I have been trying to get a sense of scale so was just wondering.

Matt

Share this post


Link to post
Share on other sites
Opps.Obviously as we are in the DirectX forum you are using this! However, i would still be interested to know what spacing you are using betweeen your vertices in that image.

Matt

Share this post


Link to post
Share on other sites
Sorry, this post scrolled off of the first page, so I didn't see your last reply. The spacing between the vertices is really just relative to whatever size your units represent, or more importantly, the distance your camera will be from the ground.

So you should decide on a detail level you want the terrain to be relative to the camera distance. Then get your quad scale from that. In my engine, 1.0 represents one inch, and the camera will be overhead of the player about 15 feet. I started off with each quad as 32x32, but then changed it to 64x64 to require less loading in the continuous world routine.

So the vertices are 64 points/inches away from each other.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!