Sign in to follow this  
Malazar

[Solved]3D models not showing propperly

Recommended Posts

Malazar    152
now i have an odd problem, probably something to do with the z/depth buffering not being set up propperly, thing is i don't know how to set it up propperly, the result is as follows: Photo Sharing and Video Hosting at Photobucket sorry about the quality of the image. the right hand version shows the model as seen in the .x viewer, the left is how it's seen in my program. anyway, my question is, what's causing this, and how do i fix it? [Edited by - Malazar on August 6, 2007 7:20:06 PM]

Share this post


Link to post
Share on other sites
Samurai Jack    455
This is not a z fighting problem. Just change the order of faces:

If you have one face has 3 vertex indexes a, b, c then draw like a, c, b

or if you had [0][1][2] then draw [0][2][1].

This is a common problem if a mesh is left handed and viewer is right handed or vice versa.

That happens when you use a OpenGL 3D tool and DirectX renderer for example.

Share this post


Link to post
Share on other sites
Malazar    152
Quote:
Original post by Malazar
how do i reverse the order? i've been loading it from a .x file.


bump.

i suppose i should rephrase that. how do i tell the scene to render using left/right handed systems or is there a way of setting this in 3ds max, so i can flip the order the mesh is created?

Share this post


Link to post
Share on other sites
Tom    352
Take a look at one of the samples that loads .X files and adapt your vertex batching code to match. Study it and see how they handle vertex orientation.

Share this post


Link to post
Share on other sites
Malazar    152
Quote:
Original post by Tom
Take a look at one of the samples that loads .X files and adapt your vertex batching code to match. Study it and see how they handle vertex orientation.


from what i've read in the directx samples, i have used the same loadign and rendering functions - the only difference is that my load mesh function takes a char input, allowing me to load and run separate models with the same function, just giving the mesh name when i call the load function.

is there some third part i'm missing?

Share this post


Link to post
Share on other sites
Stiffler    163
As someone suggested before you need to change the order of the vertices... This is because culling is based on the order of the vertices and it currently looks backwards. But, instead of changing the vertices (hard with a .x file unless you really know what your doing) you can change the way direct3d culls.

Try setting this render state before rendering and see if anything changes...

D3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW) ; // D3DCULL_CCW is the default

Good luck.

Oh, btw you can find all the different render states and arguments here at the direct x msdn clicky

EDIT:
Also, see if the direct x sample loads and renders your mesh without this problem. If it does, the problem is in your code.

Share this post


Link to post
Share on other sites
Malazar    152
Quote:
Original post by Stiffler
As someone suggested before you need to change the order of the vertices... This is because culling is based on the order of the vertices and it currently looks backwards. But, instead of changing the vertices (hard with a .x file unless you really know what your doing) you can change the way direct3d culls.

Try setting this render state before rendering and see if anything changes...

D3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW) ; // D3DCULL_CCW is the default

Good luck.

Oh, btw you can find all the different render states and arguments here at the direct x msdn clicky

EDIT:
Also, see if the direct x sample loads and renders your mesh without this problem. If it does, the problem is in your code.


hmm, this has made some improvement, though curiously, i had to set it to D3DCULL_CCW rather than just _CW - looks like somehow it set clockwise culling rather than anti-clockwise... can't figure out how, mind.

there's still the odd poly showing where it shouldn't be, but that does appear to be related more to depth buffer culling, since they're only the ones whose normals point towards the screen (such as the engine intakes). i'll have a read, there's probably another of those renderstates i could set to fix that

Share this post


Link to post
Share on other sites
Malazar    152
many thanks stiffler, spent some time reading and testing out all the various possible combinations, also found i'd not set up my device to contain a z buffer propperly, now everything's working smoothly.

many thanks to all of you ^_^

Share this post


Link to post
Share on other sites
xissburg    204
Make sure the depth buffer is turned on and check the near plane distance form your camera. The more close to the camera the near plane be, smaller will be the depth buffer accuracy;

Share this post


Link to post
Share on other sites

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