Sign in to follow this  

Highlighting polygons

This topic is 4581 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
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
You know i never really thought of it like that - how stupid!

Thanks, thats helped alot with my "scale issue" :) What far-plane clipping distance do you use with this?

Matt

Share this post


Link to post
Share on other sites
Right now I'm using a near of 20 and a far around 1500 to 3000. I haven't actually decided completely on the setup for that. I'll have to wait until I can see what all situations my camera will be in before I finalize it.

If I decide to keep the camera in the air, I can probably turn the near distance up even more. But then other situations may arise, like projectiles or other objects being tossed really close to it. I don't want them to intersect the camera from really far away. The far distance is less important. I just need to figure out how far the player should really be able to see. And again, if the camera is looking mostly down, I should be able to turn it down quite a lot.

So if I were you, I would just experiment to find something that works until you get most of your camera system designed and running.

Share this post


Link to post
Share on other sites
I have a freeform camera at the moment but as my game is an RTS i'm not sure if it is really needed.

However, I like the camera freedom Ground Control 2 and Rome Total War give you, so am tempted to keep it. Does make the terrain design a little harder though as i am quad tree culling, which is fine for the more angled views but the far distance views slow slightly. :(

Thanks for the info though, it helps alot.

Thanks,

Matt

Share this post


Link to post
Share on other sites
I really liked your Gui. It looks really good.
Is it possible to know what kind of blending you are using for the window to make it grey but at the same time transparent.?

Thanks from a newbie.

Share this post


Link to post
Share on other sites
Quote:
Original post by ramy
i was just wondering, that terrain looks amazing.
is that runnable in a game? real time?

Thank you. And yes, absolutely. You can see in the screenshot, I'm getting around 80 frames per second (it's normally around 120, but I was drawing all of those transparent quads). That's with all vertex and index buffers rendering from system memory. Within the game, it will be much faster.

Quote:
Original post by Sko44
I really liked your Gui. It looks really good.
Is it possible to know what kind of blending you are using for the window to make it grey but at the same time transparent.?

I use the D3DXSprite object to render all interface graphics. You just pass it a D3DColor value and the texture of any sprite is multiplied with the color.
Oh, and you have to enable transparency with..
Device::SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE/FALSE );

Currently I have a 1x1 texture that gets stretched and modulated with color to draw rectangles and lines. I know it would be possible to get the same effect with no texture at all, but I've had some trouble doing it with D3DXSprite. So right now, it's a little hacked.

Share this post


Link to post
Share on other sites

This topic is 4581 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.

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