Sign in to follow this  
idreamlovey

Face Culling problem

Recommended Posts

I have a mesh of home exported from 3d max. I am using DrawIndexPrimitive to render the mesh. My problem is that some of the walls of home are visible and some are not. So i rendered with D3DCULL_NONE and here i see all of them are visible. As the vertices defined in clockwised can be only visible in my engine, so i figured out that some of vertices are not in clockwise order. So i calculated in following way to detect whether the triangles are in clockwise or not:- Here v1,v2 and v3 vectors are vertices of the triangle e1 = v1-v3 and e2 = v2-v3 then i calculated the dot product of the e1 and e2 vertices that is say dAngle = e1.e2 now i reversed the position of v1 and v3 of those whose dAngle found<0 in above calculation. Now after that i see that those which are not visible becomes visible but then some of other becomes invisible(not all). Any solution for it to make all visible.

Share this post


Link to post
Share on other sites
i don't think it's your engine that needs to compensate for the mesh... it should render in either clockwise or counter-clockwise... not both. Therefore, i suggest you fix your mesh. If your mesh uses clockwise and your engine renders counter-clockwise, then you might want to add a feature to flip the faces, but a mesh using both methods just doesn't make sense.

Share this post


Link to post
Share on other sites
In 3d max i unify the all normals and also checked out for the normals whether they are showing outwards or not. And there is no problem at all found. Also one more thing when i export them as xfile and i see that the mesh is visible with D3DCULL_CCW but when i rotate the mesh with 180 degree it is visible with D3DCULL_CW not D3DCULL_CCW. What can be the possible cause for this.

Share this post


Link to post
Share on other sites
I tried to export only vertices of the data not indices and when i render the mesh by drawprimitive (no index as i was doing previosly) it appears working. But i want to use DrawIndexPrimitive.Previosly, In exporting the data first i was expoting the whole mesh vertices and then the face indices. In second attempt i am exporting the whole mesh faces vertices not indices just by replacing the indices of face directly by vertices. So i don't think that there could be any flaw in my ways of exporting the data. If it still there please tell where it could be.

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