Skip to main content
gamedev.net
🔒 Locked

q3 map rendering problems.

Started by eviltwigflipper Jan 22, 2005 at 2:59 PM 0 replies 400+ views
Original Post
eviltwigflipper
eviltwigflipper
Ive seemed to fix my loading issues, but rendering poses a problem as well. Most references on the subject are very hard to find(any good ones). From the ones I have found I have pieced together something that resembles what it should do:

/*
====================================================================================================================
void Renderer::RenderFace(bsp3_face *thisFace, vector<bsp3_Vertex*> mapVertList, vector<bsp3_index> mapIndexList)
====================================================================================================================
*/

void Renderer::RenderFace(bsp3_face *thisFace, vector<bsp3_Vertex> mapVertList, vector<bsp3_index> mapIndexList)
{
	glBegin(GL_TRIANGLES);
			for(int i = 0; i < thisFace->numOfVerts; i++)
			{
				int offset = mapIndexList.at(thisFace->startIndex + i) + thisFace->startVertIndex;

				if(offset > mapVertList.size())
					Sys_Error("RenderFace: offset is run out of bounds %d > %d\n",offset, mapVertList.size()); 

				glNormal3fv(mapVertList.at(offset).normal);
				glVertex3fv(mapVertList.at(offset).position);
			}
	glEnd();
}

/*
==================================================
void Renderer::RenderWorld(jmMapSystem *thisMap)
==================================================
*/

void Renderer::RenderWorld(jmMapSystem *thisMap)
{
	vector<bsp3_index>     mapIndexs = thisMap->map_Indexs;
    vector<bsp3_Vertex>  mapVerts  = thisMap->map_Vertexs;
	vector<bsp3_face *>    map_Faces = thisMap->map_Faces;

	int numVerts  = thisMap->numVerts;
	int numIndexs = thisMap->numIndex;
	int numFaces  = thisMap->numFaces;

// ive tried front/back face culling, and having culling off.
	 glCullFace(GL_FRONT);
     glEnable(GL_CULL_FACE);

	// Set up the GL sysem for rendering
	glVertexPointer(3, GL_FLOAT, sizeof(bsp3_Vertex), &mapVerts.at(0).position);
	glTexCoordPointer(2, GL_FLOAT, sizeof(bsp3_Vertex), &mapVerts.at(0).texcoord);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	
	for(int i = 0; i < numFaces; i++)
	{
		switch(map_Faces.at(i)->type)
		{
			case BSP3_POLYGON:
				RenderFace(map_Faces.at(i),mapVerts,mapIndexs);
			break;
			case BSP3_PATCH:
				Sys_Print("WARNING: Dont know how to render type BSP3_PATCH\n");
			break;
			case BSP3_MESH:
				Sys_Print("WARNING: Dont know how to render type BSP3_MESH\n");
			break;
			case BSP3_BILLBOARD:
				Sys_Print("WARNING: Dont know how to render type BSP3_BILLBOARD\n");
			break;
			default:
				Sys_Error("bsp3: invalid face type on face %d, type = %d\n",i,map_Faces.at(i)->type);
		}
	}
}




Problem is it doesn't render anything....anyone have any idea why? Probley like my last problem....it was a stupid programming error heh. P.S. jw when will the search button be fixed?
Ademan555
Ademan555
this shouldnt cause NOTHING to be rendered, but iirc the map is NOT guaranteed to be triangles, its polygons, so GL_POLYGON, unless im misunderstanding you, and your trying to render the MESHES in the map, which ARE only triangles....

EDIT: i cant spell :-p

hope that helps
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.