Author Tomas "Tomaz" Jakobsson E-mail tompsson@hotmail Page www.quakemods.net/tomazOki... this little tutorial will show one of many ways to get the engine to read values from the qc code. I will show how to get alpha and scale for models. And alos how to make qc controled dynamic lights. The color part is only if u have colored dynamics lights. There are tutorials on how to get that to. First of we hawe to make the engine to be able to handle more then it currently can. Thanks LordHavoc for the code. In CL_ParseUpdate in cl_parse.c after if (bits & U_MOREBITS) { i = MSG_ReadByte (); bits |= (i<<8); } // Tomaz - QC Control Begin if (bits & U_EXTEND1) { bits |= MSG_ReadByte() << 16; } // Tomaz - QC Control End after if (bits >= 256) bits |= U_MOREBITS; // Tomaz - QC Control Begin if (bits >= 65536) bits |= U_EXTEND1; // Tomaz - QC Control End if (bits & U_MOREBITS) MSG_WriteByte (msg, bits>>8); // Tomaz - QC Control Begin if (bits & U_EXTEND1) MSG_WriteByte (msg, bits>>16); // Tomaz - QC Control End Now we move on to get the other cool stuff. In CL_RelinkEntities in cl_main.c after else if (ent->model->flags & EF_TRACER3) R_VoorTrail (oldorg, ent->origin); // Tomaz - QC Glow Begin else if (ent->glow_size) { dl = CL_AllocDlight (i); VectorCopy (ent->origin, dl->origin); dl->radius = ent->glow_size; dl->die = cl.time + 0.001; dl->color[0] = ent->glow_red; dl->color[1] = ent->glow_green; dl->color[2] = ent->glow_blue; } // Tomaz - QC Glow End In CL_ParseUpdate in cl_parse.c after if (bits & U_ANGLE3) ent->msg_angles[0][2] = MSG_ReadAngle(); else ent->msg_angles[0][2] = ent->baseline.angles[2]; // Tomaz - QC Alpha Scale Glow Begin if (bits & U_ALPHA) ent->alpha = MSG_ReadFloat(); else ent->alpha = 1.0; if (bits & U_SCALE) ent->scale = MSG_ReadFloat(); else ent->scale = 1.0; if (bits & U_GLOW_SIZE) ent->glow_size = MSG_ReadFloat(); else ent->glow_size = 0; if (bits & U_GLOW_RED) ent->glow_red = MSG_ReadFloat(); else ent->glow_red = 0; if (bits & U_GLOW_GREEN) ent->glow_green = MSG_ReadFloat(); else ent->glow_green = 0; if (bits & U_GLOW_BLUE) ent->glow_blue = MSG_ReadFloat(); else ent->glow_blue = 0; // Tomaz - QC Alpha Scale Glow End In R_RotateForEntity in gl_rmain.c at the bottom add glScalef (e->scale, e->scale, e->scale); // Tomaz - QC Scale This makes the models the size we set it to. In GL_DrawALiasFrame in glrmain.c change the glColor3f glColor4f add , currententity->alpha same thing in GL_DrawAliasBlendedFrame if you have QER Interpolation In R_DrawEntitiesFromList in gl_rmain.c add // Tomaz - QC Alpha Scale Begin if ((!strncmp (currententity->model->name, "progs/bolt", 10)) || (!strncmp (currententity->model->name, "progs/flame", 11))) { currententity->alpha = 1; currententity->scale = 1; } // Tomaz - QC Alpha Scale End In R_DrawViewModel in gl_rmain.c < after currententity = &cl.viewent; if (!currententity->model) return; // Tomaz - QC Alpha Scale Begin currententity->alpha = cl_entities[cl.viewentity].alpha; currententity->scale = cl_entities[cl.viewentity].scale; // Tomaz - QC Alpha Scale End Now goto R_DrawAliasModel in gl_rmain.c at top after all the variables add // Tomaz - QC Alpha Begin glDisable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Tomaz - QC Alpha End add // Tomaz - QC Alpha Begin glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); // Tomaz - QC Alpha End after #define U_LONGENTITY (1<<14) // Tomaz - QC Alpha Scale Glow Control Begin #define U_EXTEND1 (1<<15) #define U_SCALE (1<<16) #define U_ALPHA (1<<17) #define U_GLOW_SIZE (1<<18) #define U_GLOW_RED (1<<19) #define U_GLOW_GREEN (1<<20) #define U_GLOW_BLUE (1<<21) // Tomaz - QC Alpha Scale Glow Control End at bottom add // Tomaz - QC Alpha Scale Glow Begin float alpha; float scale; float glow_size; float glow_red; float glow_green; float glow_blue; // Tomaz - QC Alpha Scale Glow End at top with all the other variables add // Tomaz - QC Alpha Scale Glow Begin float alpha; float scale; float glow_size; float glow_red; float glow_green; float glow_blue; // Tomaz - QC Alpha Scale Glow End if (ent->baseline.modelindex != ent->v.modelindex) bits |= U_MODEL; // Tomaz - QC Alpha Scale Glow Begin { eval_t *val; alpha=1; scale=1; if (val = GetEdictFieldValue(ent, "alpha")) { alpha = val->_float; } else alpha = 1; if (val = GetEdictFieldValue(ent, "scale")) { scale = val->_float; } else scale = 1; if (scale > 4) glow_size = 4; if (val = GetEdictFieldValue(ent, "glow_size")) { glow_size = val->_float; } else glow_size = 0; if (glow_size > 250) glow_size = 250; if (val = GetEdictFieldValue(ent, "glow_red")) { glow_red = val->_float; } else glow_red = 0; if (val = GetEdictFieldValue(ent, "glow_green")) { glow_green = val->_float; } else glow_green = 0; if (val = GetEdictFieldValue(ent, "glow_blue")) { glow_blue = val->_float; } else glow_blue = 0; if ((alpha <= 1) && (alpha > 0)) bits |= U_ALPHA; if ((scale <= 4) && (scale > 0)) bits |= U_SCALE; if (glow_size >= 0) { bits |= U_GLOW_SIZE; bits |= U_GLOW_RED; bits |= U_GLOW_GREEN; bits |= U_GLOW_BLUE; } } // Tomaz - QC Alpha Scale Glow End after if (bits & U_ANGLE3) MSG_WriteAngle(msg, ent->v.angles[2]); // Tomaz - QC Alpha Scale Glow Begin if (bits & U_ALPHA) MSG_WriteFloat(msg, alpha); if (bits & U_SCALE) MSG_WriteFloat(msg, scale); if (bits & U_GLOW_SIZE) MSG_WriteFloat(msg, glow_size); if (bits & U_GLOW_RED) MSG_WriteFloat(msg, glow_red); if (bits & U_GLOW_GREEN) MSG_WriteFloat(msg, glow_green); if (bits & U_GLOW_BLUE) MSG_WriteFloat(msg, glow_blue); // Tomaz - QC Alpha Scale Glow End All code is also done so that if it cant find any value it sets the alpha ans scale to 1, and sets the glow_size to 0 so it wont make any light if we dont want it to. Next thing is the code we need in the Qc. In defs.qc at the bottm add .float alpha; .float scale; .float glow_size; .float glow_red; .float glow_green; .float glow_blue; like self.alpha = 0.5; self.scale = 2; self.glow_size = 200; self.red = 1; self.blue = 1; all values is from 0-1. Except the scale that goes from 0-4.. i dont think anyone want a model that is more then 4 times as big as it used to. If anything is unclear then just let me know and im sure we can sort it out. |