Holes when rendering Quake 3 maps?

Started by
17 comments, last by Enrico 16 years, 6 months ago
Hi, I've got a strange problem in my engine. I can load and render some quake 3 maps without any problems. At the moment I'm not rendering meshes, patches or billboards; only faces are loaded. While some maps render fine, others render with holes I can't find anything in any of the Q3 map specs that explains this, anyone have any ideas? Here is a "normal" map: and here is a "holey" map: finally here is the code that takes a Quake map polygon and splits it into triangles:

for(vector<stQ3Face>::const_iterator it = faces.begin();
					it != faces.end(); ++it) {

	//At the moment only handle normal polygons
	if ((*it).type != 1) {
		continue;
	}

	int end = (*it).startVertexIndex + (*it).totalVertices;

	for (int i = (*it).startVertexIndex; i < end - 1; i++) {
		WorldTriangle newTriangle;
		newTriangle.m_Index[0] = (*it).startVertexIndex;
		newTriangle.m_Index[1] = i + 1;
		newTriangle.m_Index[2] = i;

		newTriangle.m_TexCoords[0] = vertices[newTriangle.m_Index[0]].texCoord;
		newTriangle.m_TexCoords[1] = vertices[newTriangle.m_Index[1]].texCoord;
		newTriangle.m_TexCoords[2] = vertices[newTriangle.m_Index[2]].texCoord;

		newTriangle.m_TextureName = path(textures[(*it).texID].file).leaf();

		slVec3 vec1, vec2;
		vec1 = m_VertexData[newTriangle.m_Index[1]].m_Pos - m_VertexData[newTriangle.m_Index[0]].m_Pos;
		vec2 = m_VertexData[newTriangle.m_Index[2]].m_Pos - m_VertexData[newTriangle.m_Index[0]].m_Pos;
		slVec3Cross(&newTriangle.m_FaceNormal, &vec1, &vec2);
		slVec3Normalize(&newTriangle.m_FaceNormal, &newTriangle.m_FaceNormal);


		m_TriangleData.push_back(newTriangle);
	}
}

Member of the NeHe team.
Advertisement
You said you weren't rendering Bezier patches - could the holes be places where patches would normally be rendered?
No I don't think so, it's as if every other triangle in the mesh is missing. I thought it could be to do with the winding of the vertices alternating but disabling backface culling does nothing.
Member of the NeHe team.
Are you sure your loop condition (< end -1) is correct? Shouldn't that be < end ?
Are you sure that you turn the polygons into triangles correctly?
Perhaps they're stored as trianglestrips sometimes, just a guess.
Why do you split the triangles from the maps into triangles? This makes no real sense, except for subdivision.

I just had a look at my Quake3 loader and it doesnot load any "polygons" or triangles strips from the files. Only the triangles are loaded and used for rendering and this is the way to go... there are no holes or any other render errors in my applications with this.

I had a very short look at your code, so only another small question: Why are you calculating normal vectors? These are already saved in the map file...
--
No, notice I use i + 1 as an index. The end - 1 prevents me reading past the end of the vertex array.
Member of the NeHe team.
Oops, shoulda refreshed...

OK, my engine internally only deals with triangles internally. Whereas Quake 3 represents polys as triangle fans. That is why I break them down into triangles they are then easier to deal with. I generate the normal because as far as I know there is no guarantee that all triangles in the fan will lie on the same plane (although it is likely).
Member of the NeHe team.
It seems to me the problem is with Quake3's shaders. Did you check that all of the 'textures' specified in the .bsp are loaded correctly? Because in q3 maps some textures are not really textures on the disk, but rather 'shaders' which describe special texture properties like blending, animation, etc.


Ivan
Hmm, well that would explain why I am always missing a load of textures from the maps I'm downloading, but I doubt that the geometry would be entirely missing. My engine just binds a texture ID of 0 (i.e. draws it white) if the material is missing.
Member of the NeHe team.

This topic is closed to new replies.

Advertisement