mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2025-02-28 14:21:16 +00:00
Left Handed Weapon Rendering (invert model etc)
This commit is contained in:
parent
0fc411189a
commit
2d44b6bd40
3 changed files with 42 additions and 6 deletions
|
@ -2081,7 +2081,11 @@ static float CG_CalculateWeaponPositionAndScale( playerState_t *ps, vec3_t origi
|
||||||
AngleVectors( angles, forward, right, up );
|
AngleVectors( angles, forward, right, up );
|
||||||
VectorMA( origin, offset[2], forward, origin );
|
VectorMA( origin, offset[2], forward, origin );
|
||||||
VectorMA( origin, offset[1], up, origin );
|
VectorMA( origin, offset[1], up, origin );
|
||||||
VectorMA( origin, offset[0], right, origin );
|
if (cgVR->right_handed) {
|
||||||
|
VectorMA(origin, offset[0], right, origin);
|
||||||
|
} else {
|
||||||
|
VectorMA(origin, -offset[0], right, origin);
|
||||||
|
}
|
||||||
|
|
||||||
return scale;
|
return scale;
|
||||||
|
|
||||||
|
@ -3477,16 +3481,16 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
||||||
//Weapon offset debugging
|
//Weapon offset debugging
|
||||||
if (weaponDebugging)
|
if (weaponDebugging)
|
||||||
{
|
{
|
||||||
hand.renderfx = RF_FIRST_PERSON | RF_MINLIGHT; //No depth hack for weapon adjusting mode
|
hand.renderfx = RF_FIRST_PERSON | RF_MINLIGHT | RF_VIEWWEAPON; //No depth hack for weapon adjusting mode
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT; //----(SA)
|
hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT | RF_VIEWWEAPON; //----(SA)
|
||||||
}
|
}
|
||||||
|
|
||||||
//scale the whole model (hand and weapon)
|
//scale the whole model (hand and weapon)
|
||||||
for ( int i = 0; i < 3; i++ ) {
|
for ( int i = 0; i < 3; i++ ) {
|
||||||
VectorScale( hand.axis[i], scale, hand.axis[i] );
|
VectorScale( hand.axis[i], (cgVR->right_handed || i != 1 || ps->weapon == WP_AKIMBO) ? scale : -scale, hand.axis[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#define RF_THIRD_PERSON 2 // don't draw through eyes, only mirrors (player bodies, chat sprites)
|
#define RF_THIRD_PERSON 2 // don't draw through eyes, only mirrors (player bodies, chat sprites)
|
||||||
#define RF_FIRST_PERSON 4 // only draw through eyes (view weapon, damage blood blob)
|
#define RF_FIRST_PERSON 4 // only draw through eyes (view weapon, damage blood blob)
|
||||||
#define RF_DEPTHHACK 8 // for view weapon Z crunching
|
#define RF_DEPTHHACK 8 // for view weapon Z crunching
|
||||||
|
#define RF_VIEWWEAPON 16 // specifically drawing the weapon model
|
||||||
#define RF_NOSHADOW 64 // don't add stencil shadows
|
#define RF_NOSHADOW 64 // don't add stencil shadows
|
||||||
|
|
||||||
#define RF_LIGHTING_ORIGIN 128 // use refEntity->lightingOrigin instead of refEntity->origin
|
#define RF_LIGHTING_ORIGIN 128 // use refEntity->lightingOrigin instead of refEntity->origin
|
||||||
|
|
|
@ -27,6 +27,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tr_local.h"
|
#include "tr_local.h"
|
||||||
|
#include "../../../RTCWVR/VrClientInfo.h"
|
||||||
|
|
||||||
backEndData_t *backEndData[SMP_FRAMES];
|
backEndData_t *backEndData[SMP_FRAMES];
|
||||||
backEndState_t backEnd;
|
backEndState_t backEnd;
|
||||||
|
@ -888,12 +889,14 @@ void RB_ZombieFX( int part, drawSurf_t *drawSurf, int oldNumVerts, int oldNumInd
|
||||||
RB_RenderDrawSurfList
|
RB_RenderDrawSurfList
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
|
extern vr_client_info_t vr;
|
||||||
void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
shader_t *shader, *oldShader;
|
shader_t *shader, *oldShader;
|
||||||
int fogNum, oldFogNum;
|
int fogNum, oldFogNum;
|
||||||
int entityNum, oldEntityNum;
|
int entityNum, oldEntityNum;
|
||||||
int dlighted, oldDlighted;
|
int dlighted, oldDlighted;
|
||||||
qboolean depthRange, oldDepthRange;
|
qboolean depthRange, oldDepthRange;
|
||||||
|
qboolean isLeftHandedWeapon, oldIsLeftHandedWeapon;
|
||||||
int i;
|
int i;
|
||||||
drawSurf_t *drawSurf;
|
drawSurf_t *drawSurf;
|
||||||
int oldSort;
|
int oldSort;
|
||||||
|
@ -926,12 +929,17 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
oldDlighted = qfalse;
|
oldDlighted = qfalse;
|
||||||
oldSort = -1;
|
oldSort = -1;
|
||||||
depthRange = qfalse;
|
depthRange = qfalse;
|
||||||
|
isLeftHandedWeapon = qfalse;
|
||||||
|
oldIsLeftHandedWeapon = qfalse;
|
||||||
// GR - tessellation also forces to draw everything
|
// GR - tessellation also forces to draw everything
|
||||||
oldAtiTess = -1;
|
oldAtiTess = -1;
|
||||||
|
GLint oldFaceCullMode;
|
||||||
|
GLboolean oldFaceCullEnabled;
|
||||||
|
|
||||||
backEnd.pc.c_surfaces += numDrawSurfs;
|
backEnd.pc.c_surfaces += numDrawSurfs;
|
||||||
|
|
||||||
for ( i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++ ) {
|
for ( i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++ ) {
|
||||||
|
|
||||||
if ( drawSurf->sort == oldSort ) {
|
if ( drawSurf->sort == oldSort ) {
|
||||||
// fast path, same as previous sort
|
// fast path, same as previous sort
|
||||||
oldNumVerts = tess.numVertexes;
|
oldNumVerts = tess.numVertexes;
|
||||||
|
@ -985,11 +993,12 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
oldAtiTess = atiTess;
|
oldAtiTess = atiTess;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// change the modelview matrix if needed
|
// change the modelview matrix if needed
|
||||||
//
|
//
|
||||||
if ( entityNum != oldEntityNum ) {
|
if ( entityNum != oldEntityNum ) {
|
||||||
depthRange = qfalse;
|
depthRange = qfalse;
|
||||||
|
isLeftHandedWeapon = qfalse;
|
||||||
|
|
||||||
if ( entityNum != ENTITYNUM_WORLD ) {
|
if ( entityNum != ENTITYNUM_WORLD ) {
|
||||||
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
|
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
|
||||||
|
@ -1011,6 +1020,10 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
// hack the depth range to prevent view model from poking into walls
|
// hack the depth range to prevent view model from poking into walls
|
||||||
depthRange = qtrue;
|
depthRange = qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (backEnd.currentEntity->e.renderfx & RF_VIEWWEAPON) {
|
||||||
|
isLeftHandedWeapon = (!vr.right_handed);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
backEnd.currentEntity = &tr.worldEntity;
|
backEnd.currentEntity = &tr.worldEntity;
|
||||||
backEnd.refdef.floatTime = originalTime;
|
backEnd.refdef.floatTime = originalTime;
|
||||||
|
@ -1037,6 +1050,24 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
oldDepthRange = depthRange;
|
oldDepthRange = depthRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLeftHandedWeapon != oldIsLeftHandedWeapon) {
|
||||||
|
if (isLeftHandedWeapon) {
|
||||||
|
qglGetBooleanv(GL_CULL_FACE, &oldFaceCullEnabled);
|
||||||
|
qglGetIntegerv(GL_CULL_FACE_MODE, &oldFaceCullMode);
|
||||||
|
|
||||||
|
qglEnable(GL_CULL_FACE);
|
||||||
|
glCullFace(GL_BACK);
|
||||||
|
} else{
|
||||||
|
if (!oldFaceCullEnabled)
|
||||||
|
{
|
||||||
|
qglDisable(GL_CULL_FACE);
|
||||||
|
}
|
||||||
|
qglCullFace( oldFaceCullMode );
|
||||||
|
}
|
||||||
|
oldIsLeftHandedWeapon = isLeftHandedWeapon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
oldEntityNum = entityNum;
|
oldEntityNum = entityNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue