// LordHavoc: vertex arrays
-float *aliasvertbuf;
float *aliasvertcolorbuf;
-float *aliasvert; // this may point at aliasvertbuf or at vertex arrays in the mesh backend
float *aliasvertcolor; // this may point at aliasvertcolorbuf or at vertex arrays in the mesh backend
+float *aliasvert_svectors;
+float *aliasvert_tvectors;
+float *aliasvert_normals;
float *aliasvertcolor2;
-float *aliasvertnorm;
int *aliasvertusage;
zymbonematrix *zymbonepose;
{
// allocate vertex processing arrays
gl_models_mempool = Mem_AllocPool("GL_Models");
- aliasvert = aliasvertbuf = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
aliasvertcolor = aliasvertcolorbuf = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
- aliasvertnorm = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][3]));
+ aliasvert_svectors = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
+ aliasvert_tvectors = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
+ aliasvert_normals = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
aliasvertcolor2 = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4])); // used temporarily for tinted coloring
zymbonepose = Mem_Alloc(gl_models_mempool, sizeof(zymbonematrix[256]));
aliasvertusage = Mem_Alloc(gl_models_mempool, sizeof(int[MD2MAX_VERTS]));
avn[1] = n1[1] * lerp1 + n2[1] * lerp2 + n3[1] * lerp3 + n4[1] * lerp4;
avn[2] = n1[2] * lerp1 + n2[2] * lerp2 + n3[2] * lerp3 + n4[2] * lerp4;
av += 4;
- avn += 3;
+ avn += 4;
verts1++;verts2++;verts3++;verts4++;
}
}
avn[1] = n1[1] * lerp1 + n2[1] * lerp2 + n3[1] * lerp3;
avn[2] = n1[2] * lerp1 + n2[2] * lerp2 + n3[2] * lerp3;
av += 4;
- avn += 3;
+ avn += 4;
verts1++;verts2++;verts3++;
}
}
avn[1] = n1[1] * lerp1 + n2[1] * lerp2;
avn[2] = n1[2] * lerp1 + n2[2] * lerp2;
av += 4;
- avn += 3;
+ avn += 4;
verts1++;verts2++;
}
}
avn[1] = n1[1] * lerp1;
avn[2] = n1[2] * lerp1;
av += 4;
- avn += 3;
+ avn += 4;
verts1++;
}
}
av[2] = verts1->v[2] * scale1[2] + translate[2];
VectorCopy(m_bytenormals[verts1->lightnormalindex], avn);
av += 4;
- avn += 3;
+ avn += 4;
verts1++;
}
}
blendfunc2 = GL_ZERO;
}
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
+ memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[4]));
if (!skinframe->base && !skinframe->pants && !skinframe->shirt && !skinframe->glow)
{
// untextured
m.tex[0] = R_GetTexture(r_notexture);
R_Mesh_State(&m);
c_alias_polys += model->numtris;
- for (i = 0;i < model->numverts * 2;i++)
- varray_texcoord[0][i] = model->mdlmd2data_texcoords[i] * 8.0f;
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- R_LightModel(ent, model->numverts, varray_vertex, aliasvertnorm, varray_color, colorscale, colorscale, colorscale, false);
+ for (i = 0;i < model->numverts * 4;i += 4)
+ {
+ varray_texcoord[0][i + 0] *= 8.0f;
+ varray_texcoord[0][i + 1] *= 8.0f;
+ }
+ R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, colorscale, colorscale, colorscale, false);
GL_UseColorArray();
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
return;
}
m.tex[0] = tex;
R_Mesh_State(&m);
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
if (fullbright)
GL_Color(colorscale * ifog, colorscale * ifog, colorscale * ifog, ent->alpha);
else
{
GL_UseColorArray();
- R_LightModel(ent, model->numverts, varray_vertex, aliasvertnorm, varray_color, colorscale * ifog, colorscale * ifog, colorscale * ifog, false);
+ R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, colorscale * ifog, colorscale * ifog, colorscale * ifog, false);
}
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
c_alias_polys += model->numtris;
}
m.tex[0] = tex;
R_Mesh_State(&m);
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
if (pantsfullbright)
GL_Color(pantscolor[0] * colorscale * ifog, pantscolor[1] * colorscale * ifog, pantscolor[2] * colorscale * ifog, ent->alpha);
else
{
GL_UseColorArray();
- R_LightModel(ent, model->numverts, varray_vertex, aliasvertnorm, varray_color, pantscolor[0] * colorscale * ifog, pantscolor[1] * colorscale * ifog, pantscolor[2] * colorscale * ifog, false);
+ R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, pantscolor[0] * colorscale * ifog, pantscolor[1] * colorscale * ifog, pantscolor[2] * colorscale * ifog, false);
}
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
c_alias_polys += model->numtris;
}
m.tex[0] = tex;
R_Mesh_State(&m);
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
if (shirtfullbright)
GL_Color(shirtcolor[0] * colorscale * ifog, shirtcolor[1] * colorscale * ifog, shirtcolor[2] * colorscale * ifog, ent->alpha);
else
{
GL_UseColorArray();
- R_LightModel(ent, model->numverts, varray_vertex, aliasvertnorm, varray_color, shirtcolor[0] * colorscale * ifog, shirtcolor[1] * colorscale * ifog, shirtcolor[2] * colorscale * ifog, false);
+ R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, shirtcolor[0] * colorscale * ifog, shirtcolor[1] * colorscale * ifog, shirtcolor[2] * colorscale * ifog, false);
}
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
c_alias_polys += model->numtris;
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
GL_Color(ifog * r_colorscale, ifog * r_colorscale, ifog * r_colorscale, ent->alpha);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
R_Mesh_State(&m);
c_alias_polys += model->numtris;
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
GL_Color(fogcolor[0] * fog * r_colorscale, fogcolor[1] * fog * r_colorscale, fogcolor[2] * fog * r_colorscale, ent->alpha);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
-void R_DrawQ1Q2AliasModelShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int visiblevolume)
+void R_Model_Alias_Draw(entity_render_t *ent)
{
- float projectdistance;
- projectdistance = lightradius + ent->model->radius - sqrt(DotProduct(relativelightorigin, relativelightorigin));
- if (projectdistance > 0.1)
- {
- R_Mesh_ResizeCheck(ent->model->numverts * 2);
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- R_Shadow_Volume(ent->model->numverts, ent->model->numtris, varray_vertex, ent->model->mdlmd2data_indices, ent->model->mdlmd2data_triangleneighbors, relativelightorigin, lightradius, projectdistance, visiblevolume);
- }
+ if (ent->alpha < (1.0f / 64.0f))
+ return; // basically completely transparent
+
+ c_models++;
+
+ if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_FetchSkinFrame(ent)->fog != NULL)
+ R_MeshQueue_AddTransparent(ent->origin, R_DrawQ1Q2AliasModelCallback, ent, 0);
+ else
+ R_DrawQ1Q2AliasModelCallback(ent, 0);
}
extern cvar_t r_shadows;
-void R_DrawQ1Q2AliasModelFakeShadow (entity_render_t *ent)
+void R_Model_Alias_DrawFakeShadow (entity_render_t *ent)
{
int i;
rmeshstate_t m;
{
model = ent->model;
R_Mesh_ResizeCheck(model->numverts * 2);
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
Matrix4x4_Transform(&ent->inversematrix, sl->origin, temp);
GL_Color(0.1 * r_colorscale, 0.025 * r_colorscale, 0.0125 * r_colorscale, 1);
R_Shadow_Volume(model->numverts, model->numtris, varray_vertex, model->mdlmd2data_indices, model->mdlmd2data_triangleneighbors, temp, sl->cullradius + model->radius - sqrt(f), true);
GL_UseColorArray();
lightscale = d_lightstylevalue[sl->style] * (1.0f / 65536.0f);
VectorScale(sl->light, lightscale, lightcolor);
- R_Shadow_VertexLight(model->numverts, varray_vertex, aliasvertnorm, temp, sl->cullradius2, sl->distbias, sl->subtract, lightcolor);
+ R_Shadow_VertexLight(model->numverts, varray_vertex, aliasvert_normals, temp, sl->cullradius2, sl->distbias, sl->subtract, lightcolor);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
{
model = ent->model;
R_Mesh_ResizeCheck(model->numverts * 2);
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
Matrix4x4_Transform(&ent->inversematrix, rd->origin, temp);
GL_Color(0.1 * r_colorscale, 0.025 * r_colorscale, 0.0125 * r_colorscale, 1);
R_Shadow_Volume(model->numverts, model->numtris, varray_vertex, model->mdlmd2data_indices, model->mdlmd2data_triangleneighbors, temp, rd->cullradius + model->radius - sqrt(f), true);
GL_UseColorArray();
- R_Shadow_VertexLight(model->numverts, varray_vertex, aliasvertnorm, temp, rd->cullradius2, LIGHTOFFSET, rd->subtract, rd->light);
+ R_Shadow_VertexLight(model->numverts, varray_vertex, aliasvert_normals, temp, rd->cullradius2, LIGHTOFFSET, rd->subtract, rd->light);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
R_Mesh_State(&m);
c_alias_polys += model->numtris;
- R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
// put a light direction in the entity's coordinate space
Matrix4x4_Transform3x3(&ent->inversematrix, lightdirection, projection);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
+void R_Model_Alias_DrawBaseLighting(entity_render_t *ent)
+{
+ R_Mesh_Matrix(&ent->matrix);
+ GL_Color(0, 0, 0, 1);
+ R_Mesh_ResizeCheck(ent->model->numverts);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
+ R_Mesh_Draw(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices);
+}
+
+void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int visiblevolume)
+{
+ float projectdistance;
+ projectdistance = lightradius + ent->model->radius - sqrt(DotProduct(relativelightorigin, relativelightorigin));
+ if (projectdistance > 0.1)
+ {
+ R_Mesh_Matrix(&ent->matrix);
+ R_Mesh_ResizeCheck(ent->model->numverts * 2);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
+ R_Shadow_Volume(ent->model->numverts, ent->model->numtris, varray_vertex, ent->model->mdlmd2data_indices, ent->model->mdlmd2data_triangleneighbors, relativelightorigin, lightradius, projectdistance, visiblevolume);
+ }
+}
+
+void R_Model_Alias_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float lightdistbias, float lightsubtract, float *lightcolor)
+{
+ skinframe_t *skinframe;
+ R_Mesh_Matrix(&ent->matrix);
+ skinframe = R_FetchSkinFrame(ent);
+ R_Mesh_ResizeCheck(ent->model->numverts);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
+ Mod_BuildTextureVectorsAndNormals(ent->model->numverts, ent->model->numtris, varray_vertex, ent->model->mdlmd2data_texcoords, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals);
+ R_Shadow_RenderLighting(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals, ent->model->mdlmd2data_texcoords, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, skinframe->base, r_notexture, NULL, NULL);
+}
+
int ZymoticLerpBones(int count, const zymbonematrix *bonebase, const frameblend_t *blend, const zymbone_t *bone)
{
int i;
float fog, ifog, colorscale;
vec3_t diff;
int i, *renderlist, *elements;
- zymtype1header_t *m;
rtexture_t *texture;
rmeshstate_t mstate;
const entity_render_t *ent = calldata1;
R_Mesh_Matrix(&ent->matrix);
// find the vertex index list and texture
- m = ent->model->zymdata_header;
- renderlist = (int *)(m->lump_render.start + (int) m);
+ renderlist = ent->model->zymdata_renderlist;
for (i = 0;i < shadernum;i++)
renderlist += renderlist[0] * 3 + 1;
- texture = ((rtexture_t **)(m->lump_shaders.start + (int) m))[shadernum];
+ texture = ent->model->zymdata_textures[shadernum];
- numverts = m->numverts;
+ numverts = ent->model->zymnum_verts;
numtriangles = *renderlist++;
elements = renderlist;
R_Mesh_ResizeCheck(numverts);
}
mstate.tex[0] = R_GetTexture(texture);
R_Mesh_State(&mstate);
- ZymoticLerpBones(m->numbones, (zymbonematrix *)(m->lump_poses.start + (int) m), ent->frameblend, (zymbone_t *)(m->lump_bones.start + (int) m));
- ZymoticTransformVerts(numverts, varray_vertex, (int *)(m->lump_vertbonecounts.start + (int) m), (zymvertex_t *)(m->lump_verts.start + (int) m));
- ZymoticCalcNormals(numverts, varray_vertex, aliasvertnorm, m->numshaders, (int *)(m->lump_render.start + (int) m));
- memcpy(varray_texcoord[0], (float *)(m->lump_texcoords.start + (int) m), numverts * sizeof(float[2]));
+ ZymoticLerpBones(ent->model->zymnum_bones, (zymbonematrix *) ent->model->zymdata_poses, ent->frameblend, ent->model->zymdata_bones);
+ ZymoticTransformVerts(numverts, varray_vertex, ent->model->zymdata_vertbonecounts, ent->model->zymdata_verts);
+ ZymoticCalcNormals(numverts, varray_vertex, aliasvert_normals, ent->model->zymnum_shaders, ent->model->zymdata_renderlist);
+ memcpy(varray_texcoord[0], ent->model->zymdata_texcoords, ent->model->zymnum_verts * sizeof(float[4]));
GL_UseColorArray();
- R_LightModel(ent, numverts, varray_vertex, aliasvertnorm, varray_color, ifog * colorscale, ifog * colorscale, ifog * colorscale, false);
+ R_LightModel(ent, numverts, varray_vertex, aliasvert_normals, varray_color, ifog * colorscale, ifog * colorscale, ifog * colorscale, false);
R_Mesh_Draw(numverts, numtriangles, elements);
c_alias_polys += numtriangles;
}
}
-void R_DrawZymoticModel (entity_render_t *ent)
+void R_Model_Zymotic_Draw(entity_render_t *ent)
{
int i;
- zymtype1header_t *m;
- rtexture_t *texture;
if (ent->alpha < (1.0f / 64.0f))
return; // basically completely transparent
c_models++;
- m = ent->model->zymdata_header;
- for (i = 0;i < m->numshaders;i++)
+ for (i = 0;i < ent->model->zymnum_shaders;i++)
{
- texture = ((rtexture_t **)(m->lump_shaders.start + (int) m))[i];
- if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_TextureHasAlpha(texture))
+ if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_TextureHasAlpha(ent->model->zymdata_textures[i]))
R_MeshQueue_AddTransparent(ent->origin, R_DrawZymoticModelMeshCallback, ent, i);
else
R_DrawZymoticModelMeshCallback(ent, i);
}
}
-void R_DrawQ1Q2AliasModel(entity_render_t *ent)
+void R_Model_Zymotic_DrawFakeShadow(entity_render_t *ent)
{
- if (ent->alpha < (1.0f / 64.0f))
- return; // basically completely transparent
+ // FIXME
+}
- c_models++;
+void R_Model_Zymotic_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, float lightradius2, float lightdistbias, float lightsubtract, float *lightcolor)
+{
+ // FIXME
+}
- if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_FetchSkinFrame(ent)->fog != NULL)
- R_MeshQueue_AddTransparent(ent->origin, R_DrawQ1Q2AliasModelCallback, ent, 0);
- else
- R_DrawQ1Q2AliasModelCallback(ent, 0);
+void R_Model_Zymotic_DrawOntoLight(entity_render_t *ent)
+{
+ // FIXME
}