Jump to content
  • Advertisement
Sign in to follow this  
Malazar

[Solved]3D models not showing propperly

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

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
Advertisement
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
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
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!