r5619 - in trunk/data: . qcsrc/client
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Jan 19 17:57:49 EST 2009
Author: mand1nga
Date: 2009-01-19 17:57:49 -0500 (Mon, 19 Jan 2009)
New Revision: 5619
Modified:
trunk/data/defaultNexuiz.cfg
trunk/data/qcsrc/client/View.qc
Log:
New demo camera mode for looking always to the player
New cvar camera_forward_follows for spectator-like camera
Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg 2009-01-19 14:24:09 UTC (rev 5618)
+++ trunk/data/defaultNexuiz.cfg 2009-01-19 22:57:49 UTC (rev 5619)
@@ -1396,7 +1396,7 @@
set camera_speed_roll 0.9 // Camera rotation speed
set camera_speed_chase 4 // Camera movement speed on the x/y/z axis while chasing the player
set camera_speed_free 8 // Camera movement speed on the x/y/z axis in free mode
-set camera_speed_attenuation 30 // Camera movements attenuation factor. Bigger is smoother
+set camera_speed_attenuation 30 // Camera movements attenuation factor. Bigger is smoother. Applies to mouse movements.
set camera_free 0 // Free camera instead of chasing the player
set camera_reset 0 // Reset the camera position
set camera_direction_x 0 // Move the camera on the x axis (relative to the camera angle)
@@ -1404,6 +1404,9 @@
set camera_direction_z 0 // Move the camera on the z axis (relative to the camera rotation)
set camera_mouse_treshold 0.5 // Use to ignore small mouse movements. This allows for smoother camera control
set camera_chase_smoothly 0 // Attenuate player movements (only in chase mode)
+set camera_look_player 0 // Always look to the player. Mouse input is ignored in this mode.
+set camera_look_attenuation 8 // Attenuation of "looking" movements, only if camera_look_player is set. Bigger is smoother.
+set camera_forward_follows 0 // 0: Move the camera forwards without changing altitude. 1: Move towards what you are looking.
alias +camera_move_forward "set camera_direction_x 1"
alias -camera_move_forward "set camera_direction_x 0"
Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc 2009-01-19 14:24:09 UTC (rev 5618)
+++ trunk/data/qcsrc/client/View.qc 2009-01-19 22:57:49 UTC (rev 5619)
@@ -198,7 +198,7 @@
entity e;
float fov;
float f;
- vector v1, v2;
+ vector v1, v2, delta;
dprint_load();
WaypointSprite_Load();
@@ -334,8 +334,8 @@
camera_offset = '0 0 0';
new_angles = view_angles;
camera_offset_z += 20;
- camera_offset_x -= 20 * cos(new_angles_y * DEG2RAD);
- camera_offset_y -= 20 * sin(new_angles_y * DEG2RAD);
+ camera_offset_x += 20 * -cos(new_angles_y * DEG2RAD);
+ camera_offset_y += 20 * -sin(new_angles_y * DEG2RAD);
current_origin = view_origin;
}
@@ -343,21 +343,40 @@
if( cvar("camera_roll") )
mouse_angles_z += cvar("camera_roll") * cvar("camera_speed_roll");
- m = getmousepos() * 0.1;
- if(vlen(m)>cvar("camera_mouse_treshold"))
+ if(!cvar("camera_look_player"))
{
- mouse_angles_x += m_y * cos(mouse_angles_z * DEG2RAD) + (m_x * sin(mouse_angles_z * DEG2RAD));
- mouse_angles_y -= m_x * cos(mouse_angles_z * DEG2RAD) + (m_y * -sin(mouse_angles_z * DEG2RAD));
+ m = getmousepos() * 0.1;
+ if(vlen(m)>cvar("camera_mouse_treshold"))
+ {
+ mouse_angles_x += m_y * cos(mouse_angles_z * DEG2RAD) + (m_x * sin(mouse_angles_z * DEG2RAD));
+ mouse_angles_y -= m_x * cos(mouse_angles_z * DEG2RAD) + (m_y * -sin(mouse_angles_z * DEG2RAD));
+ }
+
+ while (mouse_angles_x < -180)
+ mouse_angles_x = mouse_angles_x + 360;
+ while (mouse_angles_x > 180)
+ mouse_angles_x = mouse_angles_x - 360;
+ while (mouse_angles_y < -180)
+ mouse_angles_y = mouse_angles_y + 360;
+ while (mouse_angles_y > 180)
+ mouse_angles_y = mouse_angles_y - 360;
+
+ delta = '0 0 0';
+ if( mouse_angles_y < -90 && new_angles_y > 0)
+ delta = '0 360 0';
+ if( mouse_angles_y > 90 && new_angles_y < -90)
+ delta = '0 -360 0';
+
+ new_angles += (mouse_angles - new_angles + delta) * attenuation;
}
- new_angles += (mouse_angles - new_angles) * attenuation;
-
// Camera position
if( cvar("camera_direction_x") )
{
camera_offset_x += cvar("camera_direction_x") * speed * cos(new_angles_y * DEG2RAD);
camera_offset_y += cvar("camera_direction_x") * speed * sin(new_angles_y * DEG2RAD);
- // camera_offset_z += cvar("camera_direction_x") * speed * -sin(new_angles_x * DEG2RAD);
+ if( cvar("camera_forward_follows") )
+ camera_offset_z += cvar("camera_direction_x") * speed * -sin(new_angles_x * DEG2RAD);
}
if( cvar("camera_direction_y") )
@@ -403,6 +422,45 @@
new_origin = current_origin + current_camera_offset;
}
+ if(cvar("camera_look_player"))
+ {
+ local vector dir, delta;
+ local float n;
+
+ dir = normalize(view_origin - new_origin);
+ n = mouse_angles_z;
+ mouse_angles = vectoangles(dir);
+ mouse_angles_x = mouse_angles_x * -1;
+ mouse_angles_z = n;
+
+ while (mouse_angles_x < -180)
+ mouse_angles_x = mouse_angles_x + 360;
+ while (mouse_angles_x > 180)
+ mouse_angles_x = mouse_angles_x - 360;
+ while (mouse_angles_y < -180)
+ mouse_angles_y = mouse_angles_y + 360;
+ while (mouse_angles_y > 180)
+ mouse_angles_y = mouse_angles_y - 360;
+
+ delta = '0 0 0';
+ if(mouse_angles_y < -90 && new_angles_y > 0)
+ delta = '0 360 0';
+ if(mouse_angles_y > 90 && new_angles_y < -90)
+ delta = '0 -360 0';
+
+ n = 1 / max(1, cvar("camera_look_attenuation"));
+ new_angles += (mouse_angles - new_angles + delta) * n;
+ }
+
+ while (new_angles_x < -180)
+ new_angles_x = new_angles_x + 360;
+ while (new_angles_x > 180)
+ new_angles_x = new_angles_x - 360;
+ while (new_angles_y < -180)
+ new_angles_y = new_angles_y + 360;
+ while (new_angles_y > 180)
+ new_angles_y = new_angles_y - 360;
+
R_SetView(VF_ANGLES, new_angles);
R_SetView(VF_ORIGIN, new_origin);
}
More information about the nexuiz-commits
mailing list