If player is controlling a remote NPC

such as a mouse droid, then render on a screen as if viewing a remote camera. This might need reworking if the player controls something alive at some point, but works well for the mouse droid for now.
Also for security cameras, render to a screen
This commit is contained in:
Simon 2022-10-26 23:37:42 +01:00
parent 5fbe134973
commit a5ae9452a8
14 changed files with 45 additions and 17 deletions

View file

@ -139,7 +139,8 @@ LAMBDA1VR Stuff
bool JKVR_useScreenLayer()
{
vr.using_screen_layer = (bool)((vr.in_camera && !vr.immersive_cinematics) ||
vr.using_screen_layer = (bool)((vr.cin_camera && !vr.immersive_cinematics) ||
vr.misc_camera ||
(CL_IsRunningInGameCinematic() || CL_InGameCinematicOnStandBy()) ||
(cls.state == CA_CINEMATIC) ||
(cls.state == CA_LOADING) ||

View file

@ -4,7 +4,8 @@
#define NUM_WEAPON_SAMPLES 10
typedef struct {
bool in_camera; // cinematic camera taken over
bool cin_camera; // cinematic camera taken over
bool misc_camera; // looking through a misc camera view entity
bool using_screen_layer;
float fov;
bool immersive_cinematics;

View file

@ -124,7 +124,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, A_ESCAPE);
static bool resetCursor = qtrue;
if ( JKVR_useScreenLayer() )
if ( JKVR_useScreenLayer() && !vr.misc_camera /*bit of a fiddle, but if we are in a misc camera, we are in the game and shouldn't be in here*/)
{
interactWithTouchScreen(resetCursor, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
resetCursor = qfalse;

View file

@ -30,6 +30,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include <JKVR/VrClientInfo.h>
bool in_camera = false;
bool in_misccamera = false; // if we are viewing a misc_camera
camera_t client_camera={};
extern qboolean player_locked;

View file

@ -136,6 +136,7 @@ typedef struct camera_s
} camera_t;
extern bool in_camera;
extern bool in_misccamera;
extern camera_t client_camera;
void CGCam_Init( void );

View file

@ -4384,8 +4384,11 @@ 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 ));
cg.refdef.worldscale = cg_worldScale.value;
if (!in_camera) {
if (!in_camera &&
!in_misccamera) {
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
@ -4397,7 +4400,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
// offset vieworg appropriately if we're doing stereo separation
VectorCopy( cg.refdef.vieworg, baseOrg );
if ( separation != 0 && (!in_camera || vr->immersive_cinematics)) {
if ( separation != 0 && (!in_camera || vr->immersive_cinematics) && !in_misccamera) {
VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg );
}
@ -4406,7 +4409,9 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cgi_R_LAGoggles();
}
if (!in_camera || vr->immersive_cinematics) {
bool in_turret = ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & EF_LOCKED_TO_WEAPON );
if (!in_turret && (!in_camera || vr->immersive_cinematics)) {
//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

@ -28,7 +28,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
if (cg.drawingHUD && !vr->in_camera && !vr->using_screen_layer && !vr->scopeengaged)
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
{
float screenXScale = 1.0f / 2.5f;
float screenYScale = 1.0f / 2.5f;

View file

@ -2120,7 +2120,8 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
cg.renderingThirdPerson = qfalse;
}
vr->in_camera = in_camera;
vr->cin_camera = in_camera;
vr->misc_camera = in_misccamera;
if ( in_camera )
{
// The camera takes over the view

View file

@ -30,6 +30,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include <JKVR/VrClientInfo.h>
bool in_camera = false;
bool in_misccamera = false; // if we are viewing a misc_camera
camera_t client_camera={};
extern qboolean player_locked;

View file

@ -130,6 +130,7 @@ typedef struct camera_s
} camera_t;
extern bool in_camera;
extern bool in_misccamera;
extern camera_t client_camera;
void CGCam_Init( void );

View file

@ -2090,8 +2090,10 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll )
return;
}
*/
//draw crosshair at endpoint
//CG_DrawCrosshair( trace.endpos );
if ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & EF_LOCKED_TO_WEAPON ) {
//draw crosshair at endpoint
CG_DrawCrosshair(trace.endpos);
}
g_crosshairEntNum = trace.entityNum;
g_crosshairEntDist = 4096*trace.fraction;
@ -2482,6 +2484,11 @@ static qboolean CG_RenderingFromMiscCamera()
// don't render other 2d stuff
return qtrue;
}
if ( !Q_stricmp( "NPC", g_entities[cg.snap->ps.viewEntity].classname ))
{
//Render as if we are looking through a camera
CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/workingCamera" ));
}
else if ( !Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname ))
{
// could do a panel turret screen overlay...this is a cheesy placeholder
@ -2765,15 +2772,16 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
CG_Error( "CG_DrawActive: Undefined stereoView" );
}
bool usingMiscCamera = ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname ));
in_misccamera = ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname ))
|| ( !Q_stricmp( "NPC", g_entities[cg.snap->ps.viewEntity].classname ));
cg.refdef.worldscale = cg_worldScale.value;
if (!in_camera &&
!usingMiscCamera)
!in_misccamera)
{
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
}
@ -2782,7 +2790,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
// offset vieworg appropriately if we're doing stereo separation
VectorCopy( cg.refdef.vieworg, baseOrg );
if ( separation != 0 && (!in_camera || vr->immersive_cinematics) && !usingMiscCamera) {
if ( separation != 0 && (!in_camera || vr->immersive_cinematics) && !in_misccamera) {
VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg );
}
@ -2791,7 +2799,8 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cgi_R_LAGoggles();
}
if (!in_camera || vr->immersive_cinematics) {
bool in_turret = ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & EF_LOCKED_TO_WEAPON );
if (!in_turret && !in_misccamera && (!in_camera || vr->immersive_cinematics)) {
//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

@ -27,7 +27,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
if (cg.drawingHUD && !vr->in_camera && !vr->using_screen_layer && !vr->scopeengaged)
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
{
float screenXScale = 1.0f / 2.5f;
float screenYScale = 1.0f / 2.5f;

View file

@ -1495,6 +1495,12 @@ Ghoul2 Insert End
CG_NewClientinfo( i );
}
//Just register all weapons to avoid a pause when opening the selector
for (i=0; i < WP_MELEE; i++)
{
CG_RegisterWeapon(i);
}
for (i=0 ; i < ENTITYNUM_WORLD ; i++)
{
if(&g_entities[i])

View file

@ -1932,7 +1932,8 @@ wasForceSpeed=isForceSpeed;
cg.renderingThirdPerson = qfalse;
}
vr->in_camera = in_camera;
vr->cin_camera = in_camera;
vr->misc_camera = in_misccamera;
if ( in_camera )
{
// The camera takes over the view