mirror of
https://github.com/DrBeef/Quake2Quest.git
synced 2025-03-01 06:30:52 +00:00
Proper 6DoF weapons
This commit is contained in:
parent
9747d8b02d
commit
a04f1ffed3
9 changed files with 94 additions and 49 deletions
|
@ -833,7 +833,7 @@ void setHMDPosition( float x, float y, float z, float yaw )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMultiplayer()
|
qboolean isMultiplayer()
|
||||||
{
|
{
|
||||||
return Cvar_VariableValue("maxclients") > 1;
|
return Cvar_VariableValue("maxclients") > 1;
|
||||||
}
|
}
|
||||||
|
@ -1336,6 +1336,8 @@ void VR_Init()
|
||||||
vr_worldscale = Cvar_Get( "vr_worldscale", "26.2467", CVAR_ARCHIVE);
|
vr_worldscale = Cvar_Get( "vr_worldscale", "26.2467", CVAR_ARCHIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void M_Menu_Main_f (void);
|
||||||
|
|
||||||
void * AppThreadFunction( void * parm )
|
void * AppThreadFunction( void * parm )
|
||||||
{
|
{
|
||||||
ovrAppThread * appThread = (ovrAppThread *)parm;
|
ovrAppThread * appThread = (ovrAppThread *)parm;
|
||||||
|
@ -1418,6 +1420,7 @@ void * AppThreadFunction( void * parm )
|
||||||
Qcommon_Init(argc, (const char**)argv);
|
Qcommon_Init(argc, (const char**)argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//M_Menu_Main_f ();
|
||||||
quake2_initialised = true;
|
quake2_initialised = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1544,9 +1547,6 @@ void * AppThreadFunction( void * parm )
|
||||||
case LEFT_HANDED_DEFAULT:
|
case LEFT_HANDED_DEFAULT:
|
||||||
HandleInput_Left(appState.Ovr, appState.DisplayTime);
|
HandleInput_Left(appState.Ovr, appState.DisplayTime);
|
||||||
break;
|
break;
|
||||||
case GAMEPAD:
|
|
||||||
//HandleInput_Gamepad(appState.Ovr, appState.DisplayTime); // Someone else can implement this
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool usingScreenLayer = true; //Starts off using the screen layer
|
static bool usingScreenLayer = true; //Starts off using the screen layer
|
||||||
|
|
|
@ -55,7 +55,7 @@ int ducked;
|
||||||
|
|
||||||
float radians(float deg);
|
float radians(float deg);
|
||||||
float degrees(float rad);
|
float degrees(float rad);
|
||||||
bool isMultiplayer();
|
qboolean isMultiplayer();
|
||||||
double GetTimeInMilliSeconds();
|
double GetTimeInMilliSeconds();
|
||||||
float length(float x, float y);
|
float length(float x, float y);
|
||||||
float nonLinearFilter(float in);
|
float nonLinearFilter(float in);
|
||||||
|
|
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
// cl_ents.c -- entity parsing and management
|
// cl_ents.c -- entity parsing and management
|
||||||
|
|
||||||
|
#include <src/game/q_shared.h>
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "../../../Quake2VR/mathlib.h"
|
#include "../../../Quake2VR/mathlib.h"
|
||||||
|
|
||||||
|
@ -506,7 +507,7 @@ void CL_ParsePacketEntities (frame_t *oldframe, frame_t *newframe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qboolean isMultiplayer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
|
@ -538,16 +539,16 @@ void CL_ParsePlayerstate (frame_t *oldframe, frame_t *newframe)
|
||||||
|
|
||||||
if (flags & PS_M_ORIGIN)
|
if (flags & PS_M_ORIGIN)
|
||||||
{
|
{
|
||||||
state->pmove.origin[0] = MSG_ReadShort (&net_message);
|
state->pmove.origin[0] = MSG_ReadFloat (&net_message);
|
||||||
state->pmove.origin[1] = MSG_ReadShort (&net_message);
|
state->pmove.origin[1] = MSG_ReadFloat (&net_message);
|
||||||
state->pmove.origin[2] = MSG_ReadShort (&net_message);
|
state->pmove.origin[2] = MSG_ReadFloat (&net_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & PS_M_VELOCITY)
|
if (flags & PS_M_VELOCITY)
|
||||||
{
|
{
|
||||||
state->pmove.velocity[0] = MSG_ReadShort (&net_message);
|
state->pmove.velocity[0] = MSG_ReadFloat (&net_message);
|
||||||
state->pmove.velocity[1] = MSG_ReadShort (&net_message);
|
state->pmove.velocity[1] = MSG_ReadFloat (&net_message);
|
||||||
state->pmove.velocity[2] = MSG_ReadShort (&net_message);
|
state->pmove.velocity[2] = MSG_ReadFloat (&net_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & PS_M_TIME)
|
if (flags & PS_M_TIME)
|
||||||
|
@ -557,13 +558,13 @@ void CL_ParsePlayerstate (frame_t *oldframe, frame_t *newframe)
|
||||||
state->pmove.pm_flags = MSG_ReadByte (&net_message);
|
state->pmove.pm_flags = MSG_ReadByte (&net_message);
|
||||||
|
|
||||||
if (flags & PS_M_GRAVITY)
|
if (flags & PS_M_GRAVITY)
|
||||||
state->pmove.gravity = MSG_ReadShort (&net_message);
|
state->pmove.gravity = MSG_ReadFloat (&net_message);
|
||||||
|
|
||||||
if (flags & PS_M_DELTA_ANGLES)
|
if (flags & PS_M_DELTA_ANGLES)
|
||||||
{
|
{
|
||||||
state->pmove.delta_angles[0] = MSG_ReadShort (&net_message);
|
state->pmove.delta_angles[0] = MSG_ReadFloat (&net_message);
|
||||||
state->pmove.delta_angles[1] = MSG_ReadShort (&net_message);
|
state->pmove.delta_angles[1] = MSG_ReadFloat (&net_message);
|
||||||
state->pmove.delta_angles[2] = MSG_ReadShort (&net_message);
|
state->pmove.delta_angles[2] = MSG_ReadFloat (&net_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cl.attractloop)
|
if (cl.attractloop)
|
||||||
|
@ -596,6 +597,11 @@ void CL_ParsePlayerstate (frame_t *oldframe, frame_t *newframe)
|
||||||
if (flags & PS_WEAPONINDEX)
|
if (flags & PS_WEAPONINDEX)
|
||||||
{
|
{
|
||||||
state->gunindex = MSG_ReadByte (&net_message);
|
state->gunindex = MSG_ReadByte (&net_message);
|
||||||
|
|
||||||
|
if (!isMultiplayer()) {
|
||||||
|
//Only read this if not multiplayer
|
||||||
|
state->weapmodel = MSG_ReadByte(&net_message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & PS_WEAPONFRAME)
|
if (flags & PS_WEAPONFRAME)
|
||||||
|
@ -1349,31 +1355,55 @@ extern vec3_t hmdorientation;
|
||||||
|
|
||||||
void convertFromVRtoQ2(vec3_t in, vec3_t offset, vec3_t out);
|
void convertFromVRtoQ2(vec3_t in, vec3_t offset, vec3_t out);
|
||||||
|
|
||||||
void ProjectSource (vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result)
|
// gitem_t->weapmodel for weapons indicates model index
|
||||||
{
|
#define WEAP_BLASTER 1
|
||||||
result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1];
|
#define WEAP_SHOTGUN 2
|
||||||
result[1] = point[1] + forward[1] * distance[0] + right[1] * distance[1];
|
#define WEAP_SUPERSHOTGUN 3
|
||||||
result[2] = point[2] + forward[2] * distance[0] + right[2] * distance[1] + distance[2];
|
#define WEAP_MACHINEGUN 4
|
||||||
}
|
#define WEAP_CHAINGUN 5
|
||||||
|
#define WEAP_GRENADES 6
|
||||||
|
#define WEAP_GRENADELAUNCHER 7
|
||||||
|
#define WEAP_ROCKETLAUNCHER 8
|
||||||
|
#define WEAP_HYPERBLASTER 9
|
||||||
|
#define WEAP_RAILGUN 10
|
||||||
|
#define WEAP_BFG 11
|
||||||
|
|
||||||
static void SetWeapon6DOF(vec3_t origin, vec3_t gunorigin, vec3_t gunangles)
|
static void SetWeapon6DOF(int weapmodel, vec3_t origin, vec3_t gunorigin, vec3_t gunangles)
|
||||||
{
|
{
|
||||||
vec3_t gunoffset;
|
vec3_t gunoffset;
|
||||||
|
convertFromVRtoQ2(weaponoffset, NULL, gunoffset);
|
||||||
|
|
||||||
vec3_t n0_offset;
|
//fb / lr / ud
|
||||||
VectorSet(n0_offset, 0, 0, 0);
|
|
||||||
convertFromVRtoQ2(weaponoffset, n0_offset, gunoffset);
|
|
||||||
|
|
||||||
vec3_t offset;
|
vec3_t offset;
|
||||||
VectorSet(offset, -10, -4, -6);
|
VectorSet(offset, 10, 4, -5);
|
||||||
vec3_t forward;
|
vec3_t forward;
|
||||||
vec3_t right;
|
vec3_t right;
|
||||||
AngleVectors (weaponangles, forward, right, NULL);
|
vec3_t up;
|
||||||
vec3_t new_gun_offset;
|
|
||||||
ProjectSource (gunoffset, offset, forward, right, new_gun_offset);
|
|
||||||
|
|
||||||
VectorAdd(origin, new_gun_offset, gunorigin);
|
vec3_t tempAngles;
|
||||||
|
VectorCopy(weaponangles, tempAngles);
|
||||||
|
tempAngles[PITCH] -= 180.0;
|
||||||
|
|
||||||
|
vec3_t position_adjust;
|
||||||
|
vec3_t nullVec;
|
||||||
|
VectorSet(nullVec, 0, 0, 0);
|
||||||
|
|
||||||
|
matrix4x4 mat1;
|
||||||
|
Matrix4x4_CreateFromEntity(mat1, nullVec, offset, 1.0);
|
||||||
|
|
||||||
|
matrix4x4 mat2;
|
||||||
|
Matrix4x4_CreateFromEntity(mat2, tempAngles, nullVec, 1.0);
|
||||||
|
|
||||||
|
matrix4x4 mat3;
|
||||||
|
Matrix4x4_Concat(mat3, mat2, mat1);
|
||||||
|
|
||||||
|
Matrix3x4_OriginFromMatrix(mat3, position_adjust);
|
||||||
|
|
||||||
|
VectorAdd(origin, gunoffset, gunorigin);
|
||||||
|
VectorAdd(gunorigin, position_adjust, gunorigin);
|
||||||
|
gunorigin[2] -= 12;
|
||||||
VectorCopy(weaponangles, gunangles);
|
VectorCopy(weaponangles, gunangles);
|
||||||
|
gunangles[PITCH] -= 5; // HACK!! (gun angle not quite right)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1400,7 +1430,7 @@ void CL_AddViewWeapon (player_state_t *ps, player_state_t *ops)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// set up gun position
|
// set up gun position
|
||||||
SetWeapon6DOF(cl.refdef.vieworg, gun.origin, gun.angles);
|
SetWeapon6DOF(ps->weapmodel, cl.refdef.vieworg, gun.origin, gun.angles);
|
||||||
|
|
||||||
if (gun_frame)
|
if (gun_frame)
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,7 +109,7 @@ void CL_DrawInventory (void)
|
||||||
|
|
||||||
re.DrawPic (x, y+8, "inventory");
|
re.DrawPic (x, y+8, "inventory");
|
||||||
|
|
||||||
y += 24;
|
/* y += 24;
|
||||||
x += 24;
|
x += 24;
|
||||||
Inv_DrawString (x, y, "hotkey ### item");
|
Inv_DrawString (x, y, "hotkey ### item");
|
||||||
Inv_DrawString (x, y+8, "------ --- ----");
|
Inv_DrawString (x, y+8, "------ --- ----");
|
||||||
|
@ -143,7 +143,7 @@ void CL_DrawInventory (void)
|
||||||
Inv_DrawString (x, y, string);
|
Inv_DrawString (x, y, string);
|
||||||
y += 8;
|
y += 8;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
||||||
int size;
|
int size;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (s->name[0] == '*')
|
if (s == NULL || s->name[0] == '*')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// see if still in memory
|
// see if still in memory
|
||||||
|
|
|
@ -1583,7 +1583,12 @@ void convertFromVRtoQ2(vec3_t in, vec3_t offset, vec3_t out)
|
||||||
VectorSet(vrSpace, -in[2], in[0], in[1]);
|
VectorSet(vrSpace, -in[2], in[0], in[1]);
|
||||||
vec3_t temp;
|
vec3_t temp;
|
||||||
VectorScale(vrSpace, vr_worldscale->value, temp);
|
VectorScale(vrSpace, vr_worldscale->value, temp);
|
||||||
|
|
||||||
|
if (offset) {
|
||||||
VectorAdd(temp, offset, out);
|
VectorAdd(temp, offset, out);
|
||||||
|
} else {
|
||||||
|
VectorCopy(temp, out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SV_SetWeapon_Client6DOF(edict_t *ent)
|
static void SV_SetWeapon_Client6DOF(edict_t *ent)
|
||||||
|
|
|
@ -211,6 +211,8 @@ void ChangeWeapon (edict_t *ent)
|
||||||
ent->client->weaponstate = WEAPON_ACTIVATING;
|
ent->client->weaponstate = WEAPON_ACTIVATING;
|
||||||
ent->client->ps.gunframe = 0;
|
ent->client->ps.gunframe = 0;
|
||||||
ent->client->ps.gunindex = gi.modelindex(ent->client->pers.weapon->view_model);
|
ent->client->ps.gunindex = gi.modelindex(ent->client->pers.weapon->view_model);
|
||||||
|
ent->client->ps.weapmodel = ent->client->pers.weapon->weapmodel;
|
||||||
|
|
||||||
|
|
||||||
ent->client->anim_priority = ANIM_PAIN;
|
ent->client->anim_priority = ANIM_PAIN;
|
||||||
if(ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
if(ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
||||||
|
@ -829,7 +831,7 @@ void Blaster_Fire (edict_t *ent, vec3_t g_offset, int damage, qboolean hyper, in
|
||||||
VectorScale (forward, -2, ent->client->kick_origin);
|
VectorScale (forward, -2, ent->client->kick_origin);
|
||||||
ent->client->kick_angles[0] = -1;
|
ent->client->kick_angles[0] = -1;
|
||||||
|
|
||||||
fire_blaster (ent, start, forward, damage, 1000, effect, hyper);
|
fire_blaster (ent, start, forward, damage, 2000, effect, hyper);
|
||||||
|
|
||||||
// send muzzle flash
|
// send muzzle flash
|
||||||
gi.WriteByte (svc_muzzleflash);
|
gi.WriteByte (svc_muzzleflash);
|
||||||
|
|
|
@ -1207,6 +1207,7 @@ typedef struct
|
||||||
vec3_t gunoffset;
|
vec3_t gunoffset;
|
||||||
int gunindex;
|
int gunindex;
|
||||||
int gunframe;
|
int gunframe;
|
||||||
|
int weapmodel;
|
||||||
|
|
||||||
float blend[4]; // rgba full screen effect
|
float blend[4]; // rgba full screen effect
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <src/game/q_shared.h>
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -212,6 +213,7 @@ void SV_EmitPacketEntities (client_frame_t *from, client_frame_t *to, sizebuf_t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
qboolean isMultiplayer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
|
@ -315,16 +317,16 @@ void SV_WritePlayerstateToClient (client_frame_t *from, client_frame_t *to, size
|
||||||
|
|
||||||
if (pflags & PS_M_ORIGIN)
|
if (pflags & PS_M_ORIGIN)
|
||||||
{
|
{
|
||||||
MSG_WriteShort (msg, ps->pmove.origin[0]);
|
MSG_WriteFloat (msg, ps->pmove.origin[0]);
|
||||||
MSG_WriteShort (msg, ps->pmove.origin[1]);
|
MSG_WriteFloat (msg, ps->pmove.origin[1]);
|
||||||
MSG_WriteShort (msg, ps->pmove.origin[2]);
|
MSG_WriteFloat (msg, ps->pmove.origin[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pflags & PS_M_VELOCITY)
|
if (pflags & PS_M_VELOCITY)
|
||||||
{
|
{
|
||||||
MSG_WriteShort (msg, ps->pmove.velocity[0]);
|
MSG_WriteFloat (msg, ps->pmove.velocity[0]);
|
||||||
MSG_WriteShort (msg, ps->pmove.velocity[1]);
|
MSG_WriteFloat (msg, ps->pmove.velocity[1]);
|
||||||
MSG_WriteShort (msg, ps->pmove.velocity[2]);
|
MSG_WriteFloat (msg, ps->pmove.velocity[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pflags & PS_M_TIME)
|
if (pflags & PS_M_TIME)
|
||||||
|
@ -334,13 +336,13 @@ void SV_WritePlayerstateToClient (client_frame_t *from, client_frame_t *to, size
|
||||||
MSG_WriteByte (msg, ps->pmove.pm_flags);
|
MSG_WriteByte (msg, ps->pmove.pm_flags);
|
||||||
|
|
||||||
if (pflags & PS_M_GRAVITY)
|
if (pflags & PS_M_GRAVITY)
|
||||||
MSG_WriteShort (msg, ps->pmove.gravity);
|
MSG_WriteFloat (msg, ps->pmove.gravity);
|
||||||
|
|
||||||
if (pflags & PS_M_DELTA_ANGLES)
|
if (pflags & PS_M_DELTA_ANGLES)
|
||||||
{
|
{
|
||||||
MSG_WriteShort (msg, ps->pmove.delta_angles[0]);
|
MSG_WriteFloat (msg, ps->pmove.delta_angles[0]);
|
||||||
MSG_WriteShort (msg, ps->pmove.delta_angles[1]);
|
MSG_WriteFloat (msg, ps->pmove.delta_angles[1]);
|
||||||
MSG_WriteShort (msg, ps->pmove.delta_angles[2]);
|
MSG_WriteFloat (msg, ps->pmove.delta_angles[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -370,6 +372,11 @@ void SV_WritePlayerstateToClient (client_frame_t *from, client_frame_t *to, size
|
||||||
if (pflags & PS_WEAPONINDEX)
|
if (pflags & PS_WEAPONINDEX)
|
||||||
{
|
{
|
||||||
MSG_WriteByte (msg, ps->gunindex);
|
MSG_WriteByte (msg, ps->gunindex);
|
||||||
|
|
||||||
|
if (!isMultiplayer()) {
|
||||||
|
//Add if for multiplayer
|
||||||
|
MSG_WriteByte(msg, ps->weapmodel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pflags & PS_WEAPONFRAME)
|
if (pflags & PS_WEAPONFRAME)
|
||||||
|
|
Loading…
Reference in a new issue