Tutorial *74*

Anyone who has poked around the Quake Console command list probably noticed that there is an incomplete chase camera in Quake, invoked by typing 'chase_active 1'. In this tutorial I'll attempt to fix it up so it's more usable. First I will fix it for WinQuake, then later GLQuake. If you try the camera out right now, with no modification, in WinQuake you will notice your weapon model hovering mid-air. The player isn't drawn, so lets fix that first. Open up r_main.c, scroll down to R_DrawEntitiesOnList, you will see this code:



if (currententity == &cl_entities[cl.viewentity])

	continue;	// don't draw the player

But wait, we *want* to draw the player if the chasecam is active. Also we'll fix a pitching problem while we're at it, so change the code to read:


if (currententity == &cl_entities[cl.viewentity])

{

	if (!chase_active.value)

		continue;	// don't draw the player

	else

		currententity->angles[0] *= 0.3;

}

Next, we've got to stop the engine from drawing the view model when in the chase camera. Scroll down to R_DrawViewModel, you will see this line:


if (!r_drawviewmodel.value || r_fov_greater_than_90)

	return;

After it, add:


if (chase_active.value)

	return;

Close r_main and save it. If you were to compile right now, the camera would be pretty good, except that awful clipping outside the level. The next part is optional, for both WinQuake and GL. It's a little hack to reduce that effect. Open up chase.c and find the function Chase_Update, at the very bottom you will see the lines:


// move towards destination

VectorCopy (chase_dest, r_refdef.vieworg);

Bah, it just sets your r_refdef origin to where the chase camera wants to go, whether or not this is inside or outside the level. Right above those two lines, add:


TraceLine(r_refdef.vieworg, chase_dest, stop);

if (Length(stop) != 0)

	VectorCopy(stop, chase_dest);

This version of TraceLine only returns a value into stop if it hit something, so we check for the Length of stop not equaling 0, this is a bit cheesy, but it works. Last bit of this is to fix up GLQuake.

GLQuake actually has the chasecam done a bit better than software, it only needs one correction: The model pitches are off (they correspond exactly with where you're looking, not like how the server scales it back by a third). Open up gl_rmain.c and find the function R_DrawEntitiesOnList, after the line in the first for loop that reads:



currententity = cl_visedicts[i];

Simply add this:


if (currententity == &cl_entities[cl.viewentity])

	currententity->angles[0] *= 0.3;

Well there you have it! A semi-fixed chase cam for software and GL. If you have anymore improvements, write me at frikac@telefragged.com Thanks for listening.


 
Sign up
Login:
Passwd:
[Remember Me]