cb *= r_colorscale;
varray_texcoord[0][0] = tex->s2;varray_texcoord[0][1] = tex->t1;
- varray_texcoord[0][2] = tex->s1;varray_texcoord[0][3] = tex->t1;
- varray_texcoord[0][4] = tex->s1;varray_texcoord[0][5] = tex->t2;
- varray_texcoord[0][6] = tex->s2;varray_texcoord[0][7] = tex->t2;
+ varray_texcoord[0][4] = tex->s1;varray_texcoord[0][5] = tex->t1;
+ varray_texcoord[0][8] = tex->s1;varray_texcoord[0][9] = tex->t2;
+ varray_texcoord[0][12] = tex->s2;varray_texcoord[0][13] = tex->t2;
#endif
if (orientation == PARTICLE_BEAM)
m->texture = mesh->texture;
m->indices = p;memcpy(m->indices , mesh->indices , m->numtriangles * sizeof(int[3]));(qbyte *)p += m->numtriangles * sizeof(int[3]);
m->vertices = p;memcpy(m->vertices , mesh->vertices , m->numvertices * sizeof(float[4]));(qbyte *)p += m->numvertices * sizeof(float[4]);
- m->texcoords = p;memcpy(m->texcoords, mesh->texcoords, m->numvertices * sizeof(float[2]));(qbyte *)p += m->numvertices * sizeof(float[2]);
+ m->texcoords = p;memcpy(m->texcoords, mesh->texcoords, m->numvertices * sizeof(float[4]));(qbyte *)p += m->numvertices * sizeof(float[4]);
m->colors = p;memcpy(m->colors , mesh->colors , m->numvertices * sizeof(float[4]));(qbyte *)p += m->numvertices * sizeof(float[4]);
r_refdef.drawqueuesize += dq->size;
}
// a triangle mesh... embedded in the drawqueue
// each vertex is 4 floats (3 are used)
-// each texcoord pair is 2 floats
-// each color is 4 floats
+// each texcoord is 4 floats (3 are used)
+// each color is 4 floats (4 are used)
typedef struct drawqueuemesh_s
{
rtexture_t *texture;
varray_color = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(float[4]));
varray_bcolor = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(qbyte[4]));
for (i = 0;i < backendunits;i++)
- varray_texcoord[i] = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(float[2]));
+ varray_texcoord[i] = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(float[4]));
for (;i < MAX_TEXTUREUNITS;i++)
varray_texcoord[i] = NULL;
}
qglDisable(GL_TEXTURE_2D);CHECKGLERROR
}
qglClientActiveTexture(GL_TEXTURE0_ARB + (gl_state.clientunit = i));CHECKGLERROR
- qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), varray_texcoord[i]);CHECKGLERROR
+ if (gl_texture3d)
+ qglTexCoordPointer(3, GL_FLOAT, sizeof(float[4]), varray_texcoord[i]);CHECKGLERROR
+ else
+ qglTexCoordPointer(2, GL_FLOAT, sizeof(float[4]), varray_texcoord[i]);CHECKGLERROR
if (gl_state.texture[i])
{
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
{
qglDisable(GL_TEXTURE_2D);CHECKGLERROR
}
- qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), varray_texcoord[0]);CHECKGLERROR
+ if (gl_texture3d)
+ qglTexCoordPointer(3, GL_FLOAT, sizeof(float[4]), varray_texcoord[0]);CHECKGLERROR
+ else
+ qglTexCoordPointer(2, GL_FLOAT, sizeof(float[4]), varray_texcoord[0]);CHECKGLERROR
if (gl_state.texture[0])
{
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
if (h == 0)
h = pic->height;
}
- varray_texcoord[0][0] = 0;varray_texcoord[0][1] = 0;
- varray_texcoord[0][2] = 1;varray_texcoord[0][3] = 0;
- varray_texcoord[0][4] = 1;varray_texcoord[0][5] = 1;
- varray_texcoord[0][6] = 0;varray_texcoord[0][7] = 1;
+ varray_texcoord[0][ 0] = 0;varray_texcoord[0][ 1] = 0;
+ varray_texcoord[0][ 4] = 1;varray_texcoord[0][ 5] = 0;
+ varray_texcoord[0][ 8] = 1;varray_texcoord[0][ 9] = 1;
+ varray_texcoord[0][12] = 0;varray_texcoord[0][13] = 1;
varray_vertex[ 0] = x ;varray_vertex[ 1] = y ;varray_vertex[ 2] = 10;
varray_vertex[ 4] = x+w;varray_vertex[ 5] = y ;varray_vertex[ 6] = 10;
varray_vertex[ 8] = x+w;varray_vertex[ 9] = y+h;varray_vertex[10] = 10;
t = (num >> 4)*0.0625f + (0.5f / 256.0f);
u = 0.0625f - (1.0f / 256.0f);
v = 0.0625f - (1.0f / 256.0f);
- at[0] = s ;at[1] = t ;
- at[2] = s+u;at[3] = t ;
- at[4] = s+u;at[5] = t+v;
- at[6] = s ;at[7] = t+v;
+ at[ 0] = s ;at[ 1] = t ;
+ at[ 4] = s+u;at[ 5] = t ;
+ at[ 8] = s+u;at[ 9] = t+v;
+ at[12] = s ;at[13] = t+v;
av[ 0] = x ;av[ 1] = y ;av[ 2] = 10;
av[ 4] = x+w;av[ 5] = y ;av[ 6] = 10;
av[ 8] = x+w;av[ 9] = y+h;av[10] = 10;
av[12] = x ;av[13] = y+h;av[14] = 10;
- at += 8;
+ at += 16;
av += 16;
batchcount++;
if (batchcount >= 128)
R_Mesh_TextureState(&m);
R_Mesh_ResizeCheck(mesh->numvertices);
memcpy(varray_vertex, mesh->vertices, sizeof(float[4]) * mesh->numvertices);
- memcpy(varray_texcoord[0], mesh->texcoords, sizeof(float[2]) * mesh->numvertices);
+ memcpy(varray_texcoord[0], mesh->texcoords, sizeof(float[4]) * mesh->numvertices);
memcpy(varray_color, mesh->colors, sizeof(float[4]) * mesh->numvertices);
GL_UseColorArray();
R_Mesh_Draw(mesh->numvertices, mesh->numtriangles, mesh->indices);
{
// we use one big triangle for all the screen blends
varray_texcoord[0][0] = 0;varray_texcoord[0][1] = 0;
- varray_texcoord[0][2] = 0;varray_texcoord[0][3] = 0;
varray_texcoord[0][4] = 0;varray_texcoord[0][5] = 0;
+ varray_texcoord[0][8] = 0;varray_texcoord[0][9] = 0;
varray_vertex[0] = -5000;varray_vertex[1] = -5000;varray_vertex[2] = 10;
varray_vertex[4] = 10000;varray_vertex[5] = -5000;varray_vertex[6] = 10;
varray_vertex[8] = -5000;varray_vertex[9] = 10000;varray_vertex[10] = 10;
blendfunc2 = GL_ZERO;
}
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
+ 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);
+ 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, aliasvertnorm, varray_color, colorscale, colorscale, colorscale, false);
GL_UseColorArray();
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
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
}
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
}
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
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);
}
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, aliasvertnorm, 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_Mesh_Draw(numverts, numtriangles, elements);
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);
cvar_t r_drawentities = {0, "r_drawentities","1"};
cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
cvar_t r_shadows = {CVAR_SAVE, "r_shadows", "1"};
-cvar_t r_staticworldlights = {0, "r_staticworldlights", "1"};
+cvar_t r_staticworldlights = {0, "r_staticworldlights", "0"};
cvar_t r_speeds = {0, "r_speeds","0"};
cvar_t r_fullbright = {0, "r_fullbright","0"};
cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1"};
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
f = surf->flags & SURF_DRAWFULLBRIGHT ? 1.0f : ((surf->flags & SURF_LIGHTMAP) ? 0 : 0.5f);
R_FillColors(varray_color, mesh->numverts, f, f, f, alpha);
if (!(surf->flags & SURF_DRAWFULLBRIGHT || ent->effects & EF_FULLBRIGHT))
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
if (m.tex[0])
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], alpha, r_colorscale, mesh->numverts, modelorg);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
R_FillColors(varray_color, mesh->numverts, base, base, base, ent->alpha);
if (!(ent->effects & EF_FULLBRIGHT))
{
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, r_colorscale, mesh->numverts, modelorg);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, r_colorscale, mesh->numverts, modelorg);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
if (m.tex[0])
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha, r_colorscale, mesh->numverts, modelorg);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
- memcpy(varray_texcoord[1], mesh->uv, mesh->numverts * sizeof(float[2]));
- memcpy(varray_texcoord[2], mesh->ab, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[1], mesh->uvw, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[2], mesh->abc, mesh->numverts * sizeof(float[4]));
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
- memcpy(varray_texcoord[1], mesh->uv, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[1], mesh->uvw, mesh->numverts * sizeof(float[4]));
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->uv, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->uvw, mesh->numverts * sizeof(float[4]));
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
R_FillColors(varray_color, mesh->numverts, 0, 0, 0, 1);
RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, mesh->numverts, varray_vertex, varray_color);
RSurf_ScaleColors(varray_color, colorscale, mesh->numverts);
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
if (m.tex[0])
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], 1, r_colorscale, mesh->numverts, modelorg);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->ab, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->abc, mesh->numverts * sizeof(float[4]));
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], mesh->str, mesh->numverts * sizeof(float[4]));
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
loadmodel->mdlmd2data_indices[i*3+2] = vertremap[temptris[i][2]];
}
// store the texture coordinates
- loadmodel->mdlmd2data_texcoords = Mem_Alloc(loadmodel->mempool, sizeof(float[2]) * totalverts);
+ loadmodel->mdlmd2data_texcoords = Mem_Alloc(loadmodel->mempool, sizeof(float[4]) * totalverts);
for (i = 0;i < totalverts;i++)
{
- loadmodel->mdlmd2data_texcoords[i*2+0] = vertst[i][0];
- loadmodel->mdlmd2data_texcoords[i*2+1] = vertst[i][1];
+ loadmodel->mdlmd2data_texcoords[i*4+0] = vertst[i][0];
+ loadmodel->mdlmd2data_texcoords[i*4+1] = vertst[i][1];
}
// load the frames
loadmodel->numverts = num;
vertremap = Mem_Alloc(loadmodel->mempool, num * sizeof(int));
- loadmodel->mdlmd2data_texcoords = Mem_Alloc(loadmodel->mempool, num * sizeof(float[2]));
+ loadmodel->mdlmd2data_texcoords = Mem_Alloc(loadmodel->mempool, num * sizeof(float[4]));
for (i = 0;i < num;i++)
{
hash = md2verthashdata + i;
vertremap[i] = hash->xyz;
- loadmodel->mdlmd2data_texcoords[i*2+0] = hash->st[0];
- loadmodel->mdlmd2data_texcoords[i*2+1] = hash->st[1];
+ loadmodel->mdlmd2data_texcoords[i*4+0] = hash->st[0];
+ loadmodel->mdlmd2data_texcoords[i*4+1] = hash->st[1];
}
Mem_Free(md2verthash);
extern void R_Model_Zymotic_DrawOntoLight(entity_render_t *ent);
void Mod_LoadZymoticModel(model_t *mod, void *buffer)
{
- int i, pbase, *bonecount, numposes;
- unsigned int count, a, b, c, *renderlist, *renderlistend;
- rtexture_t **texture;
- char *shadername;
zymtype1header_t *pinmodel, *pheader;
- zymscene_t *scene;
- zymbone_t *bone;
- float corner[2], modelradius;
pinmodel = (void *)buffer;
-
if (memcmp(pinmodel->id, "ZYMOTICMODEL", 12))
Host_Error ("Mod_LoadZymoticModel: %s is not a zymotic model\n");
-
if (BigLong(pinmodel->type) != 1)
Host_Error ("Mod_LoadZymoticModel: only type 1 (skeletal pose) models are currently supported (name = %s)\n", loadmodel->name);
loadmodel->type = mod_alias;
loadmodel->aliastype = ALIASTYPE_ZYM;
-
- loadmodel->zymdata_header = pheader = Mem_Alloc(loadmodel->mempool, BigLong(pinmodel->filesize));
-
- pbase = (int) pheader;
-
- memcpy(pheader, pinmodel, BigLong(pinmodel->filesize));
+ loadmodel->DrawSky = NULL;
+ loadmodel->Draw = R_Model_Zymotic_Draw;
+ loadmodel->DrawFakeShadow = NULL;//R_Model_Zymotic_DrawFakeShadow;
+ loadmodel->DrawDepth = NULL;//R_Model_Zymotic_DrawDepth;
+ loadmodel->DrawShadowVolume = NULL;//R_Model_Zymotic_DrawShadowVolume;
+ loadmodel->DrawLight = NULL;//R_Model_Zymotic_DrawLight;
+ loadmodel->DrawOntoLight = NULL;//R_Model_Zymotic_DrawOntoLight;
// byteswap header
-#define SWAPLONG(var) var = BigLong(var)
-#define SWAPFLOAT(var) var = BigFloat(var)
-#define SWAPVEC(var) SWAPFLOAT(var[0]);SWAPFLOAT(var[1]);SWAPFLOAT(var[2])
- SWAPLONG(pheader->type);
- SWAPLONG(pheader->filesize);
- SWAPVEC(pheader->mins);
- SWAPVEC(pheader->maxs);
- SWAPFLOAT(pheader->radius);
- SWAPLONG(pheader->numverts);
- SWAPLONG(pheader->numtris);
- SWAPLONG(pheader->numshaders);
- SWAPLONG(pheader->numbones);
- SWAPLONG(pheader->numscenes);
-
-#define SWAPLUMPINFO(var) SWAPLONG(pheader->lump_##var.start);SWAPLONG(pheader->lump_##var.length)
- SWAPLUMPINFO(scenes);
- SWAPLUMPINFO(poses);
- SWAPLUMPINFO(bones);
- SWAPLUMPINFO(vertbonecounts);
- SWAPLUMPINFO(verts);
- SWAPLUMPINFO(texcoords);
- SWAPLUMPINFO(render);
- SWAPLUMPINFO(shaders);
- SWAPLUMPINFO(trizone);
+ pheader = pinmodel;
+ pheader->type = BigLong(pinmodel->type);
+ pheader->filesize = BigLong(pinmodel->filesize);
+ pheader->mins[0] = BigFloat(pinmodel->mins[0]);
+ pheader->mins[1] = BigFloat(pinmodel->mins[1]);
+ pheader->mins[2] = BigFloat(pinmodel->mins[2]);
+ pheader->maxs[0] = BigFloat(pinmodel->maxs[0]);
+ pheader->maxs[1] = BigFloat(pinmodel->maxs[1]);
+ pheader->maxs[2] = BigFloat(pinmodel->maxs[2]);
+ pheader->radius = BigFloat(pinmodel->radius);
+ pheader->numverts = loadmodel->zymnum_verts = BigLong(pinmodel->numverts);
+ pheader->numtris = loadmodel->zymnum_tris = BigLong(pinmodel->numtris);
+ pheader->numshaders = loadmodel->zymnum_shaders = BigLong(pinmodel->numshaders);
+ pheader->numbones = loadmodel->zymnum_bones = BigLong(pinmodel->numbones);
+ pheader->numscenes = loadmodel->zymnum_scenes = BigLong(pinmodel->numscenes);
+ pheader->lump_scenes.start = BigLong(pinmodel->lump_scenes.start);
+ pheader->lump_scenes.length = BigLong(pinmodel->lump_scenes.length);
+ pheader->lump_poses.start = BigLong(pinmodel->lump_poses.start);
+ pheader->lump_poses.length = BigLong(pinmodel->lump_poses.length);
+ pheader->lump_bones.start = BigLong(pinmodel->lump_bones.start);
+ pheader->lump_bones.length = BigLong(pinmodel->lump_bones.length);
+ pheader->lump_vertbonecounts.start = BigLong(pinmodel->lump_vertbonecounts.start);
+ pheader->lump_vertbonecounts.length = BigLong(pinmodel->lump_vertbonecounts.length);
+ pheader->lump_verts.start = BigLong(pinmodel->lump_verts.start);
+ pheader->lump_verts.length = BigLong(pinmodel->lump_verts.length);
+ pheader->lump_texcoords.start = BigLong(pinmodel->lump_texcoords.start);
+ pheader->lump_texcoords.length = BigLong(pinmodel->lump_texcoords.length);
+ pheader->lump_render.start = BigLong(pinmodel->lump_render.start);
+ pheader->lump_render.length = BigLong(pinmodel->lump_render.length);
+ pheader->lump_shaders.start = BigLong(pinmodel->lump_shaders.start);
+ pheader->lump_shaders.length = BigLong(pinmodel->lump_shaders.length);
+ pheader->lump_trizone.start = BigLong(pinmodel->lump_trizone.start);
+ pheader->lump_trizone.length = BigLong(pinmodel->lump_trizone.length);
loadmodel->flags = 0; // there are no flags
loadmodel->numframes = pheader->numscenes;
loadmodel->synctype = ST_SYNC;
loadmodel->numtris = pheader->numtris;
+ loadmodel->numverts = 0;
- // FIXME: add skin support and texturing and shaders and...
- loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) + sizeof(skinframe_t));
- loadmodel->skinscenes[0].firstframe = 0;
- loadmodel->skinscenes[0].framecount = 1;
- loadmodel->skinscenes[0].loop = true;
- loadmodel->skinscenes[0].framerate = 10;
- loadmodel->skinframes = (void *)(loadmodel->skinscenes + 1);
- loadmodel->skinframes->base = NULL;
- loadmodel->skinframes->fog = NULL;
- loadmodel->skinframes->pants = NULL;
- loadmodel->skinframes->shirt = NULL;
- loadmodel->skinframes->glow = NULL;
- loadmodel->skinframes->merged = NULL;
- loadmodel->numskins = 1;
- numposes = pheader->lump_poses.length / sizeof(float[3][4]) / pheader->numbones;
+ {
+ unsigned int i;
+ float modelradius, corner[2];
+ // model bbox
+ modelradius = pheader->radius;
+ for (i = 0;i < 3;i++)
+ {
+ loadmodel->normalmins[i] = pheader->mins[i];
+ loadmodel->normalmaxs[i] = pheader->maxs[i];
+ loadmodel->rotatedmins[i] = -modelradius;
+ loadmodel->rotatedmaxs[i] = modelradius;
+ }
+ corner[0] = max(fabs(loadmodel->normalmins[0]), fabs(loadmodel->normalmaxs[0]));
+ corner[1] = max(fabs(loadmodel->normalmins[1]), fabs(loadmodel->normalmaxs[1]));
+ loadmodel->yawmaxs[0] = loadmodel->yawmaxs[1] = sqrt(corner[0]*corner[0]+corner[1]*corner[1]);
+ if (loadmodel->yawmaxs[0] > modelradius)
+ loadmodel->yawmaxs[0] = loadmodel->yawmaxs[1] = modelradius;
+ loadmodel->yawmins[0] = loadmodel->yawmins[1] = -loadmodel->yawmaxs[0];
+ loadmodel->yawmins[2] = loadmodel->normalmins[2];
+ loadmodel->yawmaxs[2] = loadmodel->normalmaxs[2];
+ loadmodel->radius = modelradius;
+ loadmodel->radius2 = modelradius * modelradius;
+ }
+
+ {
+ // FIXME: add shaders, and make them switchable shader sets and...
+ loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) + sizeof(skinframe_t));
+ loadmodel->skinscenes[0].firstframe = 0;
+ loadmodel->skinscenes[0].framecount = 1;
+ loadmodel->skinscenes[0].loop = true;
+ loadmodel->skinscenes[0].framerate = 10;
+ loadmodel->skinframes = (void *)(loadmodel->skinscenes + 1);
+ loadmodel->skinframes->base = NULL;
+ loadmodel->skinframes->fog = NULL;
+ loadmodel->skinframes->pants = NULL;
+ loadmodel->skinframes->shirt = NULL;
+ loadmodel->skinframes->glow = NULL;
+ loadmodel->skinframes->merged = NULL;
+ loadmodel->numskins = 1;
+ }
// go through the lumps, swapping things
-// zymlump_t lump_scenes; // zymscene_t scene[numscenes]; // name and other information for each scene (see zymscene struct)
- scene = (void *) (pheader->lump_scenes.start + pbase);
- loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes);
- for (i = 0;i < pheader->numscenes;i++)
{
- SWAPVEC(scene->mins);
- SWAPVEC(scene->maxs);
- SWAPFLOAT(scene->radius);
- SWAPFLOAT(scene->framerate);
- SWAPLONG(scene->flags);
- SWAPLONG(scene->start);
- SWAPLONG(scene->length);
-
- memcpy(loadmodel->animscenes[i].name, scene->name, 32);
- loadmodel->animscenes[i].firstframe = scene->start;
- loadmodel->animscenes[i].framecount = scene->length;
- loadmodel->animscenes[i].framerate = scene->framerate;
- loadmodel->animscenes[i].loop = (scene->flags & ZYMSCENEFLAG_NOLOOP) == 0;
-
- if ((unsigned int) loadmodel->animscenes[i].firstframe >= numposes)
- Host_Error("Mod_LoadZymoticModel: scene firstframe (%i) >= numposes (%i)\n", loadmodel->animscenes[i].firstframe, numposes);
- if ((unsigned int) loadmodel->animscenes[i].firstframe + (unsigned int) loadmodel->animscenes[i].framecount > numposes)
- Host_Error("Mod_LoadZymoticModel: scene firstframe (%i) + framecount (%i) >= numposes (%i)\n", loadmodel->animscenes[i].firstframe, loadmodel->animscenes[i].framecount, numposes);
- if (loadmodel->animscenes[i].framerate < 0)
- Host_Error("Mod_LoadZymoticModel: scene framerate (%f) < 0\n", loadmodel->animscenes[i].framerate);
- scene++;
+ unsigned int i, numposes;
+ zymscene_t *scene;
+ // zymlump_t lump_scenes; // zymscene_t scene[numscenes]; // name and other information for each scene (see zymscene struct)
+ loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes);
+ scene = (void *) (pheader->lump_scenes.start + buffer);
+ numposes = pheader->lump_poses.length / pheader->numbones / sizeof(float[3][4]);
+ for (i = 0;i < pheader->numscenes;i++)
+ {
+ memcpy(loadmodel->animscenes[i].name, scene->name, 32);
+ loadmodel->animscenes[i].firstframe = BigLong(scene->start);
+ loadmodel->animscenes[i].framecount = BigLong(scene->length);
+ loadmodel->animscenes[i].framerate = BigFloat(scene->framerate);
+ loadmodel->animscenes[i].loop = (BigLong(scene->flags) & ZYMSCENEFLAG_NOLOOP) == 0;
+ if ((unsigned int) loadmodel->animscenes[i].firstframe >= numposes)
+ Host_Error("Mod_LoadZymoticModel: scene firstframe (%i) >= numposes (%i)\n", loadmodel->animscenes[i].firstframe, numposes);
+ if ((unsigned int) loadmodel->animscenes[i].firstframe + (unsigned int) loadmodel->animscenes[i].framecount > numposes)
+ Host_Error("Mod_LoadZymoticModel: scene firstframe (%i) + framecount (%i) >= numposes (%i)\n", loadmodel->animscenes[i].firstframe, loadmodel->animscenes[i].framecount, numposes);
+ if (loadmodel->animscenes[i].framerate < 0)
+ Host_Error("Mod_LoadZymoticModel: scene framerate (%f) < 0\n", loadmodel->animscenes[i].framerate);
+ scene++;
+ }
+ }
+
+ {
+ unsigned int i;
+ float *poses;
+ // zymlump_t lump_poses; // float pose[numposes][numbones][3][4]; // animation data
+ loadmodel->zymdata_poses = Mem_Alloc(loadmodel->mempool, pheader->lump_poses.length);
+ poses = (void *) (pheader->lump_poses.start + buffer);
+ for (i = 0;i < pheader->lump_poses.length / 4;i++)
+ loadmodel->zymdata_poses[i] = BigFloat(poses[i]);
}
-// zymlump_t lump_poses; // float pose[numposes][numbones][3][4]; // animation data
- zymswapintblock((void *) (pheader->lump_poses.start + pbase), pheader->lump_poses.length);
+ {
+ unsigned int i;
+ zymbone_t *bone;
+ // zymlump_t lump_bones; // zymbone_t bone[numbones];
+ loadmodel->zymdata_bones = Mem_Alloc(loadmodel->mempool, pheader->numbones * sizeof(zymbone_t));
+ bone = (void *) (pheader->lump_bones.start + buffer);
+ for (i = 0;i < pheader->numbones;i++)
+ {
+ memcpy(loadmodel->zymdata_bones[i].name, bone[i].name, sizeof(bone[i].name));
+ loadmodel->zymdata_bones[i].flags = BigLong(bone[i].flags);
+ loadmodel->zymdata_bones[i].parent = BigLong(bone[i].parent);
+ if (bone[i].parent >= i)
+ Host_Error("Mod_LoadZymoticModel: bone[i].parent >= i in %s\n", loadmodel->name);
+ }
+ }
-// zymlump_t lump_bones; // zymbone_t bone[numbones];
- bone = (void *) (pheader->lump_bones.start + pbase);
- for (i = 0;i < pheader->numbones;i++)
{
- SWAPLONG(bone[i].flags);
- SWAPLONG(bone[i].parent);
- if (bone[i].parent >= i)
- Host_Error("Mod_LoadZymoticModel: bone[i].parent >= i in %s\n", loadmodel->name);
+ unsigned int i, *bonecount;
+ // zymlump_t lump_vertbonecounts; // int vertbonecounts[numvertices]; // how many bones influence each vertex (separate mainly to make this compress better)
+ loadmodel->zymdata_vertbonecounts = Mem_Alloc(loadmodel->mempool, pheader->numbones * sizeof(int));
+ bonecount = (void *) (pheader->lump_vertbonecounts.start + buffer);
+ for (i = 0;i < pheader->numbones;i++)
+ {
+ loadmodel->zymdata_vertbonecounts[i] = BigLong(bonecount[i]);
+ if (loadmodel->zymdata_vertbonecounts[i] < 1)
+ Host_Error("Mod_LoadZymoticModel: bone vertex count < 1 in %s\n", loadmodel->name);
+ }
}
-// zymlump_t lump_vertbonecounts; // int vertbonecounts[numvertices]; // how many bones influence each vertex (separate mainly to make this compress better)
- zymswapintblock((void *) (pheader->lump_vertbonecounts.start + pbase), pheader->lump_vertbonecounts.length);
- bonecount = (void *) (pheader->lump_vertbonecounts.start + pbase);
- for (i = 0;i < pheader->numbones;i++)
- if (bonecount[i] < 1)
- Host_Error("Mod_LoadZymoticModel: bone vertex count < 1 in %s\n", loadmodel->name);
-
-// zymlump_t lump_verts; // zymvertex_t vert[numvertices]; // see vertex struct
- zymswapintblock((void *) (pheader->lump_verts.start + pbase), pheader->lump_verts.length);
-
-// zymlump_t lump_texcoords; // float texcoords[numvertices][2];
- zymswapintblock((void *) (pheader->lump_texcoords.start + pbase), pheader->lump_texcoords.length);
-
-// zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int count), shaders are sequentially used, each run can be used with glDrawElements (each triangle is 3 int indices)
- zymswapintblock((void *) (pheader->lump_render.start + pbase), pheader->lump_render.length);
- // validate renderlist and swap winding order of tris
- renderlist = (void *) (pheader->lump_render.start + pbase);
- renderlistend = (void *) ((qbyte *) renderlist + pheader->lump_render.length);
- i = pheader->numshaders * sizeof(int) + pheader->numtris * sizeof(int[3]);
- if (pheader->lump_render.length != i)
- Host_Error("Mod_LoadZymoticModel: renderlist is wrong size in %s (is %i bytes, should be %i bytes)\n", loadmodel->name, pheader->lump_render.length, i);
- for (i = 0;i < pheader->numshaders;i++)
{
- if (renderlist >= renderlistend)
- Host_Error("Mod_LoadZymoticModel: corrupt renderlist in %s (wrong size)\n", loadmodel->name);
- count = *renderlist++;
- if (renderlist + count * 3 > renderlistend)
- Host_Error("Mod_LoadZymoticModel: corrupt renderlist in %s (wrong size)\n", loadmodel->name);
- while (count--)
+ unsigned int i;
+ zymvertex_t *vertdata;
+ // zymlump_t lump_verts; // zymvertex_t vert[numvertices]; // see vertex struct
+ loadmodel->zymdata_verts = Mem_Alloc(loadmodel->mempool, pheader->lump_verts.length);
+ vertdata = (void *) (pheader->lump_verts.start + buffer);
+ for (i = 0;i < pheader->lump_verts.length / 4;i++)
{
- a = renderlist[0];
- b = renderlist[1];
- c = renderlist[2];
- if (a >= pheader->numverts || b >= pheader->numverts || c >= pheader->numverts)
- Host_Error("Mod_LoadZymoticModel: corrupt renderlist in %s (out of bounds index)\n", loadmodel->name);
- renderlist[0] = c;
- renderlist[1] = b;
- renderlist[2] = a;
- renderlist += 3;
+ loadmodel->zymdata_verts[i].bonenum = BigLong(vertdata[i].bonenum);
+ loadmodel->zymdata_verts[i].origin[0] = BigLong(vertdata[i].origin[0]);
+ loadmodel->zymdata_verts[i].origin[1] = BigLong(vertdata[i].origin[1]);
+ loadmodel->zymdata_verts[i].origin[2] = BigLong(vertdata[i].origin[2]);
}
}
-// zymlump_t lump_shaders; // char shadername[numshaders][32]; // shaders used on this model
- shadername = (void *) (pheader->lump_shaders.start + pbase);
- texture = (void *) shadername;
- for (i = 0;i < pheader->numshaders;i++)
{
- rtexture_t *rt;
- rt = loadtextureimage(loadmodel->texturepool, shadername, 0, 0, true, r_mipskins.integer, true);
- shadername += 32;
- *texture++ = rt; // reuse shader name list for texture pointers
+ unsigned int i;
+ float *intexcoord, *outtexcoord;
+ // zymlump_t lump_texcoords; // float texcoords[numvertices][2];
+ loadmodel->zymdata_texcoords = outtexcoord = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(float[4]));
+ intexcoord = (void *) (pheader->lump_texcoords.start + buffer);
+ for (i = 0;i < pheader->numverts;i++);
+ {
+ outtexcoord[i*4+0] = BigFloat(intexcoord[i*2+0]);
+ // flip T coordinate for OpenGL
+ outtexcoord[i*4+1] = 1 - BigFloat(intexcoord[i*2+1]);
+ }
}
-// zymlump_t lump_trizone; // byte trizone[numtris]; // see trizone explanation
- zymswapintblock((void *) (pheader->lump_trizone.start + pbase), pheader->lump_trizone.length);
+ {
+ unsigned int i, count, a, b, c, *renderlist, *renderlistend, *outrenderlist;
+ // zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int count), shaders are sequentially used, each run can be used with glDrawElements (each triangle is 3 int indices)
+ loadmodel->zymdata_renderlist = Mem_Alloc(loadmodel->mempool, pheader->lump_render.length);
+ // byteswap, validate, and swap winding order of tris
+ count = pheader->numshaders * sizeof(int) + pheader->numtris * sizeof(int[3]);
+ if (pheader->lump_render.length != count)
+ Host_Error("Mod_LoadZymoticModel: renderlist is wrong size in %s (is %i bytes, should be %i bytes)\n", loadmodel->name, pheader->lump_render.length, count);
+ outrenderlist = loadmodel->zymdata_renderlist = Mem_Alloc(loadmodel->mempool, count);
+ renderlist = (void *) (pheader->lump_render.start + buffer);
+ renderlistend = (void *) ((qbyte *) renderlist + pheader->lump_render.length);
+ for (i = 0;i < pheader->numshaders;i++)
+ {
+ if (renderlist >= renderlistend)
+ Host_Error("Mod_LoadZymoticModel: corrupt renderlist in %s (wrong size)\n", loadmodel->name);
+ count = BigLong(*renderlist);renderlist++;
+ if (renderlist + count * 3 > renderlistend)
+ Host_Error("Mod_LoadZymoticModel: corrupt renderlist in %s (wrong size)\n", loadmodel->name);
+ *outrenderlist++ = count;
+ while (count--)
+ {
+ a = BigLong(renderlist[0]);
+ b = BigLong(renderlist[1]);
+ c = BigLong(renderlist[2]);
+ renderlist += 3;
+ if (a >= pheader->numverts || b >= pheader->numverts || c >= pheader->numverts)
+ Host_Error("Mod_LoadZymoticModel: corrupt renderlist in %s (out of bounds index)\n", loadmodel->name);
+ *outrenderlist++ = c;
+ *outrenderlist++ = b;
+ *outrenderlist++ = a;
+ }
+ }
+ }
- // model bbox
- modelradius = pheader->radius;
- for (i = 0;i < 3;i++)
{
- loadmodel->normalmins[i] = pheader->mins[i];
- loadmodel->normalmaxs[i] = pheader->maxs[i];
- loadmodel->rotatedmins[i] = -modelradius;
- loadmodel->rotatedmaxs[i] = modelradius;
+ unsigned int i;
+ char *shadername;
+ // zymlump_t lump_shaders; // char shadername[numshaders][32]; // shaders used on this model
+ shadername = (void *) (pheader->lump_shaders.start + buffer);
+ for (i = 0;i < pheader->numshaders;i++)
+ loadmodel->zymdata_textures[i] = loadtextureimage(loadmodel->texturepool, shadername + i * 32, 0, 0, true, r_mipskins.integer, true);
}
- corner[0] = max(fabs(loadmodel->normalmins[0]), fabs(loadmodel->normalmaxs[0]));
- corner[1] = max(fabs(loadmodel->normalmins[1]), fabs(loadmodel->normalmaxs[1]));
- loadmodel->yawmaxs[0] = loadmodel->yawmaxs[1] = sqrt(corner[0]*corner[0]+corner[1]*corner[1]);
- if (loadmodel->yawmaxs[0] > modelradius)
- loadmodel->yawmaxs[0] = loadmodel->yawmaxs[1] = modelradius;
- loadmodel->yawmins[0] = loadmodel->yawmins[1] = -loadmodel->yawmaxs[0];
- loadmodel->yawmins[2] = loadmodel->normalmins[2];
- loadmodel->yawmaxs[2] = loadmodel->normalmaxs[2];
- loadmodel->radius = modelradius;
- loadmodel->radius2 = modelradius * modelradius;
- loadmodel->DrawSky = NULL;
- loadmodel->Draw = R_Model_Zymotic_Draw;
- loadmodel->DrawFakeShadow = NULL;//R_Model_Zymotic_DrawFakeShadow;
- loadmodel->DrawDepth = NULL;//R_Model_Zymotic_DrawDepth;
- loadmodel->DrawShadowVolume = NULL;//R_Model_Zymotic_DrawShadowVolume;
- loadmodel->DrawLight = NULL;//R_Model_Zymotic_DrawLight;
- loadmodel->DrawOntoLight = NULL;//R_Model_Zymotic_DrawOntoLight;
+ {
+ // zymlump_t lump_trizone; // byte trizone[numtris]; // see trizone explanation
+ loadmodel->zymdata_trizone = Mem_Alloc(loadmodel->mempool, pheader->numtris);
+ memcpy(loadmodel->zymdata_trizone, (void *) (pheader->lump_trizone.start + buffer), pheader->numtris);
+ }
}
vscale = (vscale - vbase) * 16.0 / ((surf->extents[1] & ~15) + 16);
}
- surf->mesh = mesh = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) + (surf->poly_numverts - 2) * sizeof(int[6]) + surf->poly_numverts * (4 + 2 + 2 + 2 + 1 + 3) * sizeof(float));
+ surf->mesh = mesh = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) + (surf->poly_numverts - 2) * sizeof(int[6]) + surf->poly_numverts * (4 + 4 + 4 + 4 + 1 + 3) * sizeof(float));
mesh->numverts = surf->poly_numverts;
mesh->numtriangles = surf->poly_numverts - 2;
mesh->verts = (float *)(mesh + 1);
- mesh->st = mesh->verts + mesh->numverts * 4;
- mesh->uv = mesh->st + mesh->numverts * 2;
- mesh->ab = mesh->uv + mesh->numverts * 2;
- mesh->lightmapoffsets = (int *)(mesh->ab + mesh->numverts * 2);
+ mesh->str = mesh->verts + mesh->numverts * 4;
+ mesh->uvw = mesh->str + mesh->numverts * 4;
+ mesh->abc = mesh->uvw + mesh->numverts * 4;
+ mesh->lightmapoffsets = (int *)(mesh->abc + mesh->numverts * 4);
mesh->index = mesh->lightmapoffsets + mesh->numverts;
mesh->triangleneighbors = mesh->index + mesh->numtriangles * 3;
mesh->normals = (float *)(mesh->triangleneighbors + mesh->numtriangles * 3);
mesh->verts[i * 4 + 0] = in[0];
mesh->verts[i * 4 + 1] = in[1];
mesh->verts[i * 4 + 2] = in[2];
- mesh->st[i * 2 + 0] = s / surf->texinfo->texture->width;
- mesh->st[i * 2 + 1] = t / surf->texinfo->texture->height;
- mesh->uv[i * 2 + 0] = u;
- mesh->uv[i * 2 + 1] = v;
- mesh->ab[i * 2 + 0] = s * (1.0f / 16.0f);
- mesh->ab[i * 2 + 1] = t * (1.0f / 16.0f);
+ mesh->str[i * 4 + 0] = s / surf->texinfo->texture->width;
+ mesh->str[i * 4 + 1] = t / surf->texinfo->texture->height;
+ mesh->uvw[i * 4 + 0] = u;
+ mesh->uvw[i * 4 + 1] = v;
+ mesh->abc[i * 4 + 0] = s * (1.0f / 16.0f);
+ mesh->abc[i * 4 + 1] = t * (1.0f / 16.0f);
mesh->lightmapoffsets[i] = ((iv * (smax+1) + iu) * 3);
mesh->normals[i * 3 + 0] = normal[0];
mesh->normals[i * 3 + 1] = normal[1];
surf->lightmaptexturestride = 0;
surf->lightmaptexture = NULL;
- surf->mesh = mesh = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) + (surf->poly_numverts - 2) * sizeof(int[6]) + surf->poly_numverts * (4 + 2 + 2 + 3) * sizeof(float));
+ surf->mesh = mesh = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) + (surf->poly_numverts - 2) * sizeof(int[6]) + surf->poly_numverts * (4 + 4 + 4 + 3) * sizeof(float));
mesh->numverts = surf->poly_numverts;
mesh->numtriangles = surf->poly_numverts - 2;
mesh->verts = (float *)(mesh + 1);
- mesh->st = mesh->verts + mesh->numverts * 4;
- mesh->ab = mesh->st + mesh->numverts * 2;
- mesh->index = (int *)(mesh->ab + mesh->numverts * 2);
+ mesh->str = mesh->verts + mesh->numverts * 4;
+ mesh->abc = mesh->str + mesh->numverts * 4;
+ mesh->index = (int *)(mesh->abc + mesh->numverts * 4);
mesh->triangleneighbors = mesh->index + mesh->numtriangles * 3;
mesh->normals = (float *)(mesh->triangleneighbors + mesh->numtriangles * 3);
mesh->verts[i * 4 + 0] = in[0];
mesh->verts[i * 4 + 1] = in[1];
mesh->verts[i * 4 + 2] = in[2];
- mesh->st[i * 2 + 0] = s / surf->texinfo->texture->width;
- mesh->st[i * 2 + 1] = t / surf->texinfo->texture->height;
- mesh->ab[i * 2 + 0] = s * (1.0f / 16.0f);
- mesh->ab[i * 2 + 1] = t * (1.0f / 16.0f);
+ mesh->str[i * 4 + 0] = s / surf->texinfo->texture->width;
+ mesh->str[i * 4 + 1] = t / surf->texinfo->texture->height;
+ mesh->abc[i * 4 + 0] = s * (1.0f / 16.0f);
+ mesh->abc[i * 4 + 1] = t * (1.0f / 16.0f);
mesh->normals[i * 3 + 0] = normal[0];
mesh->normals[i * 3 + 1] = normal[1];
mesh->normals[i * 3 + 2] = normal[2];
float *verts;
float *normals;
int *lightmapoffsets;
- float *st;
- float *uv;
- float *ab;
+ float *str;
+ float *uvw;
+ float *abc;
int *index;
int *triangleneighbors;
}
int *mdlmd2data_triangleneighbors;
// for Zymotic models
- void *zymdata_header;
+ int zymnum_verts;
+ int zymnum_tris;
+ int zymnum_shaders;
+ int zymnum_bones;
+ int zymnum_scenes;
+ float *zymdata_texcoords;
+ rtexture_t **zymdata_textures;
+ qbyte *zymdata_trizone;
+ zymbone_t *zymdata_bones;
+ unsigned int *zymdata_vertbonecounts;
+ zymvertex_t *zymdata_verts;
+ unsigned int *zymdata_renderlist;
+ float *zymdata_poses;
int sprnum_type;
mspriteframe_t *sprdata_frames;
R_Mesh_State(&m);
GL_Color(cr * r_colorscale, cg * r_colorscale, cb * r_colorscale, ca);
- varray_texcoord[0][0] = 0;
- varray_texcoord[0][1] = 0;
- varray_texcoord[0][2] = 0;
- varray_texcoord[0][3] = 1;
- varray_texcoord[0][4] = 1;
- varray_texcoord[0][5] = 1;
- varray_texcoord[0][6] = 1;
- varray_texcoord[0][7] = 0;
+ varray_texcoord[0][ 0] = 0;varray_texcoord[0][ 1] = 0;
+ varray_texcoord[0][ 4] = 0;varray_texcoord[0][ 5] = 1;
+ varray_texcoord[0][ 8] = 1;varray_texcoord[0][ 9] = 1;
+ varray_texcoord[0][12] = 1;varray_texcoord[0][13] = 0;
varray_vertex[0] = origin[0] - vright[0] * scale - vup[0] * scale;
varray_vertex[1] = origin[1] - vright[1] * scale - vup[1] * scale;
varray_vertex[2] = origin[2] - vright[2] * scale - vup[2] * scale;
#define EXPLOSIONFADESTART (1.5f)
#define EXPLOSIONFADERATE (3.0f)
-float explosiontexcoords[EXPLOSIONVERTS][2];
+float explosiontexcoords[EXPLOSIONVERTS][4];
int explosiontris[EXPLOSIONTRIS][3];
int explosionnoiseindex[EXPLOSIONVERTS];
vec3_t explosionpoint[EXPLOSIONVERTS];
v[1] = e->vert[i][1];
v[2] = e->vert[i][2];
}
- memcpy(varray_texcoord[0], explosiontexcoords, numverts * sizeof(float[2]));
+ memcpy(varray_texcoord[0], explosiontexcoords, numverts * sizeof(float[4]));
alpha = e->alpha;
VectorSubtract(r_origin, e->origin, centerdir);
VectorNormalizeFast(centerdir);
R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
viewdist = DotProduct(r_origin, vpn);
+ varray_texcoord[0][ 0] = 0;varray_texcoord[0][ 1] = 0;
+ varray_texcoord[0][ 4] = 0;varray_texcoord[0][ 5] = 1;
+ varray_texcoord[0][ 8] = 1;varray_texcoord[0][ 9] = 1;
+ varray_texcoord[0][12] = 1;varray_texcoord[0][13] = 0;
for (i = 0;i < r_numdlights;i++)
{
rd = r_dlight + i;
scale *= 1 - exp(fogdensity/DotProduct(diff,diff));
}
GL_Color(rd->light[0] * scale, rd->light[1] * scale, rd->light[2] * scale, 1);
- varray_texcoord[0][0] = 0;
- varray_texcoord[0][1] = 0;
- varray_texcoord[0][2] = 0;
- varray_texcoord[0][3] = 1;
- varray_texcoord[0][4] = 1;
- varray_texcoord[0][5] = 1;
- varray_texcoord[0][6] = 1;
- varray_texcoord[0][7] = 0;
scale = rd->cullradius * 0.25f;
if (gl_flashblend.integer)
scale *= 2.0f;
varray_vertex[i * 4 + 0] = (x) * 16.0f;\
varray_vertex[i * 4 + 1] = (y) * 16.0f;\
varray_vertex[i * 4 + 2] = (z) * 16.0f;\
- varray_texcoord[0][i * 2 + 0] = (s) * (254.0f/256.0f) + (1.0f/256.0f);\
- varray_texcoord[0][i * 2 + 1] = (t) * (254.0f/256.0f) + (1.0f/256.0f);
+ varray_texcoord[0][i * 4 + 0] = (s) * (254.0f/256.0f) + (1.0f/256.0f);\
+ varray_texcoord[0][i * 4 + 1] = (t) * (254.0f/256.0f) + (1.0f/256.0f);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
#define skygridy 32
#define skygridy1 (skygridy + 1)
#define skygridyrecip (1.0f / (skygridy))
+#define skysphere_numverts (skygridx1 * skygridy1)
+#define skysphere_numtriangles (skygridx * skygridy * 2)
+static float skysphere_vertex[skysphere_numverts * 4];
+static float skysphere_texcoord[skysphere_numverts * 4];
+static int skysphere_elements[skysphere_numtriangles * 3];
-static float skysphere[skygridx1*skygridy1*5];
-static int skysphereindices[skygridx*skygridy*6];
-static void skyspherecalc(float *sphere, float dx, float dy, float dz)
+static void skyspherecalc(void)
{
- float a, b, x, ax, ay, v[3], length;
- int i, j, *index;
+ int i, j, *e;
+ float a, b, x, ax, ay, v[3], length, *vertex, *texcoord;
+ float dx, dy, dz;
+ dx = 16;
+ dy = 16;
+ dz = 16 / 3;
+ vertex = skysphere_vertex;
+ texcoord = skysphere_texcoord;
for (j = 0;j <= skygridy;j++)
{
a = j * skygridyrecip;
v[1] = ay*x * dy;
v[2] = -sin(b * M_PI * 2) * dz;
length = 3.0f / sqrt(v[0]*v[0]+v[1]*v[1]+(v[2]*v[2]*9));
- *sphere++ = v[0] * length;
- *sphere++ = v[1] * length;
- *sphere++ = v[0];
- *sphere++ = v[1];
- *sphere++ = v[2];
+ *texcoord++ = v[0] * length;
+ *texcoord++ = v[1] * length;
+ *texcoord++ = 0;
+ *texcoord++ = 0;
+ *vertex++ = v[0];
+ *vertex++ = v[1];
+ *vertex++ = v[2];
+ *vertex++ = 1;
}
}
- index = skysphereindices;
+ e = skysphere_elements;
for (j = 0;j < skygridy;j++)
{
for (i = 0;i < skygridx;i++)
{
- *index++ = j * skygridx1 + i;
- *index++ = j * skygridx1 + i + 1;
- *index++ = (j + 1) * skygridx1 + i;
+ *e++ = j * skygridx1 + i;
+ *e++ = j * skygridx1 + i + 1;
+ *e++ = (j + 1) * skygridx1 + i;
- *index++ = j * skygridx1 + i + 1;
- *index++ = (j + 1) * skygridx1 + i + 1;
- *index++ = (j + 1) * skygridx1 + i;
+ *e++ = j * skygridx1 + i + 1;
+ *e++ = (j + 1) * skygridx1 + i + 1;
+ *e++ = (j + 1) * skygridx1 + i;
}
i++;
}
}
-static void skyspherearrays(float *v, float *t, float *source, float s)
-{
- int i;
- for (i = 0;i < (skygridx1*skygridy1);i++, t += 2, v += 4, source += 5)
- {
- t[0] = source[0] + s;
- t[1] = source[1] + s;
- v[0] = source[2];
- v[1] = source[3];
- v[2] = source[4];
- }
-}
-
static void R_SkySphere(void)
{
- int numverts, numtriangles;
- float speedscale, speedscale2;
+ int i;
+ float speedscale, *t;
static qboolean skysphereinitialized = false;
rmeshstate_t m;
if (!skysphereinitialized)
{
skysphereinitialized = true;
- skyspherecalc(skysphere, 16, 16, 16 / 3);
+ skyspherecalc();
}
+ // scroll speed for upper layer
speedscale = cl.time*8.0/128.0;
+ // wrap the scroll just to be extra kind to float accuracy
speedscale -= (int)speedscale;
- speedscale2 = cl.time*16.0/128.0;
- speedscale2 -= (int)speedscale2;
-
- numverts = skygridx1*skygridy1;
- numtriangles = skygridx*skygridy*2;
- R_Mesh_ResizeCheck(numverts);
+ R_Mesh_ResizeCheck(skysphere_numverts);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
- skyspherearrays(varray_vertex, varray_texcoord[0], skysphere, speedscale);
- R_Mesh_Draw(numverts, numtriangles, skysphereindices);
+ memcpy(varray_vertex, skysphere_vertex, skysphere_numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[0], skysphere_texcoord, skysphere_numverts * sizeof(float[4]));
+ for (i = 0, t = varray_texcoord[0];i < skysphere_numverts;i++, t += 4)
+ {
+ t[0] += speedscale;
+ t[1] += speedscale;
+ }
+ R_Mesh_Draw(skysphere_numverts, skysphere_numtriangles, skysphere_elements);
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.tex[0] = R_GetTexture(alphaskytexture);
R_Mesh_State(&m);
- skyspherearrays(varray_vertex, varray_texcoord[0], skysphere, speedscale2);
- R_Mesh_Draw(numverts, numtriangles, skysphereindices);
+ // scroll it again, this makes the lower cloud layer scroll twice as fast (just like quake did)
+ for (i = 0, t = varray_texcoord[0];i < skysphere_numverts;i++, t += 4)
+ {
+ t[0] += speedscale;
+ t[1] += speedscale;
+ }
+ R_Mesh_Draw(skysphere_numverts, skysphere_numtriangles, skysphere_elements);
}
void R_Sky(void)
m.tex[0] = texture;
R_Mesh_State(&m);
- varray_texcoord[0][0] = 0;
- varray_texcoord[0][1] = 1;
- varray_texcoord[0][2] = 0;
- varray_texcoord[0][3] = 0;
- varray_texcoord[0][4] = 1;
- varray_texcoord[0][5] = 0;
- varray_texcoord[0][6] = 1;
- varray_texcoord[0][7] = 1;
+ varray_texcoord[0][ 0] = 0;varray_texcoord[0][ 1] = 1;
+ varray_texcoord[0][ 4] = 0;varray_texcoord[0][ 5] = 0;
+ varray_texcoord[0][ 8] = 1;varray_texcoord[0][ 9] = 0;
+ varray_texcoord[0][12] = 1;varray_texcoord[0][13] = 1;
// FIXME: negate left and right in loader
varray_vertex[0] = origin[0] + frame->down * up[0] - frame->left * left[0];
varray_vertex[1] = origin[1] + frame->down * up[1] - frame->left * left[1];