   [D3D] Culling question
  Hello again, this question has probably been asked before but I couldn't find an answer.I'm writing a maze game made up of different "pieces" like the image below:Each piece is a 30x30 area containing smaller 10x10 "blocks", the blocks can either be a floor or a wall. The vertices are stored in Floor and Wall classes and added to vectors, then combined into a single array that is used to create the mesh.My question is, what would be the best way to remove the faces that won't been seen by the player? i.e. the sides of a wall that intersects with another wall. I can iterate through each vertex in the array but how do I know which ones to remove? Thanksfor (DWORD i = 0; i < p_Walls.size(); i++){vector<Vertex> vertices = p_Walls.GetVertices();for (DWORD i2 = 0; i2 < vertices.size(); i2++){Vertex vertex = p_Vertices[i2];// TODO// if (vertex.Position.x == ? && vertex.Position.z == ?)}}
  You don't need to remove them - DirectX do it by it self ewhen you use culling.Use this line:SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);And by passing all over the vertices, for each triangle, make the vertices by the order conter clockwise, so the player will see the triangle(part of the wall) if and only if he can see the order of the vertices(the order is by the conter clockwise) as the order of the vertices in the array.You can see what is it back-face culling in Wikipedia:http://en.wikipedia.org/wiki/Back-face_culling   ;Quote:Original post by talhadadYou don't need to remove them - DirectX do it by it self ewhen you use culling.That'll automatically remove the back-facing ones, it won't remove the forward facing ones that are obscured.I'd go through each wall, and generate a face normal for it. Then go through every other wall and check if there's a wall in the adjacent cell with a normal in the opposite direction. If so, you can remove both walls.However, I wouldn't really worry about it (Unless you want to do it for the experience of course) - this shouldn't make any sort of significant impact on performance.   ;  Thanks again Steve I never thought about opposite normals. My vertices already have normal data so that should be simple enough :D   