Jump to content
  • Advertisement
Sign in to follow this  

dx9 c++ trackmania style track editor

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

Hi, I am making a racing game track editor similar to trackmanias, so I have a grid and a set of pieces of 3d models of road which I place in a specific order to make a track. My pieces are exactly 50 units wide and long, and 10 units high. The textures on the pieces are completely seamless.

The problem I am having is that when I place the pieces next to eachother, from most camera angles I can see a line between them which does not look good at all (like they overlap or something - but they don't)

The line is actually small black triangles, since the track pieces are mostly grey they are easy to see and make me believe the problem could be Z fighting or something similar.

Please can you give me your ideas on this and a way to fix the problem.

heres an image: please tell me if it doesn't work


Share this post

Link to post
Share on other sites
Link doesn't seem to work for me (Times out).

What are your near and far clip planes set to (They're parameters to D3DXMatrixPerspectiveFOV*())?

What format is your z-buffer?

How wide are the black triangles? If it's 1 pixel, it might just be floating point rounding errors, and you could scale your pieces by 1.0001 or something similar to make them overlap slightly, which might help, or you could build the pieces so the track overlaps (Put a sharp ramp down at the end of the piece and make the raps overlap).

Share this post

Link to post
Share on other sites
Hi Evil Steve, thankyou very much for the reply.

I uploaded it again somewhere else, hopefully this works:

my near clip is set to 1.0f, and far is set to 1000.0f.

I am not exactly sure what format my ZBuffer is.

//I clear my ZBuffer like this:
m_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, _dwColour, 1.0f, 0);

//Heres some of my DirectX Creation code: (for a non-fullscreen window)
m_d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
m_d3dpp.BackBufferWidth = 0;
m_d3dpp.BackBufferHeight = 0;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
m_d3dpp.BackBufferCount = 1;
m_d3dpp.EnableAutoDepthStencil = TRUE;
m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, true);

Unfortunately the black triangles are a lot bigger than 1 pixel so the methods you gave me did not work. I have tried scaling the meshes but the z fighting is still there.

Thanks again,

Share this post

Link to post
Share on other sites
Your depth buffer is set to 16bit.
Try to change it to D24S8. That will give you much more precision.

m_d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;

Share this post

Link to post
Share on other sites
What Specialist84 said.

If the issue still persists, try making the pieces trapezoids if viewed from the side, instead of rectangles:

Like this: Not this:
+-----+ +---------+
/ \ | |
+---------+ +---------+

Two side-by-side pieces would then intersect:
/ /\ \
That should hide the edges quite well so long as the pieces have similar edges.

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!