mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-22 12:11:21 +00:00
Added 6DoF weapons to all the other game modes
This commit is contained in:
parent
35c101b671
commit
9eb86eaa40
11 changed files with 302 additions and 29 deletions
|
@ -52,7 +52,7 @@ float RazeXR_GetFOV();
|
|||
void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up,
|
||||
float *yaw, float *pitch, float *roll);
|
||||
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
||||
|
||||
// Set up 3D-specific console variables:
|
||||
CVAR(Int, vr_mode, 15, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||
|
@ -67,6 +67,9 @@ CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS
|
|||
// distance between viewer and the display screen
|
||||
CVAR(Float, vr_screendist, 0.80f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
|
||||
|
||||
//If the following is 0 then it uses the default for the game, this gives player the opportunity to override it themselves
|
||||
CVAR(Float, vr_units_per_meter, 0.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
|
||||
|
||||
CVAR(Float, vr_height_adjust, 0.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
|
||||
CVAR(Int, vr_control_scheme, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
CVAR(Bool, vr_move_use_offhand, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
@ -97,14 +100,55 @@ CVAR(Bool, vr_hud_fixed_roll, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
int playerHeight = 0;
|
||||
|
||||
extern int g_gameType;
|
||||
#define GAMEFLAG_DUKE 0x00000001
|
||||
|
||||
enum
|
||||
{
|
||||
GAMEFLAG_DUKE = 0x00000001,
|
||||
GAMEFLAG_NAM = 0x00000002,
|
||||
GAMEFLAG_NAPALM = 0x00000004,
|
||||
GAMEFLAG_WW2GI = 0x00000008,
|
||||
GAMEFLAG_ADDON = 0x00000010,
|
||||
GAMEFLAG_SHAREWARE = 0x00000020,
|
||||
GAMEFLAG_DUKEBETA = 0x00000060, // includes 0x20 since it's a shareware beta
|
||||
GAMEFLAG_PLUTOPAK = 0x00000080,
|
||||
GAMEFLAG_RR = 0x00000100,
|
||||
GAMEFLAG_RRRA = 0x00000200,
|
||||
GAMEFLAG_RRALL = GAMEFLAG_RR | GAMEFLAG_RRRA,
|
||||
GAMEFLAG_BLOOD = 0x00000800,
|
||||
GAMEFLAG_SW = 0x00001000,
|
||||
GAMEFLAG_POWERSLAVE = 0x00002000,
|
||||
GAMEFLAG_EXHUMED = 0x00004000,
|
||||
GAMEFLAG_PSEXHUMED = GAMEFLAG_POWERSLAVE | GAMEFLAG_EXHUMED, // the two games really are the same, except for the name and the publisher.
|
||||
GAMEFLAG_WORLDTOUR = 0x00008000,
|
||||
GAMEFLAG_DUKEDC = 0x00010000,
|
||||
GAMEFLAG_DUKENW = 0x00020000,
|
||||
GAMEFLAG_DUKEVACA = 0x00040000,
|
||||
GAMEFLAG_BLOODCP = 0x00080000,
|
||||
GAMEFLAG_ROUTE66 = 0x00100000,
|
||||
GAMEFLAG_SWWANTON = 0x00200000,
|
||||
GAMEFLAG_SWTWINDRAG = 0x00400000,
|
||||
|
||||
GAMEFLAG_DUKECOMPAT = GAMEFLAG_DUKE | GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI | GAMEFLAG_RRALL,
|
||||
GAMEFLAGMASK = 0x0000FFFF, // flags allowed from grpinfo
|
||||
|
||||
// We still need these for the parsers.
|
||||
GAMEFLAG_FURY = 0,
|
||||
GAMEFLAG_DEER = 0,
|
||||
|
||||
};
|
||||
|
||||
inline bool isDuke()
|
||||
{
|
||||
return g_gameType & (GAMEFLAG_DUKE);
|
||||
return g_gameType & (GAMEFLAG_DUKECOMPAT | GAMEFLAG_DUKEBETA | GAMEFLAG_WORLDTOUR | GAMEFLAG_DUKEDC | GAMEFLAG_DUKENW | GAMEFLAG_DUKEVACA);
|
||||
}
|
||||
|
||||
float vr_hunits_per_meter()
|
||||
{
|
||||
if (vr_units_per_meter != 0.0)
|
||||
{
|
||||
return vr_units_per_meter;
|
||||
}
|
||||
|
||||
if (isDuke())
|
||||
{
|
||||
return 24.0f;
|
||||
|
@ -279,14 +323,14 @@ VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const
|
|||
vr_hunits_per_meter(),
|
||||
-vr_hunits_per_meter());
|
||||
|
||||
if (isDuke() && vr_6dof_weapons)
|
||||
if (vr_6dof_weapons)
|
||||
{
|
||||
new_projection.rotate(-hmdorientation[PITCH], 1, 0, 0);
|
||||
new_projection.rotate(-hmdorientation[ROLL], 0, 0, 1);
|
||||
|
||||
float x, y, z, pitch, yaw;
|
||||
get_weapon_pos_and_angle(x, y, z, pitch, yaw);
|
||||
new_projection.translate(-x * weapon_stereo_effect, (z - hmdPosition[1]) * weapon_stereo_effect, -y * weapon_stereo_effect);
|
||||
float x, y, z1, z2, pitch, yaw;
|
||||
get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw);
|
||||
new_projection.translate(-x * weapon_stereo_effect, z2 * weapon_stereo_effect, -y * weapon_stereo_effect);
|
||||
|
||||
new_projection.rotate(weaponangles[YAW] - hmdorientation[YAW], 0, 1, 0);
|
||||
new_projection.rotate(weaponangles[PITCH], 1, 0, 0);
|
||||
|
|
|
@ -97,6 +97,7 @@ enum {
|
|||
kStatFlare = 14,
|
||||
kStatDebris = 15,
|
||||
kStatPathMarker = 16,
|
||||
kStatCrosshair = 17,
|
||||
kStatFree = 1024,
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "gamestate.h"
|
||||
#include "automap.h"
|
||||
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
||||
float vr_hunits_per_meter();
|
||||
|
||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||
EXTERN_CVAR(Bool, vr_6dof_crosshair);
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
PLAYER gPlayer[kMaxPlayers];
|
||||
|
@ -1535,7 +1541,73 @@ void ProcessInput(PLAYER* pPlayer)
|
|||
pPlayer->restTime = 0;
|
||||
else if (pPlayer->restTime >= 0)
|
||||
pPlayer->restTime += 4;
|
||||
|
||||
|
||||
float px, py, pz1, pz2, pitch, yaw;
|
||||
|
||||
DVector2 posXY;
|
||||
if (vr_6dof_weapons)
|
||||
{
|
||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
||||
|
||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
||||
actor->spr.pos.X -= posXY.X;
|
||||
actor->spr.pos.Y -= posXY.Y;
|
||||
actor->spr.pos.Z -= (pz2 * vr_hunits_per_meter()) - actor->viewzoffset;
|
||||
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||
|
||||
if (vr_6dof_crosshair)
|
||||
{
|
||||
HitInfo hit{};
|
||||
|
||||
double vel = 1024, zvel = 0;
|
||||
setFreeAimVelocity(vel, zvel, actor->spr.Angles.Pitch, 16.);
|
||||
|
||||
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||
hitscan(actor->spr.pos, actor->sector(),
|
||||
DVector3(actor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||
actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
||||
|
||||
if (hit.hitSector != nullptr)
|
||||
{
|
||||
double length = (hit.hitpos.XY() - actor->spr.pos.XY()).Length();
|
||||
|
||||
//Update the existing aiming sprites if there is one
|
||||
BloodStatIterator it(kStatCrosshair);
|
||||
DBloodActor *crosshair = it.Next();
|
||||
if (crosshair)
|
||||
{
|
||||
//update position
|
||||
SetActorZ(crosshair, hit.hitpos);
|
||||
}
|
||||
else
|
||||
{
|
||||
crosshair = actSpawnSprite(hit.hitSector, hit.hitpos, kStatCrosshair, 1);
|
||||
}
|
||||
|
||||
//Check we got the crosshair
|
||||
if (crosshair)
|
||||
{
|
||||
crosshair->spr.picnum = kCrosshairTile;
|
||||
crosshair->spr.scale = DVector2(0.4 + length / 512.0, 0.4 + length / 512.0);
|
||||
crosshair->spr.shade = -40;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WeaponProcess(pPlayer);
|
||||
|
||||
if (vr_6dof_weapons)
|
||||
{
|
||||
actor->spr.pos.X += posXY.X;
|
||||
actor->spr.pos.Y += posXY.Y;
|
||||
actor->spr.pos.Z += (pz2 * vr_hunits_per_meter()) - actor->viewzoffset;
|
||||
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||
}
|
||||
|
||||
if (actor->xspr.health == 0)
|
||||
{
|
||||
bool bSeqStat = playerSeqPlaying(pPlayer, 16);
|
||||
|
|
|
@ -39,7 +39,7 @@ source as it is released.
|
|||
#include "names_d.h"
|
||||
#include "dukeactor.h"
|
||||
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
||||
float vr_hunits_per_meter();
|
||||
|
||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||
|
@ -949,17 +949,17 @@ void shoot_d_override(DDukeActor* actor, int atwith, PClass *cls)
|
|||
int l, j;
|
||||
int sx, sy, sz, sa, p, vel, zvel, x, dal;
|
||||
|
||||
float px, py, pz, pitch, yaw;
|
||||
float px, py, pz1, pz2, pitch, yaw;
|
||||
|
||||
DVector2 posXY;
|
||||
if (actor->isPlayer() && vr_6dof_weapons)
|
||||
{
|
||||
get_weapon_pos_and_angle(px, py, pz, pitch, yaw);
|
||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
||||
|
||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
||||
actor->spr.pos.X -= posXY.X;
|
||||
actor->spr.pos.Y -= posXY.Y;
|
||||
actor->spr.pos.Z -= (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.pos.Z -= (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ void shoot_d_override(DDukeActor* actor, int atwith, PClass *cls)
|
|||
{
|
||||
actor->spr.pos.X += posXY.X;
|
||||
actor->spr.pos.Y += posXY.Y;
|
||||
actor->spr.pos.Z += (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.pos.Z += (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||
}
|
||||
|
@ -2559,12 +2559,12 @@ static void processweapon(int snum, ESyncBits actions)
|
|||
{
|
||||
if (pact->isPlayer() && vr_6dof_weapons && vr_6dof_crosshair)
|
||||
{
|
||||
float x, y, z, pitch, yaw;
|
||||
get_weapon_pos_and_angle(x, y, z, pitch, yaw);
|
||||
float x, y, z1, z2, pitch, yaw;
|
||||
get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw);
|
||||
|
||||
DAngle sang = pact->spr.Angles.Yaw + DAngle::fromDeg(yaw);
|
||||
|
||||
DVector3 spos = pact->spr.pos.plusZ(-(z * vr_hunits_per_meter()));
|
||||
DVector3 spos = pact->spr.pos.plusZ(-(z1 * vr_hunits_per_meter()));
|
||||
DVector2 posXY(x * vr_hunits_per_meter(), y * vr_hunits_per_meter());
|
||||
posXY = posXY.Rotated(-DAngle90 + pact->spr.Angles.Yaw);
|
||||
spos.X -= posXY.X;
|
||||
|
@ -2586,12 +2586,12 @@ static void processweapon(int snum, ESyncBits actions)
|
|||
|
||||
//Update the existing aiming sprites if there is one
|
||||
DukeStatIterator it(STAT_AIM_SPRITE);
|
||||
DDukeActor* spark = it.Next();
|
||||
if (spark)
|
||||
DDukeActor* crosshair = it.Next();
|
||||
if (crosshair)
|
||||
{
|
||||
//update position
|
||||
SetActorZ(spark, hit.hitpos);
|
||||
spark->spr.scale = DVector2(0.1 + length/512.0, 0.1 + length/512.0);
|
||||
SetActorZ(crosshair, hit.hitpos);
|
||||
crosshair->spr.scale = DVector2(0.1 + length / 512.0, 0.1 + length / 512.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|||
#include "dukeactor.h"
|
||||
#include "names_d.h"
|
||||
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
||||
float vr_hunits_per_meter();
|
||||
|
||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||
|
@ -773,17 +773,17 @@ void shoot_r_override(DDukeActor* actor, int atwith, PClass *cls)
|
|||
int l, j;
|
||||
int sx, sy, sz, sa, p, vel, zvel, x, dal;
|
||||
|
||||
float px, py, pz, pitch, yaw;
|
||||
float px, py, pz1, pz2, pitch, yaw;
|
||||
|
||||
DVector2 posXY;
|
||||
if (actor->isPlayer() && vr_6dof_weapons)
|
||||
{
|
||||
get_weapon_pos_and_angle(px, py, pz, pitch, yaw);
|
||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
||||
|
||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
||||
actor->spr.pos.X -= posXY.X;
|
||||
actor->spr.pos.Y -= posXY.Y;
|
||||
actor->spr.pos.Z -= (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.pos.Z -= (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ void shoot_r_override(DDukeActor* actor, int atwith, PClass *cls)
|
|||
{
|
||||
actor->spr.pos.X += posXY.X;
|
||||
actor->spr.pos.Y += posXY.Y;
|
||||
actor->spr.pos.Z += (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.pos.Z += (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||
}
|
||||
|
@ -3173,12 +3173,12 @@ static void processweapon(int snum, ESyncBits actions, sectortype* psectp)
|
|||
{
|
||||
if (pact->isPlayer() && vr_6dof_weapons && vr_6dof_crosshair)
|
||||
{
|
||||
float x, y, z, pitch, yaw;
|
||||
get_weapon_pos_and_angle(x, y, z, pitch, yaw);
|
||||
float x, y, z1, z2, pitch, yaw;
|
||||
get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw);
|
||||
|
||||
DAngle sang = pact->spr.Angles.Yaw + DAngle::fromDeg(yaw);
|
||||
|
||||
DVector3 spos = pact->spr.pos.plusZ(-(z * vr_hunits_per_meter()));
|
||||
DVector3 spos = pact->spr.pos.plusZ(-(z1 * vr_hunits_per_meter()));
|
||||
DVector2 posXY(x * vr_hunits_per_meter(), y * vr_hunits_per_meter());
|
||||
posXY = posXY.Rotated(-DAngle90 + pact->spr.Angles.Yaw);
|
||||
spos.X -= posXY.X;
|
||||
|
|
|
@ -243,6 +243,7 @@ enum kStatus
|
|||
kStatAnubisDrum,
|
||||
kStatExplodeTrigger = 141,
|
||||
kStatExplodeTarget = 152,
|
||||
kStatCrosshair = 789,
|
||||
kStatBubbleMachine = 1022,
|
||||
|
||||
};
|
||||
|
|
|
@ -38,6 +38,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
||||
float vr_hunits_per_meter();
|
||||
|
||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||
EXTERN_CVAR(Bool, vr_6dof_crosshair);
|
||||
|
||||
BEGIN_PS_NS
|
||||
|
||||
extern int nStatusSeqOffset;
|
||||
|
@ -2654,7 +2660,74 @@ sectdone:
|
|||
pDopple->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
||||
}
|
||||
|
||||
float px, py, pz1, pz2, pitch, yaw;
|
||||
|
||||
DVector2 posXY;
|
||||
if (vr_6dof_weapons && nPlayer == 0)
|
||||
{
|
||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
||||
|
||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + pPlayerActor->spr.Angles.Yaw);
|
||||
pPlayerActor->spr.pos.X -= posXY.X;
|
||||
pPlayerActor->spr.pos.Y -= posXY.Y;
|
||||
pPlayerActor->spr.pos.Z -= (pz2 * vr_hunits_per_meter()) - pPlayerActor->viewzoffset;
|
||||
pPlayerActor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||
pPlayerActor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||
|
||||
if (vr_6dof_crosshair)
|
||||
{
|
||||
HitInfo hit{};
|
||||
|
||||
double vel = 1024, zvel = 0;
|
||||
setFreeAimVelocity(vel, zvel, pPlayerActor->spr.Angles.Pitch, 16.);
|
||||
|
||||
pPlayerActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||
hitscan(pPlayerActor->spr.pos, pPlayerActor->sector(),
|
||||
DVector3(pPlayerActor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||
pPlayerActor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
||||
|
||||
if (hit.hitSector != nullptr)
|
||||
{
|
||||
double length = (hit.hitpos.XY() - pPlayerActor->spr.pos.XY()).Length();
|
||||
|
||||
//Update the existing aiming sprites if there is one
|
||||
ExhumedStatIterator it(kStatCrosshair);
|
||||
DExhumedActor *crosshair = it.Next();
|
||||
if (crosshair)
|
||||
{
|
||||
//update position
|
||||
SetActorZ(crosshair, hit.hitpos);
|
||||
}
|
||||
else
|
||||
{
|
||||
crosshair = insertActor(hit.hitSector, kStatCrosshair);
|
||||
crosshair->spr.pos = hit.hitpos;
|
||||
}
|
||||
|
||||
//Check we got the crosshair
|
||||
if (crosshair)
|
||||
{
|
||||
crosshair->spr.picnum = kCrosshairTile;
|
||||
crosshair->spr.scale = DVector2(0.4 + length / 512.0, 0.4 + length / 512.0);
|
||||
crosshair->spr.shade = -64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pPlayerActor->spr.pos.Z += -pPlayerActor->viewzoffset;
|
||||
|
||||
}
|
||||
|
||||
MoveWeapons(nPlayer);
|
||||
|
||||
if (vr_6dof_weapons)
|
||||
{
|
||||
pPlayerActor->spr.pos.X += posXY.X;
|
||||
pPlayerActor->spr.pos.Y += posXY.Y;
|
||||
pPlayerActor->spr.pos.Z += (pz2 * vr_hunits_per_meter());
|
||||
pPlayerActor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||
pPlayerActor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -63,6 +63,8 @@ enum STAT_ENUMS
|
|||
STAT_ITEM= 10,
|
||||
STAT_SKIP4_END = 10,
|
||||
|
||||
STAT_CROSSHAIR,
|
||||
|
||||
STAT_FAF_COPY,
|
||||
STAT_MAX=20, // everything below here can move
|
||||
STAT_PLAYER0,
|
||||
|
|
|
@ -56,6 +56,12 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "gamestate.h"
|
||||
#include "vm.h"
|
||||
|
||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
||||
float vr_hunits_per_meter();
|
||||
|
||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||
EXTERN_CVAR(Bool, vr_6dof_crosshair);
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
||||
void pSpriteControl(PLAYER* pp);
|
||||
|
@ -6932,6 +6938,8 @@ void PauseMultiPlay(void)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
extern STATE s_Splash[];
|
||||
|
||||
void domovethings(void)
|
||||
{
|
||||
short i, pnum;
|
||||
|
@ -7023,8 +7031,73 @@ void domovethings(void)
|
|||
|
||||
UpdatePlayerSprite(pp);
|
||||
|
||||
|
||||
float px, py, pz1, pz2, pitch, yaw;
|
||||
|
||||
DVector2 posXY;
|
||||
if (vr_6dof_weapons)
|
||||
{
|
||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
||||
|
||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + pp->actor->spr.Angles.Yaw);
|
||||
pp->actor->spr.pos.X -= posXY.X;
|
||||
pp->actor->spr.pos.Y -= posXY.Y;
|
||||
pp->actor->spr.pos.Z -= (pz1 * vr_hunits_per_meter());
|
||||
pp->actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||
pp->actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||
|
||||
if (vr_6dof_crosshair)
|
||||
{
|
||||
HitInfo hit{};
|
||||
|
||||
double vel = 1024, zvel = 0;
|
||||
setFreeAimVelocity(vel, zvel, pp->actor->spr.Angles.Pitch, 16.);
|
||||
|
||||
pp->actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||
hitscan(pp->actor->spr.pos, pp->actor->sector(), DVector3(pp->actor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||
pp->actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
||||
|
||||
if (hit.hitSector != nullptr)
|
||||
{
|
||||
double length = (hit.hitpos.XY() - pp->actor->spr.pos.XY()).Length();
|
||||
|
||||
//Update the existing aiming sprites if there is one
|
||||
SWStatIterator it(STAT_CROSSHAIR);
|
||||
DSWActor* crosshair = it.Next();
|
||||
if (crosshair)
|
||||
{
|
||||
//update position
|
||||
SetActorZ(crosshair, hit.hitpos);
|
||||
}
|
||||
else
|
||||
{
|
||||
crosshair = SpawnActor(STAT_CROSSHAIR, CROSSHAIRTILE, s_Crosshair, hit.hitSector, hit.hitpos, pp->actor->spr.Angles.Yaw, 0);
|
||||
}
|
||||
|
||||
//Check we got the crosshair
|
||||
if (crosshair)
|
||||
{
|
||||
crosshair->spr.scale = DVector2(0.25 + length / 512.0, 0.25 + length / 512.0);
|
||||
crosshair->spr.shade = -40;
|
||||
}
|
||||
}
|
||||
|
||||
//Now adjust Z for weapon origin
|
||||
pp->actor->spr.pos.Z -= pp->actor->viewzoffset;
|
||||
}
|
||||
}
|
||||
|
||||
pSpriteControl(pp);
|
||||
|
||||
if (vr_6dof_weapons)
|
||||
{
|
||||
pp->actor->spr.pos.X += posXY.X;
|
||||
pp->actor->spr.pos.Y += posXY.Y;
|
||||
pp->actor->spr.pos.Z += (pz1 * vr_hunits_per_meter()) + pp->actor->viewzoffset;
|
||||
pp->actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||
}
|
||||
|
||||
PlayerStateControl(pp->actor);
|
||||
|
||||
DoPlayerSectorUpdatePostMove(pp);
|
||||
|
|
|
@ -179,6 +179,13 @@ extern STATE s_NukeMushroom[];
|
|||
|
||||
void WallBounce(DSWActor*, DAngle ang);
|
||||
|
||||
|
||||
#define CROSSHAIRTILE 2326
|
||||
STATE s_Crosshair[] =
|
||||
{
|
||||
{CROSSHAIRTILE, 100, NullAnimator, &s_Crosshair[0]}
|
||||
};
|
||||
|
||||
#define PUFF 1748
|
||||
#define CALTROPS 2218
|
||||
#define PHOSPHORUS 1397
|
||||
|
|
|
@ -554,8 +554,8 @@ OptionMenu "VROptionsMenu" protected
|
|||
Slider "Height Adjust", "vr_height_adjust", 0.0, 1.0, 0.1
|
||||
StaticText ""
|
||||
Option "Positional Tracking", "vr_positional_tracking", "YesNo"
|
||||
Option "6DoF Weapons (Duke Only)", "vr_6dof_weapons", "YesNo"
|
||||
Option "VR Crosshair (Duke Only)", "vr_6dof_crosshair", "YesNo"
|
||||
Option "6DoF Weapons", "vr_6dof_weapons", "YesNo"
|
||||
Option "VR Aim-Assist", "vr_6dof_crosshair", "YesNo"
|
||||
|
||||
StaticText ""
|
||||
StaticText "HUD"
|
||||
|
|
Loading…
Reference in a new issue