08 Jan 2014
This commit is contained in:
parent
65c9bbd10f
commit
e11dac742d
|
@ -200,10 +200,10 @@ typedef struct msurfmesh_s
|
|||
|
||||
vec3_t *vertices; // vertexes array
|
||||
vec2_t *stcoords; // s\t coords array
|
||||
vec2_t *lmcoords; // l\m coords array
|
||||
vec3_t *normals; // normals array
|
||||
vec3_t tangent; // shared for mesh
|
||||
vec3_t binormal; // shared for mesh
|
||||
vec2_t *lmcoords; // l\m coords array (unused for studio models)
|
||||
vec3_t *normals; // normals array (identical for bsp polys, unique for studio models)
|
||||
vec3_t *tangent; // tangent array (identical for bsp polys, unique for studio models)
|
||||
vec3_t *binormal; // binormal array (identical for bsp polys, unique for studio models)
|
||||
byte *colors; // colors array for vertex lighting (filling 0xFF by default)
|
||||
unsigned short *indices; // indices
|
||||
|
||||
|
|
|
@ -24,5 +24,6 @@ GNU General Public License for more details.
|
|||
#define ENGINE_LARGE_LIGHTMAPS (1<<4) // change lightmap sizes from 128x128 to 256x256
|
||||
#define ENGINE_COMPENSATE_QUAKE_BUG (1<<5) // compensate stupid quake bug (inverse pitch) for mods where this bug is fixed
|
||||
#define ENGINE_DISABLE_HDTEXTURES (1<<6) // disable support of HD-textures in case custom renderer have separate way to load them
|
||||
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
|
||||
|
||||
#endif//FEATURES_H
|
|
@ -155,16 +155,14 @@ void CL_UpdateEntityFields( cl_entity_t *ent )
|
|||
{
|
||||
qboolean applyVel, applyAvel;
|
||||
|
||||
d = -1.0f;
|
||||
|
||||
applyVel = !VectorCompare( m_pGround->curstate.origin, m_pGround->prevstate.origin );
|
||||
applyAvel = !VectorCompare( m_pGround->curstate.angles, m_pGround->prevstate.angles );
|
||||
|
||||
if( applyVel || applyAvel )
|
||||
{
|
||||
ent->origin[0] += ( m_pGround->curstate.origin[0] - m_pGround->prevstate.origin[0] ) * d;
|
||||
ent->origin[1] += ( m_pGround->curstate.origin[1] - m_pGround->prevstate.origin[1] ) * d;
|
||||
// ent->origin[2] += ( m_pGround->curstate.origin[2] - m_pGround->prevstate.origin[2] ) * d;
|
||||
ent->origin[0] += ( m_pGround->curstate.origin[0] - m_pGround->prevstate.origin[0] ) * -1.0f;
|
||||
ent->origin[1] += ( m_pGround->curstate.origin[1] - m_pGround->prevstate.origin[1] ) * -1.0f;
|
||||
// ent->origin[2] += ( m_pGround->curstate.origin[2] - m_pGround->prevstate.origin[2] ) * -1.0f;
|
||||
ent->latched.prevorigin[2] = ent->origin[2];
|
||||
}
|
||||
|
||||
|
@ -176,13 +174,33 @@ void CL_UpdateEntityFields( cl_entity_t *ent )
|
|||
|
||||
ang1 = m_pGround->curstate.angles[i];
|
||||
ang2 = m_pGround->prevstate.angles[i];
|
||||
f = ang1 - ang2;
|
||||
if( d > 180.0f ) f -= 360.0f;
|
||||
else if( d < -180.0f ) f += 360.0f;
|
||||
ent->angles[i] += d * f;
|
||||
d = ang1 - ang2;
|
||||
if( d > 180.0f ) d -= 360.0f;
|
||||
else if( d < -180.0f ) d += 360.0f;
|
||||
ent->angles[i] += d * -1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// move code from StudioSetupTransform here
|
||||
if( host.features & ENGINE_COMPUTE_STUDIO_LERP )
|
||||
{
|
||||
ent->origin[0] += ( ent->curstate.origin[0] - ent->latched.prevorigin[0] ) * f;
|
||||
ent->origin[1] += ( ent->curstate.origin[1] - ent->latched.prevorigin[1] ) * f;
|
||||
ent->origin[2] += ( ent->curstate.origin[2] - ent->latched.prevorigin[2] ) * f;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
float ang1, ang2;
|
||||
|
||||
ang1 = ent->angles[i];
|
||||
ang2 = ent->latched.prevangles[i];
|
||||
d = ang1 - ang2;
|
||||
if( d > 180.0f ) d -= 360.0f;
|
||||
else if( d < -180.0f ) d += 360.0f;
|
||||
ent->angles[i] += d * f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -538,6 +538,7 @@ msurfmesh_t *R_DecalCreateMesh( decalinfo_t *decalinfo, decal_t *pdecal, msurfac
|
|||
|
||||
// mesh + ( vertex, normal, (st + lmst) ) * numVerts + elem * numElems;
|
||||
bufSize = sizeof( msurfmesh_t ) + numVerts * ( sizeof( vec3_t ) + sizeof( vec3_t ) + sizeof( vec4_t )) + numElems * sizeof( word );
|
||||
bufSize += numVerts * ( sizeof( vec3_t ) + sizeof( vec3_t )); // tangent and binormal
|
||||
bufSize += numVerts * sizeof( rgba_t ); // color array
|
||||
|
||||
buffer = Mem_Alloc( cls.mempool, bufSize );
|
||||
|
@ -556,6 +557,10 @@ msurfmesh_t *R_DecalCreateMesh( decalinfo_t *decalinfo, decal_t *pdecal, msurfac
|
|||
buffer += numVerts * sizeof( vec2_t );
|
||||
mesh->normals = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->tangent = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->binormal = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->colors = (byte *)buffer;
|
||||
buffer += numVerts * sizeof( rgba_t );
|
||||
|
||||
|
@ -572,9 +577,6 @@ msurfmesh_t *R_DecalCreateMesh( decalinfo_t *decalinfo, decal_t *pdecal, msurfac
|
|||
mesh->indices[i*3+2] = i + 2;
|
||||
}
|
||||
|
||||
VectorCopy( decalinfo->m_Basis[0], mesh->tangent );
|
||||
VectorCopy( decalinfo->m_Basis[1], mesh->binormal );
|
||||
|
||||
// clear colors (it can be used for vertex lighting)
|
||||
Q_memset( mesh->colors, 0xFF, numVerts * sizeof( rgba_t ));
|
||||
|
||||
|
@ -582,6 +584,8 @@ msurfmesh_t *R_DecalCreateMesh( decalinfo_t *decalinfo, decal_t *pdecal, msurfac
|
|||
for( i = 0; i < numVerts; i++, v += VERTEXSIZE )
|
||||
{
|
||||
VectorCopy( v, mesh->vertices[i] );
|
||||
VectorCopy( decalinfo->m_Basis[0], mesh->tangent[i] );
|
||||
VectorCopy( decalinfo->m_Basis[1], mesh->binormal[i] );
|
||||
VectorCopy( decalinfo->m_Basis[2], mesh->normals[i] );
|
||||
|
||||
mesh->stcoords[i][0] = v[3];
|
||||
|
|
|
@ -468,7 +468,9 @@ void R_TextureList_f( void )
|
|||
break;
|
||||
}
|
||||
|
||||
if( image->flags & TF_NOMIPMAP )
|
||||
if( image->flags & TF_NORMALMAP )
|
||||
Msg( "normal " );
|
||||
else if( image->flags & TF_NOMIPMAP )
|
||||
Msg( "linear " );
|
||||
if( image->flags & TF_NEAREST )
|
||||
Msg( "nearest" );
|
||||
|
@ -802,7 +804,7 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
|
|||
|
||||
/*
|
||||
=================
|
||||
GL_ResampleTexture
|
||||
GL_ApplyGamma
|
||||
|
||||
Assume input buffer is RGBA
|
||||
=================
|
||||
|
@ -901,6 +903,9 @@ void GL_GenerateMipmaps( byte *buffer, rgbdata_t *pic, gltexture_t *tex, GLenum
|
|||
return;
|
||||
}
|
||||
|
||||
// screen texture?
|
||||
if( !buffer ) return;
|
||||
|
||||
mipLevel = 0;
|
||||
w = tex->width;
|
||||
h = tex->height;
|
||||
|
@ -978,7 +983,8 @@ static void GL_UploadTexture( rgbdata_t *pic, gltexture_t *tex, qboolean subImag
|
|||
tex->fogParams[2] = pic->fogParams[2];
|
||||
tex->fogParams[3] = pic->fogParams[3];
|
||||
|
||||
GL_RoundImageDimensions( &tex->width, &tex->height, tex->flags, false );
|
||||
// NOTE: normalmaps must be power of two or software mip generator will stop working
|
||||
GL_RoundImageDimensions( &tex->width, &tex->height, tex->flags, ( tex->flags & TF_NORMALMAP ));
|
||||
|
||||
if( s&3 )
|
||||
{
|
||||
|
@ -1102,7 +1108,7 @@ static void GL_UploadTexture( rgbdata_t *pic, gltexture_t *tex, qboolean subImag
|
|||
Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name );
|
||||
|
||||
// copy or resample the texture
|
||||
if(( tex->width == tex->srcWidth && tex->height == tex->srcHeight ) || ( tex->flags & TF_TEXTURE_3D ))
|
||||
if(( tex->width == tex->srcWidth && tex->height == tex->srcHeight ) || ( tex->flags & ( TF_TEXTURE_1D|TF_TEXTURE_3D )))
|
||||
{
|
||||
data = buf;
|
||||
}
|
||||
|
@ -1124,10 +1130,12 @@ static void GL_UploadTexture( rgbdata_t *pic, gltexture_t *tex, qboolean subImag
|
|||
}
|
||||
else if( glTarget == GL_TEXTURE_CUBE_MAP_ARB )
|
||||
{
|
||||
if( GL_Support( GL_SGIS_MIPMAPS_EXT )) GL_GenerateMipmaps( data, pic, tex, glTarget, inFormat, i, subImage );
|
||||
if( GL_Support( GL_SGIS_MIPMAPS_EXT ) && !( tex->flags & TF_NORMALMAP ))
|
||||
GL_GenerateMipmaps( data, pic, tex, glTarget, inFormat, i, subImage );
|
||||
if( subImage ) pglTexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + i, 0, 0, 0, tex->width, tex->height, inFormat, dataType, data );
|
||||
else pglTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + i, 0, outFormat, tex->width, tex->height, 0, inFormat, dataType, data );
|
||||
if( !GL_Support( GL_SGIS_MIPMAPS_EXT )) GL_GenerateMipmaps( data, pic, tex, glTarget, inFormat, i, subImage );
|
||||
if( !GL_Support( GL_SGIS_MIPMAPS_EXT ) || ( tex->flags & TF_NORMALMAP ))
|
||||
GL_GenerateMipmaps( data, pic, tex, glTarget, inFormat, i, subImage );
|
||||
}
|
||||
else if( glTarget == GL_TEXTURE_3D )
|
||||
{
|
||||
|
|
|
@ -517,8 +517,8 @@ void R_StudioSetUpTransform( cl_entity_t *e )
|
|||
VectorCopy( e->origin, origin );
|
||||
VectorCopy( e->angles, angles );
|
||||
|
||||
// interpolate monsters position
|
||||
if( e->curstate.movetype == MOVETYPE_STEP )
|
||||
// interpolate monsters position (moved into UpdateEntityFields by user request)
|
||||
if( e->curstate.movetype == MOVETYPE_STEP && !( host.features & ENGINE_COMPUTE_STUDIO_LERP ))
|
||||
{
|
||||
float d, f = 0.0f;
|
||||
int i;
|
||||
|
@ -1699,7 +1699,7 @@ void R_StudioLighting( float *lv, int bone, int flags, vec3_t normal )
|
|||
r = r_studio_lambert->value;
|
||||
if( r < 1.0f ) r = 1.0f;
|
||||
lightcos = (lightcos + ( r - 1.0f )) / r; // do modified hemispherical lighting
|
||||
if( lightcos > 0.0f ) VectorMA( illum, -lightcos, plight->lightcolor, illum );
|
||||
if( lightcos > 0.0f ) VectorMA( illum, lightcos, plight->lightcolor, illum );
|
||||
|
||||
if( illum[0] <= 0.0f ) illum[0] = 0.0f;
|
||||
if( illum[1] <= 0.0f ) illum[1] = 0.0f;
|
||||
|
@ -3371,6 +3371,9 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
|
|||
if( ptexture->flags & STUDIO_NF_TRANSPARENT )
|
||||
flags |= (TF_CLAMP|TF_NOMIPMAP);
|
||||
|
||||
if( ptexture->flags & STUDIO_NF_NORMALMAP )
|
||||
flags |= (TF_NORMALMAP);
|
||||
|
||||
// store some textures for remapping
|
||||
if( !Q_strnicmp( ptexture->name, "DM_Base", 7 ) || !Q_strnicmp( ptexture->name, "remap", 5 ))
|
||||
{
|
||||
|
@ -3579,6 +3582,18 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
|
|||
loadmodel->radius = RadiusFromBounds( loadmodel->mins, loadmodel->maxs );
|
||||
loadmodel->flags = phdr->flags; // copy header flags
|
||||
|
||||
// check for static model
|
||||
if( phdr->numseqgroups == 1 && phdr->numseq == 1 && phdr->numbones == 1 )
|
||||
{
|
||||
mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex);
|
||||
|
||||
// HACKHACK: MilkShape created a default animations with 30 frames
|
||||
// FIXME: analyze real frames for more predicatable results
|
||||
// TODO: analyze all the sequences
|
||||
if( pseqdesc->numframes == 1 || pseqdesc->numframes == 30 )
|
||||
pseqdesc->flags |= STUDIO_STATIC;
|
||||
}
|
||||
|
||||
if( loaded ) *loaded = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1282,10 +1282,10 @@ static void Mod_BuildPolygon( mextrasurf_t *info, msurface_t *surf, int numVerts
|
|||
{
|
||||
float s, t;
|
||||
uint bufSize;
|
||||
vec3_t normal, tangent, binormal;
|
||||
mtexinfo_t *texinfo = surf->texinfo;
|
||||
int i, numElems;
|
||||
byte *buffer;
|
||||
vec3_t normal;
|
||||
msurfmesh_t *mesh;
|
||||
|
||||
// allocate mesh
|
||||
|
@ -1293,6 +1293,7 @@ static void Mod_BuildPolygon( mextrasurf_t *info, msurface_t *surf, int numVerts
|
|||
|
||||
// mesh + ( vertex, normal, (st + lmst) ) * numVerts + elem * numElems;
|
||||
bufSize = sizeof( msurfmesh_t ) + numVerts * ( sizeof( vec3_t ) + sizeof( vec3_t ) + sizeof( vec4_t )) + numElems * sizeof( word );
|
||||
bufSize += numVerts * ( sizeof( vec3_t ) + sizeof( vec3_t )); // tangent and binormal
|
||||
bufSize += numVerts * sizeof( rgba_t ); // color array
|
||||
|
||||
buffer = Mem_Alloc( loadmodel->mempool, bufSize );
|
||||
|
@ -1302,11 +1303,16 @@ static void Mod_BuildPolygon( mextrasurf_t *info, msurface_t *surf, int numVerts
|
|||
mesh->numVerts = numVerts;
|
||||
mesh->numElems = numElems;
|
||||
|
||||
// calc tangent and binormal
|
||||
VectorCopy( surf->texinfo->vecs[0], mesh->tangent );
|
||||
VectorCopy( surf->texinfo->vecs[1], mesh->binormal );
|
||||
VectorNormalize( mesh->tangent );
|
||||
VectorNormalize( mesh->binormal );
|
||||
// calc tangent space
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
VectorNegate( surf->plane->normal, normal );
|
||||
else VectorCopy( surf->plane->normal, normal );
|
||||
VectorCopy( surf->texinfo->vecs[0], tangent );
|
||||
VectorNegate( surf->texinfo->vecs[1], binormal );
|
||||
|
||||
VectorNormalize( normal ); // g-cont. this is even needed?
|
||||
VectorNormalize( tangent );
|
||||
VectorNormalize( binormal );
|
||||
|
||||
// setup pointers
|
||||
mesh->vertices = (vec3_t *)buffer;
|
||||
|
@ -1317,6 +1323,10 @@ static void Mod_BuildPolygon( mextrasurf_t *info, msurface_t *surf, int numVerts
|
|||
buffer += numVerts * sizeof( vec2_t );
|
||||
mesh->normals = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->tangent = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->binormal = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->colors = (byte *)buffer;
|
||||
buffer += numVerts * sizeof( rgba_t );
|
||||
|
||||
|
@ -1335,13 +1345,6 @@ static void Mod_BuildPolygon( mextrasurf_t *info, msurface_t *surf, int numVerts
|
|||
mesh->indices[i*3+2] = i + 2;
|
||||
}
|
||||
|
||||
// setup normal
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
VectorNegate( surf->plane->normal, normal );
|
||||
else VectorCopy( surf->plane->normal, normal );
|
||||
|
||||
VectorNormalize( normal ); // g-cont. this is even needed?
|
||||
|
||||
// clear colors (it can be used for vertex lighting)
|
||||
Q_memset( mesh->colors, 0xFF, numVerts * sizeof( rgba_t ));
|
||||
|
||||
|
@ -1349,6 +1352,8 @@ static void Mod_BuildPolygon( mextrasurf_t *info, msurface_t *surf, int numVerts
|
|||
{
|
||||
// vertex
|
||||
VectorCopy( verts, mesh->vertices[i] );
|
||||
VectorCopy( tangent, mesh->tangent[i] );
|
||||
VectorCopy( binormal, mesh->binormal[i] );
|
||||
VectorCopy( normal, mesh->normals[i] );
|
||||
|
||||
// texture coordinates
|
||||
|
@ -1384,11 +1389,12 @@ Mod_SubdividePolygon
|
|||
*/
|
||||
static void Mod_SubdividePolygon( mextrasurf_t *info, msurface_t *surf, int numVerts, float *verts, float tessSize )
|
||||
{
|
||||
vec3_t vTotal, nTotal, mins, maxs;
|
||||
mtexinfo_t *texinfo = surf->texinfo;
|
||||
vec3_t vTotal, nTotal, tTotal, bTotal;
|
||||
vec3_t front[MAX_SIDE_VERTS], back[MAX_SIDE_VERTS];
|
||||
float *v, m, oneDivVerts, dist, dists[MAX_SIDE_VERTS];
|
||||
qboolean lightmap = (surf->flags & SURF_DRAWTILED) ? false : true;
|
||||
vec3_t normal, tangent, binormal, mins, maxs;
|
||||
mtexinfo_t *texinfo = surf->texinfo;
|
||||
vec2_t totalST, totalLM;
|
||||
float s, t, scale;
|
||||
int i, j, f, b;
|
||||
|
@ -1453,6 +1459,7 @@ static void Mod_SubdividePolygon( mextrasurf_t *info, msurface_t *surf, int numV
|
|||
|
||||
// mesh + ( vertex, normal, (st + lmst) ) * ( numVerts + 2 );
|
||||
bufSize = sizeof( msurfmesh_t ) + (( numVerts + 2 ) * (( sizeof( vec3_t ) + sizeof( vec3_t ) + sizeof( vec4_t ))));
|
||||
bufSize += ( numVerts + 2 ) * ( sizeof( vec3_t ) + sizeof( vec3_t )); // tangent and binormal
|
||||
bufSize += ( numVerts + 2 ) * sizeof( rgba_t ); // color array
|
||||
|
||||
buffer = Mem_Alloc( loadmodel->mempool, bufSize );
|
||||
|
@ -1464,11 +1471,16 @@ static void Mod_SubdividePolygon( mextrasurf_t *info, msurface_t *surf, int numV
|
|||
mesh->numVerts = numVerts + 2;
|
||||
mesh->numElems = numVerts * 3;
|
||||
|
||||
// calc tangent and binormal
|
||||
VectorCopy( surf->texinfo->vecs[0], mesh->tangent );
|
||||
VectorNegate( surf->texinfo->vecs[1], mesh->binormal );
|
||||
VectorNormalize( mesh->tangent );
|
||||
VectorNormalize( mesh->binormal );
|
||||
// calc tangent space
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
VectorNegate( surf->plane->normal, normal );
|
||||
else VectorCopy( surf->plane->normal, normal );
|
||||
VectorCopy( surf->texinfo->vecs[0], tangent );
|
||||
VectorNegate( surf->texinfo->vecs[1], binormal );
|
||||
|
||||
VectorNormalize( normal ); // g-cont. this is even needed?
|
||||
VectorNormalize( tangent );
|
||||
VectorNormalize( binormal );
|
||||
|
||||
// setup pointers
|
||||
mesh->vertices = (vec3_t *)buffer;
|
||||
|
@ -1479,11 +1491,17 @@ static void Mod_SubdividePolygon( mextrasurf_t *info, msurface_t *surf, int numV
|
|||
buffer += mesh->numVerts * sizeof( vec2_t );
|
||||
mesh->normals = (vec3_t *)buffer;
|
||||
buffer += mesh->numVerts * sizeof( vec3_t );
|
||||
mesh->tangent = (vec3_t *)buffer;
|
||||
buffer += mesh->numVerts * sizeof( vec3_t );
|
||||
mesh->binormal = (vec3_t *)buffer;
|
||||
buffer += mesh->numVerts * sizeof( vec3_t );
|
||||
mesh->colors = (byte *)buffer;
|
||||
buffer += mesh->numVerts * sizeof( rgba_t );
|
||||
|
||||
VectorClear( vTotal );
|
||||
VectorClear( nTotal );
|
||||
VectorClear( bTotal );
|
||||
VectorClear( tTotal );
|
||||
|
||||
totalST[0] = totalST[1] = 0;
|
||||
totalLM[0] = totalLM[1] = 0;
|
||||
|
@ -1497,14 +1515,14 @@ static void Mod_SubdividePolygon( mextrasurf_t *info, msurface_t *surf, int numV
|
|||
{
|
||||
// vertex
|
||||
VectorCopy( verts, mesh->vertices[i+1] );
|
||||
|
||||
// setup normal
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
VectorNegate( surf->plane->normal, mesh->normals[i+1] );
|
||||
else VectorCopy( surf->plane->normal, mesh->normals[i+1] );
|
||||
VectorCopy( normal, mesh->normals[i+1] );
|
||||
VectorCopy( tangent, mesh->tangent[i+1] );
|
||||
VectorCopy( binormal, mesh->binormal[i+1] );
|
||||
|
||||
VectorAdd( vTotal, mesh->vertices[i+1], vTotal );
|
||||
VectorAdd( nTotal, mesh->normals[i+1], nTotal );
|
||||
VectorAdd( tTotal, mesh->tangent[i+1], tTotal );
|
||||
VectorAdd( bTotal, mesh->binormal[i+1], bTotal );
|
||||
|
||||
if( lightmap )
|
||||
{
|
||||
|
@ -1558,7 +1576,12 @@ static void Mod_SubdividePolygon( mextrasurf_t *info, msurface_t *surf, int numV
|
|||
|
||||
VectorScale( vTotal, oneDivVerts, mesh->vertices[0] );
|
||||
VectorScale( nTotal, oneDivVerts, mesh->normals[0] );
|
||||
VectorScale( tTotal, oneDivVerts, mesh->tangent[0] );
|
||||
VectorScale( bTotal, oneDivVerts, mesh->binormal[0] );
|
||||
|
||||
VectorNormalize( mesh->normals[0] );
|
||||
VectorNormalize( mesh->tangent[0] );
|
||||
VectorNormalize( mesh->binormal[0] );
|
||||
|
||||
// texture coordinates
|
||||
mesh->stcoords[0][0] = totalST[0] * oneDivVerts;
|
||||
|
@ -1571,6 +1594,8 @@ static void Mod_SubdividePolygon( mextrasurf_t *info, msurface_t *surf, int numV
|
|||
// copy first vertex to last
|
||||
VectorCopy( mesh->vertices[1], mesh->vertices[i+1] );
|
||||
VectorCopy( mesh->normals[1], mesh->normals[i+1] );
|
||||
VectorCopy( mesh->tangent[1], mesh->tangent[i+1] );
|
||||
VectorCopy( mesh->binormal[1], mesh->binormal[i+1] );
|
||||
Vector2Copy( mesh->stcoords[1], mesh->stcoords[i+1] );
|
||||
Vector2Copy( mesh->lmcoords[1], mesh->lmcoords[i+1] );
|
||||
|
||||
|
@ -1590,6 +1615,7 @@ static void Mod_ConvertSurface( mextrasurf_t *info, msurface_t *surf )
|
|||
{
|
||||
msurfmesh_t *poly, *next, *mesh;
|
||||
float *outSTcoords, *outLMcoords;
|
||||
float *outTangent, *outBinorm;
|
||||
float *outVerts, *outNorms;
|
||||
int numElems, numVerts;
|
||||
word *outIndexes;
|
||||
|
@ -1608,6 +1634,7 @@ static void Mod_ConvertSurface( mextrasurf_t *info, msurface_t *surf )
|
|||
|
||||
// mesh + ( vertex, normal, (st + lmst) ) * numVerts + elem * numElems;
|
||||
bufSize = sizeof( msurfmesh_t ) + numVerts * ( sizeof( vec3_t ) + sizeof( vec3_t ) + sizeof( vec4_t )) + numElems * sizeof( word );
|
||||
bufSize += numVerts * ( sizeof( vec3_t ) + sizeof( vec3_t )); // tangent and binormal
|
||||
bufSize += numVerts * sizeof( rgba_t ); // color array
|
||||
|
||||
// unsigned short limit
|
||||
|
@ -1622,12 +1649,6 @@ static void Mod_ConvertSurface( mextrasurf_t *info, msurface_t *surf )
|
|||
mesh->numVerts = numVerts;
|
||||
mesh->numElems = numElems;
|
||||
|
||||
// calc tangent and binormal
|
||||
VectorCopy( surf->texinfo->vecs[0], mesh->tangent );
|
||||
VectorNegate( surf->texinfo->vecs[1], mesh->binormal );
|
||||
VectorNormalize( mesh->tangent );
|
||||
VectorNormalize( mesh->binormal );
|
||||
|
||||
// setup pointers
|
||||
mesh->vertices = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
|
@ -1637,14 +1658,21 @@ static void Mod_ConvertSurface( mextrasurf_t *info, msurface_t *surf )
|
|||
buffer += numVerts * sizeof( vec2_t );
|
||||
mesh->normals = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->tangent = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->binormal = (vec3_t *)buffer;
|
||||
buffer += numVerts * sizeof( vec3_t );
|
||||
mesh->colors = (byte *)buffer;
|
||||
buffer += numVerts * sizeof( rgba_t );
|
||||
|
||||
mesh->indices = (word *)buffer;
|
||||
buffer += numElems * sizeof( word );
|
||||
|
||||
// setup moving pointers
|
||||
outVerts = (float *)mesh->vertices;
|
||||
outNorms = (float *)mesh->normals;
|
||||
outTangent = (float *)mesh->tangent;
|
||||
outBinorm = (float *)mesh->binormal;
|
||||
outSTcoords = (float *)mesh->stcoords;
|
||||
outLMcoords = (float *)mesh->lmcoords;
|
||||
outIndexes = (word *)mesh->indices;
|
||||
|
@ -1673,6 +1701,8 @@ static void Mod_ConvertSurface( mextrasurf_t *info, msurface_t *surf )
|
|||
// vertices
|
||||
VectorCopy( poly->vertices[i], outVerts );
|
||||
VectorCopy( poly->normals[i], outNorms );
|
||||
VectorCopy( poly->tangent[i], outTangent );
|
||||
VectorCopy( poly->binormal[i], outBinorm );
|
||||
|
||||
outSTcoords[0] = poly->stcoords[i][0];
|
||||
outSTcoords[1] = poly->stcoords[i][1];
|
||||
|
@ -1681,6 +1711,8 @@ static void Mod_ConvertSurface( mextrasurf_t *info, msurface_t *surf )
|
|||
|
||||
outVerts += 3;
|
||||
outNorms += 3;
|
||||
outBinorm += 3;
|
||||
outTangent += 3;
|
||||
outSTcoords += 2;
|
||||
outLMcoords += 2;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib mpeg.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\engine\!debug/xash.dll" /pdbtype:sept /libpath:"./common/soundlib"
|
||||
# ADD LINK32 msvcrtd.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib mpeg.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\engine\!debug/xash.dll" /pdbtype:sept /libpath:"./common/soundlib"
|
||||
# SUBTRACT LINK32 /incremental:no /map /nodefaultlib
|
||||
# Begin Custom Build
|
||||
TargetDir=\Xash3D\src_main\temp\engine\!debug
|
||||
|
|
|
@ -68,6 +68,9 @@ Studio models are position independent, so the cache manager can move them.
|
|||
#define STUDIO_NF_ALPHA 0x0010 // rendering as transparent texture
|
||||
#define STUDIO_NF_ADDITIVE 0x0020 // rendering with additive mode
|
||||
#define STUDIO_NF_TRANSPARENT 0x0040 // use texture with alpha channel
|
||||
#define STUDIO_NF_NORMALMAP 0x0080 // indexed normalmap
|
||||
#define STUDIO_NF_HEIGHTMAP 0x0100 // heightmap that can be used for parallax or normalmap
|
||||
#define STUDIO_NF_GLOSSMAP 0x0200 // glossmap
|
||||
|
||||
// motion flags
|
||||
#define STUDIO_X 0x0001
|
||||
|
@ -93,6 +96,7 @@ Studio models are position independent, so the cache manager can move them.
|
|||
|
||||
// sequence flags
|
||||
#define STUDIO_LOOPING 0x0001
|
||||
#define STUDIO_STATIC 0x8000 // studiomodel is static
|
||||
|
||||
// bone flags
|
||||
#define STUDIO_HAS_NORMALS 0x0001
|
||||
|
|
Binary file not shown.
Binary file not shown.
Reference in New Issue