Forum

Dynamic lights on moving brush models

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

Re: Dynamic lights on moving brush models

Postby mh » Wed Jan 03, 2018 6:02 pm

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
User avatar
mh
 
Posts: 2287
Joined: Sat Jan 12, 2008 1:38 am

Re: Dynamic lights on moving brush models

Postby toneddu2000 » Sun Jan 07, 2018 7:49 pm

So cool mh, thanks for sharing! I've always been fascinated by software rendering!

PS: what do you mean by "non-rotated version?"
toneddu2000
 
Posts: 1308
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Dynamic lights on moving brush models

Postby frag.machine » Mon Jan 08, 2018 9:47 am

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)
User avatar
frag.machine
 
Posts: 2068
Joined: Sat Nov 25, 2006 1:49 pm


Previous

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests