mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-26 05:52:03 +00:00
Some changes...
- Make HMD weapon wheel use angles for weapon selection, allows selection immediately before show animation is complete - Proper model scaling in the Player Setup menu
This commit is contained in:
parent
18e4778d48
commit
83599b76ca
2 changed files with 68 additions and 26 deletions
|
@ -2096,9 +2096,9 @@ void CG_DrawWeaponSelector( void )
|
|||
|
||||
float thumbstickAxisX = 0.0f;
|
||||
float thumbstickAxisY = 0.0f;
|
||||
float a = atan2(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]);
|
||||
if (length(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]) > 0.95f)
|
||||
{
|
||||
float a = atan2(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]);
|
||||
thumbstickAxisX = sinf(a) * 0.95f;
|
||||
thumbstickAxisY = cosf(a) * 0.95f;
|
||||
}
|
||||
|
@ -2149,22 +2149,24 @@ void CG_DrawWeaponSelector( void )
|
|||
}
|
||||
}
|
||||
|
||||
#define IGNORE_ANGLE -999.0f
|
||||
#ifdef MISSIONPACK
|
||||
float rollAngles[WP_NUM_WEAPONS] = {IGNORE_ANGLE, 30.0f, 60.0f, 90.0f, 120.0f, 150.0f, 180.0f, 210.0f, 240.0f, 270.0f, IGNORE_ANGLE, 300.0f, 330.0f, 0.0f};
|
||||
float iconAngles[WP_NUM_WEAPONS] = {0.0f, 30.0f, 60.0f, 90.0f, 120.0f, 150.0f, 180.0f, 210.0f, 240.0f, 270.0f, 300.0f, 330.0f, 360.0f, 390.0f};
|
||||
#else
|
||||
float rollAngles[WP_NUM_WEAPONS] = {IGNORE_ANGLE, 18.0f, 54.0f, 90.0f, 135.0f, 180.0f, 225.0f, 270.0f, 306.0f, 342.0f, IGNORE_ANGLE};
|
||||
float iconAngles[WP_NUM_WEAPONS] = {0.0f, 30.0f, 60.0f, 90.0f, 135.0f, 180.0f, 225.0f, 270.0f, 315.0f, 360.0f, 390.0f};
|
||||
#endif
|
||||
|
||||
qboolean selected = qfalse;
|
||||
for (int c = 0; c < WP_NUM_WEAPONS-1; ++c)
|
||||
int w = 0;
|
||||
for (int index = 0; index < WP_NUM_WEAPONS-1; ++index)
|
||||
{
|
||||
int w = c+1;
|
||||
if (w == WP_GRAPPLING_HOOK)
|
||||
if ((index+1) == WP_GRAPPLING_HOOK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//increment now we know we aren't looking at an invalid weapon id
|
||||
++w;
|
||||
|
||||
CG_RegisterWeapon(w);
|
||||
|
||||
{
|
||||
|
@ -2175,7 +2177,7 @@ void CG_DrawWeaponSelector( void )
|
|||
VectorClear(angles);
|
||||
angles[YAW] = holsterAngles[YAW];
|
||||
angles[PITCH] = holsterAngles[PITCH];
|
||||
angles[ROLL] = rollAngles[w];
|
||||
angles[ROLL] = iconAngles[w];
|
||||
vec3_t forward, up;
|
||||
AngleVectors(angles, forward, NULL, up);
|
||||
|
||||
|
@ -2183,7 +2185,8 @@ void CG_DrawWeaponSelector( void )
|
|||
VectorMA(iconOrigin, 0.2f, forward, iconBackground);
|
||||
VectorMA(iconOrigin, -0.2f, forward, iconForeground);
|
||||
|
||||
//Float sprite above selected weapon
|
||||
if (selectorMode == WS_CONTROLLER)
|
||||
{
|
||||
vec3_t diff;
|
||||
VectorSubtract(selectorOrigin, iconOrigin, diff);
|
||||
float length = VectorLength(diff);
|
||||
|
@ -2199,6 +2202,31 @@ void CG_DrawWeaponSelector( void )
|
|||
|
||||
selected = qtrue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//For HMD selector, the weapon can be selected before the selector has finished
|
||||
//its opening animation, use angles to identify the selected weapon, rather than
|
||||
//the position of the selector pointer
|
||||
float angle = AngleNormalize360(RAD2DEG(a));
|
||||
float angle360 = angle + 360; // HACK - Account for the icon at the top
|
||||
|
||||
float low = ((iconAngles[w-1]+iconAngles[w])/2.0f);
|
||||
float high = ((iconAngles[w]+iconAngles[w+1])/2.0f);
|
||||
|
||||
if (((angle > low && angle <= high) || (angle360 > low && angle360 <= high)) &&
|
||||
(length(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]) > 0.5f) &&
|
||||
selectable)
|
||||
{
|
||||
if (cg.weaponSelectorSelection != w)
|
||||
{
|
||||
cg.weaponSelectorSelection = w;
|
||||
trap_HapticEvent("selector_icon", 0, 0, 100, 0, 0);
|
||||
}
|
||||
|
||||
selected = qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
if (cg.weaponSelectorSelection == w)
|
||||
{
|
||||
|
|
|
@ -591,6 +591,8 @@ static void UI_PlayerAngles( playerInfo_t *pi, vec3_t legs[3], vec3_t torso[3],
|
|||
float dest;
|
||||
float adjust;
|
||||
|
||||
pi->viewAngles[YAW] = AngleNormalize360(uis.realtime / 50.0f);
|
||||
|
||||
VectorCopy( pi->viewAngles, headAngles );
|
||||
headAngles[YAW] = AngleMod( headAngles[YAW] );
|
||||
VectorClear( legsAngles );
|
||||
|
@ -705,6 +707,12 @@ float UI_MachinegunSpinAngle( playerInfo_t *pi ) {
|
|||
return angle;
|
||||
}
|
||||
|
||||
static void UI_ScaleModel(refEntity_t *ent)
|
||||
{
|
||||
VectorScale(ent->axis[1], 1.6f, ent->axis[1]);
|
||||
VectorScale(ent->axis[2], 1.4f, ent->axis[2]);
|
||||
ent->nonNormalizedAxes = qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
|
@ -767,8 +775,8 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti
|
|||
|
||||
// calculate distance so the player nearly fills the box
|
||||
len = 0.7 * ( maxs[2] - mins[2] );
|
||||
origin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 );
|
||||
origin[1] = 0.5 * ( mins[1] + maxs[1] );
|
||||
origin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 ) - 15;
|
||||
origin[1] = 0.5 * ( mins[1] + maxs[1] ) - 10;
|
||||
origin[2] = -0.5 * ( mins[2] + maxs[2] );
|
||||
|
||||
refdef.time = dp_realtime;
|
||||
|
@ -796,6 +804,10 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti
|
|||
legs.renderfx = renderfx;
|
||||
VectorCopy (legs.origin, legs.oldorigin);
|
||||
|
||||
UI_ScaleModel(&legs);
|
||||
//UI_ScaleModel(&torso);
|
||||
//UI_ScaleModel(&head);
|
||||
|
||||
trap_R_AddRefEntityToScene( &legs );
|
||||
|
||||
if (!legs.hModel) {
|
||||
|
@ -852,6 +864,7 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti
|
|||
VectorCopy( origin, gun.lightingOrigin );
|
||||
UI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, "tag_weapon");
|
||||
gun.renderfx = renderfx;
|
||||
//UI_ScaleModel(&gun);
|
||||
trap_R_AddRefEntityToScene( &gun );
|
||||
}
|
||||
|
||||
|
@ -870,6 +883,7 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti
|
|||
angles[PITCH] = 0;
|
||||
angles[ROLL] = UI_MachinegunSpinAngle( pi );
|
||||
AnglesToAxis( angles, barrel.axis );
|
||||
//UI_ScaleModel(&barrel);
|
||||
|
||||
UI_PositionRotatedEntityOnTag( &barrel, &gun, pi->weaponModel, "tag_barrel");
|
||||
|
||||
|
|
Loading…
Reference in a new issue