Started on JKA

- First person view working
- Merged a lot of other changes from JKO
This commit is contained in:
Simon 2023-02-01 21:11:04 +00:00
parent 89fb6f6887
commit 773593c8bd
27 changed files with 4533 additions and 58 deletions

View file

@ -27,6 +27,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "cg_headers.h"
#include "cg_media.h" //just for cgs....
#include <JKVR/VrClientInfo.h>
void CG_TargetCommand_f( void );
extern qboolean player_locked;
@ -216,6 +217,13 @@ int cmdcmp( const void *a, const void *b ) {
return Q_stricmp( (const char *)a, ((consoleCommand_t*)b)->cmd );
}
void CG_ItemSelectorSelect_f( void );
void CG_ItemSelectorNext_f( void );
void CG_ItemSelectorPrev_f( void );
void CG_ToggleSaber_f( void );
void CG_ExitScope_f( void );
void CG_EnterScope_f( void );
/* This array MUST be sorted correctly by alphabetical name field */
static consoleCommand_t commands[] = {
{ "cam_disable", CMD_CGCam_Disable }, //gets out of camera mode for debuggin
@ -252,6 +260,12 @@ static consoleCommand_t commands[] = {
{ "weapprev", CG_PrevWeapon_f },
{ "writecam", CG_WriteCam_f },
{ "zoom", CG_ToggleBinoculars },
{ "itemselectorselect", CG_ItemSelectorSelect_f },
{ "itemselectornext", CG_ItemSelectorNext_f },
{ "itemselectorprev", CG_ItemSelectorPrev_f },
{ "togglesaber", CG_ToggleSaber_f },
{ "exitscope", CG_ExitScope_f },
{ "enterscope", CG_EnterScope_f }
};
static const size_t numCommands = ARRAY_LEN( commands );

View file

@ -36,10 +36,11 @@ extern vmCvar_t cg_debugHealthBars;
extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
void CG_DrawIconBackground(void);
void CG_DrawMissionInformation( void );
void CG_DrawMoveSpeedIcon(void);
void CG_DrawInventorySelect( void );
void CG_DrawForceSelect( void );
void CG_DrawIconBackground(void);
void CG_DrawMissionInformation( void );
qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y);
qboolean CG_WorldCoordToScreenCoordFloat(vec3_t worldCoord, float *x, float *y);
@ -1622,6 +1623,47 @@ static qboolean CG_DrawCustomHealthHud( centity_t *cent )
return qtrue;
}
/*
==============
CG_DrawWeapReticle
==============
*/
static void CG_DrawWeapReticle( void )
{
vec4_t light_color = {0.7, 0.7, 0.7, 1};
vec4_t black = {0.0, 0.0, 0.0, 1};
float indent = 0.16;
float X_WIDTH=640;
float Y_HEIGHT=480;
float x = (X_WIDTH * indent), y = (Y_HEIGHT * indent), w = (X_WIDTH * (1-(2*indent))) / 2.0f, h = (Y_HEIGHT * (1-(2*indent))) / 2;
// sides
CG_FillRect( 0, 0, (X_WIDTH * indent), Y_HEIGHT, black );
CG_FillRect( X_WIDTH * (1 - indent), 0, (X_WIDTH * indent), Y_HEIGHT, black );
// top/bottom
CG_FillRect( X_WIDTH * indent, 0, X_WIDTH * (1-indent), Y_HEIGHT * indent, black );
CG_FillRect( X_WIDTH * indent, Y_HEIGHT * (1-indent), X_WIDTH * (1-indent), Y_HEIGHT * indent, black );
{
// center
if ( cgs.media.reticleShader ) {
cgi_R_DrawStretchPic( x, y, w, h, 0, 0, 1, 1, cgs.media.reticleShader ); // tl
cgi_R_DrawStretchPic( x + w, y, w, h, 1, 0, 0, 1, cgs.media.reticleShader ); // tr
cgi_R_DrawStretchPic( x, y + h, w, h, 0, 1, 1, 0, cgs.media.reticleShader ); // bl
cgi_R_DrawStretchPic( x + w, y + h, w, h, 1, 1, 0, 0, cgs.media.reticleShader ); // br
}
// hairs
CG_FillRect( 84, 239, 177, 2, black ); // left
CG_FillRect( 320, 242, 1, 58, black ); // center top
CG_FillRect( 319, 300, 2, 178, black ); // center bot
CG_FillRect( 380, 239, 177, 2, black ); // right
}
}
//--------------------------------------
static void CG_DrawBatteryCharge( void )
{
@ -4001,6 +4043,25 @@ static void CG_Draw2DScreenTints( void )
CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
}
}
/*
-------------------------
CG_DrawZoomBorders
-------------------------
*/
static void CG_DrawZoomBorders( void )
{
vec4_t modulate;
modulate[0] = modulate[1] = modulate[2] = 0.0f;
modulate[3] = 1.0f;
int bar_height = 80;
CG_FillRect( 0, 0, 640, bar_height, modulate );
CG_FillRect( 0, 480 - 80, 640, bar_height, modulate );
}
/*
=================
CG_Draw2D
@ -4047,7 +4108,15 @@ static void CG_Draw2D( void )
CGCam_DrawWideScreen();
}
//Everything below here needs to be fitted into the visible portion of the display
if (cg.zoomMode == 4)
{
CG_DrawWeapReticle();
}
else if (cg.zoomMode != 0)
{
CG_DrawZoomBorders();
}
cg.drawingHUD = CG_HUD_SCALED;
CG_DrawBatteryCharge();
@ -4060,13 +4129,16 @@ static void CG_Draw2D( void )
// Draw this before the text so that any text won't get clipped off
if ( !in_camera )
{
cg.drawingHUD = CG_HUD_NORMAL;
cg.drawingHUD = CG_HUD_ZOOM;
CG_DrawZoomMask();
cg.drawingHUD = CG_HUD_SCALED;
}
CG_DrawScrollText();
CG_DrawCaptionText();
if (!vr->immersive_cinematics) {
CG_DrawCaptionText();
}
if ( in_camera )
{//still draw the saber clash flare, but nothing else
@ -4106,6 +4178,8 @@ static void CG_Draw2D( void )
//CG_DrawIconBackground();
}
CG_DrawMoveSpeedIcon();
CG_DrawWeaponSelect();
if ( cg.zoomMode == 0 )
@ -4383,23 +4457,100 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
CG_Error( "CG_DrawActive: Undefined stereoView" );
}
in_misccamera = ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname ));
//Only vehicle in JK2 is the AT-ST
vr->in_vehicle = (g_entities[0].client &&
g_entities[0].client->NPC_class == CLASS_ATST);
vr->remote_npc = !Q_stricmp( "NPC", g_entities[cg.snap->ps.viewEntity].classname );
vr->remote_droid = false;
vr->remote_turret = false;
vr->emplaced_gun = ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & EF_LOCKED_TO_WEAPON );
in_misccamera = false;
if (cg.snap->ps.viewEntity) {
if (g_entities[cg.snap->ps.viewEntity].NPC_type) {
char modelName[256];
Q_strncpyz(modelName, g_entities[cg.snap->ps.viewEntity].NPC_type, sizeof modelName);
vr->remote_droid = vr->remote_npc &&
(!Q_stricmp("gonk", modelName) || !Q_stricmp("seeker", modelName) ||
!Q_stricmp("remote", modelName)
|| !Q_strncmp("r2d2", modelName, 4) ||
!Q_strncmp("r5d2", modelName, 4) || !Q_stricmp("mouse", modelName));
}
vr->remote_turret = (!Q_stricmp("misc_panel_turret",
g_entities[cg.snap->ps.viewEntity].classname));
in_misccamera = (!Q_stricmp("misc_camera", g_entities[cg.snap->ps.viewEntity].classname))
|| vr->remote_droid
|| vr->remote_turret;
}
cg.refdef.worldscale = cg_worldScale.value;
bool usingScope = (cg.zoomMode == 2 || cg.zoomMode == 4);
//Normal 1st person view angles
if (!in_camera &&
!in_misccamera) {
!in_misccamera &&
!vr->remote_droid &&
!vr->remote_npc &&
!usingScope &&
!cg.renderingThirdPerson)
{
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
}
//Controlling an NPC that isn't a droid
if (vr->remote_npc &&
!vr->remote_droid)
{
if (vr->remote_cooldown > cg.time)
{
VectorCopy(cg.refdefViewAngles, vr->remote_angles);
vr->take_snap = true;
}
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
cg.refdef.viewangles[YAW] = vr->remote_angles[YAW] + (vr->hmdorientation[YAW] - vr->hmdorientation_snap[YAW]) + (vr->snapTurn - vr->remote_snapTurn);
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
}
//Sniper/E11 scope
if (usingScope)
{
cg.refdef.viewangles[ROLL] = vr->clientviewangles[ROLL];
cg.refdef.viewangles[PITCH] = vr->weaponangles[PITCH];
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW]
+ vr->weaponangles[YAW] + SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
}
//Normal 3rd person view angles
if (!in_camera &&
!in_misccamera &&
cg.renderingThirdPerson)
{
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
(vr->hmdorientation[YAW] - vr->hmdorientation_first[YAW]) +
SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
}
//Immersive cinematic sequence 6DoF
if ((in_camera && vr->immersive_cinematics) || vr->emplaced_gun || cg.renderingThirdPerson)
{
BG_ConvertFromVR(vr->hmdposition_offset, cg.refdef.vieworg, cg.refdef.vieworg);
}
// clear around the rendered view if sized down
CG_TileClear();
// offset vieworg appropriately if we're doing stereo separation
VectorCopy( cg.refdef.vieworg, baseOrg );
if ( separation != 0 && (!in_camera || vr->immersive_cinematics) && !in_misccamera) {
if ( separation != 0 && (!in_camera || vr->immersive_cinematics) && !in_misccamera && !usingScope ) {
VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg );
}
@ -4408,9 +4559,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cgi_R_LAGoggles();
}
bool in_turret = ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & EF_LOCKED_TO_WEAPON );
if (!in_turret && (!in_camera || vr->immersive_cinematics)) {
if (!vr->emplaced_gun && !in_misccamera && !in_camera) {
//Vertical Positional Movement
cg.refdef.vieworg[2] -= DEFAULT_PLAYER_HEIGHT;
cg.refdef.vieworg[2] += (vr->hmdposition[1] + cg_heightAdjust.value) * cg_worldScale.value;

View file

@ -68,7 +68,9 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#define MAX_STEP_CHANGE 32
#define MAX_VERTS_ON_POLY 10
#define MAX_MARK_POLYS 256
#define MAX_MARK_POLYS 2048
#define MARK_TOTAL_TIME 10000
#define MARK_FADE_TIME 1000
#define STAT_MINUS 10 // num frame for '-' stats digit
@ -100,8 +102,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#define WAVE_AMPLITUDE 1
#define WAVE_FREQUENCY 0.4
#define DEFAULT_PLAYER_HEIGHT 64
#define DEFAULT_PLAYER_HEIGHT 58
//=================================================
// player entities need to track more information
@ -202,6 +203,7 @@ typedef centity_s centity_t;
typedef struct markPoly_s {
struct markPoly_s *prevMark, *nextMark;
int time;
int fadeTime; // custom fade time (to slow down fade of saber burn marks)
qhandle_t markShader;
qboolean alphaFade; // fade alpha instead of rgb
float color[4];
@ -453,6 +455,15 @@ typedef struct {
int weaponAnimation;
int weaponAnimationTime;
int itemSelectorType; // 0 - weapons, 1 - gadgets, 2 - fighting-style, 3 - force powers
int itemSelectorSelection;
int itemSelectorTime;
vec3_t itemSelectorOrigin;
vec3_t itemSelectorOffset;
int moveSpeedSelect;
int moveSpeedSelectTime;
int inventorySelect; // Current inventory item chosen
int inventorySelectTime;
@ -585,6 +596,7 @@ extern vmCvar_t cg_drawFPS;
extern vmCvar_t cg_drawSnapshot;
extern vmCvar_t cg_drawAmmoWarning;
extern vmCvar_t cg_drawCrosshair;
extern vmCvar_t cg_drawCrosshairForce;
extern vmCvar_t cg_dynamicCrosshair;
extern vmCvar_t cg_crosshairForceHint;
extern vmCvar_t cg_crosshairIdentifyTarget;
@ -635,6 +647,9 @@ extern vmCvar_t cg_thirdPersonCameraDamp;
extern vmCvar_t cg_thirdPersonTargetDamp;
extern vmCvar_t cg_saberAutoThird;
extern vmCvar_t cg_gunAutoFirst;
extern vmCvar_t cg_debugSaberCombat;
extern vmCvar_t cg_saberBurnMarkCoolDownTime;
extern vmCvar_t cg_autoUseBacta;
extern vmCvar_t cg_zProj;
extern vmCvar_t cg_stereoSeparation;
@ -873,6 +888,8 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire );
void CG_AddViewWeapon (playerState_t *ps);
void CG_DrawWeaponSelect( void );
void CG_DrawItemSelector( void );
void CG_OutOfAmmoChange( void ); // should this be in pmove?
//
@ -975,6 +992,9 @@ void cgi_Cvar_Set( const char *var_name, const char *value );
char* cgi_Cvar_Get( const char *var_name );
//Haptics
int cgi_HapticEvent( char *description, int position, int channel, int intensity, float yaw, float height);
// ServerCommand and ConsoleCommand parameter access
int cgi_Argc( void );
void cgi_Argv( int n, char *buffer, int bufferLength );

View file

@ -307,6 +307,9 @@ vmCvar_t cg_thirdPersonCameraDamp;
vmCvar_t cg_thirdPersonTargetDamp;
vmCvar_t cg_saberAutoThird;
vmCvar_t cg_gunAutoFirst;
vmCvar_t cg_debugSaberCombat;
vmCvar_t cg_saberBurnMarkCoolDownTime;
vmCvar_t cg_autoUseBacta;
vmCvar_t cg_thirdPersonAlpha;
vmCvar_t cg_thirdPersonAutoAlpha;
@ -1426,6 +1429,11 @@ static void CG_RegisterGraphics( void ) {
cgs.media.cloakedShader = cgi_R_RegisterShader( "gfx/effects/cloakedShader" );
cgi_R_RegisterShader( "gfx/misc/ion_shield" );
//VR Hand models
cgs.media.handModel_relaxed = cgi_R_RegisterModel( "models/players/kyle/lhand_r.md3" );
cgs.media.handModel_force = cgi_R_RegisterModel( "models/players/kyle/lhand_f.md3" );
cgs.media.boltShader = cgi_R_RegisterShader( "gfx/misc/blueLine" );
// FIXME: do these conditionally
@ -3093,7 +3101,7 @@ INVENTORY SELECTION
CG_InventorySelectable
===============
*/
static inline qboolean CG_InventorySelectable( int index)
qboolean CG_InventorySelectable( int index)
{
if (cg.snap->ps.inventory[index]) // Is there any in the inventory?
{

View file

@ -125,6 +125,7 @@ typedef struct {
qhandle_t charsetShader;
qhandle_t whiteShader;
qhandle_t selectShader;
qhandle_t crosshairShader[NUM_CROSSHAIRS];
qhandle_t backTileShader;
// qhandle_t noammoShader;
@ -145,6 +146,8 @@ typedef struct {
qhandle_t turretComputerOverlayShader;
qhandle_t turretCrossHairShader;
qhandle_t iconMoveSpeed[3];
//Chunks
qhandle_t chunkModels[NUM_CHUNK_TYPES][4];
sfxHandle_t chunkSound;
@ -178,6 +181,10 @@ typedef struct {
qhandle_t explosionModel;
qhandle_t surfaceExplosionShader;
//Hand models
qhandle_t handModel_relaxed;
qhandle_t handModel_force;
qhandle_t halfShieldModel;
qhandle_t solidWhiteShader;
@ -186,6 +193,10 @@ typedef struct {
qhandle_t refractShader;
qhandle_t boltShader;
qhandle_t reticleShader;
qhandle_t vignetteShader;
// Disruptor zoom graphics
qhandle_t disruptorMask;
qhandle_t disruptorInsert;

View file

@ -364,6 +364,12 @@ static void CG_RegisterCustomSounds(clientInfo_t *ci, int iSoundEntryBase,
}
//SB: Never render any player model if 1st person and using the saber
bool CG_getPlayer1stPersonSaber(const centity_t *cent) {
return (!cent->gent->NPC && !cg.renderingThirdPerson &&
cent->gent->client->ps.weapon == WP_SABER);
}
/*
================
@ -4624,12 +4630,18 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
}
}
bool player1stPersonSaber = CG_getPlayer1stPersonSaber(cent);
// if ( gent->client->ps.powerups[PW_WEAPON_OVERCHARGE] > 0 )
// {
// centity_t *cent = &cg_entities[gent->s.number];
// cgi_S_AddLoopingSound( 0, cent->lerpOrigin, vec3_origin, cgs.media.overchargeLoopSound );
// }
if (player1stPersonSaber) {
ent->renderfx = RF_THIRD_PERSON;
}
//get the dude's color choice in
ent->shaderRGBA[0] = gent->client->renderInfo.customRGBA[0];
ent->shaderRGBA[1] = gent->client->renderInfo.customRGBA[1];
@ -5907,9 +5919,26 @@ static void CG_CreateSaberMarks( vec3_t start, vec3_t end, vec3_t normal )
v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * (0.15f + Q_flrand(0.0f, 1.0f) * 0.05f);
}
// save it persistantly, do burn first
// Allow to prolong saber mark cool down time
int glowFadeTime = MARK_FADE_TIME + (cg_saberBurnMarkCoolDownTime.value * MARK_TOTAL_TIME);
// If glow fade time is longer than mark time, prolong mark time
int glowExtraTime;
if (glowFadeTime > MARK_TOTAL_TIME - 8500) {
glowExtraTime = glowFadeTime - (MARK_TOTAL_TIME - 8500);
} else {
glowExtraTime = 0;
}
// Maker sure burn mark is always visible for some time after glow cool down
int burnExtraTime;
if (glowFadeTime > MARK_TOTAL_TIME - MARK_FADE_TIME) {
burnExtraTime = glowFadeTime - (MARK_TOTAL_TIME - MARK_FADE_TIME);
} else {
burnExtraTime = 0;
}
// Save it persistantly, do burn first
mark = CG_AllocMark();
mark->time = cg.time;
mark->time = cg.time + burnExtraTime;
mark->alphaFade = qtrue;
mark->markShader = cgs.media.rivetMarkShader;
mark->poly.numVerts = mf->numPoints;
@ -5917,9 +5946,9 @@ static void CG_CreateSaberMarks( vec3_t start, vec3_t end, vec3_t normal )
memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );
// And now do a glow pass
// by moving the start time back, we can hack it to fade out way before the burn does
mark = CG_AllocMark();
mark->time = cg.time - 8500;
mark->time = cg.time - 8500 + glowExtraTime;
mark->fadeTime = glowFadeTime;
mark->alphaFade = qfalse;
mark->markShader = cgi_R_RegisterShader("gfx/effects/saberDamageGlow" );
mark->poly.numVerts = mf->numPoints;
@ -5989,6 +6018,12 @@ static void CG_AddSaberBladeGo( centity_t *cent, centity_t *scent, refEntity_t *
{
return;
}
if (vr->item_selector && cent->gent->client->ps.clientNum == 0 && !cg.renderingThirdPerson)
{
return;
}
/*
Ghoul2 Insert Start
*/
@ -6568,7 +6603,10 @@ Ghoul2 Insert End
*/
if ( !client->ps.saber[saberNum].blade[bladeNum].active && client->ps.saber[saberNum].blade[bladeNum].length <= 0 )
{
return;
if (vr->saberBlockDebounce > cg.time)
{
//saberColor = SABER_RED;
}
}
if ( (!WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && client->ps.saber[saberNum].trailStyle < 2 )
@ -6736,6 +6774,41 @@ Ghoul2 Insert End
client->ps.saber[saberNum].blade[bladeNum].radius,
client->ps.saber[saberNum].blade[bladeNum].color,
renderfx, (qboolean)!noDlight );
if (CG_getPlayer1stPersonSaber(cent) &&
cent->gent->client->ps.saberEventFlags & (SEF_BLOCKED|SEF_PARRIED) &&
vr->saberBlockDebounce < cg.time)
{
cvar_t *vr_saber_block_debounce_time = gi.cvar("vr_saber_block_debounce_time", "200", CVAR_ARCHIVE); // defined in VrCvars.h
vr->saberBlockDebounce = cg.time + vr_saber_block_debounce_time->integer;
cgi_HapticEvent("shotgun_fire", 0, 0, 100, 0, 0);
}
/* if (CG_getPlayer1stPersonSaber(cent) &&
cent->gent->client->ps.saberLockEnemy != ENTITYNUM_NONE)
{
refEntity_t hiltEnt;
memset( &hiltEnt, 0, sizeof(refEntity_t) );
hiltEnt.hModel = cgs.media.saberHilt;
VectorCopy(org_, hiltEnt.origin);
VectorCopy(hiltEnt.origin, hiltEnt.oldorigin);
vectoangles(axis_[0], hiltEnt.angles);
vec3_t axis[3];
AnglesToAxis(hiltEnt.angles, axis);
VectorSubtract(vec3_origin, axis[2], hiltEnt.axis[0]);
VectorCopy(axis[1], hiltEnt.axis[1]);
VectorCopy(axis[0], hiltEnt.axis[2]);
VectorMA(hiltEnt.origin, 1.0f, hiltEnt.axis[2], hiltEnt.origin);
VectorCopy(hiltEnt.origin, hiltEnt.oldorigin);
cgi_R_AddRefEntityToScene(&hiltEnt);
}
*/
}
void CG_AddSaberBlade( centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles )
@ -6867,6 +6940,12 @@ void CG_Player( centity_t *cent ) {
{
return;
}
if (cent->gent->client->ps.clientNum == 0) {
vr->velocitytriggered = (!cg.renderingThirdPerson &&
(cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE));
}
G_RagDoll(cent->gent, cent->lerpAngles);
@ -6899,9 +6978,12 @@ Ghoul2 Insert Start
// add a water splash if partially in and out of water
CG_PlayerSplash( cent );
bool playerInATST = (g_entities[0].client &&
g_entities[0].client->NPC_class == CLASS_ATST);
// get the player model information
ent.renderfx = 0;
if ( !cg.renderingThirdPerson || cg.zoomMode )
if ( !playerInATST && (!cg.renderingThirdPerson || cg.zoomMode ))
{//in first person or zoomed in
if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD)
{//no viewentity
@ -7267,6 +7349,13 @@ extern vmCvar_t cg_thirdPersonAlpha;
{
VectorCopy( ent.origin, cent->gent->client->renderInfo.muzzlePoint );
VectorCopy( ent.axis[0], cent->gent->client->renderInfo.muzzleDir );
if ( !cg.renderingThirdPerson && cent->gent->client->ps.clientNum == 0 && (cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE))
{
vec3_t angles;
BG_CalculateVRSaberPosition(cent->gent->client->renderInfo.muzzlePoint, angles);
AngleVectors( angles, cent->gent->client->renderInfo.muzzleDir, NULL, NULL );
}
}
}
//now try to get the right data
@ -7281,6 +7370,11 @@ extern vmCvar_t cg_thirdPersonAlpha;
&boltMatrix, G2Angles, ent.origin, cg.time,
cgs.model_draw, cent->currentState.modelScale );
gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.handRPoint );
if (!cg.renderingThirdPerson && !cent->gent->client->ps.saberInFlight && cent->gent->client->ps.clientNum == 0)
{
vec3_t angles;
BG_CalculateVRSaberPosition(cent->gent->client->renderInfo.handRPoint, angles);
}
}
if ( cent->gent->handLBolt != -1 )
{
@ -7289,6 +7383,11 @@ extern vmCvar_t cg_thirdPersonAlpha;
&boltMatrix, G2Angles, ent.origin, cg.time,
cgs.model_draw, cent->currentState.modelScale );
gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.handLPoint );
if (!cg.renderingThirdPerson && !cent->gent->client->ps.saberInFlight && cent->gent->client->ps.clientNum == 0)
{
vec3_t angles;
BG_CalculateVROffHandPosition(cent->gent->client->renderInfo.handLPoint, angles);
}
}
if ( cent->gent->footLBolt != -1 )
{
@ -7995,9 +8094,13 @@ Ghoul2 Insert End
// add a water splash if partially in and out of water
CG_PlayerSplash( cent );
// get the player model information
bool playerInATST = (g_entities[0].client &&
g_entities[0].client->NPC_class == CLASS_ATST);
// get the player model information
renderfx = 0;
if ( !cg.renderingThirdPerson || cg.zoomMode )
if ( !playerInATST && (!cg.renderingThirdPerson || cg.zoomMode ))
{
if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD)
{//no viewentity
@ -8180,14 +8283,18 @@ Ghoul2 Insert End
//FIXME: allow it to be put anywhere and move this out of if(torso.hModel)
//Will have to call CG_PositionRotatedEntityOnTag
//CG_PositionEntityOnTag( &gun, &torso, torso.hModel, "tag_weapon");
vec3_t angs;
BG_CalculateVRWeaponPosition(gun.origin, angs);
AnglesToAxis(angs, gun.axis);
//Gotta move this forward but test for now
VectorCopy( gun.origin, gun.lightingOrigin );
if (cent->gent->client->ps.clientNum == 0)
{
vec3_t angs;
BG_CalculateVRWeaponPosition(gun.origin, angs);
AnglesToAxis(angs, gun.axis);
//Gotta move this forward but test for now
VectorCopy( gun.origin, gun.lightingOrigin );
}
else
{
CG_PositionEntityOnTag( &gun, &torso, torso.hModel, "tag_weapon");
}
//--------------------- start saber hacks
/*
@ -8359,6 +8466,39 @@ Ghoul2 Insert End
}
if (CG_getPlayer1stPersonSaber(cent) && !cent->currentState.saberInFlight && !vr->item_selector &&
cent->gent->client->ps.saberLockEnemy == ENTITYNUM_NONE)
{
/* refEntity_t hiltEnt;
memset( &hiltEnt, 0, sizeof(refEntity_t) );
hiltEnt.hModel = cgs.media.saberHilt;
BG_CalculateVRSaberPosition(hiltEnt.origin, hiltEnt.angles);
vec3_t axis[3];
AnglesToAxis(hiltEnt.angles, axis);
VectorSubtract(vec3_origin, axis[2], hiltEnt.axis[0]);
VectorCopy(axis[1], hiltEnt.axis[1]);
VectorCopy(axis[0], hiltEnt.axis[2]);
VectorMA(hiltEnt.origin, 1.0f, hiltEnt.axis[2], hiltEnt.origin);
VectorCopy(hiltEnt.origin, hiltEnt.oldorigin);
for (auto & axi : hiltEnt.axis)
VectorScale(axi, 0.85f, axi);
cgi_R_AddRefEntityToScene(&hiltEnt);
*/
//Should be a much better place to do this...
static int playingSaberSwingSound = 0;
if (vr->primaryVelocityTriggeredAttack && ((cg.time - playingSaberSwingSound) > 800))
{
//cgi_S_StartSound ( hiltEnt.origin, cent->gent->s.number, CHAN_AUTO, cgi_S_RegisterSound( va( "sound/weapons/saber/saberhup%d.wav", Q_irand( 1, 9 ) ) ) );
playingSaberSwingSound = cg.time;
}
}
//FIXME: for debug, allow to draw a cone of the NPC's FOV...
if ( cent->currentState.number == 0 && cg.renderingThirdPerson )
{

View file

@ -457,6 +457,10 @@ void cgi_R_WorldEffectCommand( const char *command )
Q_syscall( CG_R_WORLD_EFFECT_COMMAND, command );
}
int cgi_HapticEvent( char *description, int position, int channel, int intensity, float yaw, float height) {
return Q_syscall( CG_HAPTICEVENT, description, position, channel, intensity, PASSFLOAT(yaw), PASSFLOAT(height));
}
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile /* = NULL */) {
return Q_syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits, psAudioFile);

View file

@ -31,6 +31,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "FxScheduler.h"
#include "../game/wp_saber.h"
#include "../game/g_vehicles.h"
#include "bg_local.h"
#include <JKVR/VrClientInfo.h>
#define MASK_CAMERACLIP (MASK_SOLID)
@ -1677,7 +1678,7 @@ static qboolean CG_CalcViewValues( void ) {
}
}
if ( (cg.renderingThirdPerson||cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE)
if ( (cg.renderingThirdPerson)//||cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE)
&& !cg.zoomMode
&& !viewEntIsCam )
{
@ -2114,10 +2115,10 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
cg_thirdPerson.integer
|| (cg.snap->ps.stats[STAT_HEALTH] <= 0)
|| (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
|| (
(g_entities[0].client&&g_entities[0].client->NPC_class==CLASS_ATST)
// || (
// (g_entities[0].client&&g_entities[0].client->NPC_class==CLASS_ATST)
// || (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)
)
/// )
);
vr->third_person = cg.renderingThirdPerson;
@ -2215,19 +2216,94 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
cgi_CM_SnapPVS( cg.refdef.vieworg, cg.snap->areamask );
}
// Don't draw the in-view weapon when in camera mode
if ( !in_camera
&& !cg_pano.integer
&& cg.snap->ps.weapon != WP_SABER
&& ( cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD ) )
if (cg.predicted_player_state.stats[STAT_HEALTH] > 0 &&
cg.predicted_player_state.stats[STAT_HEALTH] < 40)
{
CG_AddViewWeapon( &cg.predicted_player_state );
cgi_HapticEvent("heartbeat", 0, 0, cg.predicted_player_state.stats[STAT_HEALTH], 0, 0);
}
else if( cg.snap->ps.viewEntity != 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
if (vr->item_selector)
{
if( g_entities[cg.snap->ps.viewEntity].client && g_entities[cg.snap->ps.viewEntity].NPC )
CG_DrawItemSelector();
}
else
{
// Don't draw the in-view weapon when in camera mode
if ( !in_camera
&& !cg_pano.integer
&& cg.snap->ps.weapon != WP_SABER
&& ( cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD ) )
{
CG_AddViewWeapon( &g_entities[cg.snap->ps.viewEntity ].client->ps ); // HAX - because I wanted to --eez
CG_AddViewWeapon( &cg.predicted_player_state );
}
else if( cg.snap->ps.viewEntity != 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
{
if( g_entities[cg.snap->ps.viewEntity].client && g_entities[cg.snap->ps.viewEntity].NPC )
{
CG_AddViewWeapon( &g_entities[cg.snap->ps.viewEntity ].client->ps ); // HAX - because I wanted to --eez
}
}
//Render hand models when appropriate
if (!in_camera
&& !cg.renderingThirdPerson
&& cg.predicted_player_state.stats[STAT_HEALTH] > 0
&& cg.snap->ps.weapon != WP_MELEE
&& !vr->weapon_stabilised
&& !vr->in_vehicle
&& !cg_pano.integer
&& (cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD))
{
vec3_t end, forward;
refEntity_t handEnt;
memset( &handEnt, 0, sizeof(refEntity_t) );
BG_CalculateVROffHandPosition(handEnt.origin, handEnt.angles);
//Move it back a bit?
AngleVectors(handEnt.angles, forward, NULL, NULL);
VectorMA( handEnt.origin, -3.0f, forward, handEnt.origin );
handEnt.renderfx = RF_DEPTHHACK | RF_VRVIEWMODEL;
if (cg.snap->ps.powerups[PW_FORCE_PUSH] > cg.time ||
(cg.snap->ps.forcePowersActive & (1<<FP_GRIP)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_LIGHTNING)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_ABSORB)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_DRAIN)))
{
handEnt.hModel = cgs.media.handModel_force;
}
else
{
handEnt.hModel = cgs.media.handModel_relaxed;
}
VectorCopy(handEnt.origin, handEnt.oldorigin);
AnglesToAxis(handEnt.angles, handEnt.axis);
for ( int i = 0; i < 3; i++ ) {
VectorScale( handEnt.axis[i], (vr->right_handed || i != 1) ? 1.0f : -1.0f, handEnt.axis[i] );
}
cgi_R_AddRefEntityToScene(&handEnt);
if (cg.snap->ps.weapon == WP_NONE)
{
BG_CalculateVRWeaponPosition(handEnt.origin, handEnt.angles);
//Move it back a bit?
AngleVectors(handEnt.angles, forward, NULL, NULL);
VectorMA( handEnt.origin, -3.0f, forward, handEnt.origin );
VectorCopy(handEnt.origin, handEnt.oldorigin);
vec3_t axis[3];
AnglesToAxis(handEnt.angles, handEnt.axis);
for ( int i = 0; i < 3; i++ ) {
VectorScale( handEnt.axis[i], (!vr->right_handed || i != 1) ? 1.0f : -1.0f, handEnt.axis[i] );
}
cgi_R_AddRefEntityToScene(&handEnt);
}
}
}

View file

@ -1201,26 +1201,31 @@ void CG_AddViewWeapon( playerState_t *ps )
trace_t trace;
VectorMA(origin, 256, forward, endForward);
static vec3_t WHITE ={1.0f,1.0f,1.0f};
static vec3_t RED = {1.0f,0.0f,0.0f};
FX_AddLine( -1, origin, endForward, 0.1f, 4.0f, 0.0f,
1.0f, 0.0f, 0.0f,
WHITE, WHITE, 0.0f,
120, cgi_R_RegisterShader( "gfx/effects/redLine" ),
RED, RED, 0.0f,
120, cgi_R_RegisterShader( "gfx/effects/whiteline2" ),
0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
VectorMA(origin, 20, right, endRight);
vec3_t BLUE = {0.0f,0.0f,1.0f};
FX_AddLine( -1, origin, endRight, 0.1f, 4.0f, 0.0f,
1.0f, 0.0f, 0.0f,
WHITE, WHITE, 0.0f,
120, cgi_R_RegisterShader( "gfx/effects/blueLine" ),
BLUE, BLUE, 0.0f,
120, cgi_R_RegisterShader( "gfx/misc/whiteline2" ),
0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
VectorMA(origin, 20, up, endUp);
vec3_t GREEN = {0.0f,1.0f,0.0f};
FX_AddLine( -1, origin, endUp, 0.1f, 4.0f, 0.0f,
1.0f, 0.0f, 0.0f,
WHITE, WHITE, 0.0f,
GREEN, GREEN, 0.0f,
120, cgi_R_RegisterShader( "gfx/misc/whiteline2" ),
0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
CG_CenterPrint(vr->test_name, 240);
}
// set up gun position
@ -1236,9 +1241,15 @@ void CG_AddViewWeapon( playerState_t *ps )
extraOffset[2] = -6;
}
VectorMA( hand.origin, cg_gun_x.value+extraOffset[0], cg.refdef.viewaxis[0], hand.origin );
VectorMA( hand.origin, (cg_gun_y.value+leanOffset+extraOffset[1]), cg.refdef.viewaxis[1], hand.origin );
VectorMA( hand.origin, (cg_gun_z.value+fovOffset+extraOffset[2]), cg.refdef.viewaxis[2], hand.origin );
if (vr->in_vehicle)
{
//Shunt the origin up if we are in a vehicle to avoid blinding the player with a muzzle flash
VectorMA( hand.origin, 2.0f * cg_worldScale.value, cg.refdef.viewaxis[2], hand.origin );
}
//VectorMA( hand.origin, cg_gun_x.value+extraOffset[0], cg.refdef.viewaxis[0], hand.origin );
//VectorMA( hand.origin, (cg_gun_y.value+leanOffset+extraOffset[1]), cg.refdef.viewaxis[1], hand.origin );
//VectorMA( hand.origin, (cg_gun_z.value+fovOffset+extraOffset[2]), cg.refdef.viewaxis[2], hand.origin );
AnglesToAxis(angles, hand.axis);
@ -1536,6 +1547,31 @@ int CG_WeaponCheck( int weaponIndex )
return value;
}
/*
===================
CG_DrawMoveSpeedIcon
===================
*/
void CG_DrawMoveSpeedIcon(void) {
if ((cg.zoomMode != 0) || !(cg_drawHUD.integer)) {
return;
}
if ((cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD)) {
return;
}
if (cg.moveSpeedSelect != vr->move_speed)
{
cg.moveSpeedSelect = vr->move_speed;
cg.moveSpeedSelectTime = cg.time;
}
if (((cg.moveSpeedSelectTime+WEAPON_SELECT_TIME)>cg.time)) {
cgi_R_SetColor(colorTable[CT_WHITE]);
CG_DrawPic(96, 64, 48, 64, cgs.media.iconMoveSpeed[cg.moveSpeedSelect]);
}
}
int cgi_UI_GetItemText(char *menuFile,char *itemName, char *text);
const char *weaponDesc[13] =
@ -2783,6 +2819,502 @@ void CG_Weapon_f( void )
cg.weaponSelect = num;
}
void Cmd_UseInventory_f(gentity_t *ent);
extern float cg_zoomFov; //from cg_view.cpp
void CG_ExitScope_f( )
{
if ( cg.zoomMode )
{
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomend.wav" );
// already zooming, so must be wanting to turn it off
cg.zoomMode = 0;
cg.zoomTime = cg.time;
cg.zoomLocked = qfalse;
}
}
void CG_EnterScope_f( )
{
if ( cg.zoomMode == 0 || cg.zoomMode == 3 )
{
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomstart.wav" );
// not already zooming, so do it now
if (cg.weaponSelect == WP_DISRUPTOR) {
cg.zoomMode = 2;
cg_zoomFov = 80.0f;
cg.zoomLocked = qfalse;
} else {
//Our specially created E11 Blaster scope
cg.zoomMode = 4;
cg_zoomFov = 30.0f;
cg.zoomLocked = qtrue;
}
}
}
void CG_ToggleSaber_f( )
{
if (player->client->ps.saber->Active())
{
//G_SoundOnEnt( player, CHAN_WEAPON, "sound/weapons/saber/saberon.wav" );
player->client->ps.saber->Deactivate();
}
else
{
player->client->ps.saber->Activate();
//G_SoundOnEnt( player, CHAN_WEAPON, "sound/weapons/saber/saberoff.wav" );
}
}
//Selects the currently selected thing (if one _is_ selected)
void CG_ItemSelectorSelect_f( void )
{
cg.itemSelectorTime = 0;
cgi_Cvar_Set("timescale", "1.0");
if (cg.itemSelectorSelection == -1)
{
return;
}
if (cg.itemSelectorType == 0) // weapons
{
if (cg.weaponSelect == cg.itemSelectorSelection)
{
return;
}
cg.weaponSelectTime = cg.time;
cg.weaponSelect = cg.itemSelectorSelection;
}
else if (cg.itemSelectorType == 1) // gadgets
{
cg.inventorySelectTime = cg.time;
cg.inventorySelect = cg.itemSelectorSelection;
//Immediately use the selected inventory item
if (player)
{
Cmd_UseInventory_f(player);
}
}
else if (cg.itemSelectorType == 2) //fighting style
{
cgi_SendConsoleCommand(va( "setSaberLevel %i\n", cg.itemSelectorSelection + 1));
}
else // 3 - force powers
{
if (cg.forcepowerSelect == cg.itemSelectorSelection)
{
return;
}
cg.forcepowerSelectTime = cg.time;
cg.forcepowerSelect = cg.itemSelectorSelection;
}
//reset ready for next time
cg.itemSelectorSelection = -1;
}
void CG_ItemSelectorNext_f( void )
{
if (cg.itemSelectorType == 3)
{
return;
}
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
//Only show the stance selection if using saber and in third person
int selectors = ((cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) &&
cent->currentState.weapon == WP_SABER && cg_thirdPerson.integer) ? 3 : 2;
cg.itemSelectorType = (cg.itemSelectorType+1) % selectors;
cg.itemSelectorTime = cg.time;
}
void CG_ItemSelectorPrev_f( void )
{
if (cg.itemSelectorType == 3)
{
return;
}
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
//Only show the stance selection if using saber and in third person
int selectors = ((cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) &&
cent->currentState.weapon == WP_SABER && cg_thirdPerson.integer) ? 3 : 2;
if (--cg.itemSelectorType < 0)
cg.itemSelectorType = selectors-1;
cg.itemSelectorTime = cg.time;
}
extern int force_icons[NUM_FORCE_POWERS];
extern int inv_icons[INV_MAX];
qboolean CG_InventorySelectable( int index);
qboolean ForcePower_Valid(int index);
void CG_DrawItemSelector( void )
{
if (cg.predicted_player_state.stats[STAT_HEALTH] <= 0)
{
return;
}
if (cg.itemSelectorTime == 0)
{
cg.itemSelectorTime = cg.time;
if (vr->item_selector == 2)
{
cg.itemSelectorType = 3;
VectorCopy(vr->offhandposition[0], cg.itemSelectorOrigin);
VectorCopy(vr->offhandoffset, cg.itemSelectorOffset);
}
else {
cg.itemSelectorType = 0;
VectorCopy(vr->weaponposition, cg.itemSelectorOrigin);
VectorCopy(vr->weaponoffset, cg.itemSelectorOffset);
}
}
float dist = 10.0f;
float radius = 4.4f;
float scale = 0.05f;
float frac = (cg.time - cg.itemSelectorTime) / 20.0f;
if (frac > 1.0f)
{
frac = 1.0f;
}
cgi_Cvar_Set("timescale", "0.22");
vec3_t controllerOrigin, controllerAngles, controllerOffset, selectorOrigin;
if (cg.itemSelectorType == 3)
{
BG_CalculateVROffHandPosition(controllerOrigin, controllerAngles);
VectorSubtract(vr->offhandposition[0], cg.itemSelectorOrigin, controllerOffset);
}
else
{
BG_CalculateVRWeaponPosition(controllerOrigin, controllerAngles);
VectorSubtract(vr->weaponposition, cg.itemSelectorOrigin, controllerOffset);
}
vec3_t wheelAngles, wheelOrigin, beamOrigin, wheelForward, wheelRight, wheelUp;
vec3_t angles;
VectorClear(angles);
angles[YAW] = vr->hmdorientation[YAW];
BG_CalculateVRPositionInWorld(cg.itemSelectorOrigin, cg.itemSelectorOffset, angles, wheelOrigin, wheelAngles);
AngleVectors(wheelAngles, wheelForward, wheelRight, wheelUp);
VectorCopy(controllerOrigin, wheelOrigin);
VectorCopy(wheelOrigin, beamOrigin);
VectorMA(wheelOrigin, (dist * frac), wheelForward, wheelOrigin);
VectorCopy(wheelOrigin, selectorOrigin);
vec3_t pos;
memset(&pos, 0, sizeof pos);
{
pos[0] = (sinf(DEG2RAD(wheelAngles[YAW] - controllerAngles[YAW])) / sinf(DEG2RAD(22.5f)));
pos[1] = ((wheelAngles[PITCH] - controllerAngles[PITCH]) / 22.5f);
float len = VectorLength(pos);
if (len > 1.0f)
{
pos[0] *= (1.0f / len);
pos[1] *= (1.0f / len);
}
}
VectorMA(selectorOrigin, radius * pos[0], wheelRight, selectorOrigin);
VectorMA(selectorOrigin, radius * pos[1], wheelUp, selectorOrigin);
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
refEntity_t beam;
beam.shaderRGBA[3] = 0xff;
int count;
switch (cg.itemSelectorType)
{
case 0: //weapons
if (vr->in_vehicle)
count = 2;
else
count = WP_MELEE;
beam.shaderRGBA[0] = 0xff;
beam.shaderRGBA[1] = 0xae;
beam.shaderRGBA[2] = 0x40;
break;
case 1: //gadgets
count = INV_GOODIE_KEY;
beam.shaderRGBA[0] = 0x00;
beam.shaderRGBA[1] = 0xff;
beam.shaderRGBA[2] = 0x00;
break;
case 2: //fighting style
count = 3;
beam.shaderRGBA[0] = 0xff;
beam.shaderRGBA[1] = 0xff;
beam.shaderRGBA[2] = 0xff;
break;
case 3: // force powers
count = MAX_SHOWPOWERS;
beam.shaderRGBA[0] = 0x00;
beam.shaderRGBA[1] = 0x00;
beam.shaderRGBA[2] = 0xff;
break;
}
VectorCopy(beamOrigin, beam.oldorigin);
VectorCopy(selectorOrigin, beam.origin );
beam.customShader = cgi_R_RegisterShader( "gfx/misc/whiteline2" );
beam.reType = RT_LINE;
beam.radius = 0.3f;
cgi_R_AddRefEntityToScene( &beam );
if (cg.itemSelectorType == 0) // weapons
{
if (cg.weaponSelect != WP_NONE &&
cg.weaponSelect != WP_MELEE) {
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
VectorCopy(wheelOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cg_weapons[cg.weaponSelect].weaponIcon;
sprite.radius = 1.8f;
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
}
/* else if (cg.itemSelectorType == 2) // fighting style
{
//For the fighting style show the active one in the middle
int level = cent->gent->client->ps.saberAnimLevel;
if (cent->gent->client->ps.forcePowersKnown & (1 << FP_SABER_OFFENSE) &&
level > FORCE_LEVEL_0) {
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
VectorCopy(wheelOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
switch (level) {
case FORCE_LEVEL_1:
sprite.customShader = cgs.media.HUDSaberStyleFast;
break;
case FORCE_LEVEL_2:
sprite.customShader = cgs.media.HUDSaberStyleMed;
break;
case FORCE_LEVEL_3:
sprite.customShader = cgs.media.HUDSaberStyleStrong;
break;
}
sprite.radius = 1.8f;
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
}*/
else if (cg.itemSelectorType == 3) // force powers
{
if (cent->gent->client->ps.forcePowersKnown != 0) {
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
VectorCopy(wheelOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = force_icons[showPowers[cg.forcepowerSelect]];
sprite.radius = 1.8f;
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
}
if (cg.itemSelectorType != 3) {
for (int s = -1; s < 2; s += 2) {
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
vec3_t right;
AngleVectors(wheelAngles, NULL, right, NULL);
float offset = ((float) s * 6.0f) + (((float) s * 0.3f) *
sinf(DEG2RAD(AngleNormalize360(cg.time - cg.itemSelectorTime))));
VectorMA(wheelOrigin, offset, right, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.binocularArrow;
sprite.radius = 0.6f;
sprite.rotation = 180.0f * ((s - 1.0f) / 2.0f);
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
}
qboolean selected = qfalse;
for (int index = 0; index < count; ++index)
{
int itemId = index;
if (cg.itemSelectorType == 0) {
if (vr->in_vehicle)
{
itemId = WP_ATST_MAIN + index;
}
else
{
itemId = index + 1; // We need to ignore WP_NONE for weapons
if (itemId == count)
{
break;
}
#ifdef _DEMO
if (itemId == WP_SABER ||
itemId == WP_BRYAR_PISTOL ||
itemId == WP_BLASTER ||
itemId == WP_FLECHETTE ||
itemId == WP_REPEATER ||
itemId == WP_THERMAL) {
CG_RegisterWeapon(itemId);
} else {
continue;
}
#else
CG_RegisterWeapon(itemId);
#endif
}
}
{
bool selectable;
switch (cg.itemSelectorType)
{
case 0: //weapons
selectable = vr->in_vehicle || // both ATST weapons are always selectable
(CG_WeaponSelectable(itemId, cg.weaponSelect, qfalse) && cg.snap->ps.ammo[weaponData[itemId].ammoIndex]);
break;
case 1: //gadgets
selectable = CG_InventorySelectable(itemId) && inv_icons[itemId];
break;
case 2: //fighting style
{
if (cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) {
selectable = itemId < cent->gent->client->ps.forcePowerLevel[FP_SABER_OFFENSE];
} else {
selectable = false;
}
}
break;
case 3: // force powers
selectable = ForcePower_Valid(itemId);
break;
}
if (selectable) {
//first calculate wheel slot position
vec3_t angles, iconOrigin, iconBackground, iconForeground;
VectorClear(angles);
angles[YAW] = wheelAngles[YAW];
angles[PITCH] = wheelAngles[PITCH];
angles[ROLL] =
(float)(360 / (count - ((cg.itemSelectorType == 0 && !vr->in_vehicle) ? 1 : 0))) * index;
vec3_t forward, up;
AngleVectors(angles, forward, NULL, up);
VectorMA(wheelOrigin, (radius * frac), up, iconOrigin);
VectorMA(iconOrigin, 0.2f, forward, iconBackground);
VectorMA(iconOrigin, -0.2f, forward, iconForeground);
{
vec3_t diff;
VectorSubtract(selectorOrigin, iconOrigin, diff);
float length = VectorLength(diff);
if (length <= 1.0f &&
frac == 1.0f &&
selectable) {
if (cg.itemSelectorSelection != itemId) {
cg.itemSelectorSelection = itemId;
cgi_HapticEvent("selector_icon", 0, vr->right_handed ?
((cg.itemSelectorType == 3) ? 2 : 1) : ((cg.itemSelectorType == 3) ? 1 : 2), 100, 0, 0);
}
selected = qtrue;
}
}
if (cg.itemSelectorSelection == itemId) {
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
VectorCopy(iconOrigin, sprite.origin);
sprite.origin[2] += 2.5f + (0.5f * sinf(DEG2RAD(
AngleNormalize360(cg.time - cg.itemSelectorTime))));
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.binocularArrow;
sprite.radius = 0.6f;
sprite.rotation = -90.0f;
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
cgi_R_AddRefEntityToScene(&sprite);
}
{
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
float sRadius = 1.3f;
VectorCopy(iconOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
switch (cg.itemSelectorType)
{
case 0: //weapons
sprite.customShader = cg_weapons[itemId].weaponIcon;
break;
case 1: //gadgets
sprite.customShader = inv_icons[itemId];
break;
/* case 2: //fighting style
switch ( itemId )
{
case 0://FORCE_LEVEL_1:
sprite.customShader = cgs.media.HUDSaberStyleFast;
break;
case 1://FORCE_LEVEL_2:
sprite.customShader = cgs.media.HUDSaberStyleMed;
break;
case 2://FORCE_LEVEL_3:
sprite.customShader = cgs.media.HUDSaberStyleStrong;
break;
}
break;
*/ case 3: // force powers
sprite.customShader = force_icons[showPowers[itemId]];
break;
}
sprite.radius =
sRadius * (cg.itemSelectorSelection == itemId ? 1.3f : 0.6f);
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
sprite.shaderRGBA[3] = 255;
cgi_R_AddRefEntityToScene(&sprite);
}
}
}
}
if (!selected)
{
cg.itemSelectorSelection = -1;
}
}
/*
===================
CG_OutOfAmmoChange

View file

@ -29,6 +29,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "g_vehicles.h"
#include "../qcommon/tri_coll_test.h"
#include "../cgame/cg_local.h"
#include <JKVR/VrClientInfo.h>
#define JK2_RAGDOLL_GRIPNOHEALTH
@ -9059,6 +9060,11 @@ void ForceThrow( gentity_t *self, qboolean pull, qboolean fake )
parts = SETANIM_BOTH;
}
}
//Handle this here so it is refreshed on every frame, not just when the lightning gun is first fired
cgi_HapticEvent("RTCWQuest:fire_tesla", 0, (vr->right_handed ? 2 : 1), 100, 0, 0);
NPC_SetAnim( self, parts, anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_RESTART );
self->client->ps.saberMove = self->client->ps.saberBounceMove = LS_READY;//don't finish whatever saber anim you may have been in
self->client->ps.saberBlocked = BLOCKED_NONE;
@ -11168,9 +11174,23 @@ void ForceShootLightning( gentity_t *self )
return;
}
AngleVectors( self->client->ps.viewangles, forward, NULL, NULL );
if (self->client->ps.clientNum == 0 && !cg.renderingThirdPerson)
{
vec3_t origin, angles;
BG_CalculateVROffHandPosition(origin, angles);
AngleVectors(angles, forward, NULL, NULL);
}
else
{
AngleVectors(self->client->ps.viewangles, forward, NULL, NULL);
}
VectorNormalize( forward );
//Handle this here so it is refreshed on every frame, not just when the lightning gun is first fired
cgi_HapticEvent("RTCWQuest:fire_tesla", 0, (vr->right_handed ? 2 : 1), 100, 0, 0);
//FIXME: if lightning hits water, do water-only-flagged radius damage from that point
if ( self->client->ps.forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_2 )
{//arc

View file

@ -252,7 +252,7 @@ static consoleCommand_t commands[] = {
{ "itemselectorprev", CG_ItemSelectorPrev_f },
{ "togglesaber", CG_ToggleSaber_f },
{ "exitscope", CG_ExitScope_f },
{ "enterscope", CG_EnterScope_f },
{ "enterscope", CG_EnterScope_f }
};
static const size_t numCommands = ARRAY_LEN( commands );

View file

@ -5731,9 +5731,13 @@ Ghoul2 Insert End
// add a water splash if partially in and out of water
CG_PlayerSplash( cent );
// get the player model information
bool playerInATST = (g_entities[0].client &&
g_entities[0].client->NPC_class == CLASS_ATST);
// get the player model information
renderfx = 0;
if ( !cg.renderingThirdPerson || cg.zoomMode )
if ( !playerInATST && (!cg.renderingThirdPerson || cg.zoomMode ))
{
if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD)
{//no viewentity

Binary file not shown.

BIN
assets/z_vr_assets_jka.pk3 Normal file

Binary file not shown.

View file

@ -209,7 +209,8 @@ import java.util.Vector;
//Our assets
copy_asset("/sdcard/JKQuest/JK2/base", "z_vr_assets.pk3", true);
copy_asset("/sdcard/JKQuest/JK3/base", "z_vr_assets_jka.pk3", true);
//Bummser's default configuration
String model = android.os.Build.MODEL;
if (model.contains("Quest")) {

View file

@ -4,3 +4,12 @@ cd ..
powershell Compress-Archive z_vr_assets/* z_vr_assets.zip
rename z_vr_assets.zip z_vr_assets.pk3
move z_vr_assets.pk3 assets/
cd assets
del z_vr_assets_jka.pk3
cd ..
powershell Compress-Archive z_vr_assets_jka/* z_vr_assets_jka.zip
rename z_vr_assets_jka.zip z_vr_assets_jka.pk3
move z_vr_assets_jka.pk3 assets/
pause

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 KiB