mirror of
https://github.com/nzp-team/dquakeplus.git
synced 2024-11-10 06:31:40 +00:00
Add entity scalefactor
This commit is contained in:
parent
c0326bf2c9
commit
23a9dc0b9a
9 changed files with 67 additions and 77 deletions
|
@ -666,6 +666,12 @@ void CL_ParseUpdate (int bits)
|
|||
else
|
||||
ent->rendercolor[2] = 0;
|
||||
// Tomaz - QC Alpha Scale Glow End
|
||||
|
||||
if (bits & U_SCALE)
|
||||
ent->scale = MSG_ReadByte();
|
||||
else
|
||||
ent->scale = ENTSCALE_DEFAULT;
|
||||
|
||||
if ( bits & U_NOLERP )//there's no data for nolerp, it is the value itself
|
||||
ent->forcelink = true;
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ typedef struct
|
|||
float currentmag2;
|
||||
float maxspeed;
|
||||
float facingenemy;
|
||||
float scale;
|
||||
} entvars_t;
|
||||
|
||||
#define PROGHEADER_CRC 14116
|
||||
|
|
|
@ -51,6 +51,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define U_EXTEND2 (1<<21) // another byte to follow
|
||||
#define U_FRAMETIME (1<<22) // another byte to follow
|
||||
// Tomaz - QC Alpha Scale Glow Control End
|
||||
#define U_SCALE (1<<23)
|
||||
|
||||
|
||||
#define SU_VIEWHEIGHT (1<<0)
|
||||
|
@ -76,6 +77,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define SND_ATTENUATION (1<<1) // a byte
|
||||
#define SND_LOOPING (1<<2) // a long
|
||||
|
||||
#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 22
|
||||
|
|
|
@ -343,8 +343,8 @@ int R_FrustumCheckSphere (vec3_t centre, float radius);
|
|||
int R_CullBox (vec3_t emins, vec3_t emaxs);
|
||||
qboolean R_CullSphere (vec3_t centre, float radius);
|
||||
void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
|
||||
void R_RotateForEntity (entity_t *e, int shadow);
|
||||
void R_BlendedRotateForEntity (entity_t *e, int shadow);
|
||||
void R_RotateForEntity (entity_t *e, int shadow, unsigned char scale);
|
||||
void R_BlendedRotateForEntity (entity_t *e, int shadow, unsigned char scale);
|
||||
void R_RotateForViewEntity (entity_t *ent); //clone (R_RotateForEntity)
|
||||
void R_RotateForTagEntity (tagentity_t *tagent, md3tag_t *tag, float *m); //for q3 models
|
||||
void R_StoreEfrags (efrag_t **ppefrag);
|
||||
|
|
|
@ -694,7 +694,7 @@ void R_DrawHLModel(entity_t *curent)
|
|||
shadevector[2] = 1;
|
||||
VectorNormalize (shadevector);
|
||||
|
||||
R_BlendedRotateForEntity(curent, 0);
|
||||
R_BlendedRotateForEntity(curent, 0, curent->scale);
|
||||
|
||||
HL_SetupBones(&model); /* Setup the bones */
|
||||
SetupLighting(&model); /* Setup the light */
|
||||
|
|
|
@ -406,7 +406,7 @@ qboolean R_CullSphere (vec3_t centre, float radius)
|
|||
R_RotateForEntity
|
||||
=============
|
||||
*/
|
||||
void R_RotateForEntity (entity_t *e, int shadow)
|
||||
void R_RotateForEntity (entity_t *e, int shadow, unsigned char scale)
|
||||
{
|
||||
// Translate.
|
||||
const ScePspFVector3 translation =
|
||||
|
@ -414,14 +414,6 @@ void R_RotateForEntity (entity_t *e, int shadow)
|
|||
e->origin[0], e->origin[1], e->origin[2]
|
||||
};
|
||||
sceGumTranslate(&translation);
|
||||
/*
|
||||
// Scale.
|
||||
const ScePspFVector3 scale =
|
||||
{
|
||||
e->scale, e->scale, e->scale
|
||||
};
|
||||
sceGumScale(&scale);
|
||||
*/
|
||||
|
||||
// Rotate.
|
||||
sceGumRotateZ(e->angles[YAW] * (GU_PI / 180.0f));
|
||||
|
@ -431,6 +423,16 @@ void R_RotateForEntity (entity_t *e, int shadow)
|
|||
sceGumRotateX (e->angles[ROLL] * (GU_PI / 180.0f));
|
||||
}
|
||||
|
||||
// Scale.
|
||||
if (scale != ENTSCALE_DEFAULT) {
|
||||
float scalefactor = ENTSCALE_DECODE(scale);
|
||||
const ScePspFVector3 scale =
|
||||
{
|
||||
scalefactor, scalefactor, scalefactor
|
||||
};
|
||||
sceGumScale(&scale);
|
||||
}
|
||||
|
||||
sceGumUpdateMatrix();
|
||||
}
|
||||
|
||||
|
@ -465,46 +467,6 @@ void R_InterpolateEntity(entity_t *e, int shadow) // Tomaz - New Shadow
|
|||
//if I get this method to work well, make sure we go back and check for r_i_model_transforms again, (because vmodel and other models that don't use interpolation)
|
||||
//probably go back and edit animations too as I redo the last 2 textures..
|
||||
|
||||
|
||||
/*if (e->translate_start_time == 0 || timepassed > 1)
|
||||
{
|
||||
e->translate_start_time = realtime;
|
||||
VectorCopy (e->origin, e->origin1);
|
||||
VectorCopy (e->origin, e->origin2);
|
||||
}
|
||||
|
||||
//our origin has been updated
|
||||
if (!VectorCompare (e->origin, e->origin2))
|
||||
{
|
||||
e->translate_start_time = realtime;
|
||||
VectorCopy (e->origin2, e->origin1);
|
||||
VectorCopy (e->origin, e->origin2);
|
||||
blend = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
blend = 1;
|
||||
if (cl.paused)
|
||||
blend = 0;
|
||||
|
||||
e->origin1[0] += (blend * 0.25 * (e->origin2[0] - e->origin1[0]));
|
||||
e->origin1[1] += (blend * 0.25 * (e->origin2[1] - e->origin1[1]));
|
||||
e->origin1[2] += (blend * 0.25 * (e->origin2[2] - e->origin1[2]));
|
||||
}
|
||||
|
||||
//VectorSubtract (e->origin2, e->origin1, deltaVec);
|
||||
|
||||
// Translate.
|
||||
const ScePspFVector3 translation =
|
||||
{*/
|
||||
/*e->origin[0] + (blend * deltaVec[0]),
|
||||
e->origin[1] + (blend * deltaVec[1]),
|
||||
e->origin[2] + (blend * deltaVec[2])*/
|
||||
/*
|
||||
e->origin1[0], e->origin1[1], e->origin1[2]
|
||||
};
|
||||
*/
|
||||
|
||||
if (e->translate_start_time == 0 || timepassed > 1)
|
||||
{
|
||||
e->translate_start_time = realtime;
|
||||
|
@ -538,7 +500,7 @@ void R_InterpolateEntity(entity_t *e, int shadow) // Tomaz - New Shadow
|
|||
e->origin[2] + (blend * deltaVec[2])
|
||||
};
|
||||
sceGumTranslate(&translation);
|
||||
|
||||
|
||||
|
||||
// orientation interpolation (Euler angles, yuck!)
|
||||
timepassed = realtime - e->rotate_start_time;
|
||||
|
@ -599,7 +561,7 @@ R_BlendedRotateForEntity
|
|||
fenix@io.com: model transform interpolation
|
||||
=============
|
||||
*/
|
||||
void R_BlendedRotateForEntity (entity_t *e, int shadow) // Tomaz - New Shadow
|
||||
void R_BlendedRotateForEntity (entity_t *e, int shadow, unsigned char scale) // Tomaz - New Shadow
|
||||
{
|
||||
float timepassed;
|
||||
float blend;
|
||||
|
@ -640,15 +602,17 @@ void R_BlendedRotateForEntity (entity_t *e, int shadow) // Tomaz - New Shadow
|
|||
e->origin[2] + (blend * d[2])
|
||||
};
|
||||
sceGumTranslate(&translation);
|
||||
/*
|
||||
// Scale.
|
||||
const ScePspFVector3 scale = {
|
||||
e->scale + (blend * d[0]),
|
||||
e->scale + (blend * d[1]),
|
||||
e->scale + (blend * d[2]
|
||||
};
|
||||
sceGumScale(&scale);
|
||||
*/
|
||||
|
||||
// Scale.
|
||||
if (scale != ENTSCALE_DEFAULT) {
|
||||
float scalefactor = ENTSCALE_DECODE(scale);
|
||||
const ScePspFVector3 scale =
|
||||
{
|
||||
scalefactor, scalefactor, scalefactor
|
||||
};
|
||||
sceGumScale(&scale);
|
||||
}
|
||||
|
||||
// orientation interpolation (Euler angles, yuck!)
|
||||
timepassed = realtime - e->rotate_start_time;
|
||||
|
||||
|
@ -774,6 +738,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;
|
||||
bool additive = false;
|
||||
bool filter = false;
|
||||
|
||||
|
@ -867,8 +833,8 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
glvert_t* const vertices =
|
||||
static_cast<glvert_t*>(sceGuGetMemory(sizeof(glvert_t) * 4));
|
||||
|
||||
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);
|
||||
|
||||
vertices[0].st[0] = 0.0f;
|
||||
vertices[0].st[1] = 1.0f;
|
||||
|
@ -876,8 +842,8 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
vertices[0].xyz[1] = point[1];
|
||||
vertices[0].xyz[2] = point[2];
|
||||
|
||||
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);
|
||||
|
||||
vertices[1].st[0] = 0.0f;
|
||||
vertices[1].st[1] = 0.0f;
|
||||
|
@ -885,8 +851,8 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
vertices[1].xyz[1] = point[1];
|
||||
vertices[1].xyz[2] = point[2];
|
||||
|
||||
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);
|
||||
|
||||
vertices[2].st[0] = 1.0f;
|
||||
vertices[2].st[1] = 0.0f;
|
||||
|
@ -894,8 +860,8 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
vertices[2].xyz[1] = point[1];
|
||||
vertices[2].xyz[2] = point[2];
|
||||
|
||||
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);
|
||||
|
||||
vertices[3].st[0] = 1.0f;
|
||||
vertices[3].st[1] = 1.0f;
|
||||
|
@ -1563,7 +1529,7 @@ void R_SetupQ2AliasFrame (entity_t *e, md2_t *pheader)
|
|||
frame = e->frame;
|
||||
|
||||
sceGumPushMatrix ();
|
||||
R_RotateForEntity (e, 0);
|
||||
R_RotateForEntity (e, 0, e->scale);
|
||||
|
||||
if ((frame >= pheader->num_frames) || (frame < 0))
|
||||
{
|
||||
|
@ -1992,6 +1958,7 @@ 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);
|
||||
|
||||
const ScePspFVector3 translation = {
|
||||
paliashdr->scale_origin[0] * scale, paliashdr->scale_origin[1], paliashdr->scale_origin[2]
|
||||
|
@ -2003,11 +1970,14 @@ void R_DrawAliasModel (entity_t *e)
|
|||
sceGumTranslate(&translation);
|
||||
sceGumScale(&scaling);
|
||||
} else {
|
||||
float scale = 128.0f;
|
||||
if (e->scale != ENTSCALE_DEFAULT && e->scale != 0) scale *= ENTSCALE_DECODE(e->scale);
|
||||
|
||||
const ScePspFVector3 translation = {
|
||||
paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]
|
||||
};
|
||||
const ScePspFVector3 scaling = {
|
||||
paliashdr->scale[0] * 128.f, paliashdr->scale[1] * 128.f, paliashdr->scale[2] * 128.f
|
||||
paliashdr->scale[0] * scale, paliashdr->scale[1] * scale, paliashdr->scale[2] * scale
|
||||
};
|
||||
|
||||
sceGumTranslate(&translation);
|
||||
|
@ -2962,7 +2932,7 @@ void R_DrawQ3Model (entity_t *ent)
|
|||
if (ent == &cl.viewent)
|
||||
R_RotateForViewEntity (ent);
|
||||
else
|
||||
R_RotateForEntity(ent, 0);
|
||||
R_RotateForEntity(ent, 0, ent->scale);
|
||||
|
||||
if ((ent == &cl.viewent) && (scr_fov.value != 0))
|
||||
{
|
||||
|
@ -3044,7 +3014,7 @@ void R_DrawQ3Model (entity_t *ent)
|
|||
|
||||
sceGumPushMatrix ();
|
||||
|
||||
R_RotateForEntity (ent, 0);
|
||||
R_RotateForEntity (ent, 0, ent->scale);
|
||||
|
||||
VectorCopy (ent->origin, downmove);
|
||||
downmove[2] -= farclip;
|
||||
|
@ -3125,7 +3095,7 @@ void R_DrawNullModel(void)
|
|||
sceGuDisable(GU_TEXTURE_2D);
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
sceGuShadeModel (GU_SMOOTH);
|
||||
R_RotateForEntity(currententity, 0);
|
||||
R_RotateForEntity(currententity, 0, currententity->scale);
|
||||
typedef struct VERT_t
|
||||
{
|
||||
float x, y, z;
|
||||
|
|
|
@ -1298,7 +1298,7 @@ void R_DrawBrushModel (entity_t *e)
|
|||
|
||||
|
||||
e->angles[0] = -e->angles[0]; // stupid quake bug
|
||||
R_BlendedRotateForEntity (e, 0); //blend transform
|
||||
R_BlendedRotateForEntity (e, 0, e->scale); //blend transform
|
||||
clipping::begin_brush_model();
|
||||
e->angles[0] = -e->angles[0]; // stupid quake bug
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef struct entity_s
|
|||
float rendercolor[3];
|
||||
//Crow_bar
|
||||
|
||||
unsigned char scale;
|
||||
struct model_s *model; // NULL = no model
|
||||
char old_model[128]; // NULL = no model
|
||||
struct efrag_s *efrag; // linked list of efrags
|
||||
|
|
|
@ -514,6 +514,10 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg, qboolean nomap)
|
|||
|
||||
if (ent->baseline.modelindex != ent->v.modelindex)
|
||||
bits |= U_MODEL;
|
||||
|
||||
if (ent->v.scale != ENTSCALE_DEFAULT && ent->v.scale != 0)
|
||||
bits |= U_SCALE;
|
||||
|
||||
// Tomaz - QC Alpha Scale Glow Begin
|
||||
|
||||
{
|
||||
|
@ -627,6 +631,9 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg, qboolean nomap)
|
|||
if (bits & U_RENDERCOLOR3)
|
||||
MSG_WriteFloat(msg, rendercolor[2]);
|
||||
// Tomaz - QC Alpha Scale Glow End
|
||||
|
||||
if (bits & U_SCALE)
|
||||
MSG_WriteByte(msg, ENTSCALE_ENCODE(ent->v.scale));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue