Big improvement to railgun scope

ready for primetime I  think!
This commit is contained in:
Simon 2022-02-19 17:30:32 +00:00
parent 08193518cc
commit 1841ee1892
12 changed files with 121 additions and 33 deletions

View file

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.ioq3quest"
android:installLocation="preferExternal"
android:versionCode="20"
android:versionName="0.13.1">
android:versionCode="21"
android:versionName="0.14.0">
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-feature android:glEsVersion="0x00030001" />
<!-- <uses-feature android:name="oculus.software.overlay_keyboard" android:required="false"/>-->

Binary file not shown.

View file

@ -121,6 +121,9 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
//copy demo
copy_asset("/sdcard/ioquake3Quest/baseq3", "pak0.pk3", false);
//Scope
copy_asset("/sdcard/ioquake3Quest/baseq3", "scope.tga", false);
//glsl
copy_asset("/sdcard/ioquake3Quest", "glsl.zip", true);
new File("/sdcard/ioquake3Quest/baseq3/glsl").mkdirs();

View file

@ -2536,6 +2536,49 @@ void CG_DrawTimedMenus( void ) {
}
}
#endif
/*
==============
CG_DrawWeapReticle
==============
*/
static void CG_DrawWeapReticle( void )
{
int weap;
vec4_t color = {0, 0, 0, 1};
float indent = 0.2;
float X_WIDTH=640;
float Y_HEIGHT=480;
float x = (X_WIDTH * indent), y = (Y_HEIGHT * indent) + 3, w = (X_WIDTH * (1-(2*indent))) / 2.0f, h = (Y_HEIGHT * (1-(2*indent))) / 2;
CG_AdjustFrom640( &x, &y, &w, &h );
// sides
CG_FillRect( 0, 0, (X_WIDTH * indent), Y_HEIGHT, color );
CG_FillRect( X_WIDTH * (1 - indent), 0, (X_WIDTH * indent), Y_HEIGHT, color );
// top/bottom
CG_FillRect( X_WIDTH * indent, 0, X_WIDTH * (1-indent), Y_HEIGHT * indent, color );
CG_FillRect( X_WIDTH * indent, Y_HEIGHT * (1-indent), X_WIDTH * (1-indent), Y_HEIGHT * indent, color );
{
// center
if ( cgs.media.reticleShader ) {
trap_R_DrawStretchPic( x, y, w, h, 0, 0, 1, 1, cgs.media.reticleShader ); // tl
trap_R_DrawStretchPic( x + w, y, w, h, 1, 0, 0, 1, cgs.media.reticleShader ); // tr
trap_R_DrawStretchPic( x, y + h, w, h, 0, 1, 1, 0, cgs.media.reticleShader ); // bl
trap_R_DrawStretchPic( x + w, y + h, w, h, 1, 1, 0, 0, cgs.media.reticleShader ); // br
}
// hairs
CG_FillRect( 84, 242, 177, 2, color ); // left
CG_FillRect( 320, 245, 1, 58, color ); // center top
CG_FillRect( 319, 303, 2, 178, color ); // center bot
CG_FillRect( 380, 242, 177, 2, color ); // right
}
}
/*
=================
CG_Draw2D
@ -2593,9 +2636,9 @@ static void CG_Draw2D(stereoFrame_t stereoFrame)
CG_DrawProxWarning();
#endif
//Use 2D crosshair when using weapon zoom
if(vr->weapon_zoomed)
CG_DrawCrosshair();
if(vr->weapon_zoomed) {
CG_DrawWeapReticle();
}
CG_DrawCrosshairNames();
CG_DrawWeaponSelect();

View file

@ -739,6 +739,8 @@ typedef struct {
qhandle_t backTileShader;
qhandle_t noammoShader;
qhandle_t scopeShader;
qhandle_t smokePuffShader;
qhandle_t smokePuffRageProShader;
qhandle_t shotgunSmokePuffShader;
@ -784,6 +786,8 @@ typedef struct {
qhandle_t dishFlashModel;
qhandle_t lightningExplosionModel;
qhandle_t reticleShader;
// weapon effect shaders
qhandle_t railExplosionShader;
qhandle_t plasmaExplosionShader;

View file

@ -226,7 +226,7 @@ static cvarTable_t cvarTable[] = {
{ &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE },
{ &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
{ &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE },
{ &cg_megagibs, "cg_megagibs", "1", CVAR_ARCHIVE },
{ &cg_megagibs, "cg_megagibs", "0", CVAR_ARCHIVE },
{ &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },
{ &cg_drawStatus, "cg_drawStatus", "1", CVAR_ARCHIVE },
{ &cg_drawTimer, "cg_drawTimer", "0", CVAR_ARCHIVE },
@ -1043,6 +1043,8 @@ static void CG_RegisterGraphics( void ) {
cgs.media.wakeMarkShader = trap_R_RegisterShader( "wake" );
cgs.media.bloodMarkShader = trap_R_RegisterShader( "bloodMark" );
cgs.media.reticleShader = trap_R_RegisterShader( "scope.tga" );
// register the inline models
cgs.numInlineModels = trap_CM_NumInlineModels();
for ( i = 1 ; i < cgs.numInlineModels ; i++ ) {

View file

@ -350,18 +350,20 @@ static void CG_OffsetFirstPersonView( void ) {
VectorCopy(cg.refdef.vieworg, cg.v_death_origin);
float hitRollCoeff = trap_Cvar_VariableValue("vr_rollWhenHit");
// add angles based on damage kick
if ( cg.damageTime ) {
ratio = cg.time - cg.damageTime;
if ( ratio < DAMAGE_DEFLECT_TIME ) {
ratio /= DAMAGE_DEFLECT_TIME;
angles[PITCH] += ratio * cg.v_dmg_pitch;
angles[ROLL] += ratio * cg.v_dmg_roll;
angles[ROLL] += ratio * cg.v_dmg_roll * hitRollCoeff;
} else {
ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;
if ( ratio > 0 ) {
angles[PITCH] += ratio * cg.v_dmg_pitch;
angles[ROLL] += ratio * cg.v_dmg_roll;
angles[ROLL] += ratio * cg.v_dmg_roll * hitRollCoeff;
}
}
}
@ -612,7 +614,6 @@ static void CG_DamageBlendBlob( void ) {
trap_R_AddRefEntityToScene( &ent );
}
/*
===============
CG_CalcViewValues
@ -710,8 +711,8 @@ static int CG_CalcViewValues( void ) {
//If we are zoomed, then we use the refdefViewANgles (which are the weapon angles)
vec3_t angles;
VectorCopy(cg.refdefViewAngles, angles);
angles[ROLL] = 0;
AnglesToAxis( angles, cg.refdef.viewaxis );
angles[ROLL] = vr->hmdorientation[ROLL];
AnglesToAxis( angles, cg.refdef.viewaxis );
} else {
//We are connected to a multiplayer server, so make the appropriate adjustment to the view
//angles as we send orientation to the server that includes the weapon angles
@ -724,7 +725,7 @@ static int CG_CalcViewValues( void ) {
} else {
if (vr->weapon_zoomed) {
vec3_t angles;
angles[ROLL] = 0;
angles[ROLL] = vr->hmdorientation[ROLL];
angles[PITCH] = vr->weaponangles[PITCH];
angles[YAW] = (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]) + vr->weaponangles[YAW];
AnglesToAxis(angles, cg.refdef.viewaxis);

View file

@ -200,7 +200,7 @@ static void UI_SetupMenu_Init( void ) {
setupMenuInfo.setupplayer.color = color_red;
setupMenuInfo.setupplayer.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
/* y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.setupcontrols.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupcontrols.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.setupcontrols.generic.x = 320;
@ -210,7 +210,7 @@ static void UI_SetupMenu_Init( void ) {
setupMenuInfo.setupcontrols.string = "CONTROLS";
setupMenuInfo.setupcontrols.color = color_red;
setupMenuInfo.setupcontrols.style = UI_CENTER;
*/
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.setupsystem.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupsystem.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
@ -307,7 +307,7 @@ static void UI_SetupMenu_Init( void ) {
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framel );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framer );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupplayer );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupcontrols );
// Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupcontrols );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupsystem );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.game );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.vr );

View file

@ -48,10 +48,12 @@ VR OPTIONS MENU
#define ID_WEAPONPITCH 133
#define ID_HEIGHTADJUST 134
#define ID_TWOHANDED 135
#define ID_DRAWHUD 136
#define ID_GORE 137
#define ID_SCOPE 136
#define ID_DRAWHUD 137
#define ID_ROLLHIT 138
#define ID_GORE 139
#define ID_BACK 138
#define ID_BACK 140
#define NUM_HUDDEPTH 6
#define NUM_DIRECTIONMODE 2
@ -76,6 +78,8 @@ typedef struct {
menuslider_s weaponpitch;
menuslider_s heightadjust;
menuradiobutton_s twohanded;
menuradiobutton_s scope;
menuradiobutton_s rollhit;
menulist_s gore;
menubitmap_s back;
@ -110,15 +114,17 @@ static void VR_SetMenuItems( void ) {
s_VR.refreshrate.curvalue = 4;
break;
}
s_VR.weaponpitch.curvalue = trap_Cvar_VariableValue( "vr_weaponPitch" ) != 0;
s_VR.weaponpitch.curvalue = trap_Cvar_VariableValue( "vr_weaponPitch" ) + 25;
s_VR.heightadjust.curvalue = trap_Cvar_VariableValue( "vr_heightAdjust" ) != 0;
s_VR.twohanded.curvalue = trap_Cvar_VariableValue( "vr_twoHandedWeapons" ) != 0;
s_VR.scope.curvalue = trap_Cvar_VariableValue( "vr_weaponScope" ) != 0;
s_VR.rollhit.curvalue = trap_Cvar_VariableValue( "vr_rollWhenHit" ) != 0;
//GORE
{
int level = trap_Cvar_VariableValue( "cg_gibs" ) +
trap_Cvar_VariableValue( "com_blood" ) +
trap_Cvar_VariableValue( "cg_megagibs" );
int level = trap_Cvar_VariableValue( "com_blood" ) +
trap_Cvar_VariableValue( "cg_gibs" ) +
trap_Cvar_VariableValue( "cg_megagibs" );
s_VR.gore.curvalue = level % NUM_GORE;
}
@ -175,7 +181,7 @@ static void VR_Event( void* ptr, int notification ) {
break;
case ID_WEAPONPITCH:
trap_Cvar_SetValue( "vr_weaponPitch", s_VR.weaponpitch.curvalue );
trap_Cvar_SetValue( "vr_weaponPitch", s_VR.weaponpitch.curvalue - 25 );
break;
case ID_HEIGHTADJUST:
@ -186,10 +192,18 @@ static void VR_Event( void* ptr, int notification ) {
trap_Cvar_SetValue( "vr_twoHandedWeapons", s_VR.twohanded.curvalue );
break;
case ID_SCOPE:
trap_Cvar_SetValue( "vr_weaponScope", s_VR.scope.curvalue );
break;
case ID_DRAWHUD:
trap_Cvar_SetValue( "cg_drawStatus", s_VR.drawhud.curvalue );
break;
case ID_ROLLHIT:
trap_Cvar_SetValue( "vr_rollWhenHit", s_VR.rollhit.curvalue );
break;
case ID_GORE: {
switch ((int)s_VR.gore.curvalue) {
case 0:
@ -198,8 +212,8 @@ static void VR_Event( void* ptr, int notification ) {
trap_Cvar_SetValue( "cg_megagibs", 0);
break;
case 1:
trap_Cvar_SetValue( "com_blood", 0);
trap_Cvar_SetValue( "cg_gibs", 1);
trap_Cvar_SetValue( "com_blood", 1);
trap_Cvar_SetValue( "cg_gibs", 0);
trap_Cvar_SetValue( "cg_megagibs", 0);
break;
case 2:
@ -277,9 +291,9 @@ static void VR_MenuInit( void ) {
static const char *s_gore[] =
{
"None",
"Gibs Only",
"Blood Only",
"Blood & Gibs",
"Extra Gore",
"Extra Gore (Performance Hit)",
NULL
};
@ -417,6 +431,24 @@ static void VR_MenuInit( void ) {
s_VR.twohanded.generic.x = VR_X_POS;
s_VR.twohanded.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.scope.generic.type = MTYPE_RADIOBUTTON;
s_VR.scope.generic.name = "Railgun Scope:";
s_VR.scope.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.scope.generic.callback = VR_Event;
s_VR.scope.generic.id = ID_SCOPE;
s_VR.scope.generic.x = VR_X_POS;
s_VR.scope.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.rollhit.generic.type = MTYPE_RADIOBUTTON;
s_VR.rollhit.generic.name = "Roll when hit:";
s_VR.rollhit.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.rollhit.generic.callback = VR_Event;
s_VR.rollhit.generic.id = ID_ROLLHIT;
s_VR.rollhit.generic.x = VR_X_POS;
s_VR.rollhit.generic.y = y;
y += BIGCHAR_HEIGHT + 10;
s_VR.gore.generic.type = MTYPE_SPINCONTROL;
@ -453,6 +485,7 @@ static void VR_MenuInit( void ) {
Menu_AddItem( &s_VR.menu, &s_VR.weaponpitch );
Menu_AddItem( &s_VR.menu, &s_VR.heightadjust );
Menu_AddItem( &s_VR.menu, &s_VR.twohanded );
Menu_AddItem( &s_VR.menu, &s_VR.scope );
Menu_AddItem( &s_VR.menu, &s_VR.gore );
Menu_AddItem( &s_VR.menu, &s_VR.back );

View file

@ -28,8 +28,9 @@ cvar_t *vr_directionMode = NULL;
cvar_t *vr_weaponPitch = NULL;
cvar_t *vr_twoHandedWeapons = NULL;
cvar_t *vr_refreshrate = NULL;
cvar_t *vr_weaponZoom = NULL;
cvar_t *vr_weaponScope = NULL;
cvar_t *vr_jumpTrigger = NULL;
cvar_t *vr_rollWhenHit = NULL;
engine_t* VR_Init( ovrJava java )
{
@ -59,8 +60,9 @@ void VR_InitCvars( void )
vr_heightAdjust = Cvar_Get ("vr_heightAdjust", "0.0", CVAR_ARCHIVE);
vr_twoHandedWeapons = Cvar_Get ("vr_twoHandedWeapons", "1", CVAR_ARCHIVE);
vr_refreshrate = Cvar_Get ("vr_refreshrate", "0", CVAR_ARCHIVE);
vr_weaponZoom = Cvar_Get ("vr_weaponZoom", "0", CVAR_ARCHIVE);
vr_weaponScope = Cvar_Get ("vr_weaponScope", "1", CVAR_ARCHIVE);
vr_jumpTrigger = Cvar_Get ("vr_jumpTrigger", "1", CVAR_ARCHIVE);
vr_rollWhenHit = Cvar_Get ("vr_rollWhenHit", "0", CVAR_ARCHIVE);
// Values are: scale,right,up,forward,pitch,yaw,roll
// VALUES PROVIDED BY SkillFur - Thank-you!

View file

@ -70,7 +70,7 @@ extern cvar_t *vr_weaponPitch;
extern cvar_t *vr_heightAdjust;
extern cvar_t *vr_twoHandedWeapons;
extern cvar_t *vr_refreshrate;
extern cvar_t *vr_weaponZoom;
extern cvar_t *vr_weaponScope;
extern cvar_t *vr_jumpTrigger;
@ -244,10 +244,10 @@ static void IN_VRController( qboolean isRightController, ovrTracking remoteTrack
vr.offhandoffset[2] = vr.offhandposition[2] - vr.hmdposition[2];
}
vr.weapon_zoomed = vr_weaponZoom->integer &&
vr.weapon_zoomed = vr_weaponScope->integer &&
vr.weapon_stabilised &&
(cl.snap.ps.weapon == WP_RAILGUN) &&
(VectorLength(vr.weaponoffset) < 0.3f) &&
(VectorLength(vr.weaponoffset) < 0.2f) &&
cl.snap.ps.stats[STAT_HEALTH] > 0;
if (vr_twoHandedWeapons->integer && vr.weapon_stabilised)

View file

@ -255,7 +255,7 @@ void VR_DrawFrame( engine_t* engine ) {
}
else {
//Zoom back out quicker
vr.weapon_zoomLevel -= 0.1;
vr.weapon_zoomLevel -= 0.25f;
if (vr.weapon_zoomLevel < 1.0f)
vr.weapon_zoomLevel = 1.0f;
}