- case PICO_NORMAL:
- Sys_Printf( "%s\n", str );
- break;
-
- case PICO_VERBOSE:
- Sys_FPrintf( SYS_VRB, "%s\n", str );
- break;
-
- case PICO_WARNING:
- Sys_Printf( "WARNING: %s\n", str );
- break;
-
- case PICO_ERROR:
- Sys_Printf( "ERROR: %s\n", str );
- break;
-
- case PICO_FATAL:
- Error( "ERROR: %s\n", str );
- break;
+ case PICO_NORMAL:
+ Sys_Printf( "%s\n", str );
+ break;
+
+ case PICO_VERBOSE:
+ Sys_FPrintf( SYS_VRB, "%s\n", str );
+ break;
+
+ case PICO_WARNING:
+ Sys_Printf( "WARNING: %s\n", str );
+ break;
+
+ case PICO_ERROR:
+ Sys_Printf( "ERROR: %s\n", str );
+ break;
+
+ case PICO_FATAL:
+ Error( "ERROR: %s\n", str );
+ break;
/* init */
if ( numPicoModels <= 0 ) {
memset( picoModels, 0, sizeof( picoModels ) );
}
/* init */
if ( numPicoModels <= 0 ) {
memset( picoModels, 0, sizeof( picoModels ) );
}
/* init */
if ( numPicoModels <= 0 ) {
memset( picoModels, 0, sizeof( picoModels ) );
}
/* init */
if ( numPicoModels <= 0 ) {
memset( picoModels, 0, sizeof( picoModels ) );
}
/* try to find existing picoModel */
model = FindModel( name, frame );
if ( model != NULL ) {
return model;
}
/* try to find existing picoModel */
model = FindModel( name, frame );
if ( model != NULL ) {
return model;
}
/* none found, so find first non-null picoModel */
pm = NULL;
for ( i = 0; i < MAX_MODELS; i++ )
/* none found, so find first non-null picoModel */
pm = NULL;
for ( i = 0; i < MAX_MODELS; i++ )
/* too many picoModels? */
if ( pm == NULL ) {
Error( "MAX_MODELS (%d) exceeded, there are too many model files referenced by the map.", MAX_MODELS );
}
/* too many picoModels? */
if ( pm == NULL ) {
Error( "MAX_MODELS (%d) exceeded, there are too many model files referenced by the map.", MAX_MODELS );
}
/* attempt to parse model */
*pm = PicoLoadModel( name, frame );
/* attempt to parse model */
*pm = PicoLoadModel( name, frame );
/* if loading failed, make a bogus model to silence the rest of the warnings */
if ( *pm == NULL ) {
/* allocate a new model */
/* if loading failed, make a bogus model to silence the rest of the warnings */
if ( *pm == NULL ) {
/* allocate a new model */
/* set data */
PicoSetModelName( *pm, name );
PicoSetModelFrameNum( *pm, frame );
}
/* set data */
PicoSetModelName( *pm, name );
PicoSetModelFrameNum( *pm, frame );
}
Sys_Printf( "Model %s\n", name );
numSurfaces = PicoGetModelNumSurfaces( *pm );
for ( i = 0; i < numSurfaces; i++ )
Sys_Printf( "Model %s\n", name );
numSurfaces = PicoGetModelNumSurfaces( *pm );
for ( i = 0; i < numSurfaces; i++ )
*/
void InsertModel( const char *name, int skin, 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, vec3_t colormod ){
*/
void InsertModel( const char *name, int skin, 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, vec3_t colormod ){
- int i, j, s, numSurfaces;
- m4x4_t identity, nTransform;
- picoModel_t *model;
- picoShader_t *shader;
- picoSurface_t *surface;
- shaderInfo_t *si;
- mapDrawSurface_t *ds;
- bspDrawVert_t *dv;
- char *picoShaderName;
- char shaderName[ MAX_QPATH ];
- picoVec_t *xyz, *normal, *st;
- byte *color;
- picoIndex_t *indexes;
- remap_t *rm, *glob;
- skinfile_t *sf, *sf2;
- double normalEpsilon_save;
- double distanceEpsilon_save;
- char skinfilename[ MAX_QPATH ];
- char *skinfilecontent;
- int skinfilesize;
- char *skinfileptr, *skinfilenextptr;
-
-
+ int i, j, s, numSurfaces;
+ m4x4_t identity, nTransform;
+ picoModel_t *model;
+ picoShader_t *shader;
+ picoSurface_t *surface;
+ shaderInfo_t *si;
+ mapDrawSurface_t *ds;
+ bspDrawVert_t *dv;
+ char *picoShaderName;
+ char shaderName[ MAX_QPATH ];
+ picoVec_t *xyz, *normal, *st;
+ byte *color;
+ picoIndex_t *indexes;
+ remap_t *rm, *glob;
+ skinfile_t *sf, *sf2;
+ double normalEpsilon_save;
+ double distanceEpsilon_save;
+ char skinfilename[ MAX_QPATH ];
+ char *skinfilecontent;
+ int skinfilesize;
+ char *skinfileptr, *skinfilenextptr;
+
+
skinfilesize = vfsLoadFile( skinfilename, (void**) &skinfilecontent, 0 );
if ( skinfilesize >= 0 ) {
Sys_Printf( "Skin %d of %s does not exist, using 0 instead\n", skin, name );
skinfilesize = vfsLoadFile( skinfilename, (void**) &skinfilecontent, 0 );
if ( skinfilesize >= 0 ) {
Sys_Printf( "Skin %d of %s does not exist, using 0 instead\n", skin, name );
/* hack: Stable-1_2 and trunk have differing row/column major matrix order
this transpose is necessary with Stable-1_2
uncomment the following line with old m4x4_t (non 1.3/spog_branch) code */
//% m4x4_transpose( transform );
/* hack: Stable-1_2 and trunk have differing row/column major matrix order
this transpose is necessary with Stable-1_2
uncomment the following line with old m4x4_t (non 1.3/spog_branch) code */
//% m4x4_transpose( transform );
/* create transform matrix for normals */
memcpy( nTransform, transform, sizeof( m4x4_t ) );
if ( m4x4_invert( nTransform ) ) {
Sys_FPrintf( SYS_VRB, "WARNING: Can't invert model transform matrix, using transpose instead\n" );
}
m4x4_transpose( nTransform );
/* create transform matrix for normals */
memcpy( nTransform, transform, sizeof( m4x4_t ) );
if ( m4x4_invert( nTransform ) ) {
Sys_FPrintf( SYS_VRB, "WARNING: Can't invert model transform matrix, using transpose instead\n" );
}
m4x4_transpose( nTransform );
/* each surface on the model will become a new map drawsurface */
numSurfaces = PicoGetModelNumSurfaces( model );
//% Sys_FPrintf( SYS_VRB, "Model %s has %d surfaces\n", name, numSurfaces );
/* each surface on the model will become a new map drawsurface */
numSurfaces = PicoGetModelNumSurfaces( model );
//% Sys_FPrintf( SYS_VRB, "Model %s has %d surfaces\n", name, numSurfaces );
/* only handle triangle surfaces initially (fixme: support patches) */
if ( PicoGetSurfaceType( surface ) != PICO_TRIANGLES ) {
continue;
}
/* only handle triangle surfaces initially (fixme: support patches) */
if ( PicoGetSurfaceType( surface ) != PICO_TRIANGLES ) {
continue;
}
if ( !Q_stricmp( surface->name, sf2->name ) ) {
Sys_FPrintf( SYS_VRB, "Skin file: mapping %s to %s\n", surface->name, sf2->to );
picoShaderName = sf2->to;
if ( !Q_stricmp( surface->name, sf2->name ) ) {
Sys_FPrintf( SYS_VRB, "Skin file: mapping %s to %s\n", surface->name, sf2->to );
picoShaderName = sf2->to;
if ( glob != NULL ) {
Sys_FPrintf( SYS_VRB, "Globbing %s to %s\n", picoShaderName, glob->to );
picoShaderName = glob->to;
}
if ( glob != NULL ) {
Sys_FPrintf( SYS_VRB, "Globbing %s to %s\n", picoShaderName, glob->to );
picoShaderName = glob->to;
}
/* shader renaming for sof2 */
if ( renameModelShaders ) {
strcpy( shaderName, picoShaderName );
/* shader renaming for sof2 */
if ( renameModelShaders ) {
strcpy( shaderName, picoShaderName );
/* set particulars */
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
ds->verts = safe_malloc( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
memset( ds->verts, 0, ds->numVerts * sizeof( ds->verts[ 0 ] ) );
/* set particulars */
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
ds->verts = safe_malloc( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
memset( ds->verts, 0, ds->numVerts * sizeof( ds->verts[ 0 ] ) );
ds->numIndexes = PicoGetSurfaceNumIndexes( surface );
ds->indexes = safe_malloc( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
memset( ds->indexes, 0, ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
ds->numIndexes = PicoGetSurfaceNumIndexes( surface );
ds->indexes = safe_malloc( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
memset( ds->indexes, 0, ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
/* xyz and normal */
xyz = PicoGetSurfaceXYZ( surface, i );
VectorCopy( xyz, dv->xyz );
m4x4_transform_point( transform, dv->xyz );
/* xyz and normal */
xyz = PicoGetSurfaceXYZ( surface, i );
VectorCopy( xyz, dv->xyz );
m4x4_transform_point( transform, dv->xyz );
normal = PicoGetSurfaceNormal( surface, i );
VectorCopy( normal, dv->normal );
m4x4_transform_normal( nTransform, dv->normal );
normal = PicoGetSurfaceNormal( surface, i );
VectorCopy( normal, dv->normal );
m4x4_transform_normal( nTransform, dv->normal );
/* ydnar: gs mods: added support for explicit shader texcoord generation */
else if ( si->tcGen ) {
/* project the texture */
dv->st[ 0 ] = DotProduct( si->vecs[ 0 ], dv->xyz );
dv->st[ 1 ] = DotProduct( si->vecs[ 1 ], dv->xyz );
}
/* ydnar: gs mods: added support for explicit shader texcoord generation */
else if ( si->tcGen ) {
/* project the texture */
dv->st[ 0 ] = DotProduct( si->vecs[ 0 ], dv->xyz );
dv->st[ 1 ] = DotProduct( si->vecs[ 1 ], dv->xyz );
}
/* set lightmap/color bits */
color = PicoGetSurfaceColor( surface, 0, i );
for ( j = 0; j < MAX_LIGHTMAPS; j++ )
/* set lightmap/color bits */
color = PicoGetSurfaceColor( surface, 0, i );
for ( j = 0; j < MAX_LIGHTMAPS; j++ )
/* copy indexes */
indexes = PicoGetSurfaceIndexes( surface, 0 );
for ( i = 0; i < ds->numIndexes; i++ )
ds->indexes[ i ] = indexes[ i ];
/* copy indexes */
indexes = PicoGetSurfaceIndexes( surface, 0 );
for ( i = 0; i < ds->numIndexes; i++ )
ds->indexes[ i ] = indexes[ i ];
/* ydnar: giant hack land: generate clipping brushes for model triangles */
if ( si->clipModel || ( spawnFlags & 2 ) ) { /* 2nd bit */
/* ydnar: giant hack land: generate clipping brushes for model triangles */
if ( si->clipModel || ( spawnFlags & 2 ) ) { /* 2nd bit */
- vec3_t points[ 4 ], backs[ 3 ];
- vec4_t plane, reverse, pa, pb, pc;
-
-
+ vec3_t points[ 4 ], backs[ 3 ];
+ vec4_t plane, reverse, pa, pb, pc;
+
+
/* walk triangle list */
for ( i = 0; i < ds->numIndexes; i += 3 )
{
/* overflow hack */
AUTOEXPAND_BY_REALLOC( mapplanes, ( nummapplanes + 64 ) << 1, allocatedmapplanes, 1024 );
/* walk triangle list */
for ( i = 0; i < ds->numIndexes; i += 3 )
{
/* overflow hack */
AUTOEXPAND_BY_REALLOC( mapplanes, ( nummapplanes + 64 ) << 1, allocatedmapplanes, 1024 );
/* make points and back points */
for ( j = 0; j < 3; j++ )
{
/* get vertex */
dv = &ds->verts[ ds->indexes[ i + j ] ];
/* make points and back points */
for ( j = 0; j < 3; j++ )
{
/* get vertex */
dv = &ds->verts[ ds->indexes[ i + j ] ];
/* copy xyz */
VectorCopy( dv->xyz, points[ j ] );
}
VectorCopy( points[0], points[3] ); // for cyclic usage
/* copy xyz */
VectorCopy( dv->xyz, points[ j ] );
}
VectorCopy( points[0], points[3] ); // for cyclic usage
/* make plane for triangle */
// div0: add some extra spawnflags:
// 0: snap normals to axial planes for extrusion
/* make plane for triangle */
// div0: add some extra spawnflags:
// 0: snap normals to axial planes for extrusion
// that's at least sqrt(1/3) backPlaneDistance, unless in DOWN mode; in DOWN mode, we are screwed anyway if we encounter a plane that's perpendicular to the xy plane)
if ( PlaneFromPoints( pa, points[ 2 ], points[ 1 ], backs[ 1 ] ) &&
// that's at least sqrt(1/3) backPlaneDistance, unless in DOWN mode; in DOWN mode, we are screwed anyway if we encounter a plane that's perpendicular to the xy plane)
if ( PlaneFromPoints( pa, points[ 2 ], points[ 1 ], backs[ 1 ] ) &&
- PlaneFromPoints( pb, points[ 1 ], points[ 0 ], backs[ 0 ] ) &&
+ PlaneFromPoints( pb, points[ 1 ], points[ 0 ], backs[ 0 ] ) &&
PlaneFromPoints( pc, points[ 0 ], points[ 2 ], backs[ 2 ] ) ) {
/* set up brush sides */
buildBrush->numsides = 5;
buildBrush->sides[ 0 ].shaderInfo = si;
for ( j = 1; j < buildBrush->numsides; j++ )
PlaneFromPoints( pc, points[ 0 ], points[ 2 ], backs[ 2 ] ) ) {
/* set up brush sides */
buildBrush->numsides = 5;
buildBrush->sides[ 0 ].shaderInfo = si;
for ( j = 1; j < buildBrush->numsides; j++ )
buildBrush->sides[ 0 ].planenum = FindFloatPlane( plane, plane[ 3 ], 3, points );
buildBrush->sides[ 1 ].planenum = FindFloatPlane( pa, pa[ 3 ], 2, &points[ 1 ] ); // pa contains points[1] and points[2]
buildBrush->sides[ 0 ].planenum = FindFloatPlane( plane, plane[ 3 ], 3, points );
buildBrush->sides[ 1 ].planenum = FindFloatPlane( pa, pa[ 3 ], 2, &points[ 1 ] ); // pa contains points[1] and points[2]
- int num, frame, skin, castShadows, recvShadows, spawnFlags;
- entity_t *e2;
- const char *targetName;
- const char *target, *model, *value;
- 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;
- remap_t *remap, *remap2;
- char *split;
-
-
+ int num, frame, skin, castShadows, recvShadows, spawnFlags;
+ entity_t *e2;
+ const char *targetName;
+ const char *target, *model, *value;
+ 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;
+ remap_t *remap, *remap2;
+ char *split;
+
+
/* misc_model entities target non-worldspawn brush model entities */
if ( targetName[ 0 ] == '\0' ) {
return;
/* misc_model entities target non-worldspawn brush model entities */
if ( targetName[ 0 ] == '\0' ) {
return;
/* get lightmap scale */
/* vortex: added _ls key (short name of lightmapscale) */
baseLightmapScale = 0.0f;
if ( strcmp( "", ValueForKey( e, "lightmapscale" ) ) ||
/* get lightmap scale */
/* vortex: added _ls key (short name of lightmapscale) */
baseLightmapScale = 0.0f;
if ( strcmp( "", ValueForKey( e, "lightmapscale" ) ) ||
strcmp( "", ValueForKey( e, "_ls" ) ) ) {
baseLightmapScale = FloatForKey( e, "lightmapscale" );
if ( baseLightmapScale <= 0.0f ) {
strcmp( "", ValueForKey( e, "_ls" ) ) ) {
baseLightmapScale = FloatForKey( e, "lightmapscale" );
if ( baseLightmapScale <= 0.0f ) {
}
if ( baseLightmapScale > 0.0f ) {
Sys_Printf( "World Entity has lightmap scale of %.4f\n", baseLightmapScale );
}
if ( baseLightmapScale > 0.0f ) {
Sys_Printf( "World Entity has lightmap scale of %.4f\n", baseLightmapScale );
/* convert misc_models into raw geometry */
if ( Q_stricmp( "misc_model", ValueForKey( e2, "classname" ) ) ) {
continue;
/* convert misc_models into raw geometry */
if ( Q_stricmp( "misc_model", ValueForKey( e2, "classname" ) ) ) {
continue;
/* get model name */
model = ValueForKey( e2, "model" );
if ( model[ 0 ] == '\0' ) {
Sys_Printf( "WARNING: misc_model at %i %i %i without a model key\n",
/* get model name */
model = ValueForKey( e2, "model" );
if ( model[ 0 ] == '\0' ) {
Sys_Printf( "WARNING: misc_model at %i %i %i without a model key\n",
else if ( strcmp( "", ValueForKey( e2, "frame" ) ) ) {
frame = IntForKey( e2, "frame" );
}
else if ( strcmp( "", ValueForKey( e2, "frame" ) ) ) {
frame = IntForKey( e2, "frame" );
}
/* worldspawn (and func_groups) default to cast/recv shadows in worldspawn group */
if ( e == entities ) {
castShadows = WORLDSPAWN_CAST_SHADOWS;
recvShadows = WORLDSPAWN_RECV_SHADOWS;
}
/* worldspawn (and func_groups) default to cast/recv shadows in worldspawn group */
if ( e == entities ) {
castShadows = WORLDSPAWN_CAST_SHADOWS;
recvShadows = WORLDSPAWN_RECV_SHADOWS;
}
/* other entities don't cast any shadows, but recv worldspawn shadows */
else
{
castShadows = ENTITY_CAST_SHADOWS;
recvShadows = ENTITY_RECV_SHADOWS;
}
/* other entities don't cast any shadows, but recv worldspawn shadows */
else
{
castShadows = ENTITY_CAST_SHADOWS;
recvShadows = ENTITY_RECV_SHADOWS;
}
/* get explicit shadow flags */
GetEntityShadowFlags( e2, e, &castShadows, &recvShadows );
/* get explicit shadow flags */
GetEntityShadowFlags( e2, e, &castShadows, &recvShadows );
/* get scale */
scale[ 0 ] = scale[ 1 ] = scale[ 2 ] = 1.0f;
temp = FloatForKey( e2, "modelscale" );
/* get scale */
scale[ 0 ] = scale[ 1 ] = scale[ 2 ] = 1.0f;
temp = FloatForKey( e2, "modelscale" );
if ( value[ 0 ] != '\0' ) {
sscanf( value, "%f %f %f", &scale[ 0 ], &scale[ 1 ], &scale[ 2 ] );
}
if ( value[ 0 ] != '\0' ) {
sscanf( value, "%f %f %f", &scale[ 0 ], &scale[ 1 ], &scale[ 2 ] );
}
/* get "angle" (yaw) or "angles" (pitch yaw roll) */
angles[ 0 ] = angles[ 1 ] = angles[ 2 ] = 0.0f;
angles[ 2 ] = FloatForKey( e2, "angle" );
/* get "angle" (yaw) or "angles" (pitch yaw roll) */
angles[ 0 ] = angles[ 1 ] = angles[ 2 ] = 0.0f;
angles[ 2 ] = FloatForKey( e2, "angle" );
if ( value[ 0 ] != '\0' ) {
sscanf( value, "%f %f %f", &angles[ 1 ], &angles[ 2 ], &angles[ 0 ] );
}
if ( value[ 0 ] != '\0' ) {
sscanf( value, "%f %f %f", &angles[ 1 ], &angles[ 2 ], &angles[ 0 ] );
}
/* set transform matrix (thanks spog) */
m4x4_identity( transform );
m4x4_pivoted_transform_by_vec3( transform, origin, angles, eXYZ, scale, vec3_origin );
/* set transform matrix (thanks spog) */
m4x4_identity( transform );
m4x4_pivoted_transform_by_vec3( transform, origin, angles, eXYZ, scale, vec3_origin );
/* get shader remappings */
remap = NULL;
for ( ep = e2->epairs; ep != NULL; ep = ep->next )
{
/* look for keys prefixed with "_remap" */
if ( ep->key != NULL && ep->value != NULL &&
/* get shader remappings */
remap = NULL;
for ( ep = e2->epairs; ep != NULL; ep = ep->next )
{
/* look for keys prefixed with "_remap" */
if ( ep->key != NULL && ep->value != NULL &&
!Q_strncasecmp( ep->key, "_remap", 6 ) ) {
/* create new remapping */
remap2 = remap;
remap = safe_malloc( sizeof( *remap ) );
remap->next = remap2;
strcpy( remap->from, ep->value );
!Q_strncasecmp( ep->key, "_remap", 6 ) ) {
/* create new remapping */
remap2 = remap;
remap = safe_malloc( sizeof( *remap ) );
remap->next = remap2;
strcpy( remap->from, ep->value );
/* note it */
//% Sys_FPrintf( SYS_VRB, "Remapping %s to %s\n", remap->from, remap->to );
}
}
/* note it */
//% Sys_FPrintf( SYS_VRB, "Remapping %s to %s\n", remap->from, remap->to );
}
}
/* ydnar: cel shader support */
value = ValueForKey( e2, "_celshader" );
if ( value[ 0 ] == '\0' ) {
/* ydnar: cel shader support */
value = ValueForKey( e2, "_celshader" );
if ( value[ 0 ] == '\0' ) {
/* vortex: added _ls key (short name of lightmapscale) */
lightmapScale = 0.0f;
if ( strcmp( "", ValueForKey( e2, "lightmapscale" ) ) ||
/* vortex: added _ls key (short name of lightmapscale) */
lightmapScale = 0.0f;
if ( strcmp( "", ValueForKey( e2, "lightmapscale" ) ) ||
strcmp( "", ValueForKey( e2, "_ls" ) ) ) {
lightmapScale = FloatForKey( e2, "lightmapscale" );
if ( lightmapScale <= 0.0f ) {
strcmp( "", ValueForKey( e2, "_ls" ) ) ) {
lightmapScale = FloatForKey( e2, "lightmapscale" );
if ( lightmapScale <= 0.0f ) {
}
if ( lightmapScale > 0.0f ) {
Sys_Printf( "misc_model has lightmap scale of %.4f\n", lightmapScale );
}
if ( lightmapScale > 0.0f ) {
Sys_Printf( "misc_model has lightmap scale of %.4f\n", lightmapScale );
/* insert the model */
InsertModel( model, skin, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle, colormod );
/* insert the model */
InsertModel( model, skin, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle, colormod );