Page 1 of 1
Determining surface center of plane
Posted: Sun May 05, 2013 3:43 pm
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.
Re: Determining surface center of plane
Posted: Sun May 05, 2013 4:50 pm
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.
Re: Determining surface center of plane
Posted: Sun May 05, 2013 5:00 pm
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
Re: Determining surface center of plane
Posted: Sun May 05, 2013 7:58 pm
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)
Re: Determining surface center of plane
Posted: Mon May 06, 2013 2:46 am
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.
Re: Determining surface center of plane
Posted: Mon May 06, 2013 7:51 pm
by leileilol
i'd rather do it on load time
Re: Determining surface center of plane
Posted: Mon May 06, 2013 8:48 pm
by qbism
OK. There's always .ent, do it as a particle emitter