Weapon Model Adjust

- Angular adjustments now possible
- Improved knife haptics
- Weapon direction laser to allow weapon alignment (needs to be configurable)
This commit is contained in:
Simon 2020-07-12 23:26:56 +01:00
parent 39aac7000e
commit 20ea9c6817
10 changed files with 277 additions and 122 deletions

View file

@ -16,7 +16,7 @@ typedef struct {
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
vec3_t hmdorientation_delta;
vec3_t weaponangles_unadjusted;
vec3_t weaponangles_knife;
vec3_t weaponangles;
vec3_t weaponangles_last; // Don't use this, it is just for calculating delta!
vec3_t weaponangles_delta;

View file

@ -8,7 +8,7 @@
enum control_scheme;
#define SCOPE_ENGAGE_DISTANCE 0.3
#define VELOCITY_TRIGGER 2.0
#define VELOCITY_TRIGGER 1.8
ovrInputStateTrackedRemote leftTrackedRemoteState_old;
ovrInputStateTrackedRemote leftTrackedRemoteState_new;

View file

@ -50,7 +50,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
{
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
vec3_t rotation = {0};
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles_unadjusted);
rotation[PITCH] = 10;
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles_knife);
rotation[PITCH] = vr_weapon_pitchadjust->value;
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles);

View file

@ -18,9 +18,7 @@ GNU General Public License for more details.
#include <math.h>
//#include "../rtcw/src/common/header/common.h"
//#include "../rtcw/src/client/header/keyboard.h"
#include "../rtcw/src//game/q_shared.h"
#include "../rtcw/src/game/q_shared.h"
// euler angle order
#define PITCH 0
@ -91,9 +89,9 @@ GNU General Public License for more details.
//#define VectorClear(x) ((x)[0]=(x)[1]=(x)[2]=0)
#define Vector2Lerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]))
#define VectorLerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]), (c)[2] = (v1)[2] + (lerp) * ((v2)[2] - (v1)[2]))
#define VectorNormalize( v ) { float ilength = (float)sqrt(DotProduct(v, v));if (ilength) ilength = 1.0f / ilength;v[0] *= ilength;v[1] *= ilength;v[2] *= ilength; }
#define VectorNormalize2( v, dest ) {float ilength = (float)sqrt(DotProduct(v,v));if (ilength) ilength = 1.0f / ilength;dest[0] = v[0] * ilength;dest[1] = v[1] * ilength;dest[2] = v[2] * ilength; }
#define VectorNormalizeFast( v ) {float ilength = (float)rsqrt(DotProduct(v,v)); v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; }
//#define VectorNormalize( v ) { float ilength = (float)sqrt(DotProduct(v, v));if (ilength) ilength = 1.0f / ilength;v[0] *= ilength;v[1] *= ilength;v[2] *= ilength; }
//#define VectorNormalize2( v, dest ) {float ilength = (float)sqrt(DotProduct(v,v));if (ilength) ilength = 1.0f / ilength;dest[0] = v[0] * ilength;dest[1] = v[1] * ilength;dest[2] = v[2] * ilength; }
//#define VectorNormalizeFast( v ) {float ilength = (float)rsqrt(DotProduct(v,v)); v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; }
#define VectorNormalizeLength( v ) VectorNormalizeLength2((v), (v))
//#define VectorNegate(x, y) ((y)[0] = -(x)[0], (y)[1] = -(x)[1], (y)[2] = -(x)[2])
#define VectorM(scale1, b1, c) ((c)[0] = (scale1) * (b1)[0],(c)[1] = (scale1) * (b1)[1],(c)[2] = (scale1) * (b1)[2])

View file

@ -368,7 +368,7 @@ cvarTable_t cvarTable[] = {
{ &cg_reticleBrightness, "cg_reticleBrightness", "0.7", CVAR_ARCHIVE },
{ &cg_markTime, "cg_marktime", "20000", CVAR_ARCHIVE },
{ &cg_lagometer, "cg_lagometer", "1", CVAR_ARCHIVE },
{ &cg_railTrailTime, "cg_railTrailTime", "400", CVAR_ARCHIVE },
{ &cg_railTrailTime, "cg_railTrailTime", "50", CVAR_ARCHIVE },
{ &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT },
{ &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT },
{ &cg_gun_z, "cg_gunZ", "0", CVAR_CHEAT },
@ -489,24 +489,25 @@ cvarTable_t cvarTable[] = {
//Default Weapon adjustments - these WILL be overridden
{ &vr_weapon_adjustment_1, "vr_weapon_adjustment_1", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_2, "vr_weapon_adjustment_2", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_3, "vr_weapon_adjustment_3", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_4, "vr_weapon_adjustment_4", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_5, "vr_weapon_adjustment_5", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_6, "vr_weapon_adjustment_6", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_7, "vr_weapon_adjustment_7", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_8, "vr_weapon_adjustment_8", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_9, "vr_weapon_adjustment_9", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_10, "vr_weapon_adjustment_10", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_11, "vr_weapon_adjustment_11", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_12, "vr_weapon_adjustment_12", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_13, "vr_weapon_adjustment_13", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_14, "vr_weapon_adjustment_14", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_18, "vr_weapon_adjustment_18", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_19, "vr_weapon_adjustment_19", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_20, "vr_weapon_adjustment_20", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_22, "vr_weapon_adjustment_22", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
// scale,right,up,forward,pitch,yaw,roll
{ &vr_weapon_adjustment_1, "vr_weapon_adjustment_1", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_2, "vr_weapon_adjustment_2", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_3, "vr_weapon_adjustment_3", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_4, "vr_weapon_adjustment_4", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_5, "vr_weapon_adjustment_5", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_6, "vr_weapon_adjustment_6", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_7, "vr_weapon_adjustment_7", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_8, "vr_weapon_adjustment_8", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_9, "vr_weapon_adjustment_9", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_10, "vr_weapon_adjustment_10", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_11, "vr_weapon_adjustment_11", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_12, "vr_weapon_adjustment_12", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_13, "vr_weapon_adjustment_13", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_14, "vr_weapon_adjustment_14", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_18, "vr_weapon_adjustment_18", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_19, "vr_weapon_adjustment_19", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_20, "vr_weapon_adjustment_20", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_22, "vr_weapon_adjustment_22", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE},
// NERVE - SMF

View file

@ -33,9 +33,196 @@ If you have questions concerning this license or the applicable additional terms
*
*/
#include <math.h>
#include "cg_local.h"
#include "../../../RTCWVR/VrClientInfo.h"
#define M_PI2 (float)6.28318530717958647692
/*
=================
SinCos
=================
*/
void SinCos( float radians, float *sine, float *cosine )
{
#if _MSC_VER == 1200
_asm
{
fld dword ptr [radians]
fsincos
mov edx, dword ptr [cosine]
mov eax, dword ptr [sine]
fstp dword ptr [edx]
fstp dword ptr [eax]
}
#else
// I think, better use math.h function, instead of ^
#if defined (__linux__) && !defined (__ANDROID__)
sincosf(radians, sine, cosine);
#else
*sine = sinf(radians);
*cosine = cosf(radians);
#endif
#endif
}
void Matrix4x4_Concat (matrix4x4 out, const matrix4x4 in1, const matrix4x4 in2)
{
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + in1[0][2] * in2[2][0] + in1[0][3] * in2[3][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + in1[0][2] * in2[2][1] + in1[0][3] * in2[3][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + in1[0][2] * in2[2][2] + in1[0][3] * in2[3][2];
out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + in1[0][2] * in2[2][3] + in1[0][3] * in2[3][3];
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + in1[1][2] * in2[2][0] + in1[1][3] * in2[3][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + in1[1][2] * in2[2][1] + in1[1][3] * in2[3][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + in1[1][2] * in2[2][2] + in1[1][3] * in2[3][2];
out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + in1[1][2] * in2[2][3] + in1[1][3] * in2[3][3];
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + in1[2][2] * in2[2][0] + in1[2][3] * in2[3][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + in1[2][2] * in2[2][1] + in1[2][3] * in2[3][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + in1[2][2] * in2[2][2] + in1[2][3] * in2[3][2];
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3] * in2[3][3];
out[3][0] = in1[3][0] * in2[0][0] + in1[3][1] * in2[1][0] + in1[3][2] * in2[2][0] + in1[3][3] * in2[3][0];
out[3][1] = in1[3][0] * in2[0][1] + in1[3][1] * in2[1][1] + in1[3][2] * in2[2][1] + in1[3][3] * in2[3][1];
out[3][2] = in1[3][0] * in2[0][2] + in1[3][1] * in2[1][2] + in1[3][2] * in2[2][2] + in1[3][3] * in2[3][2];
out[3][3] = in1[3][0] * in2[0][3] + in1[3][1] * in2[1][3] + in1[3][2] * in2[2][3] + in1[3][3] * in2[3][3];
}
void Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale )
{
float angle, sr, sp, sy, cr, cp, cy;
if( angles[ROLL] )
{
#ifdef XASH_VECTORIZE_SINCOS
SinCosFastVector3( DEG2RAD(angles[YAW]), DEG2RAD(angles[PITCH]), DEG2RAD(angles[ROLL]),
&sy, &sp, &sr,
&cy, &cp, &cr);
#else
angle = angles[YAW] * (M_PI2 / 360.0f);
SinCos( angle, &sy, &cy );
angle = angles[PITCH] * (M_PI2 / 360.0f);
SinCos( angle, &sp, &cp );
angle = angles[ROLL] * (M_PI2 / 360.0f);
SinCos( angle, &sr, &cr );
#endif
out[0][0] = (cp*cy) * scale;
out[0][1] = (sr*sp*cy+cr*-sy) * scale;
out[0][2] = (cr*sp*cy+-sr*-sy) * scale;
out[0][3] = origin[0];
out[1][0] = (cp*sy) * scale;
out[1][1] = (sr*sp*sy+cr*cy) * scale;
out[1][2] = (cr*sp*sy+-sr*cy) * scale;
out[1][3] = origin[1];
out[2][0] = (-sp) * scale;
out[2][1] = (sr*cp) * scale;
out[2][2] = (cr*cp) * scale;
out[2][3] = origin[2];
out[3][0] = 0.0f;
out[3][1] = 0.0f;
out[3][2] = 0.0f;
out[3][3] = 1.0f;
}
else if( angles[PITCH] )
{
#ifdef XASH_VECTORIZE_SINCOS
SinCosFastVector2( DEG2RAD(angles[YAW]), DEG2RAD(angles[PITCH]),
&sy, &sp,
&cy, &cp);
#else
angle = angles[YAW] * (M_PI2 / 360.0f);
SinCos( angle, &sy, &cy );
angle = angles[PITCH] * (M_PI2 / 360.0f);
SinCos( angle, &sp, &cp );
#endif
out[0][0] = (cp*cy) * scale;
out[0][1] = (-sy) * scale;
out[0][2] = (sp*cy) * scale;
out[0][3] = origin[0];
out[1][0] = (cp*sy) * scale;
out[1][1] = (cy) * scale;
out[1][2] = (sp*sy) * scale;
out[1][3] = origin[1];
out[2][0] = (-sp) * scale;
out[2][1] = 0.0f;
out[2][2] = (cp) * scale;
out[2][3] = origin[2];
out[3][0] = 0.0f;
out[3][1] = 0.0f;
out[3][2] = 0.0f;
out[3][3] = 1.0f;
}
else if( angles[YAW] )
{
angle = angles[YAW] * (M_PI2 / 360.0f);
SinCos( angle, &sy, &cy );
out[0][0] = (cy) * scale;
out[0][1] = (-sy) * scale;
out[0][2] = 0.0f;
out[0][3] = origin[0];
out[1][0] = (sy) * scale;
out[1][1] = (cy) * scale;
out[1][2] = 0.0f;
out[1][3] = origin[1];
out[2][0] = 0.0f;
out[2][1] = 0.0f;
out[2][2] = scale;
out[2][3] = origin[2];
out[3][0] = 0.0f;
out[3][1] = 0.0f;
out[3][2] = 0.0f;
out[3][3] = 1.0f;
}
else
{
out[0][0] = scale;
out[0][1] = 0.0f;
out[0][2] = 0.0f;
out[0][3] = origin[0];
out[1][0] = 0.0f;
out[1][1] = scale;
out[1][2] = 0.0f;
out[1][3] = origin[1];
out[2][0] = 0.0f;
out[2][1] = 0.0f;
out[2][2] = scale;
out[2][3] = origin[2];
out[3][0] = 0.0f;
out[3][1] = 0.0f;
out[3][2] = 0.0f;
out[3][3] = 1.0f;
}
}
void Matrix4x4_ConvertToEntity( vec4_t *in, vec3_t angles, vec3_t origin )
{
float xyDist = sqrt( in[0][0] * in[0][0] + in[1][0] * in[1][0] );
// enough here to get angles?
if( xyDist > 0.001f )
{
angles[0] = RAD2DEG( atan2( -in[2][0], xyDist ));
angles[1] = RAD2DEG( atan2( in[1][0], in[0][0] ));
angles[2] = RAD2DEG( atan2( in[2][1], in[2][2] ));
}
else // forward is mostly Z, gimbal lock
{
angles[0] = RAD2DEG( atan2( -in[2][0], xyDist ));
angles[1] = RAD2DEG( atan2( -in[0][1], in[1][1] ));
angles[2] = 0.0f;
}
origin[0] = in[0][3];
origin[1] = in[1][3];
origin[2] = in[2][3];
}
int wolfkickModel;
int hWeaponSnd;
int hflakWeaponSnd;
@ -1790,7 +1977,7 @@ static void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ) {
switch (cg.predictedPlayerState.weapon)
{
case WP_KNIFE:
VectorCopy(cgVR->weaponangles_unadjusted, angles);
VectorCopy(cgVR->weaponangles_knife, angles);
break;
default:
VectorCopy(cgVR->weaponangles, angles);
@ -1822,16 +2009,22 @@ static float CG_CalculateWeaponPositionAndScale( vec3_t origin, vec3_t angles )
char weapon_adjustment[256];
trap_Cvar_VariableStringBuffer(cvar_name, weapon_adjustment, 256);
vec3_t adjust;
vec3_t temp_offset;
VectorClear(temp_offset);
sscanf(weapon_adjustment, "%f,%f,%f,%f", &scale, &(temp_offset[0]), &(temp_offset[1]), &(temp_offset[2]));
sscanf(weapon_adjustment, "%f,%f,%f,%f,%f,%f,%f", &scale, &(temp_offset[0]), &(temp_offset[1]), &(temp_offset[2]), &(adjust[PITCH]), &(adjust[YAW]), &(adjust[ROLL]));
VectorScale(temp_offset, scale, offset);
//int lrOffset = (( r_lefthand->value != 0.0f ) ? -1 : 1);
//offset[1] *= lrOffset;
//Adjust angles for weapon models that aren't aligned very well
matrix4x4 m1, m2, m3;
vec3_t zero;
VectorClear(zero);
Matrix4x4_CreateFromEntity(m1, angles,zero, 1.0);
Matrix4x4_CreateFromEntity(m2, adjust,zero, 1.0);
Matrix4x4_Concat(m3, m1, m2);
Matrix4x4_ConvertToEntity(m3, angles, zero);
}
//Now move weapon closer to proper origin
vec3_t forward, right, up;
AngleVectors( angles, forward, right, up );
@ -3245,6 +3438,29 @@ void CG_AddViewWeapon( playerState_t *ps ) {
break;
}
//Add beam
static centity_t beam_entity;
VectorCopy(hand.origin, beam_entity.currentState.pos.trBase); //beam origin
vec3_t forward;
AngleVectors(angles, forward, NULL, NULL);
VectorMA(beam_entity.currentState.pos.trBase, 64, forward, beam_entity.currentState.origin2); //beam end
//Weapon offset debugging
{
vec3_t origin;
vec3_t origin2;
vec3_t angles;
CG_CalculateVRWeaponPosition(
origin,
angles );
vec3_t forward;
AngleVectors(angles, forward, NULL, NULL);
VectorMA(origin, 48, forward, origin2); //beam end
CG_RailTrail2(NULL, origin, origin2);
}
//CG_Beam(&beam_entity);
cg.predictedPlayerEntity.lastWeaponClientFrame = cg.clientFrame;
}

View file

@ -110,9 +110,9 @@ void Weapon_Knife( gentity_t *ent ) {
vec3_t angles;
if (gVR != NULL) {
VectorCopy(gVR->weaponangles_unadjusted, angles);
VectorCopy(gVR->weaponangles_knife, angles);
angles[YAW] = ent->client->ps.viewangles[YAW] +
(gVR->weaponangles_unadjusted[YAW] - gVR->hmdorientation[YAW]);
(gVR->weaponangles_knife[YAW] - gVR->hmdorientation[YAW]);
}
AngleVectors( angles, forward, right, up );
@ -140,6 +140,9 @@ void Weapon_Knife( gentity_t *ent ) {
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
//we hit something
trap_Vibrate(100, gVR->right_handed ? 1 : 0, 0.9);
if ( tr.entityNum == ENTITYNUM_WORLD ) { // don't worry about doing any damage
return;
}
@ -183,8 +186,6 @@ void Weapon_Knife( gentity_t *ent ) {
}
}
trap_Vibrate(50, gVR->right_handed ? 1 : 0, 0.6);
G_Damage( traceEnt, ent, ent, vec3_origin, tr.endpos, ( damage + rand() % 5 ) * s_quadFactor, 0, mod );
}

View file

@ -413,6 +413,8 @@ typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4];
typedef vec_t vec5_t[5];
typedef vec_t matrix4x4[4][4];
typedef int fixed4_t;
typedef int fixed8_t;
typedef int fixed16_t;

View file

@ -422,71 +422,6 @@ void convertFromVR(float worldscale, vec3_t in, vec3_t offset, vec3_t out)
}
}
/*
==============
RB_SurfaceBeam
==============
*/
void R_LaserBeam( vec3_t vieworigin ) {
#define NUM_BEAM_SEGS 6
int i;
vec3_t angles;
vec3_t perpvec;
vec3_t direction, normalized_direction;
vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
vec3_t oldorigin, origin;
float worldscale = Cvar_VariableValue("cg_worldScale");
float heightAdjust = Cvar_VariableValue("cg_heightAdjust");
convertFromVR(worldscale, vr.weaponoffset, vieworigin, origin);
origin[2] -= 24; // mmmmmmm magic number
origin[2] += (vr.hmdposition[1] + heightAdjust) * worldscale;
VectorCopy(vr.weaponangles, angles);
angles[YAW] += cl.viewangles[YAW] - vr.hmdorientation[YAW];
vec3_t forward;
AngleVectors(angles, forward, NULL, NULL);
VectorMA( origin, 256, forward, oldorigin );
normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
PerpendicularVector( perpvec, normalized_direction );
VectorScale( perpvec, 4, perpvec );
for ( i = 0; i < NUM_BEAM_SEGS ; i++ )
{
RotatePointAroundVector( start_points[i], normalized_direction, perpvec, ( 360.0 / NUM_BEAM_SEGS ) * i );
VectorAdd( start_points[i], direction, end_points[i] );
}
GL_Bind( tr.whiteImage );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );
qglColor3f( 1, 0, 0 );
GLboolean text = qglIsEnabled(GL_TEXTURE_COORD_ARRAY);
GLboolean glcol = qglIsEnabled(GL_COLOR_ARRAY);
if (glcol)
qglDisableClientState(GL_COLOR_ARRAY);
if (text)
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
GLfloat vtx[NUM_BEAM_SEGS*6+6];
for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {
memcpy(vtx+i*6, start_points[ i % NUM_BEAM_SEGS], sizeof(GLfloat)*3);
memcpy(vtx+i*6+3, end_points[ i % NUM_BEAM_SEGS], sizeof(GLfloat)*3);
}
qglVertexPointer (3, GL_FLOAT, 0, vtx);
qglDrawArrays(GL_TRIANGLE_STRIP, 0, NUM_BEAM_SEGS*2+2);
if (glcol)
qglEnableClientState(GL_COLOR_ARRAY);
if (text)
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
}
/*
@@@@@@@@@@@@@@@@@@@@@
@ -657,8 +592,6 @@ void RE_RenderScene( const refdef_t *fd ) {
R_RenderView( &parms );
R_LaserBeam (fd->vieworg);
// the next scene rendered in this frame will tack on after this one
r_firstSceneDrawSurf = tr.refdef.numDrawSurfs;
r_firstSceneEntity = r_numentities;

View file

@ -32,42 +32,45 @@
// Weapon offsets - This is the default for the weapon models
// put the weapon id at the end of the cvar name, so the knife is vr_weapon_adjustment_1
// Values are: scale,right,up,forward
// Default values are: "0.62,-9.8,11.3,-16.1"
// Values are: scale,right,up,forward,pitch,yaw,roll
// Default values are: "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0"
// Knife
seta vr_weapon_adjustment_1 "0.5,-8.0,8.0,-15.0"
seta vr_weapon_adjustment_1 "0.5,-9.8,8.0,-20.0,10.0,-10.0,-40.0"
// Luger
seta vr_weapon_adjustment_2 "0.5,-10,17.0,-20.1"
seta vr_weapon_adjustment_2 "0.5,-14,17.0,-20.1,0.0,0.0,0.0"
// MP40
seta vr_weapon_adjustment_3 "0.6,-9.8,9.5,-14.1"
seta vr_weapon_adjustment_3 "0.6,-13.8,9.5,-14.1,0.0,0.0,0.0"
// Grenade Launcher
seta vr_weapon_adjustment_6 "0.55,-10,18.0,-24.0"
// Colt
seta vr_weapon_adjustment_11 "0.5,-10,17.0,-20.1"
// Thompson
seta vr_weapon_adjustment_12 "0.7,-9.8,11.3,-16.1"
seta vr_weapon_adjustment_6 "0.55,-14,18.0,-24.0,0.0,0.0,0.0"
// Sten
seta vr_weapon_adjustment_18 "0.52,-9.8,11.3,-16.1"
seta vr_weapon_adjustment_6 "0.62,-9.8,10.5,-16.1,-1.0,0.0,0.0"
// Colt
seta vr_weapon_adjustment_11 "0.5,-14,17.0,-20.1,0.0,0.0,0.0"
// Thompson
seta vr_weapon_adjustment_12 "0.7,-13.8,11.3,-16.1,0.0,0.0,0.0"
// Sten
seta vr_weapon_adjustment_18 "0.52,-13.8,11.3,-16.1,0.0,0.0,0.0"
// Panzer Faust (Rocket Launcher)
seta vr_weapon_adjustment_7 "0.9,-5.0,8.0,-5.0"
seta vr_weapon_adjustment_7 "0.9,-9.0,8.0,-5.0,0.0,0.0,0.0"
// Flame Thrower
seta vr_weapon_adjustment_9 "0.7,-9.8,5.9,-9.0"
seta vr_weapon_adjustment_9 "0.7,-13.8,5.9,-9.0,0.0,0.0,0.0"
// Tesla Coil
seta vr_weapon_adjustment_10 "0.72,-9.8,11.3,-12.1"
seta vr_weapon_adjustment_10 "0.72,-13.8,11.3,-12.1,0.0,0.0,0.0"
// Garand (snooper scope sniper rifle)
seta vr_weapon_adjustment_13 "0.59,-9.8,10.0,-12.0"
seta vr_weapon_adjustment_13 "0.59,-13.8,10.0,-12.0,0.0,0.0,0.0"
// Dynamite
seta vr_weapon_adjustment_22 "0.55,-10,18.0,-24.0"
seta vr_weapon_adjustment_22 "0.55,-14,18.0,-24.0,0.0,0.0,0.0"