]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
texcoord arrays are now 3 component (padded to 4 floats)
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Oct 2002 14:38:14 +0000 (14:38 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Oct 2002 14:38:14 +0000 (14:38 +0000)
rewrote zym model loader
partially rewrote skysphere rendering

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2502 d7cf8633-e32d-0410-b094-e92efae38249

17 files changed:
cl_particles.c
cl_screen.c
cl_screen.h
gl_backend.c
gl_draw.c
gl_models.c
gl_rmain.c
gl_rsurf.c
model_alias.c
model_brush.c
model_brush.h
model_shared.h
r_crosshairs.c
r_explosion.c
r_light.c
r_sky.c
r_sprites.c

index 97accb552deee570bc67d46b711d3d4f4414c4c1..d092dc3c2b2b4479a299059f46cb9a448918166a 100644 (file)
@@ -1505,9 +1505,9 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2)
        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)
index 5abb2196485b195b6812a1c0c89e51ffb9cb67b9..86081c27ae17dc093f2f27e26a88e736cf42ed21 100644 (file)
@@ -602,7 +602,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
        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;
 }
index 9a4859b583c6f72c4e4c9917b75ec2333b681c17..c48a2cf4592c859e7b961b2f87f097fc1fa001d5 100644 (file)
@@ -18,8 +18,8 @@ drawqueue_t;
 
 // 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;
index 2ec09f0bc95c0d97e1866405a9bba87fe4ce67c9..2a77e876d1a62ad23a4af444483cc16f7bfe1ec3 100644 (file)
@@ -104,7 +104,7 @@ void GL_Backend_AllocArrays(void)
        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;
 }
@@ -310,7 +310,10 @@ void GL_SetupTextureState(void)
                                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
@@ -333,7 +336,10 @@ void GL_SetupTextureState(void)
                {
                        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
index 7fc4db6316f301e747b6c52873c4234d0ef2e6d2..c3ade96d266b115b5c764812a7008786d95887f8 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -459,10 +459,10 @@ void R_DrawQueue(void)
                                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;
@@ -490,15 +490,15 @@ void R_DrawQueue(void)
                                        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)
@@ -520,7 +520,7 @@ void R_DrawQueue(void)
                        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);
@@ -533,8 +533,8 @@ void R_DrawQueue(void)
        {
                // 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;
index a0a077b3cf038200fc3c42a6ef56e06b9660035c..30ba77fdcdf881d07d06802599719e606d97f327 100644 (file)
@@ -265,6 +265,8 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                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
@@ -280,9 +282,11 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                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);
@@ -322,8 +326,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                }
                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
@@ -355,8 +357,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                                }
                                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
@@ -386,8 +386,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                                }
                                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
@@ -416,8 +414,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                        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);
                }
@@ -431,8 +427,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                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);
        }
@@ -862,7 +856,6 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        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;
@@ -872,13 +865,12 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        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);
@@ -925,10 +917,10 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        }
        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);
@@ -951,19 +943,15 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
 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);
index 4a10f505a5b4e3baab4fbf57780afa66764ca076..6ad76ed1dae71cf9ba7fd9758d32dea9fcf3271f 100644 (file)
@@ -52,7 +52,7 @@ unsigned short d_lightstylevalue[256];
 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"};
index 9bbf8afcdb218430e18bb584ebab88eb9f10000a..592ec34c11db0c29c6d4ea9cf6a50a1a897305c7 100644 (file)
@@ -844,7 +844,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
        {
                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))
@@ -870,7 +870,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                        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);
                }
@@ -931,7 +931,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m
        {
                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))
                {
@@ -974,7 +974,7 @@ static void RSurfShader_Wall_Pass_BaseFullbright(const entity_render_t *ent, con
        {
                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);
        }
@@ -996,7 +996,7 @@ static void RSurfShader_Wall_Pass_Glow(const entity_render_t *ent, const msurfac
        {
                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);
        }
@@ -1019,7 +1019,7 @@ static void RSurfShader_Wall_Pass_Fog(const entity_render_t *ent, const msurface
                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);
        }
@@ -1056,9 +1056,9 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render
                {
                        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);
                }
        }
@@ -1091,8 +1091,8 @@ static void RSurfShader_OpaqueWall_Pass_BaseDoubleTex(const entity_render_t *ent
                {
                        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);
                }
        }
@@ -1115,7 +1115,7 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(const entity_render_t *ent,
                {
                        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);
                }
        }
@@ -1147,7 +1147,7 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const entity_render_t *ent,
                {
                        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);
                }
        }
@@ -1182,7 +1182,7 @@ static void RSurfShader_OpaqueWall_Pass_Light(const entity_render_t *ent, const
                                {
                                        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);
@@ -1212,7 +1212,7 @@ static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const te
                        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);
                }
@@ -1236,7 +1236,7 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, c
                {
                        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);
                }
        }
@@ -1259,7 +1259,7 @@ static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const t
                {
                        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);
                }
        }
index 557811e801a25a2fc6c121ddf70af6cd5a464faf..9debb5387a21283b131028c919c664bb4820761f 100644 (file)
@@ -507,11 +507,11 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer)
                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
@@ -739,13 +739,13 @@ void Mod_LoadQ2AliasModel (model_t *mod, void *buffer)
 
        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);
@@ -825,203 +825,246 @@ extern void R_Model_Zymotic_DrawLight(entity_render_t *ent, vec3_t relativelight
 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);
+       }
 }
index b5bc85e1b14248e83d2a4e3394ed08bce28734dc..44bb23ffca98aa5fac17d5c399e1aa70f0ba8bf2 100644 (file)
@@ -2091,14 +2091,14 @@ void Mod_GenerateWallMesh (msurface_t *surf, int vertexonly)
                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);
@@ -2132,12 +2132,12 @@ void Mod_GenerateWallMesh (msurface_t *surf, int vertexonly)
                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];
@@ -2154,13 +2154,13 @@ void Mod_GenerateVertexMesh (msurface_t *surf)
        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);
 
@@ -2183,10 +2183,10 @@ void Mod_GenerateVertexMesh (msurface_t *surf)
                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];
index e95fdae6bf5b91f9a6d53c9bcc2cb2ce1308534a..ff58a377092b6d9c308bc6ff530d45fb6317a022 100644 (file)
@@ -145,9 +145,9 @@ typedef struct surfmesh_s
        float *verts;
        float *normals;
        int *lightmapoffsets;
-       float *st;
-       float *uv;
-       float *ab;
+       float *str;
+       float *uvw;
+       float *abc;
        int *index;
        int *triangleneighbors;
 }
index c80f495133c91096b27d867586104f8e59caa9f7..769062343f823549312fa9de8407e601443c1937 100644 (file)
@@ -207,7 +207,19 @@ typedef struct model_s
        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;
index 2de8d9b9f112849f4d392ed22ee8013f9007d36e..7e7bf7061501efda90534c03dc1c3855e5b8d91a 100644 (file)
@@ -42,14 +42,10 @@ void R_DrawCrosshairSprite(rtexture_t *texture, vec3_t origin, vec_t scale, floa
        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;
index 6dac84caf655f9faacf6478edaca0000044d37af..168a9ff38304864ded562ab0036c1805c96f09fc 100644 (file)
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #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];
@@ -198,7 +198,7 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2)
                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);
index 3424cdd5438de3811c8f2f33f9b63d266e18fe71..1d5c2cbb6216e0f50dde08cf48dc8b671ba669a9 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -153,6 +153,10 @@ void R_DrawCoronas(void)
        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;
@@ -168,14 +172,6 @@ void R_DrawCoronas(void)
                                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;
diff --git a/r_sky.c b/r_sky.c
index e73d3672bbacd77596d07ea68d885dcb4dac378f..6f1cb06ac2074c853c5f36b7420b15cad15a1a43 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -122,8 +122,8 @@ static void R_SkyBox(void)
        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;
@@ -182,13 +182,22 @@ static void R_SkyBox(void)
 #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;
@@ -202,64 +211,51 @@ static void skyspherecalc(float *sphere, float dx, float dy, float dz)
                        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;
@@ -270,16 +266,27 @@ static void R_SkySphere(void)
 
        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)
index b69140da5a7d64ca5ea8e3f98b868b19579d8c41..5da6042a191aaa89a9cfcad0be1d18d1de32f9e5 100644 (file)
@@ -89,14 +89,10 @@ static void R_DrawSpriteImage (int additive, mspriteframe_t *frame, int texture,
        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];