mirror of
https://github.com/nzp-team/quakespasm.git
synced 2024-11-21 19:31:21 +00:00
NX/VITA: Add entity scalefactor
This commit is contained in:
parent
9127ae4759
commit
3c15d7d6e9
10 changed files with 47 additions and 20 deletions
|
@ -614,6 +614,11 @@ void CL_ParseUpdate (int bits)
|
|||
ent->light_lev = MSG_ReadByte();
|
||||
// NZP END
|
||||
|
||||
if (bits & U_SCALE)
|
||||
ent->scale = MSG_ReadByte();
|
||||
else
|
||||
ent->scale = ENTSCALE_DEFAULT;
|
||||
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE and PROTOCOL_NEHAHRA
|
||||
if (cl.protocol == PROTOCOL_FITZQUAKE || cl.protocol == PROTOCOL_RMQ)
|
||||
{
|
||||
|
@ -621,8 +626,6 @@ void CL_ParseUpdate (int bits)
|
|||
ent->alpha = MSG_ReadByte();
|
||||
else
|
||||
ent->alpha = ent->baseline.alpha;
|
||||
if (bits & U_SCALE)
|
||||
MSG_ReadByte(); // PROTOCOL_RMQ: currently ignored
|
||||
if (bits & U_FRAME2)
|
||||
ent->frame = (ent->frame & 0x00FF) | (MSG_ReadByte() << 8);
|
||||
if (bits & U_MODEL2)
|
||||
|
|
|
@ -353,12 +353,17 @@ qboolean R_CullModelForEntity (entity_t *e)
|
|||
R_RotateForEntity -- johnfitz -- modified to take origin and angles instead of pointer to entity
|
||||
===============
|
||||
*/
|
||||
void R_RotateForEntity (vec3_t origin, vec3_t angles)
|
||||
void R_RotateForEntity (vec3_t origin, vec3_t angles, unsigned char scale)
|
||||
{
|
||||
glTranslatef (origin[0], origin[1], origin[2]);
|
||||
glRotatef (angles[1], 0, 0, 1);
|
||||
glRotatef (-angles[0], 0, 1, 0);
|
||||
glRotatef (angles[2], 1, 0, 0);
|
||||
|
||||
if (scale != ENTSCALE_DEFAULT) {
|
||||
float scalefactor = ENTSCALE_DECODE(scale);
|
||||
glScalef(scalefactor, scalefactor, scalefactor);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -353,7 +353,7 @@ void R_CullSurfaces (void);
|
|||
qboolean R_CullBox (vec3_t emins, vec3_t emaxs);
|
||||
void R_StoreEfrags (efrag_t **ppefrag);
|
||||
qboolean R_CullModelForEntity (entity_t *e);
|
||||
void R_RotateForEntity (vec3_t origin, vec3_t angles);
|
||||
void R_RotateForEntity (vec3_t origin, vec3_t angle, unsigned char scale);
|
||||
void R_MarkLights (dlight_t *light, int num, mnode_t *node);
|
||||
|
||||
void R_InitParticles (void);
|
||||
|
|
|
@ -164,6 +164,7 @@ typedef struct
|
|||
float currentmag2;
|
||||
float maxspeed;
|
||||
float facingenemy;
|
||||
float scale;
|
||||
vec3_t colormod;
|
||||
vec3_t glowmod;
|
||||
float light_lev;
|
||||
|
|
|
@ -142,6 +142,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define ENTALPHA_TOSAVE(a) (((a)==ENTALPHA_DEFAULT)?0.0f:(((a)==ENTALPHA_ZERO)?-1.0f:((float)(a)-1)/(254))) //server convert to float for savegame
|
||||
//johnfitz
|
||||
|
||||
#define ENTSCALE_DEFAULT 16 // Equivalent to float 1.0f due to byte packing.
|
||||
#define ENTSCALE_ENCODE(a) ((a) ? ((a) * ENTSCALE_DEFAULT) : ENTSCALE_DEFAULT) // Convert to byte
|
||||
#define ENTSCALE_DECODE(a) ((float)(a) / ENTSCALE_DEFAULT) // Convert to float for rendering
|
||||
|
||||
|
||||
// defaults for clientinfo messages
|
||||
#define DEFAULT_VIEWHEIGHT 32
|
||||
|
||||
|
|
|
@ -883,7 +883,7 @@ void R_DrawTransparentAliasModel (entity_t *e)
|
|||
// transform it
|
||||
//
|
||||
glPushMatrix ();
|
||||
R_RotateForEntity (lerpdata.origin, lerpdata.angles);
|
||||
R_RotateForEntity (lerpdata.origin, lerpdata.angles, e->scale);
|
||||
|
||||
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
|
||||
glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);
|
||||
|
@ -985,7 +985,7 @@ void R_DrawZombieLimb (entity_t *e,int which)
|
|||
|
||||
glPushMatrix ();
|
||||
|
||||
R_RotateForEntity (lerpdata.origin, lerpdata.angles);
|
||||
R_RotateForEntity (lerpdata.origin, lerpdata.angles, e->scale);
|
||||
|
||||
paliashdr = (aliashdr_t *)Mod_Extradata (e->model);
|
||||
rs_aliaspolys += paliashdr->numtris;
|
||||
|
@ -1080,7 +1080,7 @@ void R_DrawAliasModel (entity_t *e)
|
|||
// transform it
|
||||
//
|
||||
glPushMatrix ();
|
||||
R_RotateForEntity (lerpdata.origin, lerpdata.angles);
|
||||
R_RotateForEntity (lerpdata.origin, lerpdata.angles, ENTSCALE_DEFAULT);
|
||||
/* //sB needs fixing in Quakespasm but fuck GL bro
|
||||
//specChar = clmodel->name[strlen(clmodel->name) - 5];
|
||||
if(doZHack && specChar == '#')
|
||||
|
@ -1113,11 +1113,14 @@ void R_DrawAliasModel (entity_t *e)
|
|||
// Special handling of view model to keep FOV from altering look. Pretty good. Not perfect but rather close.
|
||||
if ((e == &cl.viewent || e == &cl.viewent2) && scr_fov_viewmodel.value) {
|
||||
float scale = 1.0f / tan (DEG2RAD (scr_fov.value / 2.0f)) * scr_fov_viewmodel.value / 90.0f;
|
||||
if (e->scale != ENTSCALE_DEFAULT && e->scale != 0) scale *= ENTSCALE_DECODE(e->scale);
|
||||
glTranslatef (paliashdr->scale_origin[0] * scale, paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
|
||||
glScalef (paliashdr->scale[0] * scale, paliashdr->scale[1], paliashdr->scale[2]);
|
||||
} else {
|
||||
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
|
||||
glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);
|
||||
float scale = 1.0f;
|
||||
if (e->scale != ENTSCALE_DEFAULT && e->scale != 0) scale *= ENTSCALE_DECODE(e->scale);
|
||||
glTranslatef (paliashdr->scale_origin[0] * scale, paliashdr->scale_origin[1] * scale, paliashdr->scale_origin[2] * scale);
|
||||
glScalef (paliashdr->scale[0] * scale, paliashdr->scale[1] * scale, paliashdr->scale[2] * scale);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1454,7 +1457,7 @@ void R_DrawAliasModel_ShowTris (entity_t *e)
|
|||
R_SetupEntityTransform (e, &lerpdata);
|
||||
|
||||
glPushMatrix ();
|
||||
R_RotateForEntity (lerpdata.origin,lerpdata.angles);
|
||||
R_RotateForEntity (lerpdata.origin,lerpdata.angles, e->scale);
|
||||
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
|
||||
glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);
|
||||
|
||||
|
|
|
@ -608,7 +608,7 @@ void R_DrawBrushModel (entity_t *e)
|
|||
e->origin[1] -= DIST_EPSILON;
|
||||
e->origin[2] -= DIST_EPSILON;
|
||||
}
|
||||
R_RotateForEntity (e->origin, e->angles);
|
||||
R_RotateForEntity (e->origin, e->angles, e->scale);
|
||||
if (gl_zfix.value)
|
||||
{
|
||||
e->origin[0] += DIST_EPSILON;
|
||||
|
@ -673,7 +673,7 @@ void R_DrawBrushModel_ShowTris (entity_t *e)
|
|||
|
||||
glPushMatrix ();
|
||||
e->angles[0] = -e->angles[0]; // stupid quake bug
|
||||
R_RotateForEntity (e->origin, e->angles);
|
||||
R_RotateForEntity (e->origin, e->angles, e->scale);
|
||||
e->angles[0] = -e->angles[0]; // stupid quake bug
|
||||
|
||||
//
|
||||
|
|
|
@ -86,6 +86,8 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
mspriteframe_t *frame;
|
||||
float *s_up, *s_right;
|
||||
float angle, sr, cr;
|
||||
float scale = ENTSCALE_DECODE(e->scale);
|
||||
if (scale == 0) scale = 1.0f;
|
||||
|
||||
//TODO: frustum cull it?
|
||||
|
||||
|
@ -156,23 +158,23 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
glBegin (GL_TRIANGLE_FAN); //was GL_QUADS, but changed to support r_showtris
|
||||
|
||||
glTexCoord2f (0, frame->tmax);
|
||||
VectorMA (e->origin, frame->down, s_up, point);
|
||||
VectorMA (point, frame->left, s_right, point);
|
||||
VectorMA (e->origin, frame->down * scale, s_up, point);
|
||||
VectorMA (point, frame->left * scale, s_right, point);
|
||||
glVertex3fv (point);
|
||||
|
||||
glTexCoord2f (0, 0);
|
||||
VectorMA (e->origin, frame->up, s_up, point);
|
||||
VectorMA (point, frame->left, s_right, point);
|
||||
VectorMA (e->origin, frame->up * scale, s_up, point);
|
||||
VectorMA (point, frame->left * scale, s_right, point);
|
||||
glVertex3fv (point);
|
||||
|
||||
glTexCoord2f (frame->smax, 0);
|
||||
VectorMA (e->origin, frame->up, s_up, point);
|
||||
VectorMA (point, frame->right, s_right, point);
|
||||
VectorMA (e->origin, frame->up * scale, s_up, point);
|
||||
VectorMA (point, frame->right * scale, s_right, point);
|
||||
glVertex3fv (point);
|
||||
|
||||
glTexCoord2f (frame->smax, frame->tmax);
|
||||
VectorMA (e->origin, frame->down, s_up, point);
|
||||
VectorMA (point, frame->right, s_right, point);
|
||||
VectorMA (e->origin, frame->down * scale, s_up, point);
|
||||
VectorMA (point, frame->right * scale, s_right, point);
|
||||
glVertex3fv (point);
|
||||
|
||||
glEnd ();
|
||||
|
|
|
@ -73,6 +73,8 @@ typedef struct entity_s
|
|||
int dlightbits;
|
||||
float light_lev;
|
||||
|
||||
unsigned char scale;
|
||||
|
||||
// FIXME: could turn these into a union
|
||||
int trivial_accept;
|
||||
struct mnode_s *topnode; // for bmodels, first world node
|
||||
|
|
|
@ -654,6 +654,9 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
|
|||
if (ent->baseline.light_lev != ent->v.light_lev)
|
||||
bits |= U_LIGHTLEVEL;
|
||||
|
||||
if (ent->v.scale != ENTSCALE_DEFAULT && ent->v.scale != 0)
|
||||
bits |= U_SCALE;
|
||||
|
||||
//johnfitz -- alpha
|
||||
if (pr_alpha_supported)
|
||||
{
|
||||
|
@ -736,6 +739,9 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
|
|||
MSG_WriteByte(msg, ent->v.light_lev);
|
||||
// NZP END
|
||||
|
||||
if (bits & U_SCALE)
|
||||
MSG_WriteByte(msg, ENTSCALE_ENCODE(ent->v.scale));
|
||||
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE
|
||||
if (bits & U_ALPHA)
|
||||
MSG_WriteByte(msg, ent->alpha);
|
||||
|
|
Loading…
Reference in a new issue