Determining surface center of plane

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Determining surface center of plane

Post by leileilol »

How would I go to do that? All plane gives me is a normal. Say I wanted to spawn a particle right in the pixel center of each repeated texture, like say fire from lava, smoke from demn faces, blood out of wall jesuses and jesus switches, etc... there's got to be SOME clue in the leaf data to do this in world space.

NOT GL btw.
i should not be here
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Determining surface center of plane

Post by Baker »

I'm giving a GLQuake example but this could be converted to software.

To draw a texture poly, you have to know sl, sh, tl, th.

If you are drawing a polygon where sl < 0.5 < sh and tl < 0.5 < th, you have a polygon that contains the center of the texture. So calculate the x,y,z for s = 0.5 and t = 0.5.

And then you have what you want. Even though I'm talking GL here, software has to know the texture coordinates.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Determining surface center of plane

Post by leileilol »

There are no brush polygons in software.

Code: Select all

void D_DrawPoly (void)
{
// this driver takes spans, not polygons

}
I wonder if anyone ever implemented that function though
i should not be here
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Determining surface center of plane

Post by Baker »

If you really wanted it, you pull out the calculations in GLQuake's BuildSursurfceDisplayList, which go like this in a very condensed version (using surface info that should be available in the software renderer from model load) ...

Code: Select all

float		*vec, s, t;
	for (i=0 ; i < surf->numedges ; i++)
	{
		int lindex = curmodel->surfedges[surf->firstedge + i];

		medge_t 	*r_pedge = lindex > 0 ? &pedges[lindex] : &pedges[-lindex]; 
		vec =  lindex > 0 ? curmodel->vertexes[r_pedge->v[0]].position : curmodel->vertexes[r_pedge->v[1]].position;

		s = (DotProduct (vec, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]) / surf->texinfo->texture->width;
		t = (DotProduct (vec, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]); / surf->texinfo->texture->height;
	}
void BuildSursurfceDisplayList (model_t *curmodel, msurface_t *surf)
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Determining surface center of plane

Post by qbism »

Pixel center of each texture... Pick it up from the texture source coords as it proceeds through spans. Has nothing to do with the title of this thread.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Determining surface center of plane

Post by leileilol »

i'd rather do it on load time
i should not be here
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Determining surface center of plane

Post by qbism »

OK. There's always .ent, do it as a particle emitter
Post Reply