Dynamic lights on moving brush models

Post tutorials on how to do certain tasks within game or engine code here.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Dynamic lights on moving brush models

Post 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.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Dynamic lights on moving brush models

Post 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?"
Meadow Fun!! - my first commercial game, made with FTEQW game engine
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Dynamic lights on moving brush models

Post 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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Dynamic lights on moving brush models

Post by toneddu2000 »

Ah, thanks a lot frag.machine! Always helpful!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Post Reply