adds a picomodel into the bsp
*/
-void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale )
+void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle )
{
int i, j, k, s, numSurfaces;
m4x4_t identity, nTransform;
/* fix bogus lightmap scale */
if( lightmapScale <= 0.0f )
lightmapScale = 1.0f;
+
+ /* fix bogus shade angle */
+ if( shadeAngle <= 0.0f )
+ shadeAngle = 0.0f;
/* each surface on the model will become a new map drawsurface */
numSurfaces = PicoGetModelNumSurfaces( model );
if( PicoGetSurfaceType( surface ) != PICO_TRIANGLES )
continue;
- /* fix the surface's normals */
- PicoFixSurfaceNormals( surface );
-
/* allocate a surface (ydnar: gs mods) */
ds = AllocDrawSurface( SURFACE_TRIANGLES );
ds->entityNum = eNum;
/* set shader */
ds->shaderInfo = si;
-
- /* set lightmap scale */
- ds->lightmapScale = lightmapScale;
-
+
/* force to meta? */
if( (si != NULL && si->forceMeta) || (spawnFlags & 4) ) /* 3rd bit */
ds->type = SURFACE_FORCED_META;
+
+ /* fix the surface's normals (jal: conditioned by shader info) */
+ if( !(spawnFlags & 64) && ( shadeAngle == 0.0f || ds->type != SURFACE_FORCED_META ) )
+ PicoFixSurfaceNormals( surface );
+
+ /* set sample size */
+ if( lightmapSampleSize > 0.0f )
+ ds->sampleSize = lightmapSampleSize;
+
+ /* set lightmap scale */
+ if( lightmapScale > 0.0f )
+ ds->lightmapScale = lightmapScale;
+
+ /* set shading angle */
+ if( shadeAngle > 0.0f )
+ ds->shadeAngleDegrees = shadeAngle;
/* set particulars */
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
{
dv->lightmap[ j ][ 0 ] = 0.0f;
dv->lightmap[ j ][ 1 ] = 0.0f;
- dv->color[ j ][ 0 ] = color[ 0 ];
- dv->color[ j ][ 1 ] = color[ 1 ];
- dv->color[ j ][ 2 ] = color[ 2 ];
- dv->color[ j ][ 3 ] = color[ 3 ];
+ if(spawnFlags & 32) // spawnflag 32: model color -> alpha hack
+ {
+ dv->color[ j ][ 0 ] = 255.0f;
+ dv->color[ j ][ 1 ] = 255.0f;
+ dv->color[ j ][ 2 ] = 255.0f;
+ dv->color[ j ][ 3 ] = RGBTOGRAY( color );
+ }
+ else
+ {
+ dv->color[ j ][ 0 ] = color[ 0 ];
+ dv->color[ j ][ 1 ] = color[ 1 ];
+ dv->color[ j ][ 2 ] = color[ 2 ];
+ dv->color[ j ][ 3 ] = color[ 3 ];
+ }
}
}
/* temp hack */
- if( !si->clipModel &&
- ((si->compileFlags & C_TRANSLUCENT) || !(si->compileFlags & C_SOLID)) )
+ if( !si->clipModel && !(si->compileFlags & C_SOLID) )
continue;
/* walk triangle list */
char shader[ MAX_QPATH ];
shaderInfo_t *celShader;
float temp, baseLightmapScale, lightmapScale;
+ float shadeAngle;
+ int lightmapSampleSize;
vec3_t origin, scale, angles;
m4x4_t transform;
epair_t *ep;
}
/* get lightmap scale */
- baseLightmapScale = FloatForKey( e, "_lightmapscale" );
- if( baseLightmapScale <= 0.0f )
- baseLightmapScale = 0.0f;
+ /* vortex: added _ls key (short name of lightmapscale) */
+ baseLightmapScale = 0.0f;
+ if( strcmp( "", ValueForKey( e, "lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e, "_lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e, "_ls" ) ) )
+ {
+ baseLightmapScale = FloatForKey( e, "lightmapscale" );
+ if( baseLightmapScale <= 0.0f )
+ baseLightmapScale = FloatForKey( e, "_lightmapscale" );
+ if( baseLightmapScale <= 0.0f )
+ baseLightmapScale = FloatForKey( e, "_ls" );
+ if( baseLightmapScale < 0.0f )
+ baseLightmapScale = 0.0f;
+ if( baseLightmapScale > 0.0f )
+ Sys_Printf( "World Entity has lightmap scale of %.4f\n", baseLightmapScale );
+ }
+
/* walk the entity list */
for( num = 1; num < numEntities; num++ )
}
else
celShader = *globalCelShader ? ShaderInfoForShader(globalCelShader) : NULL;
-
+
+ /* jal : entity based _samplesize */
+ lightmapSampleSize = 0;
+ if ( strcmp( "", ValueForKey( e2, "_lightmapsamplesize" ) ) )
+ lightmapSampleSize = IntForKey( e2, "_lightmapsamplesize" );
+ else if ( strcmp( "", ValueForKey( e2, "_samplesize" ) ) )
+ lightmapSampleSize = IntForKey( e2, "_samplesize" );
+
+ if( lightmapSampleSize < 0 )
+ lightmapSampleSize = 0;
+
+ if( lightmapSampleSize > 0.0f )
+ Sys_Printf( "misc_model has lightmap sample size of %.d\n", lightmapSampleSize );
+
/* get lightmap scale */
- lightmapScale = FloatForKey( e2, "_lightmapscale" );
- if( lightmapScale <= 0.0f )
- lightmapScale = baseLightmapScale;
+ /* vortex: added _ls key (short name of lightmapscale) */
+ lightmapScale = 0.0f;
+ if( strcmp( "", ValueForKey( e2, "lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e2, "_lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e2, "_ls" ) ) )
+ {
+ lightmapScale = FloatForKey( e2, "lightmapscale" );
+ if( lightmapScale <= 0.0f )
+ lightmapScale = FloatForKey( e2, "_lightmapscale" );
+ if( lightmapScale <= 0.0f )
+ lightmapScale = FloatForKey( e2, "_ls" );
+ if( lightmapScale < 0.0f )
+ lightmapScale = 0.0f;
+ if( lightmapScale > 0.0f )
+ Sys_Printf( "misc_model has lightmap scale of %.4f\n", lightmapScale );
+ }
+
+ /* jal : entity based _shadeangle */
+ shadeAngle = 0.0f;
+ if ( strcmp( "", ValueForKey( e2, "_shadeangle" ) ) )
+ shadeAngle = FloatForKey( e2, "_shadeangle" );
+ /* vortex' aliases */
+ else if ( strcmp( "", ValueForKey( mapEnt, "_smoothnormals" ) ) )
+ shadeAngle = FloatForKey( mapEnt, "_smoothnormals" );
+ else if ( strcmp( "", ValueForKey( mapEnt, "_sn" ) ) )
+ shadeAngle = FloatForKey( mapEnt, "_sn" );
+ else if ( strcmp( "", ValueForKey( mapEnt, "_smooth" ) ) )
+ shadeAngle = FloatForKey( mapEnt, "_smooth" );
+
+ if( shadeAngle < 0.0f )
+ shadeAngle = 0.0f;
+
+ if( shadeAngle > 0.0f )
+ Sys_Printf( "misc_model has shading angle of %.4f\n", shadeAngle );
/* insert the model */
- InsertModel( (char*) model, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale );
+ InsertModel( (char*) model, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle );
/* free shader remappings */
while( remap != NULL )