#include "quakedef.h"
+#include "cl_collision.h"
cvar_t r_quickmodels = {0, "r_quickmodels", "1"};
}
*/
-void R_AliasLerpVerts(int vertcount,
+void R_AliasLerpVerts(int vertcount, float *vertices, float *normals,
float lerp1, const trivertx_t *verts1, const vec3_t fscale1, const vec3_t translate1,
float lerp2, const trivertx_t *verts2, const vec3_t fscale2, const vec3_t translate2,
float lerp3, const trivertx_t *verts3, const vec3_t fscale3, const vec3_t translate3,
vec3_t scale1, scale2, scale3, scale4, translate;
const float *n1, *n2, *n3, *n4;
float *av, *avn;
- av = aliasvert;
- avn = aliasvertnorm;
+ av = vertices;
+ avn = normals;
VectorScale(fscale1, lerp1, scale1);
if (lerp2)
{
return &model->skinframes[model->skinscenes[s].firstframe];
}
-void R_SetupMDLMD2Frames(const entity_render_t *ent, float colorr, float colorg, float colorb)
+void R_LerpMDLMD2Vertices(const entity_render_t *ent, float *vertices, float *normals)
{
const md2frame_t *frame1, *frame2, *frame3, *frame4;
const trivertx_t *frame1verts, *frame2verts, *frame3verts, *frame4verts;
frame2verts = &model->mdlmd2data_pose[ent->frameblend[1].frame * model->numverts];
frame3verts = &model->mdlmd2data_pose[ent->frameblend[2].frame * model->numverts];
frame4verts = &model->mdlmd2data_pose[ent->frameblend[3].frame * model->numverts];
- R_AliasLerpVerts(model->numverts,
+ R_AliasLerpVerts(model->numverts, vertices, normals,
ent->frameblend[0].lerp, frame1verts, frame1->scale, frame1->translate,
ent->frameblend[1].lerp, frame2verts, frame2->scale, frame2->translate,
ent->frameblend[2].lerp, frame3verts, frame3->scale, frame3->translate,
ent->frameblend[3].lerp, frame4verts, frame4->scale, frame4->translate);
-
- R_LightModel(ent, model->numverts, colorr, colorg, colorb, false);
-
- //R_AliasTransformVerts(model->numverts);
}
void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
{
- int i, c, pantsfullbright, shirtfullbright, colormapped;
+ int i, c, pantsfullbright, shirtfullbright, colormapped, tex;
float pantscolor[3], shirtcolor[3];
- float fog;
+ float fog, colorscale;
vec3_t diff;
qbyte *bcolor;
rmeshstate_t m;
}
model = ent->model;
- R_Mesh_ResizeCheck(model->numverts, model->numtris);
+ R_Mesh_ResizeCheck(model->numverts);
skinframe = R_FetchSkinFrame(ent);
blendfunc2 = GL_ZERO;
}
+ colorscale = r_colorscale;
+ if (gl_combine.integer)
+ colorscale *= 0.25f;
+
if (!skinframe->base && !skinframe->pants && !skinframe->shirt && !skinframe->glow)
{
// untextured
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.wantoverbright = true;
+ if (gl_combine.integer)
+ m.texrgbscale[0] = 4;
m.tex[0] = R_GetTexture(r_notexture);
R_Mesh_State(&m);
c_alias_polys += model->numtris;
- memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
for (i = 0;i < model->numverts * 2;i++)
varray_texcoord[0][i] = model->mdlmd2data_texcoords[i] * 8.0f;
aliasvert = varray_vertex;
aliasvertcolor = varray_color;
- R_SetupMDLMD2Frames(ent, mesh_colorscale, mesh_colorscale, mesh_colorscale);
+ R_LerpMDLMD2Vertices(ent, aliasvert, aliasvertnorm);
+ R_LightModel(ent, model->numverts, colorscale, colorscale, colorscale, false);
aliasvert = aliasvertbuf;
aliasvertcolor = aliasvertcolorbuf;
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
return;
}
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.wantoverbright = true;
+ if (gl_combine.integer)
+ m.texrgbscale[0] = 4;
m.tex[0] = R_GetTexture(skinframe->merged);
R_Mesh_State(&m);
c_alias_polys += model->numtris;
- memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
aliasvert = varray_vertex;
aliasvertcolor = varray_color;
- R_SetupMDLMD2Frames(ent, mesh_colorscale, mesh_colorscale, mesh_colorscale);
+ R_LerpMDLMD2Vertices(ent, aliasvert, aliasvertnorm);
+ R_LightModel(ent, model->numverts, colorscale, colorscale, colorscale, false);
aliasvert = aliasvertbuf;
aliasvertcolor = aliasvertcolorbuf;
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
return;
}
- R_SetupMDLMD2Frames(ent, 1 - fog, 1 - fog, 1 - fog);
+ R_LerpMDLMD2Vertices(ent, aliasvert, aliasvertnorm);
+ R_LightModel(ent, model->numverts, colorscale * (1 - fog), colorscale * (1 - fog), colorscale * (1 - fog), false);
if (colormapped)
{
pantsfullbright = shirtfullbright = false;
}
- memset(&m, 0, sizeof(m));
- m.blendfunc1 = blendfunc1;
- m.blendfunc2 = blendfunc2;
- m.wantoverbright = true;
- m.tex[0] = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
- if (m.tex[0])
+ tex = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
+ if (tex)
{
+ memset(&m, 0, sizeof(m));
+ m.blendfunc1 = blendfunc1;
+ m.blendfunc2 = blendfunc2;
+ if (gl_combine.integer)
+ m.texrgbscale[0] = 4;
+ m.tex[0] = tex;
R_Mesh_State(&m);
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
- R_ModulateColors(aliasvertcolor, varray_color, model->numverts, mesh_colorscale, mesh_colorscale, mesh_colorscale);
- memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ R_ModulateColors(aliasvertcolor, varray_color, model->numverts, colorscale, colorscale, colorscale);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
if (colormapped)
{
if (skinframe->pants)
{
- memset(&m, 0, sizeof(m));
- m.blendfunc1 = blendfunc1;
- m.blendfunc2 = blendfunc2;
- m.wantoverbright = true;
- m.tex[0] = R_GetTexture(skinframe->pants);
- if (m.tex[0])
+ tex = R_GetTexture(skinframe->pants);
+ if (tex)
{
+ memset(&m, 0, sizeof(m));
+ m.blendfunc1 = blendfunc1;
+ m.blendfunc2 = blendfunc2;
+ if (gl_combine.integer)
+ m.texrgbscale[0] = 4;
+ m.tex[0] = tex;
R_Mesh_State(&m);
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
if (pantsfullbright)
- R_FillColors(varray_color, model->numverts, pantscolor[0] * mesh_colorscale, pantscolor[1] * mesh_colorscale, pantscolor[2] * mesh_colorscale, ent->alpha);
+ R_FillColors(varray_color, model->numverts, pantscolor[0] * colorscale, pantscolor[1] * colorscale, pantscolor[2] * colorscale, ent->alpha);
else
- R_ModulateColors(aliasvertcolor, varray_color, model->numverts, pantscolor[0] * mesh_colorscale, pantscolor[1] * mesh_colorscale, pantscolor[2] * mesh_colorscale);
- memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ R_ModulateColors(aliasvertcolor, varray_color, model->numverts, pantscolor[0] * colorscale, pantscolor[1] * colorscale, pantscolor[2] * colorscale);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
if (skinframe->shirt)
{
- memset(&m, 0, sizeof(m));
- m.blendfunc1 = blendfunc1;
- m.blendfunc2 = blendfunc2;
- m.wantoverbright = true;
- m.tex[0] = R_GetTexture(skinframe->shirt);
- if (m.tex[0])
+ tex = R_GetTexture(skinframe->shirt);
+ if (tex)
{
+ memset(&m, 0, sizeof(m));
+ m.blendfunc1 = blendfunc1;
+ m.blendfunc2 = blendfunc2;
+ if (gl_combine.integer)
+ m.texrgbscale[0] = 4;
+ m.tex[0] = tex;
R_Mesh_State(&m);
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
if (shirtfullbright)
- R_FillColors(varray_color, model->numverts, shirtcolor[0] * mesh_colorscale, shirtcolor[1] * mesh_colorscale, shirtcolor[2] * mesh_colorscale, ent->alpha);
+ R_FillColors(varray_color, model->numverts, shirtcolor[0] * colorscale, shirtcolor[1] * colorscale, shirtcolor[2] * colorscale, ent->alpha);
else
- R_ModulateColors(aliasvertcolor, varray_color, model->numverts, shirtcolor[0] * mesh_colorscale, shirtcolor[1] * mesh_colorscale, shirtcolor[2] * mesh_colorscale);
- memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ R_ModulateColors(aliasvertcolor, varray_color, model->numverts, shirtcolor[0] * colorscale, shirtcolor[1] * colorscale, shirtcolor[2] * colorscale);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
}
if (skinframe->glow)
{
- memset(&m, 0, sizeof(m));
- m.blendfunc1 = blendfunc1;
- m.blendfunc2 = blendfunc2;
- m.wantoverbright = true;
- m.tex[0] = R_GetTexture(skinframe->glow);
- if (m.tex[0])
+ tex = R_GetTexture(skinframe->glow);
+ if (tex)
{
+ memset(&m, 0, sizeof(m));
+ m.blendfunc1 = blendfunc1;
+ m.blendfunc2 = blendfunc2;
+ m.tex[0] = tex;
R_Mesh_State(&m);
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
- R_FillColors(varray_color, model->numverts, (1 - fog) * mesh_colorscale, (1 - fog) * mesh_colorscale, (1 - fog) * mesh_colorscale, ent->alpha);
- memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ R_FillColors(varray_color, model->numverts, (1 - fog) * r_colorscale, (1 - fog) * r_colorscale, (1 - fog) * r_colorscale, ent->alpha);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
if (fog)
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
- m.wantoverbright = false;
m.tex[0] = R_GetTexture(skinframe->fog);
R_Mesh_State(&m);
c_alias_polys += model->numtris;
- R_FillColors(varray_color, model->numverts, fogcolor[0] * fog * mesh_colorscale, fogcolor[1] * fog * mesh_colorscale, fogcolor[2] * fog * mesh_colorscale, ent->alpha);
- memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ R_FillColors(varray_color, model->numverts, fogcolor[0] * fog * r_colorscale, fogcolor[1] * fog * r_colorscale, fogcolor[2] * fog * r_colorscale, ent->alpha);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
+ }
+}
+
+void R_DrawQ1Q2AliasModelFakeShadow (entity_render_t *ent)
+{
+ int i;
+ rmeshstate_t m;
+ model_t *model;
+ float *v, planenormal[3], planedist, dist, projection[3], floororigin[3], surfnormal[3], lightdirection[3], v2[3];
+
+ lightdirection[0] = 0.5;
+ lightdirection[1] = 0.2;
+ lightdirection[2] = -1;
+ VectorNormalizeFast(lightdirection);
+
+ VectorMA(ent->origin, 65536.0f, lightdirection, v2);
+ if (CL_TraceLine(ent->origin, v2, floororigin, surfnormal, 0, false, NULL) == 1)
+ return;
+
+ R_Mesh_Matrix(&ent->matrix);
+
+ model = ent->model;
+ R_Mesh_ResizeCheck(model->numverts);
+
+ memset(&m, 0, sizeof(m));
+ m.blendfunc1 = GL_SRC_ALPHA;
+ m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ R_Mesh_State(&m);
+
+ c_alias_polys += model->numtris;
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
+ R_FillColors(varray_color, model->numverts, 0, 0, 0, 0.5);
+
+ // put a light direction in the entity's coordinate space
+ Matrix4x4_Transform3x3(&ent->inversematrix, lightdirection, projection);
+ VectorNormalizeFast(projection);
+
+ // put the plane's normal in the entity's coordinate space
+ Matrix4x4_Transform3x3(&ent->inversematrix, surfnormal, planenormal);
+ VectorNormalizeFast(planenormal);
+
+ // put the plane's distance in the entity's coordinate space
+ VectorSubtract(floororigin, ent->origin, floororigin);
+ planedist = DotProduct(floororigin, surfnormal) + 2;
+
+ dist = -1.0f / DotProduct(projection, planenormal);
+ VectorScale(projection, dist, projection);
+ for (i = 0, v = varray_vertex;i < model->numverts;i++, v += 4)
+ {
+ dist = DotProduct(v, planenormal) - planedist;
+ if (dist > 0)
+ //if (i & 1)
+ VectorMA(v, dist, projection, v);
}
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
int ZymoticLerpBones(int count, const zymbonematrix *bonebase, const frameblend_t *blend, const zymbone_t *bone)
void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
{
- float fog;
+ float fog, colorscale;
vec3_t diff;
- int i, *renderlist;
+ int i, *renderlist, *elements;
zymtype1header_t *m;
rtexture_t *texture;
rmeshstate_t mstate;
texture = ((rtexture_t **)(m->lump_shaders.start + (int) m))[shadernum];
numverts = m->numverts;
- numtriangles = renderlist[0];
- R_Mesh_ResizeCheck(numverts, numtriangles);
+ numtriangles = *renderlist++;
+ elements = renderlist;
+ R_Mesh_ResizeCheck(numverts);
fog = 0;
if (fogenabled)
R_LightModel(ent, numverts, 1 - fog, 1 - fog, 1 - fog, false);
memset(&mstate, 0, sizeof(mstate));
- mstate.wantoverbright = true;
if (ent->effects & EF_ADDITIVE)
{
mstate.blendfunc1 = GL_SRC_ALPHA;
mstate.blendfunc1 = GL_ONE;
mstate.blendfunc2 = GL_ZERO;
}
+ colorscale = r_colorscale;
+ if (gl_combine.integer)
+ {
+ mstate.texrgbscale[0] = 4;
+ colorscale *= 0.25f;
+ }
mstate.tex[0] = R_GetTexture(texture);
R_Mesh_State(&mstate);
c_alias_polys += numtriangles;
- memcpy(varray_element, renderlist + 1, numtriangles * sizeof(int[3]));
memcpy(varray_vertex, aliasvert, numverts * sizeof(float[4]));
- R_ModulateColors(aliasvertcolor, varray_color, numverts, mesh_colorscale, mesh_colorscale, mesh_colorscale);
+ R_ModulateColors(aliasvertcolor, varray_color, numverts, colorscale, colorscale, colorscale);
memcpy(varray_texcoord[0], (float *)(m->lump_texcoords.start + (int) m), numverts * sizeof(float[2]));
- R_Mesh_Draw(numverts, numtriangles);
+ R_Mesh_Draw(numverts, numtriangles, elements);
if (fog)
{
memset(&mstate, 0, sizeof(mstate));
- mstate.wantoverbright = false;
mstate.blendfunc1 = GL_SRC_ALPHA;
mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
// FIXME: need alpha mask for fogging...
R_Mesh_State(&mstate);
c_alias_polys += numtriangles;
- memcpy(varray_element, renderlist + 1, numtriangles * sizeof(int[3]));
memcpy(varray_vertex, aliasvert, numverts * sizeof(float[4]));
- R_FillColors(varray_color, numverts, fogcolor[0] * mesh_colorscale, fogcolor[1] * mesh_colorscale, fogcolor[2] * mesh_colorscale, ent->alpha * fog);
+ R_FillColors(varray_color, numverts, fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, ent->alpha * fog);
//memcpy(mesh_texcoord[0], (float *)(m->lump_texcoords.start + (int) m), numverts * sizeof(float[2]));
- R_Mesh_Draw(numverts, numtriangles);
+ R_Mesh_Draw(numverts, numtriangles, elements);
}
}
else
R_DrawQ1Q2AliasModelCallback(ent, 0);
}
-