Various improvements

- 6DoF weapons
This commit is contained in:
Simon 2019-10-01 23:02:11 +01:00
parent 0716496d65
commit 2825144e9b
14 changed files with 78 additions and 69 deletions

View file

@ -1327,6 +1327,7 @@ void VR_Init()
vr_height_adjust = Cvar_Get( "vr_height_adjust", "0.0", CVAR_ARCHIVE); vr_height_adjust = Cvar_Get( "vr_height_adjust", "0.0", CVAR_ARCHIVE);
vr_flashlight_model = Cvar_Get( "vr_flashlight_model", "1", CVAR_ARCHIVE); vr_flashlight_model = Cvar_Get( "vr_flashlight_model", "1", CVAR_ARCHIVE);
vr_mirror_weapons = Cvar_Get( "vr_mirror_weapons", "0", CVAR_ARCHIVE); vr_mirror_weapons = Cvar_Get( "vr_mirror_weapons", "0", CVAR_ARCHIVE);
vr_weaponscale = Cvar_Get( "vr_weaponscale", "0.4", CVAR_ARCHIVE);
//The Engine (which is a derivative of Quake) uses a very specific unit size: //The Engine (which is a derivative of Quake) uses a very specific unit size:
//Wolfenstein 3D, DOOM and QUAKE use the same coordinate/unit system: //Wolfenstein 3D, DOOM and QUAKE use the same coordinate/unit system:

View file

@ -13,3 +13,4 @@ cvar_t *vr_height_adjust;
cvar_t *vr_flashlight_model; cvar_t *vr_flashlight_model;
cvar_t *vr_mirror_weapons; cvar_t *vr_mirror_weapons;
cvar_t *vr_worldscale; cvar_t *vr_worldscale;
cvar_t *vr_weaponscale;

View file

@ -106,7 +106,7 @@ void HandleInput_Right(ovrMobile * Ovr, double displayTime )
{ {
vec2_t v; vec2_t v;
rotateAboutOrigin(weaponoffset[0], weaponoffset[2], -(cl.viewangles[YAW] - hmdorientation[YAW]), v); rotateAboutOrigin(-weaponoffset[0], weaponoffset[2], (cl.refdef.viewangles[YAW] - hmdorientation[YAW]), v);
weaponoffset[0] = v[0]; weaponoffset[0] = v[0];
weaponoffset[2] = v[1]; weaponoffset[2] = v[1];
@ -123,7 +123,7 @@ void HandleInput_Right(ovrMobile * Ovr, double displayTime )
{ {
vec2_t v; vec2_t v;
rotateAboutOrigin(weaponvelocity[0], weaponvelocity[2], -cl.viewangles[YAW], v); rotateAboutOrigin(-weaponvelocity[0], weaponvelocity[2], (cl.refdef.viewangles[YAW] - hmdorientation[YAW]), v);
weaponvelocity[0] = v[0]; weaponvelocity[0] = v[0];
weaponvelocity[2] = v[1]; weaponvelocity[2] = v[1];
@ -137,6 +137,8 @@ void HandleInput_Right(ovrMobile * Ovr, double displayTime )
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick //Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
const ovrQuatf quatRemote = rightRemoteTracking_new.HeadPose.Pose.Orientation; const ovrQuatf quatRemote = rightRemoteTracking_new.HeadPose.Pose.Orientation;
QuatToYawPitchRoll(quatRemote, vr_weapon_pitchadjust->value, weaponangles); QuatToYawPitchRoll(quatRemote, vr_weapon_pitchadjust->value, weaponangles);
weaponangles[YAW] += (cl.refdef.viewangles[YAW] - hmdorientation[YAW]);
weaponangles[ROLL] *= -1.0f;
if (vr_weapon_stabilised->value && if (vr_weapon_stabilised->value &&
@ -149,13 +151,9 @@ void HandleInput_Right(ovrMobile * Ovr, double displayTime )
float zxDist = length(x, z); float zxDist = length(x, z);
if (zxDist != 0.0f && z != 0.0f) { if (zxDist != 0.0f && z != 0.0f) {
VectorSet(weaponangles, degrees(atanf(y / zxDist)), (cl.viewangles[YAW] - hmdorientation[YAW]) - degrees(atan2f(x, -z)), weaponangles[ROLL]); VectorSet(weaponangles, -degrees(atanf(y / zxDist)), (cl.refdef.viewangles[YAW] - hmdorientation[YAW]) - degrees(atan2f(x, -z)), weaponangles[ROLL]);
} }
} }
else
{
weaponangles[YAW] += (cl.viewangles[YAW] - hmdorientation[YAW]);
}
//Use (Action) //Use (Action)
if ((rightTrackedRemoteState_new.Buttons & ovrButton_Joystick) != if ((rightTrackedRemoteState_new.Buttons & ovrButton_Joystick) !=
@ -199,16 +197,16 @@ void HandleInput_Right(ovrMobile * Ovr, double displayTime )
flashlightoffset[2] = leftRemoteTracking_new.HeadPose.Pose.Position.z - hmdPosition[2]; flashlightoffset[2] = leftRemoteTracking_new.HeadPose.Pose.Position.z - hmdPosition[2];
vec2_t v; vec2_t v;
rotateAboutOrigin(flashlightoffset[0], flashlightoffset[2], -(cl.viewangles[YAW] - hmdorientation[YAW]), v); rotateAboutOrigin(-flashlightoffset[0], flashlightoffset[2], (cl.refdef.viewangles[YAW] - hmdorientation[YAW]), v);
flashlightoffset[0] = v[0]; flashlightoffset[0] = v[0];
flashlightoffset[2] = v[1]; flashlightoffset[2] = v[1];
QuatToYawPitchRoll(leftRemoteTracking_new.HeadPose.Pose.Orientation, 15.0f, flashlightangles); QuatToYawPitchRoll(leftRemoteTracking_new.HeadPose.Pose.Orientation, 15.0f, flashlightangles);
flashlightangles[YAW] += (cl.viewangles[YAW] - hmdorientation[YAW]); flashlightangles[YAW] += (cl.refdef.viewangles[YAW] - hmdorientation[YAW]);
if (vr_walkdirection->value == 0) { if (vr_walkdirection->value == 0) {
controllerYawHeading = -cl.viewangles[YAW] + flashlightangles[YAW]; controllerYawHeading = -cl.refdef.viewangles[YAW] + flashlightangles[YAW];
} }
else else
{ {
@ -230,9 +228,9 @@ void HandleInput_Right(ovrMobile * Ovr, double displayTime )
vec2_t v; vec2_t v;
rotateAboutOrigin(-positionDeltaThisFrame[0] * multiplier, rotateAboutOrigin(-positionDeltaThisFrame[0] * multiplier,
positionDeltaThisFrame[2] * multiplier, -hmdorientation[YAW], v); positionDeltaThisFrame[2] * multiplier, (cl.refdef.viewangles[YAW] - hmdorientation[YAW]), v);
positional_movementSideways = v[0]; //positional_movementSideways = v[0];
positional_movementForward = v[1]; //positional_movementForward = v[1];
ALOGV(" positional_movementSideways: %f, positional_movementForward: %f", ALOGV(" positional_movementSideways: %f, positional_movementForward: %f",
positional_movementSideways, positional_movementSideways,
@ -324,9 +322,6 @@ void HandleInput_Right(ovrMobile * Ovr, double displayTime )
remote_movementSideways = v[0]; remote_movementSideways = v[0];
remote_movementForward = v[1]; remote_movementForward = v[1];
// remote_movementForward = cosf(radians(flashlightangles[PITCH])) * v[1];
// remote_movementUp = sinf(radians(flashlightangles[PITCH])) * v[1];
ALOGV(" remote_movementSideways: %f, remote_movementForward: %f", ALOGV(" remote_movementSideways: %f, remote_movementForward: %f",
remote_movementSideways, remote_movementSideways,
remote_movementForward); remote_movementForward);

View file

@ -1341,6 +1341,21 @@ void CL_AddPacketEntities (frame_t *frame)
} }
extern cvar_t *vr_worldscale;
extern vec3_t weaponangles;
extern vec3_t weaponoffset;
void convertFromVRtoQ2(vec3_t in, vec3_t offset, vec3_t out);
static void SetWeapon6DOF(vec3_t origin, vec3_t gunorigin, vec3_t gunangles)
{
vec3_t offset;
vec3_t gunoffset;
VectorSet(offset, 0, 0, 0);
convertFromVRtoQ2(weaponoffset, offset, gunoffset);
VectorAdd(origin, gunoffset, gunorigin);
VectorCopy(weaponangles, gunangles);
}
/* /*
============== ==============
@ -1366,16 +1381,7 @@ void CL_AddViewWeapon (player_state_t *ps, player_state_t *ops)
return; return;
// set up gun position // set up gun position
for (i=0 ; i<3 ; i++) SetWeapon6DOF(cl.refdef.vieworg, gun.origin, gun.angles);
{
gun.origin[i] = cl.refdef.vieworg[i] + ps->gunoffset[i];
gun.angles[i] = ps->gunangles[i];
/* gun.origin[i] = cl.refdef.vieworg[i] + ops->gunoffset[i]
+ cl.lerpfrac * (ps->gunoffset[i] - ops->gunoffset[i]);
gun.angles[i] = cl.refdef.viewangles[i] + LerpAngle (ops->gunangles[i],
ps->gunangles[i], cl.lerpfrac);
*/ }
if (gun_frame) if (gun_frame)
{ {

View file

@ -3971,13 +3971,11 @@ const char *M_Quit_Key (int key)
switch (key) switch (key)
{ {
case K_ESCAPE: case K_ESCAPE:
case 'n':
case 'N':
M_PopMenu (); M_PopMenu ();
break; break;
case 'Y': case K_ENTER:
case 'y': case K_SPACE:
cls.key_dest = key_console; cls.key_dest = key_console;
CL_Quit_f (); CL_Quit_f ();
break; break;

View file

@ -1577,12 +1577,13 @@ extern vec3_t weaponoffset;
extern cvar_t *vr_worldscale; extern cvar_t *vr_worldscale;
static void convertFromVRtoQ2(vec3_t in, vec3_t out) void convertFromVRtoQ2(vec3_t in, vec3_t offset, vec3_t out)
{ {
vec3_t vrSpace; vec3_t vrSpace;
VectorSet(vrSpace, -in[2], in[0], in[1]); VectorSet(vrSpace, -in[2], in[0], in[1]);
VectorScale(vrSpace, vr_worldscale->value, out); vec3_t temp;
out[2] += 16; VectorScale(vrSpace, vr_worldscale->value, temp);
VectorAdd(temp, offset, out);
} }
static void SV_SetWeapon_Client6DOF(edict_t *ent) static void SV_SetWeapon_Client6DOF(edict_t *ent)
@ -1592,10 +1593,12 @@ static void SV_SetWeapon_Client6DOF(edict_t *ent)
VectorCopy(ent->client->v_angle, angles_b); VectorCopy(ent->client->v_angle, angles_b);
vec3_t origin; vec3_t origin;
vec3_t weaponoffsetQ2;
vec3_t offset; vec3_t offset;
convertFromVRtoQ2(weaponoffset, offset); VectorSet(offset, 0, 0, 8);
convertFromVRtoQ2(weaponoffset, offset, weaponoffsetQ2);
VectorCopy(ent->s.origin, origin); VectorCopy(ent->s.origin, origin);
VectorAdd(offset, origin, ent->s.origin); VectorAdd(weaponoffsetQ2, origin, ent->s.origin);
VectorCopy(weaponangles, ent->client->v_angle); // use adjusted angles VectorCopy(weaponangles, ent->client->v_angle); // use adjusted angles
} }

View file

@ -338,26 +338,6 @@ void SV_CalcViewOffset (edict_t *ent)
} }
extern cvar_t *vr_worldscale;
extern vec3_t weaponangles;
extern vec3_t weaponoffset;
static void convertFromVRtoQ2(vec3_t in, vec3_t out)
{
vec3_t vrSpace;
VectorSet(vrSpace, -in[2], in[0], in[1]);
VectorScale(vrSpace, vr_worldscale->value, out);
out[2] += 16;
}
static void SetWeapon_Client6DOF(edict_t *ent)
{
vec3_t origin;
vec3_t offset;
convertFromVRtoQ2(weaponoffset, ent->client->ps.gunoffset);
VectorCopy(weaponangles, ent->client->ps.gunangles);
}
/* /*
============== ==============
SV_CalcGunOffset SV_CalcGunOffset
@ -408,8 +388,6 @@ void SV_CalcGunOffset (edict_t *ent)
ent->client->ps.gunoffset[i] += up[i]* (-gun_z->value); ent->client->ps.gunoffset[i] += up[i]* (-gun_z->value);
} }
*/ */
SetWeapon_Client6DOF(ent);
} }

View file

@ -490,7 +490,7 @@ void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
ent->client->ps.gunframe = FRAME_IDLE_FIRST; ent->client->ps.gunframe = FRAME_IDLE_FIRST;
return; return;
} }
/*
if (pause_frames) if (pause_frames)
{ {
for (n = 0; pause_frames[n]; n++) for (n = 0; pause_frames[n]; n++)
@ -502,7 +502,7 @@ void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
} }
} }
} }
*/
ent->client->ps.gunframe++; ent->client->ps.gunframe++;
return; return;
} }

View file

@ -29,6 +29,7 @@ vec3_t vec3_origin = {0,0,0};
#pragma optimize( "", off ) #pragma optimize( "", off )
#endif #endif
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ) void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees )
{ {
float m[3][3]; float m[3][3];

View file

@ -521,6 +521,8 @@ R_DrawAliasModel
================= =================
*/ */
extern cvar_t *vr_weaponscale;
void MYgluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar );
void R_DrawAliasModel (entity_t *e) void R_DrawAliasModel (entity_t *e)
{ {
int i; int i;
@ -740,7 +742,7 @@ void R_DrawAliasModel (entity_t *e)
if (currententity->flags & RF_DEPTHHACK) // hack the depth range to prevent view model from poking into walls if (currententity->flags & RF_DEPTHHACK) // hack the depth range to prevent view model from poking into walls
qglDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); qglDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) ) /* if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
{ {
extern void MYgluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar ); extern void MYgluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar );
@ -752,8 +754,30 @@ void R_DrawAliasModel (entity_t *e)
qglMatrixMode( GL_MODELVIEW ); qglMatrixMode( GL_MODELVIEW );
qglCullFace( GL_BACK ); qglCullFace( GL_BACK );
}*/
if ( currententity->flags & RF_WEAPONMODEL )
{
qglMatrixMode( GL_PROJECTION );
qglPushMatrix();
qglLoadIdentity();
MYgluPerspective( r_newrefdef.fov_y, ( float ) r_newrefdef.width / r_newrefdef.height, 0.1, 8192);
if ( r_lefthand->value == 1.0F ) {
qglScalef(-vr_weaponscale->value, vr_weaponscale->value, vr_weaponscale->value);
} else {
qglScalef(vr_weaponscale->value, vr_weaponscale->value, vr_weaponscale->value);
} }
qglMatrixMode( GL_MODELVIEW );
if ( r_lefthand->value == 1.0F ) {
qglCullFace( GL_BACK );
}
}
qglPushMatrix (); qglPushMatrix ();
e->angles[PITCH] = -e->angles[PITCH]; // sigh. e->angles[PITCH] = -e->angles[PITCH]; // sigh.
R_RotateForEntity (e); R_RotateForEntity (e);
@ -830,13 +854,17 @@ void R_DrawAliasModel (entity_t *e)
qglEnable( GL_CULL_FACE ); qglEnable( GL_CULL_FACE );
#endif #endif
if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) ) if ( ( currententity->flags & RF_WEAPONMODEL ) )
{ {
qglMatrixMode( GL_PROJECTION ); qglMatrixMode( GL_PROJECTION );
qglPopMatrix(); qglPopMatrix();
qglMatrixMode( GL_MODELVIEW ); qglMatrixMode( GL_MODELVIEW );
if ( r_lefthand->value == 1.0F ) {
qglCullFace(GL_FRONT); qglCullFace(GL_FRONT);
} }
}
if ( currententity->flags & RF_TRANSLUCENT ) if ( currententity->flags & RF_TRANSLUCENT )
{ {

View file

@ -781,7 +781,7 @@ void R_SetupGL (void)
// yfov = 2*atan((float)r_newrefdef.height/r_newrefdef.width)*180/M_PI; // yfov = 2*atan((float)r_newrefdef.height/r_newrefdef.width)*180/M_PI;
qglMatrixMode(GL_PROJECTION); qglMatrixMode(GL_PROJECTION);
qglLoadIdentity (); qglLoadIdentity ();
MYgluPerspective (r_newrefdef.fov_y, screenaspect, 4, 8192); MYgluPerspective (r_newrefdef.fov_y, screenaspect, 0.1, 8192);
qglCullFace(GL_FRONT); qglCullFace(GL_FRONT);

View file

@ -1 +0,0 @@
map demo1

View file

@ -1 +1 @@
quake2 --supersampling 1.35 quake2 --supersampling 1.5

View file

@ -1,7 +1,6 @@
// good config for Quake 2 on Android // good config for Quake 2 on Android
set cl_drawfps "1" set cl_drawfps "1"
//set cl_maxfps "25"
set gl_ext_multitexture "1" set gl_ext_multitexture "1"
//set developer "1" //set developer "1"
/////////////////////// key bindings /////////////////////// key bindings