mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-22 04:01:33 +00:00
Few small changes...
- Tidied up selector rendering a little bit for when no weapon held - render a hand when no weapon held - don't allow weapon stabilisation when holding no weapon or using saber - better support for left handed mode - disable face culling for VR view models (weapons / hands) so they look much better, especially left handed!
This commit is contained in:
parent
5df6bfbe27
commit
b1207a60ca
7 changed files with 74 additions and 15 deletions
|
@ -163,7 +163,8 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
if (!vr.weapon_stabilised && vr.item_selector == 0)
|
||||
{
|
||||
if (distance < STABILISATION_DISTANCE &&
|
||||
vr_two_handed_weapons->integer) {
|
||||
vr_two_handed_weapons->integer &&
|
||||
vr.weaponid > WP_SABER) {
|
||||
vr.weapon_stabilised = true;
|
||||
} else {
|
||||
vr.item_selector = 2;
|
||||
|
|
|
@ -1310,7 +1310,7 @@ void CG_AddViewWeapon( playerState_t *ps )
|
|||
AnglesToAxis( angles, gun.axis );
|
||||
CG_PositionEntityOnTag( &gun, &hand, weapon->handsModel, "tag_weapon");
|
||||
|
||||
gun.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON;
|
||||
gun.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_VRVIEWMODEL;
|
||||
|
||||
//---------
|
||||
// OK, we are making an assumption here that if we have the phaser that it is always on....
|
||||
|
|
|
@ -76,6 +76,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#define RF_FORCE_ENT_ALPHA 0x800000 // override shader alpha settings
|
||||
|
||||
#define RF_VRVIEWMODEL 0x1000000 // specifically drawing a VR hand/weapon model
|
||||
|
||||
// refdef flags
|
||||
#define RDF_NOWORLDMODEL 1 // used for player configuration screen
|
||||
#define RDF_HYPERSPACE 4 // teleportation effect
|
||||
|
|
|
@ -653,6 +653,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
int entityNum, oldEntityNum;
|
||||
int dlighted, oldDlighted;
|
||||
int depthRange, oldDepthRange;
|
||||
int isVRViewModel, oldIsVRViewModel;
|
||||
int i;
|
||||
drawSurf_t *drawSurf;
|
||||
unsigned int oldSort;
|
||||
|
@ -678,10 +679,15 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
oldShader = NULL;
|
||||
oldFogNum = -1;
|
||||
oldDepthRange = qfalse;
|
||||
isVRViewModel = qfalse;
|
||||
oldIsVRViewModel = qfalse;
|
||||
oldDlighted = qfalse;
|
||||
oldSort = (unsigned int) -1;
|
||||
depthRange = qfalse;
|
||||
|
||||
GLint oldFaceCullMode;
|
||||
GLboolean oldFaceCullEnabled;
|
||||
|
||||
backEnd.pc.c_surfaces += numDrawSurfs;
|
||||
|
||||
for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) {
|
||||
|
@ -780,6 +786,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
//
|
||||
if ( entityNum != oldEntityNum ) {
|
||||
depthRange = qfalse;
|
||||
isVRViewModel = qfalse;
|
||||
|
||||
if ( entityNum != REFENTITYNUM_WORLD ) {
|
||||
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
|
||||
|
@ -801,6 +808,10 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
// hack the depth range to prevent view model from poking into walls
|
||||
depthRange = qtrue;
|
||||
}
|
||||
|
||||
if (backEnd.currentEntity->e.renderfx & RF_VRVIEWMODEL) {
|
||||
isVRViewModel = qtrue;
|
||||
}
|
||||
} else {
|
||||
backEnd.currentEntity = &tr.worldEntity;
|
||||
backEnd.refdef.floatTime = originalTime;
|
||||
|
@ -832,6 +843,25 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
oldDepthRange = depthRange;
|
||||
}
|
||||
|
||||
if (isVRViewModel != oldIsVRViewModel) {
|
||||
if (isVRViewModel) {
|
||||
qglGetBooleanv(GL_CULL_FACE, &oldFaceCullEnabled);
|
||||
qglGetIntegerv(GL_CULL_FACE_MODE, &oldFaceCullMode);
|
||||
|
||||
//Draw all faces on weapons
|
||||
qglDisable(GL_CULL_FACE);
|
||||
} else{
|
||||
if (!oldFaceCullEnabled)
|
||||
{
|
||||
qglDisable(GL_CULL_FACE);
|
||||
} else{
|
||||
qglEnable(GL_CULL_FACE);
|
||||
}
|
||||
qglCullFace( oldFaceCullMode );
|
||||
}
|
||||
oldIsVRViewModel = isVRViewModel;
|
||||
}
|
||||
|
||||
oldEntityNum = entityNum;
|
||||
}
|
||||
|
||||
|
|
|
@ -2035,7 +2035,7 @@ wasForceSpeed=isForceSpeed;
|
|||
VectorMA( handEnt.origin, -1.0f, forward, handEnt.origin );
|
||||
|
||||
|
||||
handEnt.renderfx = RF_DEPTHHACK;
|
||||
handEnt.renderfx = RF_DEPTHHACK | RF_VRVIEWMODEL;
|
||||
|
||||
if (cg.snap->ps.powerups[PW_FORCE_PUSH] > cg.time ||
|
||||
(cg.snap->ps.forcePowersActive & (1<<FP_GRIP)) ||
|
||||
|
@ -2048,9 +2048,31 @@ wasForceSpeed=isForceSpeed;
|
|||
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, -1.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1221,7 +1221,8 @@ void CG_AddViewWeapon( playerState_t *ps )
|
|||
AnglesToAxis( angles, gun.axis );
|
||||
CG_PositionEntityOnTag( &gun, &hand, weapon->handsModel, "tag_weapon");
|
||||
|
||||
gun.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON;
|
||||
gun.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_VRVIEWMODEL;
|
||||
|
||||
|
||||
//---------
|
||||
// OK, we are making an assumption here that if we have the phaser that it is always on....
|
||||
|
@ -2860,14 +2861,17 @@ void CG_DrawItemSelector( void )
|
|||
|
||||
if (cg.itemSelectorType == 0) // weapons
|
||||
{
|
||||
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);
|
||||
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
|
||||
{
|
||||
|
@ -2910,13 +2914,13 @@ void CG_DrawItemSelector( void )
|
|||
}
|
||||
}
|
||||
|
||||
if (cg.itemSelectorType != 1) {
|
||||
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 * 2.0f) + (((float) s * 0.3f) *
|
||||
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;
|
||||
|
|
|
@ -197,7 +197,7 @@ import static android.system.Os.setenv;
|
|||
copy_asset("/sdcard/JKQuest/JK3/base", "weapons_vr_ja.cfg", true);
|
||||
|
||||
//Our assets
|
||||
copy_asset("/sdcard/JKQuest/JK2/base", "z_vr_assets.pk3", false);
|
||||
copy_asset("/sdcard/JKQuest/JK2/base", "z_vr_assets.pk3", true);
|
||||
|
||||
//Read these from a file and pass through
|
||||
commandLineParams = new String("jo");
|
||||
|
|
Loading…
Reference in a new issue