1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  
     | 
    
      /*
Copyright (C) 2011 VULTUREIIC
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//VULTUREIIC
//Like so many other things, the camera features never got finished. I had in mind all kinds of neat things too
#include "quakedef.h"
#include "vx_stuff.h"
vec3_t	camera_pos; //Where the camera is
vec3_t	camera_angles; //Where the camera is looking
vec3_t	camera_pos_finish; //Where we want the camera to stop
vec3_t	camera_angles_finish; //Where we want the camera looking when we stop
float	camera_speed; //Speed that the camera moves
cameramode_t cameratype;
void CameraRandomPoint (vec3_t org)
{
	/* ?TONIK? WTF is cl.simorg */
	vec3_t stop, normal, dest, forward, right, up, vec;
	dest[0] = org[0] + (rand() % 500 - 250);
	dest[1] = org[1] + (rand() % 500 - 250);
	dest[2] = org[2] + (rand() % 100 + 50);
	CL_TraceLine (org, dest, stop, normal);
	VectorSubtract (org, stop, vec);
	AngleVectors (vec, forward, right, up);
	if (!VectorCompare (dest, stop)) {
		dest[0] = stop[0] + forward[0] * 15 + normal[0] * 15;
		dest[1] = stop[1] + forward[1] * 15 + normal[1] * 15;
		dest[2] = stop[2] + forward[2] * 15 + normal[2] * 15;
	}
	VectorCopy (dest, camera_pos);
}
void CameraUpdate (qbool dead)
{
	vec3_t dest, destangles;
	if ((cls.demoplayback || cl.spectator) && amf_camera_chase.value == 1)
		cameratype = C_CHASECAM;
	else if ((cls.demoplayback || cl.spectator) && amf_camera_chase.value == 2)
	{
		if (cameratype == C_NORMAL)
			CameraRandomPoint (cl.simorg);
		cameratype = C_EXTERNAL;
	}
	else if (dead && (cls.demoplayback || cl.spectator) && amf_camera_death.value)
	{
		if (cameratype == C_NORMAL)
			CameraRandomPoint (cl.simorg);
		cameratype = C_EXTERNAL;
	}
	else
		cameratype = C_NORMAL;
	if (cameratype == C_NORMAL)
	{
		VectorCopy (cl.simorg, camera_pos);
		VectorCopy (cl.simangles, camera_angles);
		return;
	}
	//CHASECAM
	if (cameratype == C_CHASECAM)
	{
		if (!dead)
		{
			float	dist = amf_camera_chase_dist.value;
			float	height = amf_camera_chase_height.value;
			int i;
			vec3_t	forward, up, right, normal, impact;
			
			AngleVectors (cl.viewangles, forward, right, up);
			for (i=0;i<3;i++)
				dest[i] = r_refdef.vieworg[i] + forward[i] * dist;
			dest[2] = dest[2] + height;
			CL_TraceLine (r_refdef.vieworg, dest, impact, normal);
			if (!VectorCompare(dest, impact))
			{
				dest[0] = impact[0] + forward[0] * 8 + normal[0] * 4;
				dest[1] = impact[1] + forward[1] * 8 + normal[1] * 4;
				dest[2] = impact[2] + forward[2] * 8 + normal[2] * 4;
			}
			VectorCopy(cl.simangles, destangles);
		}
		else
		{
			cameratype = C_EXTERNAL;
			//cameratype = C_NORMAL;
			return;
		}
	}
	else if (cameratype == C_EXTERNAL)
	{
		vec3_t normal, impact, vec;
		CL_TraceLine (camera_pos, cl.simorg, impact, normal);
		if (!VectorCompare(cl.simorg, impact))
			CameraRandomPoint (cl.simorg);
		VectorSubtract(cl.simorg, camera_pos, vec);
		vectoangles(vec, destangles);
		destangles[0] = -destangles[0];
		VectorCopy(camera_pos, dest);
	}
	VectorCopy(dest, r_refdef.vieworg);
	VectorCopy(destangles, r_refdef.viewangles);
	VectorCopy (dest, camera_pos);
	VectorCopy (destangles, camera_angles);
}
 
     |