Archived

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

D3D8: How to draw cube edges?

This topic is 5139 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 want to draw cube edges with solid cube drawing. I try to draw cube within triangle list with some diffuse color, and then (or before) I draw line list (edges of cube) with some emissive color (to highlight edges for example), but I get some artifactes for my lines (lines flashes) ;( I try to change each line to 2 triangles, but artifacts didnt leave my cube ;( What should I do to draw correct highlight edges of my cube? I try to use ALPHABLEND, but it should be depends of sequent of drawing triangles, because in different view angles some triangles are transparent, and some are not. P.S. Iam sorry, if my English not so good ;(

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Your artifacts are probably caused by z-fighting. You could try either:

1) Use a Z-Bias (The D3D SDK tells you how you can set one up)
2) Push each line out slightly along it''s vertices'' normals

It''ll probably be easier and just as effective to use a Z-Bias.

Share this post


Link to post
Share on other sites
I tried to do both cases, but artifacts still present.
Maybe I do not use ZBias correctly, but I do not found any tutorial or example in DX8 SDK ;(

In second case I push alittle but nothing changed, but when I increase distance between cube and lines it bacame looks bad ;(

Share this post


Link to post
Share on other sites
If you are eventually going add a texture to your cube anyway, then you may want to create a texture with a border and map it to each of the sides? This should create the effect of an outline without any z-buffer issues.






_______________________________________
Understanding is a three edged sword...

Share this post


Link to post
Share on other sites
Hmm, I''m not sure, but I think z-biasing was introduced in DX9

You could try something like this:
m_pD3DDevice->SetRenderState(D3DRS_DEPTHBIAS, FtoDW(0.00045f));

I''ve got it working fine in DX9, might work in 8. You can only z-bias triangles, not lines, so you set a value for your z-bias, draw your triangles, then draw your lines.

---------------------------------------

Let''s struggle for our dream of Game!

http://andrewporritt.4t.com

Share this post


Link to post
Share on other sites
If I understud you whant to put 2 differnt objects in one opsition in the matrix?...If so...eaven in real life you cant put 2 objects on one spot.Try to separete edges from the cube or cut the cube on that position where you want to put highlight edge ..and there put something to highlight edge and combine that .... in extencion of the cube you put that highlight...if you combine it propertly ...nobody will notise that is cube with more parts then usual. Did you understand me?

Share this post


Link to post
Share on other sites
Make the line drawing cube a tad larger then the solid cube. Don''t use zbias because it changes from card to card. You may be able to fix the z fighting on your computer but it won''t fix it on another.
Now after you have done that I''m guessing you''ll say it still is giving you trouble. Lines gave me trouble too. I think it has to do with the resolution. They show up at some angles and disappear at other depending on how you look at them in the current resolution. The best solution I think would be to make a texture with a border and apply that to your triangles.
~Wave

Share this post


Link to post
Share on other sites
This is an easy idea for ya. It wouldn''t get the effect you want but it would be close.

step 1 render the scene normally
step 2 change to wireframe and set up renderstates like materials, textures and colours to get the colour you want for the lines.
step 3 render teh scene again.
step 4 present the screne

You''ll get the lines between the poloygons on the inside too but it would be a start.

Share this post


Link to post
Share on other sites