From 7a2b6570f2bff4dde288961fd5580631d81c2e43 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 26 Oct 2004 15:30:13 +0000 Subject: [PATCH] Giving shaders the normals info. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@369 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/gl_q2bsp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/engine/common/gl_q2bsp.c b/engine/common/gl_q2bsp.c index dba75791c..bd8a24155 100644 --- a/engine/common/gl_q2bsp.c +++ b/engine/common/gl_q2bsp.c @@ -333,6 +333,7 @@ int numvertexes; vec2_t *map_vertstmexcoords; vec2_t *map_vertlstmexcoords; byte_vec4_t *map_colors_array; +vec3_t *map_normals_array; #ifdef Q3SHADERS typedef struct { @@ -1903,6 +1904,7 @@ void CModQ3_LoadVertexes (lump_t *l) { q3dvertex_t *in; vec4_t *out; + vec3_t *nout; int i, count, j; vec2_t *lmout, *stout; byte_vec4_t *cout; @@ -1919,10 +1921,12 @@ void CModQ3_LoadVertexes (lump_t *l) stout = Hunk_Alloc ( count*sizeof(*stout) ); lmout = Hunk_Alloc ( count*sizeof(*lmout) ); cout = Hunk_Alloc ( count*sizeof(*cout) ); + nout = Hunk_Alloc ( count*sizeof(*nout) ); map_verts = out; map_vertstmexcoords = stout; map_vertlstmexcoords = lmout; map_colors_array = cout; + map_normals_array = nout; numvertexes = count; for ( i=0 ; ipoint[j] ); + nout[i][j] = LittleFloat (in->normal[j]); } for ( j=0 ; j < 2 ; j++) { @@ -2177,7 +2182,7 @@ mesh_t *GL_CreateMeshForPatch ( model_t *mod, q3dface_t *surf ) firstvert = LittleLong ( surf->firstvertex ); for ( i = 0; i < numverts; i++ ) { VectorCopy ( map_verts[firstvert + i], points[i] ); -// VectorCopy ( mod->bmodel->normals_array[firstvert + i], normals[i] ); + VectorCopy ( map_normals_array[firstvert + i], normals[i] ); Vector4Scale ( map_colors_array[firstvert + i], (1.0 / 255.0), colors[i] ); Vector2Copy ( map_vertstmexcoords[firstvert + i], tex_st[i] ); Vector2Copy ( map_vertlstmexcoords[firstvert + i], lm_st[i] ); @@ -2376,8 +2381,8 @@ continue; #ifdef Q3SHADERS out->mesh = Hunk_Alloc(sizeof(mesh_t) + (sizeof(vec3_t)) * numverts); - out->mesh->normals_array= (vec3_t *)(out->mesh+1); - out->mesh->colors_array = map_colors_array + LittleLong(in->firstindex); + out->mesh->normals_array= map_normals_array + LittleLong(in->firstvertex); + out->mesh->colors_array = map_colors_array + LittleLong(in->firstvertex); out->mesh->indexes = map_surfindexes + LittleLong(in->firstindex); out->mesh->xyz_array = map_verts + LittleLong(in->firstvertex); out->mesh->st_array = map_vertstmexcoords + LittleLong(in->firstvertex);