More changes, rendering effects like alpha and colormod SHOULD work :)

This commit is contained in:
James Brown 2000-06-29 14:32:27 +00:00
parent 0802498b8b
commit 68ae22b1ac
4 changed files with 50 additions and 16 deletions

View file

@ -280,6 +280,7 @@ typedef struct
byte glowsize;
byte glowcolor;
byte colormod;
byte alpha;
} entity_state_t;

View file

@ -258,10 +258,12 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits)
if (bits & U_GLOWCOLOR)
to->glowcolor = MSG_ReadByte();
if (bits & U_COLORMOD) {
if (bits & U_COLORMOD)
to->colormod = MSG_ReadByte();
Con_DPrintf("CM: %f\n)", (float) to->colormod);
}
if (bits & U_ALPHA)
to->alpha = MSG_ReadByte();
if (bits & U_SOLID)
{
@ -524,6 +526,12 @@ void CL_LinkPacketEntities (void)
//
ent->glowsize = s1->glowsize < 128 ? s1->glowsize * 8.0 : (s1->glowsize - 256) * 8.0;
ent->glowcolor = s1->glowcolor;
if (ent->alpha != 1)
ent->alpha = s1->alpha / 255;
else
ent->alpha = 1;
if (s1->colormod) {
ent->colormod[0] = (float) ((s1->colormod >> 5) & 7) * (1.0 / 7.0);
ent->colormod[1] = (float) ((s1->colormod >> 2) & 7) * (1.0 / 7.0);

View file

@ -90,6 +90,7 @@ int d_lightstylevalue[256]; // 8.8 fraction of base light value
vec3_t shadecolor; // Ender (Extend) Colormod
float modelalpha; // Ender (EXtend) Alpha
void R_MarkLeaves (void);
@ -370,6 +371,14 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
verts += posenum * paliashdr->poseverts;
order = (int *)((byte *)paliashdr + paliashdr->commands);
if (modelalpha != 1.0)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glDepthMask(0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
while (1)
{
// get the vertex count and primitive type
@ -392,12 +401,12 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
// normals and vertexes come from the frame list
l = shadedots[verts->lightnormalindex] * shadelight;
// Ender: Test (Colormod) [QSG Begin]
if (shadecolor[0] || shadecolor[1] || shadecolor[2]) {
glColor3f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l);
if (modelalpha) {
glColor4f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l, modelalpha);
} else {
glColor3f (l, l, l);
glColor3f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l);
}
// Ender: Test (Colormod) [QSG End]
@ -407,6 +416,13 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
glEnd ();
}
if (modelalpha != 1.0) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // normal alpha blend
glDisable(GL_BLEND);
glDepthMask(1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
}
@ -540,11 +556,6 @@ void R_DrawAliasModel (entity_t *e)
ambientlight = shadelight = R_LightPoint (currententity->origin);
// Ender (Extend)
shadecolor[0] = currententity->colormod[0];
shadecolor[1] = currententity->colormod[1];
shadecolor[2] = currententity->colormod[2];
// allways give the gun some light
if (e == &cl.viewent && ambientlight < 24)
ambientlight = shadelight = 24;
@ -673,6 +684,11 @@ void R_DrawEntitiesOnList (void)
if (!r_drawentities->value)
return;
// Ender (Extend)
modelalpha = currententity->alpha;
shadecolor[0] = currententity->colormod[0];
shadecolor[1] = currententity->colormod[1];
shadecolor[2] = currententity->colormod[2];
// draw sprites seperately, because of alpha blending
for (i=0 ; i<cl_numvisedicts ; i++)
@ -751,6 +767,8 @@ void R_DrawViewModel (void)
ambientlight = j;
shadelight = j;
shadecolor[0] = shadecolor[1] = shadecolor[2] = 0;
// add dynamic lights
for (lnum=0 ; lnum<MAX_DLIGHTS ; lnum++)
{

View file

@ -223,8 +223,8 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
if (stdver > 1) {
if (to->glowsize != from->glowsize) bits |= U_GLOWSIZE;
if (to->glowcolor != from->glowcolor) bits |= U_GLOWCOLOR;
// LordHavocFIX
// if (to->colormod != from->colormod) bits |= U_COLORMOD;
if (to->colormod != from->colormod) bits |= U_COLORMOD;
if (to->alpha != from->alpha) bits |= U_ALPHA;
}
if (bits >= 16777216)
@ -294,6 +294,8 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
MSG_WriteByte(msg, to->glowcolor);
if (bits & U_COLORMOD)
MSG_WriteByte(msg, to->colormod);
if (bits & U_ALPHA)
MSG_WriteByte(msg, to->colormod);
// Ender (QSG - End)
}
@ -571,7 +573,7 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
state->glowsize = 0;
state->glowcolor = 254;
state->colormod = 0;
state->alpha = 1;
if ((val = GETEDICTFIELDVALUE(ent, eval_glowsize))) {
tmp = (int)val->_float >> 3;
state->glowsize = bound(-128, tmp, 127);
@ -582,10 +584,15 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
state->glowcolor = (int) val->_float;
}
if ((val = GETEDICTFIELDVALUE(ent, eval_alpha))) {
if (val->_float != 0)
state->alpha = (int) val->_float;
}
if ((val = GETEDICTFIELDVALUE(ent, eval_colormod))) {
if (val->vector[0] != 0 || val->vector[1] != 0 || val->vector[2] != 0) {
int modred, modgreen, modblue;
Con_Printf("Setting colormod! :)\n");
modred = val->vector[0] * 8.0;
if (modred < 0) modred = 0;
if (modred > 7) modred = 7;