Archived

This topic is now archived and is closed to further replies.

I'm gonna feel stupid...

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

After writing several 3D progs and thinking I had the hang of things I''m getting tripped up by something that should be fairly easy. Say I have an object, a simple cube. And I want the edges of the cube to be a different color to set it off a bit. Imagine a die that has had gold lines painted on every edge and you have a pretty good idea of what I''m after. This is working fine except that the lines aren''t being culled. Of course I can see that since you only have two points D3D can''t tell when the line is "backwards" and cull it. But I thought there must be some way using built-in D3D functionality. Google wasn''t helpful I could always do a square texture with the gold around the rim but this seemed like something that there is probably a trick to and I''d like to know it. Besides, it was intended to be just a colored cube and a texture seems like overkill. Probably some render state buried in the docs that I haven''t seen. Any takers?

Share this post


Link to post
Share on other sites
Try using a ZBuffer. The cube''s front end should be closer to the camera than the farther lines. The zbuffer will detected that and not draw the lines in the back.

Share this post


Link to post
Share on other sites
Here is your answer:

Assuming that Zbuffer was enabled all along...

2 pass-method:

1)Draw the cube normally as you always would (no lines yet).

2) set Render state to WIREFRAME (D3DRS_FILLMODE IIRC).

3) Turn off Texture, set up a color, and Draw the cube again, this will only draw the borders.

hmm on second thought it might not work, as you may have diagonal lines at the triangles that make up a quad face....

www.cppnow.com

Share this post


Link to post
Share on other sites
Yep, felling pretty stupid

I don''t know why, but I completely overlooked that. I guess my mind was focusing so hard on a culling solution that I overlooked the obvious.

Thanks for setting me straight!

Share this post


Link to post
Share on other sites