From 0b86577ab8b9bcd3403b77eafc33c2048b147d35 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 30 Aug 2011 21:49:21 +0200 Subject: [PATCH] interface work for colormod --- tools/quake3/q3map2/map.c | 9 +++++++++ tools/quake3/q3map2/model.c | 7 +++++-- tools/quake3/q3map2/q3map2.h | 9 +++++++-- tools/quake3/q3map2/surface.c | 4 +++- tools/quake3/q3map2/surface_foliage.c | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/tools/quake3/q3map2/map.c b/tools/quake3/q3map2/map.c index 9534bdb3..9e192445 100644 --- a/tools/quake3/q3map2/map.c +++ b/tools/quake3/q3map2/map.c @@ -1587,6 +1587,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups ) parseMesh_t *patch; qboolean funcGroup; int castShadows, recvShadows; + vec3_t colormod; /* eof check */ @@ -1735,6 +1736,12 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups ) if( lightmapScale > 0.0f ) Sys_Printf( "Entity %d (%s) has lightmap scale of %.4f\n", mapEnt->mapEntityNum, classname, lightmapScale ); } + + VectorClear(colormod); + if( strcmp( "", ValueForKey( mapEnt, "_color" ) ) ) + { + GetVectorForKey( mapEnt, "_color", colormod ); + } /* ydnar: get cel shader :) for this entity */ value = ValueForKey( mapEnt, "_celshader" ); @@ -1797,6 +1804,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups ) brush->lightmapScale = lightmapScale; brush->celShader = celShader; brush->shadeAngleDegrees = shadeAngle; + brush->colormod = colormod; } for( patch = mapEnt->patches; patch != NULL; patch = patch->next ) @@ -1807,6 +1815,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups ) patch->lightmapSampleSize = lightmapSampleSize; patch->lightmapScale = lightmapScale; patch->celShader = celShader; + patch->colormod = colormod; } /* ydnar: gs mods: set entity bounds */ diff --git a/tools/quake3/q3map2/model.c b/tools/quake3/q3map2/model.c index 2b3bb7ed..b67fc4e3 100644 --- a/tools/quake3/q3map2/model.c +++ b/tools/quake3/q3map2/model.c @@ -206,7 +206,7 @@ InsertModel() - ydnar adds a picomodel into the bsp */ -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 ) +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; @@ -420,6 +420,9 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap if( lightmapScale > 0.0f ) ds->lightmapScale = lightmapScale; + /* set color mod */ + ds->colormod = colormod; + /* set shading angle */ if( shadeAngle > 0.0f ) ds->shadeAngleDegrees = shadeAngle; @@ -899,7 +902,7 @@ void AddTriangleModels( entity_t *e ) skin = IntForKey(e2, "skin"); /* insert the model */ - InsertModel( model, skin, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle ); + InsertModel( model, skin, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle, colormod ); /* free shader remappings */ while( remap != NULL ) diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index e912d15b..6133243c 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -911,6 +911,7 @@ typedef struct brush_s /* ydnar: gs mods */ int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */ float lightmapScale; + vec3_t colormod; float shadeAngleDegrees; /* jal : entity based _shadeangle */ vec3_t eMins, eMaxs; indexMap_t *im; @@ -924,7 +925,7 @@ typedef struct brush_s vec3_t mins, maxs; int numsides; - + side_t sides[ 6 ]; /* variably sized */ } brush_t; @@ -964,6 +965,7 @@ typedef struct parseMesh_s /* ydnar: gs mods */ int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */ float lightmapScale; + vec3_t colormod; vec3_t eMins, eMaxs; indexMap_t *im; @@ -1061,6 +1063,9 @@ typedef struct mapDrawSurface_s /* ydnar: per-surface (per-entity, actually) lightmap sample size scaling */ float lightmapScale; + /* divVerent: per-surface (per-entity, actually) color modding */ + vec3_t colormod; + /* jal: per-surface (per-entity, actually) shadeangle */ float shadeAngleDegrees; @@ -1669,7 +1674,7 @@ void PicoPrintFunc( int level, const char *str ); void PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize ); picoModel_t *FindModel( const char *name, int frame ); picoModel_t *LoadModel( const char *name, int frame ); -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 ); +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 AddTriangleModels( entity_t *e ); diff --git a/tools/quake3/q3map2/surface.c b/tools/quake3/q3map2/surface.c index b5dd724e..bc479b93 100644 --- a/tools/quake3/q3map2/surface.c +++ b/tools/quake3/q3map2/surface.c @@ -921,6 +921,7 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin ds->fogNum = -1; ds->sampleSize = b->lightmapSampleSize; ds->lightmapScale = b->lightmapScale; + ds->colormod = b->colormod; ds->numVerts = w->numpoints; ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) ); memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) ); @@ -1109,6 +1110,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh ds->mapMesh = p; ds->sampleSize = p->lightmapSampleSize; ds->lightmapScale = p->lightmapScale; /* ydnar */ + ds->colormod = p->colormod; ds->patchWidth = mesh->width; ds->patchHeight = mesh->height; ds->numVerts = ds->patchWidth * ds->patchHeight; @@ -3173,7 +3175,7 @@ int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, surfaceModel_t *model, b } /* insert the model */ - InsertModel( (char *) model->model, 0, 0, transform, NULL, ds->celShader, ds->entityNum, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0 ); + InsertModel( (char *) model->model, 0, 0, transform, NULL, ds->celShader, ds->entityNum, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0, ds->colormod ); /* return to sender */ return 1; diff --git a/tools/quake3/q3map2/surface_foliage.c b/tools/quake3/q3map2/surface_foliage.c index cc5452ae..f15fdef4 100644 --- a/tools/quake3/q3map2/surface_foliage.c +++ b/tools/quake3/q3map2/surface_foliage.c @@ -275,7 +275,7 @@ void Foliage( mapDrawSurface_t *src ) m4x4_scale_for_vec3( transform, scale ); /* add the model to the bsp */ - InsertModel( foliage->model, 0, 0, transform, NULL, NULL, src->entityNum, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0 ); + InsertModel( foliage->model, 0, 0, transform, NULL, NULL, src->entityNum, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0, src->colormod ); /* walk each new surface */ for( i = oldNumMapDrawSurfs; i < numMapDrawSurfs; i++ ) -- 2.39.2