void R_Model_Alias_GetVerts(const entity_render_t *ent, float *vertices, float *normals, float *svectors, float *tvectors)
{
int i, vertcount;
- float vlerp1, nlerp1, vlerp2, nlerp2, vlerp3, nlerp3, vlerp4, nlerp4;
+ float lerp1, lerp2, lerp3, lerp4;
const aliasvertex_t *verts1, *verts2, *verts3, *verts4;
if (vertices == NULL)
vertcount = ent->model->numverts;
verts1 = ent->model->mdlmd2data_pose + ent->frameblend[0].frame * vertcount;
- vlerp1 = ent->frameblend[0].lerp * (1.0f / 16.0f);
- nlerp1 = ent->frameblend[0].lerp * (1.0f / 127.0f);
+ lerp1 = ent->frameblend[0].lerp;
if (ent->frameblend[1].lerp)
{
verts2 = ent->model->mdlmd2data_pose + ent->frameblend[1].frame * vertcount;
- vlerp2 = ent->frameblend[1].lerp * (1.0f / 16.0f);
- nlerp2 = ent->frameblend[1].lerp * (1.0f / 127.0f);
+ lerp2 = ent->frameblend[1].lerp;
if (ent->frameblend[2].lerp)
{
verts3 = ent->model->mdlmd2data_pose + ent->frameblend[2].frame * vertcount;
- vlerp3 = ent->frameblend[2].lerp * (1.0f / 16.0f);
- nlerp3 = ent->frameblend[2].lerp * (1.0f / 127.0f);
+ lerp3 = ent->frameblend[2].lerp;
if (ent->frameblend[3].lerp)
{
verts4 = ent->model->mdlmd2data_pose + ent->frameblend[3].frame * vertcount;
- vlerp4 = ent->frameblend[3].lerp * (1.0f / 16.0f);
- nlerp4 = ent->frameblend[3].lerp * (1.0f / 127.0f);
+ lerp4 = ent->frameblend[3].lerp;
// generate vertices
if (svectors != NULL)
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, svectors += 4, tvectors += 4, verts1++, verts2++, verts3++, verts4++)
{
- VectorMAMAMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vlerp3, verts3->origin, vlerp4, verts4->origin, vertices);
- VectorMAMAMAM(nlerp1, verts1->normal, nlerp2, verts2->normal, nlerp3, verts3->normal, nlerp4, verts4->normal, normals);
- VectorMAMAMAM(nlerp1, verts1->svector, nlerp2, verts2->svector, nlerp3, verts3->svector, nlerp4, verts4->svector, svectors);
+ VectorMAMAMAM(lerp1, verts1->origin, lerp2, verts2->origin, lerp3, verts3->origin, lerp4, verts4->origin, vertices);
+ VectorMAMAMAM(lerp1, verts1->normal, lerp2, verts2->normal, lerp3, verts3->normal, lerp4, verts4->normal, normals);
+ VectorMAMAMAM(lerp1, verts1->svector, lerp2, verts2->svector, lerp3, verts3->svector, lerp4, verts4->svector, svectors);
CrossProduct(svectors, normals, tvectors);
}
}
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, verts1++, verts2++, verts3++, verts4++)
{
- VectorMAMAMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vlerp3, verts3->origin, vlerp4, verts4->origin, vertices);
- VectorMAMAMAM(nlerp1, verts1->normal, nlerp2, verts2->normal, nlerp3, verts3->normal, nlerp4, verts4->normal, normals);
+ VectorMAMAMAM(lerp1, verts1->origin, lerp2, verts2->origin, lerp3, verts3->origin, lerp4, verts4->origin, vertices);
+ VectorMAMAMAM(lerp1, verts1->normal, lerp2, verts2->normal, lerp3, verts3->normal, lerp4, verts4->normal, normals);
}
}
else
for (i = 0;i < vertcount;i++, vertices += 4, verts1++, verts2++, verts3++, verts4++)
- VectorMAMAMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vlerp3, verts3->origin, vlerp4, verts4->origin, vertices);
+ VectorMAMAMAM(lerp1, verts1->origin, lerp2, verts2->origin, lerp3, verts3->origin, lerp4, verts4->origin, vertices);
}
else
{
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, svectors += 4, tvectors += 4, verts1++, verts2++, verts3++)
{
- VectorMAMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vlerp3, verts3->origin, vertices);
- VectorMAMAM(nlerp1, verts1->normal, nlerp2, verts2->normal, nlerp3, verts3->normal, normals);
- VectorMAMAM(nlerp1, verts1->svector, nlerp2, verts2->svector, nlerp3, verts3->svector, svectors);
+ VectorMAMAM(lerp1, verts1->origin, lerp2, verts2->origin, lerp3, verts3->origin, vertices);
+ VectorMAMAM(lerp1, verts1->normal, lerp2, verts2->normal, lerp3, verts3->normal, normals);
+ VectorMAMAM(lerp1, verts1->svector, lerp2, verts2->svector, lerp3, verts3->svector, svectors);
CrossProduct(svectors, normals, tvectors);
}
}
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, verts1++, verts2++, verts3++)
{
- VectorMAMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vlerp3, verts3->origin, vertices);
- VectorMAMAM(nlerp1, verts1->normal, nlerp2, verts2->normal, nlerp3, verts3->normal, normals);
+ VectorMAMAM(lerp1, verts1->origin, lerp2, verts2->origin, lerp3, verts3->origin, vertices);
+ VectorMAMAM(lerp1, verts1->normal, lerp2, verts2->normal, lerp3, verts3->normal, normals);
}
}
else
for (i = 0;i < vertcount;i++, vertices += 4, verts1++, verts2++, verts3++)
- VectorMAMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vlerp3, verts3->origin, vertices);
+ VectorMAMAM(lerp1, verts1->origin, lerp2, verts2->origin, lerp3, verts3->origin, vertices);
}
}
else
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, svectors += 4, tvectors += 4, verts1++, verts2++)
{
- VectorMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vertices);
- VectorMAM(nlerp1, verts1->normal, nlerp2, verts2->normal, normals);
- VectorMAM(nlerp1, verts1->svector, nlerp2, verts2->svector, svectors);
+ VectorMAM(lerp1, verts1->origin, lerp2, verts2->origin, vertices);
+ VectorMAM(lerp1, verts1->normal, lerp2, verts2->normal, normals);
+ VectorMAM(lerp1, verts1->svector, lerp2, verts2->svector, svectors);
CrossProduct(svectors, normals, tvectors);
}
}
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, verts1++, verts2++)
{
- VectorMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vertices);
- VectorMAM(nlerp1, verts1->normal, nlerp2, verts2->normal, normals);
+ VectorMAM(lerp1, verts1->origin, lerp2, verts2->origin, vertices);
+ VectorMAM(lerp1, verts1->normal, lerp2, verts2->normal, normals);
}
}
else
for (i = 0;i < vertcount;i++, vertices += 4, verts1++, verts2++)
- VectorMAM(vlerp1, verts1->origin, vlerp2, verts2->origin, vertices);
+ VectorMAM(lerp1, verts1->origin, lerp2, verts2->origin, vertices);
}
}
else
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, svectors += 4, tvectors += 4, verts1++)
{
- VectorM(vlerp1, verts1->origin, vertices);
- VectorM(nlerp1, verts1->normal, normals);
- VectorM(nlerp1, verts1->svector, svectors);
+ VectorM(lerp1, verts1->origin, vertices);
+ VectorM(lerp1, verts1->normal, normals);
+ VectorM(lerp1, verts1->svector, svectors);
CrossProduct(svectors, normals, tvectors);
}
}
{
for (i = 0;i < vertcount;i++, vertices += 4, normals += 4, verts1++)
{
- VectorM(vlerp1, verts1->origin, vertices);
- VectorM(nlerp1, verts1->normal, normals);
+ VectorM(lerp1, verts1->origin, vertices);
+ VectorM(lerp1, verts1->normal, normals);
}
}
else
for (i = 0;i < vertcount;i++, vertices += 4, verts1++)
- VectorM(vlerp1, verts1->origin, vertices);
+ VectorM(lerp1, verts1->origin, vertices);
}
}
if (modelradius < dist)
modelradius = dist;
- VectorScale(temp, 16.0f, temp);
- temp[0] = bound(-32768, temp[0], 32767);
- temp[1] = bound(-32768, temp[1], 32767);
- temp[2] = bound(-32768, temp[2], 32767);
-
j = vertremap[i]; // not onseam
if (j >= 0)
VectorCopy(temp, out[j].origin);
{
int i;
for (i = 0;i < numverts;i++)
- VectorScale(vertices[i].origin, (1.0f / 16.0f), &vertexbuffer[i * 4]);
+ VectorCopy(vertices[i].origin, &vertexbuffer[i * 4]);
Mod_BuildTextureVectorsAndNormals(numverts, numtriangles, vertexbuffer, texcoords, elements, svectorsbuffer, tvectorsbuffer, normalsbuffer);
for (i = 0;i < numverts;i++)
{
- vertices[i].normal[0] = normalsbuffer[i * 4 + 0] * 127.0f;
- vertices[i].normal[1] = normalsbuffer[i * 4 + 1] * 127.0f;
- vertices[i].normal[2] = normalsbuffer[i * 4 + 2] * 127.0f;
- vertices[i].svector[0] = svectorsbuffer[i * 4 + 0] * 127.0f;
- vertices[i].svector[1] = svectorsbuffer[i * 4 + 1] * 127.0f;
- vertices[i].svector[2] = svectorsbuffer[i * 4 + 2] * 127.0f;
+ vertices[i].normal[0] = normalsbuffer[i * 4 + 0];
+ vertices[i].normal[1] = normalsbuffer[i * 4 + 1];
+ vertices[i].normal[2] = normalsbuffer[i * 4 + 2];
+ vertices[i].svector[0] = svectorsbuffer[i * 4 + 0];
+ vertices[i].svector[1] = svectorsbuffer[i * 4 + 1];
+ vertices[i].svector[2] = svectorsbuffer[i * 4 + 2];
}
}
return true;
}
+void Mod_BuildMDLMD2MeshInfo(void)
+{
+ int i;
+ aliasmesh_t *mesh;
+ aliasskin_t *skin;
+ aliaslayer_t *layer;
+ skinframe_t *skinframe;
+
+ loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3]));
+ Mod_ValidateElements(loadmodel->mdlmd2data_indices, loadmodel->numtris, loadmodel->numverts, __FILE__, __LINE__);
+ Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris);
+
+ loadmodel->mdlmd2num_meshes = 1;
+ mesh = loadmodel->mdlmd2data_meshes = Mem_Alloc(loadmodel->mempool, loadmodel->mdlmd2num_meshes * sizeof(aliasmesh_t));
+ mesh->num_skins = 0;
+ mesh->num_frames = 0;
+ for (i = 0;i < loadmodel->numframes;i++)
+ mesh->num_frames += loadmodel->animscenes[i].framecount;
+ for (i = 0;i < loadmodel->numskins;i++)
+ mesh->num_skins += loadmodel->skinscenes[i].framecount;
+ mesh->num_triangles = loadmodel->numtris;
+ mesh->num_vertices = loadmodel->numverts;
+ mesh->data_skins = Mem_Alloc(loadmodel->mempool, mesh->num_skins * sizeof(aliasskin_t));
+ mesh->data_elements = loadmodel->mdlmd2data_indices;
+ mesh->data_neighbors = loadmodel->mdlmd2data_triangleneighbors;
+ mesh->data_texcoords = loadmodel->mdlmd2data_texcoords;
+ mesh->data_vertices = loadmodel->mdlmd2data_pose;
+ for (i = 0, skin = mesh->data_skins, skinframe = loadmodel->skinframes;i < mesh->num_skins;i++, skin++, skinframe++)
+ {
+ skin->flags = 0;
+ // fog texture only exists if some pixels are transparent...
+ if (skinframe->fog != NULL)
+ skin->flags |= ALIASSKIN_TRANSPARENT;
+ // fog and gloss layers always exist
+ skin->num_layers = 2;
+ if (skinframe->glow != NULL)
+ skin->num_layers++;
+ if (skinframe->merged != NULL)
+ skin->num_layers++;
+ if (skinframe->base != NULL)
+ skin->num_layers++;
+ if (skinframe->pants != NULL)
+ skin->num_layers++;
+ if (skinframe->shirt != NULL)
+ skin->num_layers++;
+ layer = skin->data_layers = Mem_Alloc(loadmodel->mempool, skin->num_layers * sizeof(aliaslayer_t));
+ if (skinframe->glow != NULL)
+ {
+ layer->flags = ALIASLAYER_REALTIME_NODRAW;
+ layer->texture = skinframe->glow;
+ layer++;
+ }
+ if (skinframe->merged != NULL)
+ {
+ layer->flags = ALIASLAYER_COLORMAP_NODRAW | ALIASLAYER_DIFFUSE;
+ if (skinframe->glow != NULL)
+ layer->flags |= ALIASLAYER_ADD;
+ layer->texture = skinframe->merged;
+ layer->nmap = skinframe->nmap;
+ layer++;
+ }
+ if (skinframe->base != NULL)
+ {
+ layer->flags = ALIASLAYER_COLORMAP_DRAW | ALIASLAYER_DIFFUSE;
+ if (skinframe->glow != NULL)
+ layer->flags |= ALIASLAYER_ADD;
+ layer->texture = skinframe->base;
+ layer->nmap = skinframe->nmap;
+ layer++;
+ }
+ if (skinframe->pants != NULL)
+ {
+ layer->flags = ALIASLAYER_COLORMAP_DRAW | ALIASLAYER_COLORMAP_DIFFUSE_SHIRT;
+ if (skinframe->glow != NULL || skinframe->base != NULL)
+ layer->flags |= ALIASLAYER_ADD;
+ layer->texture = skinframe->pants;
+ layer->nmap = skinframe->nmap;
+ layer++;
+ }
+ if (skinframe->shirt != NULL)
+ {
+ layer->flags = ALIASLAYER_COLORMAP_DRAW | ALIASLAYER_COLORMAP_DIFFUSE_SHIRT;
+ if (skinframe->glow != NULL || skinframe->base != NULL || skinframe->pants != NULL)
+ layer->flags |= ALIASLAYER_ADD;
+ layer->texture = skinframe->shirt;
+ layer->nmap = skinframe->nmap;
+ layer++;
+ }
+ layer->flags = ALIASLAYER_REALTIME_DRAW | ALIASLAYER_SPECULAR;
+ layer->texture = skinframe->gloss;
+ layer->nmap = skinframe->nmap;
+ layer++;
+ layer->flags = ALIASLAYER_REALTIME_NODRAW | ALIASLAYER_FOG;
+ layer->texture = skinframe->fog;
+ layer++;
+ }
+}
+
#define BOUNDI(VALUE,MIN,MAX) if (VALUE < MIN || VALUE >= MAX) Host_Error("model %s has an invalid ##VALUE (%d exceeds %d - %d)\n", loadmodel->name, VALUE, MIN, MAX);
#define BOUNDF(VALUE,MIN,MAX) if (VALUE < MIN || VALUE >= MAX) Host_Error("model %s has an invalid ##VALUE (%f exceeds %f - %f)\n", loadmodel->name, VALUE, MIN, MAX);
extern void R_Model_Alias_Draw(entity_render_t *ent);
loadmodel->radius = modelradius;
loadmodel->radius2 = modelradius * modelradius;
- loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3]));
- Mod_ValidateElements(loadmodel->mdlmd2data_indices, loadmodel->numtris, loadmodel->numverts, __FILE__, __LINE__);
- Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris);
+ Mod_BuildMDLMD2MeshInfo();
}
static void Mod_MD2_ConvertVerts (vec3_t scale, vec3_t translate, trivertx_t *v, aliasvertex_t *out, int *vertremap)
dist += temp[2]*temp[2];
if (modelradius < dist)
modelradius = dist;
- VectorScale(temp, 16.0f, temp);
- temp[0] = bound(-32768, temp[0], 32767);
- temp[1] = bound(-32768, temp[1], 32767);
- temp[2] = bound(-32768, temp[2], 32767);
VectorCopy(temp, out[i].origin);
}
}
loadmodel->radius = modelradius;
loadmodel->radius2 = modelradius * modelradius;
- loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3]));
- Mod_ValidateElements(loadmodel->mdlmd2data_indices, loadmodel->numtris, loadmodel->numverts, __FILE__, __LINE__);
- Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris);
+ Mod_BuildMDLMD2MeshInfo();
}
extern void R_Model_Zymotic_DrawSky(entity_render_t *ent);