Doom 3 Proc file troubles

Started by
8 comments, last by gulgi 19 years, 3 months ago
From what I understand of the Doom III proc format it is something like this: mapProcFile003 <-- header model { /* name = */ "bathroom_light_mover" /* numSurfaces = */ 1 /* surface 0 */ { "_emptyname" /* numVerts = */ 24 /* numIndexes = */ 36 ( <x cord> <y cord> <z cord > <u cord > <v cord> <normalx> <normaly> <normalz> ) After this are the index buffers. If this is correct, then this data gets read into the appriote buffers, but DirectX wont render it. Here is my code:

void dx9System::RenderPlane(model thisplane)
{
	IDirect3DVertexBuffer9 *vb;
	IDirect3DIndexBuffer9 *ib;
	int numofprim = ((thisplane.mapsurfaces->numofindexs / 3) * 2);
	int i;
	int texcoordnum = 0;

	if(thisplane.mapsurfaces->numofverts < 1 || thisplane.mapsurfaces->numofindexs < 1)
		sys_error("RenderPlane: This surface has a illegal number of verts or indexs\n");

	device->CreateVertexBuffer(thisplane.mapsurfaces->numofverts * sizeof(NormalTexVertex),
							  D3DUSAGE_WRITEONLY,FVF_NORMAL_TEX, D3DPOOL_MANAGED,
							  &vb,0);
	device->CreateIndexBuffer(thisplane.mapsurfaces->numofindexs * sizeof(WORD),
							  D3DUSAGE_WRITEONLY,D3DFMT_INDEX16, D3DPOOL_MANAGED,
							  &ib,0);

	NormalTexVertex *verts;
	vb->Lock(0,0,(void **)&verts,0);
		for(i = 0; i < thisplane.mapsurfaces->numofverts; i+=3)
		{
			verts = NormalTexVertex(thisplane.mapsurfaces->verts,thisplane.mapsurfaces->verts[i+1],
									   thisplane.mapsurfaces->verts[i+2],thisplane.mapsurfaces->texcoords[texcoordnum],
									   thisplane.mapsurfaces->texcoords[texcoordnum+1]);

			texcoordnum += 2;
		}
	vb->Unlock();

	WORD *indicies;
	ib->Lock(0,0,(void **)&indicies,0);
		for(i = 0; i< thisplane.mapsurfaces->numofindexs; i++);
		{
			indicies = thisplane.mapsurfaces->indexs;
		}
	ib->Unlock();

	device->SetStreamSource(0,vb,0,sizeof(NormalTexVertex));
	device->SetIndices(ib);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,thisplane.mapsurfaces->numofverts,0,numofprim);
}



Just wondering if anyone had any suggestions why it renders nothing to the screen. This of course gets rendered in between the "BeginScene" and EndScene code.
Advertisement
That's basically correct (they use z as up-vector..).

I'm not to used to D3D.. but it doesn't look like you'r setting a texture..
Why not try with just a color and no texturing first.

And your handling of vertex and index buffers just seem.. weird (but I'm a OpenGL person so what do I know ;]).
I read in all the data. Put it into the buffers, then just renders it every frame.

The model:s in the proc-file.. only the ones with names that start with "_area" is actual areas.. the rest are "objects" that needs to be moved to the right place, trough shader code or translation beforehand.

Good luck!
Regardless sense I have lighting off, the geometry should still render as white. It's just not rendering anything.. : (
I believe, there was a link of how to load Doom3 levels on http://nehe.gamedev.net in the new section? Because it was published some time ago and nehe does not support searching, I can not find that post.

It was a small OpenGL Level viewer with source.

I don't understand why does Doom3 have .map and .proc files? Both text, box seem to be the same at the first look.
D3 levels are sometimes at really weird positions in space. so like -9800, 5000 etc.... maybe your camera is not near to that position and clips everything away?
Quote:Original post by Samurai Jack
I believe, there was a link of how to load Doom3 levels on http://nehe.gamedev.net in the new section? Because it was published some time ago and nehe does not support searching, I can not find that post.

Was there? Have to look.. mine doesn't support everything as of yet.
I have seen lots of applications that can load and display md5 files.. and that was the only thing I found.
You don't hapend to have a link? :)

Quote:Original post by Samurai Jack
I don't understand why does Doom3 have .map and .proc files? Both text, box seem to be the same at the first look.
The .map file is used by the editor when editing. Then the .proc file is compiled from the .map file. (And the .cm file is the collision model..)
Thanx for the infos.
I believe it was this "portal engine":

http://developer.infi.nl/index.php?ID=5
Thanks for all the information. I found a error, I put the surfaces into a array, and I was reading the array as a pointer. I fixed it but it still doesn't render anything.
/*======================================================void dx9System::RenderPlane(model thisplane);======================================================*/void dx9System::RenderPlane(model thisplane){	IDirect3DVertexBuffer9 *vb;	IDirect3DIndexBuffer9 *ib;	int numofprim = ((thisplane.mapsurfaces->numofindexs / 3) * 2);	int i,a;	int texcoordnum = 0;	if(thisplane.numofsurfaces < 1)		sys_error("RenderPlane: Numofsurfaces is invalid for this model\n");	for(a = 0; a<thisplane.numofsurfaces; a++)	{		if(thisplane.mapsurfaces[a].numofverts < 1 || thisplane.mapsurfaces[a].numofindexs < 1)			sys_error("RenderPlane: This surface has a illegal number of verts or indexs\n");		device->CreateVertexBuffer(thisplane.mapsurfaces[a].numofverts * sizeof(NormalTexVertex),								D3DUSAGE_WRITEONLY,FVF_NORMAL_TEX, D3DPOOL_MANAGED,								&vb,0);		device->CreateIndexBuffer(thisplane.mapsurfaces[a].numofindexs * sizeof(WORD),								D3DUSAGE_WRITEONLY,D3DFMT_INDEX16, D3DPOOL_MANAGED,								&ib,0);		NormalTexVertex *verts;		vb->Lock(0,0,(void **)&verts,0);			for(i = 0; i < thisplane.mapsurfaces[a].numofverts; i+=3)			{				if(thisplane.mapsurfaces[a].verts == 0 && thisplane.mapsurfaces[a].verts[i+1] == 0 &&				   thisplane.mapsurfaces[a].verts[i+2] == 0)				   sys_error("RenderPlane: Invalid triangle found\n");				verts = NormalTexVertex(thisplane.mapsurfaces[a].verts,thisplane.mapsurfaces[a].verts[i+1],										thisplane.mapsurfaces[a].verts[i+2],thisplane.mapsurfaces[a].texcoords[texcoordnum],										thisplane.mapsurfaces[a].texcoords[texcoordnum+1]);				texcoordnum += 2;			}		vb->Unlock();		WORD *indicies;		ib->Lock(0,0,(void **)&indicies,0);			for(i = 0; i< thisplane.mapsurfaces[a].numofindexs; i++);			{				indicies = thisplane.mapsurfaces[a].indexs;			}		ib->Unlock();		device->SetTexture(0,testtexture);		device->SetStreamSource(0,vb,0,sizeof(NormalTexVertex));		device->SetIndices(ib);		device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,thisplane.mapsurfaces[a].numofverts,0,numofprim);	}}


And renderplane is called like this

void jmMap::DrawWorld(void){	for(int i = 0; i<this->maxmodels; i++)	{		gameRenderSystem.r_RenderPlane(mapmodels);	}}

Very stupid mistake, but didn't fix my problem entirelly. Just wondering if anyone has a second to help me. : )

[Edited by - crozzbreed23 on January 3, 2005 6:14:15 PM]
Ok..I finally got it to load in something, and it renders it kinda wired.

http://www.geocities.com/eviltwigflipper/help01.txt

Im guessing because im not setting the Z as the up vector. What is a good way to do that?
Quote:Original post by Samurai Jack
I believe it was this "portal engine":

http://developer.infi.nl/index.php?ID=5

The thing I have some problems with is parsing the material file in an efficient manner, and doin the right thing with the materials. But that page will be good to have as a reference when I try implement collision. :) Thx.

Quote:Original post by crozzbreed23
Ok..I finally got it to load in something, and it renders it kinda wired.

http://www.geocities.com/eviltwigflipper/help01.txt

Im guessing because im not setting the Z as the up vector. What is a good way to do that?
.jpg is a better extension for jpeg:s.. ;]
When I read in vertices etc, I read: x, -z, y works like a charm. (same for Quake3).

If your camera is at the origin, then that is just models that needs to be placed in the right place in the level. The .map file has a info_player_start wich contains location and rotation for where the player starts in the level.

This topic is closed to new replies.

Advertisement