Forum

Page 3 of 3

Re: Dynamic lights on moving brush models

PostPosted: Wed Jan 03, 2018 6:02 pm
by mh
Software Quake version

Image

In the dlight_t struct, add a new member:
Code: Select all
vec3_t   transformed;

In R_MarkLights, replace occurrances of "light->origin" with "light->transformed".

In R_PushDlights, before the call to R_MarkLights, add:
Code: Select all
l->transformed[0] = l->origin[0];
l->transformed[1] = l->origin[1];
l->transformed[2] = l->origin[2];

In R_DrawBEntitiesOnList, before the call to R_MarkLights, add:
Code: Select all
cl_dlights[k].transformed[0] = cl_dlights[k].origin[0] - currententity->origin[0];
cl_dlights[k].transformed[1] = cl_dlights[k].origin[1] - currententity->origin[1];
cl_dlights[k].transformed[2] = cl_dlights[k].origin[2] - currententity->origin[2];

In R_AddDynamicLights, before the calculation of "rad = cl_dlights[lnum].radius;", add:
Code: Select all
if (currententity == &cl_entities[0])
{
   cl_dlights[lnum].transformed[0] = cl_dlights[lnum].origin[0];
   cl_dlights[lnum].transformed[1] = cl_dlights[lnum].origin[1];
   cl_dlights[lnum].transformed[2] = cl_dlights[lnum].origin[2];
}
else
{
   cl_dlights[lnum].transformed[0] = cl_dlights[lnum].origin[0] - currententity->origin[0];
   cl_dlights[lnum].transformed[1] = cl_dlights[lnum].origin[1] - currententity->origin[1];
   cl_dlights[lnum].transformed[2] = cl_dlights[lnum].origin[2] - currententity->origin[2];
}

Elsewhere in R_AddDynamicLights, replace occurrances of "cl_dlights[lnum].origin" with "cl_dlights[lnum].transformed".

Done.

This is obviously the non-rotated version.

Re: Dynamic lights on moving brush models

PostPosted: Sun Jan 07, 2018 7:49 pm
by toneddu2000
So cool mh, thanks for sharing! I've always been fascinated by software rendering!

PS: what do you mean by "non-rotated version?"

Re: Dynamic lights on moving brush models

PostPosted: Mon Jan 08, 2018 9:47 am
by frag.machine
Originally Quake had no support to rotate BSP models like doors or plats. This was introduced later when the source code was released.

Re: Dynamic lights on moving brush models

PostPosted: Mon Jan 08, 2018 10:30 am
by toneddu2000
Ah, thanks a lot frag.machine! Always helpful!