예제 #1
0
파일: view.c 프로젝트: CatalystG/tyrquake
/*
==================
CalcGunAngle
==================
*/
void
CalcGunAngle(void)
{
    float yaw, pitch, move;
    static float oldyaw = 0;
    static float oldpitch = 0;

    yaw = r_refdef.viewangles[YAW];
    pitch = -r_refdef.viewangles[PITCH];

    yaw = angledelta(yaw - r_refdef.viewangles[YAW]) * 0.4;
    if (yaw > 10)
	yaw = 10;
    if (yaw < -10)
	yaw = -10;
    pitch = angledelta(-pitch - r_refdef.viewangles[PITCH]) * 0.4;
    if (pitch > 10)
	pitch = 10;
    if (pitch < -10)
	pitch = -10;
    move = host_frametime * 20;
    if (yaw > oldyaw) {
	if (oldyaw + move < yaw)
	    yaw = oldyaw + move;
    } else {
	if (oldyaw - move > yaw)
	    yaw = oldyaw - move;
    }

    if (pitch > oldpitch) {
	if (oldpitch + move < pitch)
	    pitch = oldpitch + move;
    } else {
	if (oldpitch - move > pitch)
	    pitch = oldpitch - move;
    }

    oldyaw = yaw;
    oldpitch = pitch;

    cl.viewent.angles[YAW] = r_refdef.viewangles[YAW] + yaw;
    cl.viewent.angles[PITCH] = -(r_refdef.viewangles[PITCH] + pitch);

    cl.viewent.angles[ROLL] -=
	v_idlescale.value * sin(cl.time * v_iroll_cycle.value) *
	v_iroll_level.value;
    cl.viewent.angles[PITCH] -=
	v_idlescale.value * sin(cl.time * v_ipitch_cycle.value) *
	v_ipitch_level.value;
    cl.viewent.angles[YAW] -=
	v_idlescale.value * sin(cl.time * v_iyaw_cycle.value) *
	v_iyaw_level.value;
}
예제 #2
0
static void
CalcGunAngle (void)
{
	float       yaw, pitch, move;
	static float oldpitch = 0, oldyaw = 0;

	yaw = r_data->refdef->viewangles[YAW];
	pitch = -r_data->refdef->viewangles[PITCH];

	yaw = angledelta (yaw - r_data->refdef->viewangles[YAW]) * 0.4;
	yaw = bound (-10, yaw, 10);
	pitch = angledelta (-pitch - r_data->refdef->viewangles[PITCH]) * 0.4;
	pitch = bound (-10, pitch, 10);

	move = host_frametime * 20;
	if (yaw > oldyaw) {
		if (oldyaw + move < yaw)
			yaw = oldyaw + move;
	} else {
		if (oldyaw - move > yaw)
			yaw = oldyaw - move;
	}

	if (pitch > oldpitch) {
		if (oldpitch + move < pitch)
			pitch = oldpitch + move;
	} else {
		if (oldpitch - move > pitch)
			pitch = oldpitch - move;
	}

	oldyaw = yaw;
	oldpitch = pitch;

	cl.viewent.angles[YAW] = r_data->refdef->viewangles[YAW] + yaw;
	cl.viewent.angles[PITCH] = -(r_data->refdef->viewangles[PITCH] + pitch);
}
예제 #3
0
/*
==================
CalcGunAngle
==================
*/
void CalcGunAngle (void)
{	
	float	yaw, pitch, move;
	static float oldyaw = 0;
	static float oldpitch = 0;
	
	yaw = r_refdef.viewangles[YAW];
	pitch = -r_refdef.viewangles[PITCH];

	yaw = angledelta(yaw - r_refdef.viewangles[YAW]) * 0.4f;
	if (yaw > 10)
		yaw = 10;
	if (yaw < -10)
		yaw = -10;
	pitch = angledelta(-pitch - r_refdef.viewangles[PITCH]) * 0.4f;
	if (pitch > 10)
		pitch = 10;
	if (pitch < -10)
		pitch = -10;
	move = host_frametime*20;
	if (yaw > oldyaw)
	{
		if (oldyaw + move < yaw)
			yaw = oldyaw + move;
	}
	else
	{
		if (oldyaw - move > yaw)
			yaw = oldyaw - move;
	}
	
	if (pitch > oldpitch)
	{
		if (oldpitch + move < pitch)
			pitch = oldpitch + move;
	}
	else
	{
		if (oldpitch - move > pitch)
			pitch = oldpitch - move;
	}
	
	oldyaw = yaw;
	oldpitch = pitch;

	// ELUTODO: all around the code: scr_vrect.height doesn't count the status bar
	if (!cls.demoplayback && !in_osk)
	{
		// ELUTODO: Some small gimbal lock issues
		cl.viewent.angles[YAW] = r_refdef.viewangles[YAW] + yaw - cl_crossx.value/scr_vrect.width * IR_YAWRANGE;
		cl.viewent.angles[PITCH] = - (r_refdef.viewangles[PITCH] + pitch + cl_crossy.value/scr_vrect.height * IR_PITCHRANGE);
		if (cl_weapon_inrollangle.value)
			cl.viewent.angles[ROLL] = in_rollangle;
	}
	else
	{
		// ELUTODO: Maybe there are other cases besides demo playback
		cl.viewent.angles[YAW] = r_refdef.viewangles[YAW] + yaw;
		cl.viewent.angles[PITCH] = - (r_refdef.viewangles[PITCH] + pitch);
	}

	cl.viewent.angles[ROLL] -= v_idlescale.value * sinf(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
	cl.viewent.angles[PITCH] -= v_idlescale.value * sinf(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value;
	cl.viewent.angles[YAW] -= v_idlescale.value * sinf(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value;
}