mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 01:00:53 +00:00
fullbrights on player skins now work properly instead of using the fb skin
of the player model.
This commit is contained in:
parent
92f357a2ad
commit
1444bac78d
7 changed files with 111 additions and 75 deletions
|
@ -458,5 +458,6 @@ byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
|
||||||
model_t *Mod_FindName (char *name);
|
model_t *Mod_FindName (char *name);
|
||||||
void Mod_ProcessTexture(miptex_t *mt, texture_t *tx);
|
void Mod_ProcessTexture(miptex_t *mt, texture_t *tx);
|
||||||
void Mod_LoadLighting (lump_t *l);
|
void Mod_LoadLighting (lump_t *l);
|
||||||
|
int Mod_CalcFullbright (byte *in, byte *out, int pixels);
|
||||||
|
|
||||||
#endif // _MODEL_H
|
#endif // _MODEL_H
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
client.h
|
skin.h
|
||||||
|
|
||||||
Client definitions
|
Client skin definitions
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
@ -29,21 +29,26 @@
|
||||||
#ifndef _SKIN_H
|
#ifndef _SKIN_H
|
||||||
#define _SKIN_H
|
#define _SKIN_H
|
||||||
|
|
||||||
#include "client.h"
|
#define MAX_CACHED_SKINS 128
|
||||||
|
|
||||||
|
#define RSSHOT_WIDTH 320
|
||||||
|
#define RSSHOT_HEIGHT 200
|
||||||
|
|
||||||
typedef struct skin_s
|
typedef struct skin_s
|
||||||
{
|
{
|
||||||
char name[16];
|
char name[16];
|
||||||
qboolean failedload; // the name isn't a valid skin
|
qboolean failedload; // the name isn't a valid skin
|
||||||
cache_user_t cache;
|
cache_user_t cache;
|
||||||
|
int fb_texture;
|
||||||
} skin_t;
|
} skin_t;
|
||||||
|
|
||||||
extern byte player_8bit_texels[320 * 200];
|
extern byte player_8bit_texels[320 * 200];
|
||||||
|
extern skin_t skin_cache[MAX_CACHED_SKINS];
|
||||||
struct tex_s;
|
struct tex_s;
|
||||||
struct player_info_s;
|
struct player_info_s;
|
||||||
|
|
||||||
void Skin_Find (struct player_info_s *sc);
|
void Skin_Find (struct player_info_s *sc);
|
||||||
byte *Skin_Cache (skin_t *skin);
|
struct tex_s *Skin_Cache (skin_t *skin);
|
||||||
void Skin_Skins_f (void);
|
void Skin_Skins_f (void);
|
||||||
void Skin_AllSkins_f (void);
|
void Skin_AllSkins_f (void);
|
||||||
void Skin_NextDownload (void);
|
void Skin_NextDownload (void);
|
||||||
|
@ -54,9 +59,4 @@ void Skin_Set_Translate (struct player_info_s *player);
|
||||||
void Skin_Do_Translation (player_info_t *player);
|
void Skin_Do_Translation (player_info_t *player);
|
||||||
void Skin_Process (skin_t *skin, struct tex_s *);
|
void Skin_Process (skin_t *skin, struct tex_s *);
|
||||||
|
|
||||||
#define MAX_CACHED_SKINS 128
|
|
||||||
|
|
||||||
#define RSSHOT_WIDTH 320
|
|
||||||
#define RSSHOT_HEIGHT 200
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,41 +40,39 @@
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
Mod_CalcFullbright (byte *in, byte *out, int pixels)
|
||||||
|
{
|
||||||
|
int fb = 0;
|
||||||
|
|
||||||
|
while (pixels--) {
|
||||||
|
if (*in >= 256 - 32) {
|
||||||
|
fb = 1;
|
||||||
|
*out++ = *in++;
|
||||||
|
} else {
|
||||||
|
*out++ = 255;
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fb;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Mod_Fullbright (byte * skin, int width, int height, char *name)
|
Mod_Fullbright (byte * skin, int width, int height, char *name)
|
||||||
{
|
{
|
||||||
int j;
|
|
||||||
int pixels;
|
int pixels;
|
||||||
qboolean hasfullbrights = false;
|
int texnum = 0;
|
||||||
int texnum;
|
byte *ptexels;
|
||||||
|
|
||||||
// Check for fullbright pixels..
|
// Check for fullbright pixels..
|
||||||
pixels = width * height;
|
pixels = width * height;
|
||||||
|
|
||||||
for (j = 0; j < pixels; j++) {
|
// ptexels = Hunk_Alloc(s);
|
||||||
if (skin[j] >= 256 - 32) {
|
ptexels = malloc (pixels);
|
||||||
hasfullbrights = true;
|
if (Mod_CalcFullbright (skin, ptexels, pixels)) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasfullbrights) {
|
|
||||||
byte *ptexels;
|
|
||||||
|
|
||||||
// ptexels = Hunk_Alloc(s);
|
|
||||||
ptexels = malloc (pixels);
|
|
||||||
|
|
||||||
Con_DPrintf ("FB Model ID: '%s'\n", name);
|
Con_DPrintf ("FB Model ID: '%s'\n", name);
|
||||||
for (j = 0; j < pixels; j++) {
|
|
||||||
if (skin[j] >= 256 - 32) {
|
|
||||||
ptexels[j] = skin[j];
|
|
||||||
} else {
|
|
||||||
ptexels[j] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
texnum = GL_LoadTexture (name, width, height, ptexels, true, true, 1);
|
texnum = GL_LoadTexture (name, width, height, ptexels, true, true, 1);
|
||||||
free (ptexels);
|
|
||||||
return texnum;
|
|
||||||
}
|
}
|
||||||
return 0;
|
free (ptexels);
|
||||||
|
return texnum;
|
||||||
}
|
}
|
||||||
|
|
|
@ -722,6 +722,7 @@ R_DrawAliasModel (entity_t *e)
|
||||||
float an;
|
float an;
|
||||||
int anim;
|
int anim;
|
||||||
qboolean torch = false;
|
qboolean torch = false;
|
||||||
|
int fb_texture = 0;
|
||||||
|
|
||||||
clmodel = currententity->model;
|
clmodel = currententity->model;
|
||||||
|
|
||||||
|
@ -823,19 +824,34 @@ R_DrawAliasModel (entity_t *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
anim = (int) (cl.time * 10) & 3;
|
anim = (int) (cl.time * 10) & 3;
|
||||||
glBindTexture (GL_TEXTURE_2D,
|
|
||||||
paliashdr->gl_texturenum[currententity->skinnum][anim]);
|
|
||||||
|
|
||||||
// we can't dynamically colormap textures, so they are cached
|
// we can't dynamically colormap textures, so they are cached
|
||||||
// seperately for the players. Heads are just uncolored.
|
// seperately for the players. Heads are just uncolored.
|
||||||
if (currententity->scoreboard && !gl_nocolors->int_val) {
|
if (currententity->scoreboard && !gl_nocolors->int_val) {
|
||||||
|
skin_t *skin;
|
||||||
|
|
||||||
i = currententity->scoreboard - cl.players;
|
i = currententity->scoreboard - cl.players;
|
||||||
if (!currententity->scoreboard->skin) {
|
if (!currententity->scoreboard->skin) {
|
||||||
Skin_Find (currententity->scoreboard);
|
Skin_Find (currententity->scoreboard);
|
||||||
CL_NewTranslation (i);
|
CL_NewTranslation (i);
|
||||||
}
|
}
|
||||||
|
skin = currententity->scoreboard->skin;
|
||||||
if (i >= 0 && i < MAX_CLIENTS)
|
if (i >= 0 && i < MAX_CLIENTS)
|
||||||
glBindTexture (GL_TEXTURE_2D, playertextures + i);
|
glBindTexture (GL_TEXTURE_2D, playertextures + i);
|
||||||
|
if (gl_fb_models->int_val) {
|
||||||
|
if (skin)
|
||||||
|
fb_texture = skin->fb_texture;
|
||||||
|
else
|
||||||
|
fb_texture = paliashdr->gl_fb_texturenum[currententity->skinnum]
|
||||||
|
[anim];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
glBindTexture (GL_TEXTURE_2D,
|
||||||
|
paliashdr->gl_texturenum[currententity->skinnum][anim]);
|
||||||
|
if (clmodel->hasfullbrights && gl_fb_models->int_val &&
|
||||||
|
paliashdr->gl_fb_texturenum[currententity->skinnum][anim])
|
||||||
|
fb_texture = paliashdr->gl_fb_texturenum[currententity->skinnum]
|
||||||
|
[anim];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gl_affinemodels->int_val)
|
if (gl_affinemodels->int_val)
|
||||||
|
@ -848,11 +864,11 @@ R_DrawAliasModel (entity_t *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This block is GL fullbright support for objects...
|
// This block is GL fullbright support for objects...
|
||||||
if (clmodel->hasfullbrights && gl_fb_models->int_val &&
|
if (fb_texture) {
|
||||||
paliashdr->gl_fb_texturenum[currententity->skinnum][anim]) {
|
glBindTexture (GL_TEXTURE_2D, fb_texture);
|
||||||
glBindTexture (GL_TEXTURE_2D, paliashdr->gl_fb_texturenum[currententity->skinnum][anim]);
|
|
||||||
if (gl_lerp_anim->int_val) {
|
if (gl_lerp_anim->int_val) {
|
||||||
R_SetupAliasBlendedFrame (currententity->frame, paliashdr, currententity, true);
|
R_SetupAliasBlendedFrame (currententity->frame, paliashdr,
|
||||||
|
currententity, true);
|
||||||
} else {
|
} else {
|
||||||
R_SetupAliasFrame (currententity->frame, paliashdr, true);
|
R_SetupAliasFrame (currententity->frame, paliashdr, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,33 +136,19 @@ build_skin_32 (byte * original, int tinwidth, int tinheight,
|
||||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
Skin_Do_Translation (player_info_t *player)
|
build_skin (int texnum, byte *ptexels, int width, int height)
|
||||||
{
|
{
|
||||||
int inwidth, inheight;
|
|
||||||
int tinwidth, tinheight;
|
int tinwidth, tinheight;
|
||||||
unsigned int scaled_width, scaled_height;
|
unsigned int scaled_width, scaled_height;
|
||||||
byte *original;
|
|
||||||
|
|
||||||
// locate the original skin pixels
|
// locate the original skin pixels
|
||||||
tinwidth = 296; // real model width
|
tinwidth = 296; // real model width
|
||||||
tinheight = 194; // real model height
|
tinheight = 194; // real model height
|
||||||
|
|
||||||
if (!player->skin)
|
|
||||||
Skin_Find (player);
|
|
||||||
if ((original = Skin_Cache (player->skin)) != NULL) {
|
|
||||||
// skin data width
|
|
||||||
inwidth = 320;
|
|
||||||
inheight = 200;
|
|
||||||
} else {
|
|
||||||
original = player_8bit_texels;
|
|
||||||
inwidth = 296;
|
|
||||||
inheight = 194;
|
|
||||||
}
|
|
||||||
|
|
||||||
// because this happens during gameplay, do it fast
|
// because this happens during gameplay, do it fast
|
||||||
// instead of sending it through GL_Upload8()
|
// instead of sending it through GL_Upload8()
|
||||||
glBindTexture (GL_TEXTURE_2D, playertextures + (player - cl.players));
|
glBindTexture (GL_TEXTURE_2D, texnum);
|
||||||
|
|
||||||
// FIXME deek: This 512x256 limit sucks!
|
// FIXME deek: This 512x256 limit sucks!
|
||||||
scaled_width = min (gl_max_size->int_val, 512);
|
scaled_width = min (gl_max_size->int_val, 512);
|
||||||
|
@ -173,13 +159,37 @@ Skin_Do_Translation (player_info_t *player)
|
||||||
scaled_height >>= gl_playermip->int_val;
|
scaled_height >>= gl_playermip->int_val;
|
||||||
|
|
||||||
if (VID_Is8bit ()) { // 8bit texture upload
|
if (VID_Is8bit ()) { // 8bit texture upload
|
||||||
build_skin_8 (original, tinwidth, tinheight, scaled_width,
|
build_skin_8 (ptexels, tinwidth, tinheight, scaled_width,
|
||||||
scaled_height, inwidth);
|
scaled_height, width);
|
||||||
} else {
|
} else {
|
||||||
build_skin_32 (original, tinwidth, tinheight, scaled_width,
|
build_skin_32 (ptexels, tinwidth, tinheight, scaled_width,
|
||||||
scaled_height, inwidth);
|
scaled_height, width);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Skin_Do_Translation (player_info_t *player)
|
||||||
|
{
|
||||||
|
int texnum;
|
||||||
|
int inwidth, inheight;
|
||||||
|
byte *original;
|
||||||
|
tex_t *skin;
|
||||||
|
|
||||||
|
if (!player->skin)
|
||||||
|
Skin_Find (player);
|
||||||
|
|
||||||
|
if ((skin = (tex_t*)Skin_Cache (player->skin)) != NULL) {
|
||||||
|
// skin data width
|
||||||
|
inwidth = 320;
|
||||||
|
inheight = 200;
|
||||||
|
original = skin->data;
|
||||||
|
} else {
|
||||||
|
original = player_8bit_texels;
|
||||||
|
inwidth = 296;
|
||||||
|
inheight = 194;
|
||||||
|
}
|
||||||
|
texnum = playertextures + (player - cl.players);
|
||||||
|
build_skin (texnum, original, inwidth, inheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -196,4 +206,11 @@ Skin_Init_Translation (void)
|
||||||
void
|
void
|
||||||
Skin_Process (skin_t *skin, tex_t *tex)
|
Skin_Process (skin_t *skin, tex_t *tex)
|
||||||
{
|
{
|
||||||
|
int pixels = tex->width * tex->height;
|
||||||
|
byte *ptexels = Hunk_TempAlloc (pixels);
|
||||||
|
|
||||||
|
if (Mod_CalcFullbright (tex->data, ptexels, pixels)) {
|
||||||
|
skin->fb_texture = player_fb_textures + (skin - skin_cache);
|
||||||
|
build_skin (skin->fb_texture, ptexels, tex->width, tex->height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "skin.h"
|
#include "skin.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
#include "texture.h"
|
||||||
|
|
||||||
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
||||||
// avoid the
|
// avoid the
|
||||||
|
@ -608,13 +609,13 @@ R_AliasSetupSkin (void)
|
||||||
r_affinetridesc.skinheight = pmdl->skinheight;
|
r_affinetridesc.skinheight = pmdl->skinheight;
|
||||||
|
|
||||||
if (currententity->scoreboard) {
|
if (currententity->scoreboard) {
|
||||||
byte *base;
|
tex_t *base;
|
||||||
|
|
||||||
if (!currententity->scoreboard->skin)
|
if (!currententity->scoreboard->skin)
|
||||||
Skin_Find (currententity->scoreboard);
|
Skin_Find (currententity->scoreboard);
|
||||||
base = Skin_Cache (currententity->scoreboard->skin);
|
base = Skin_Cache (currententity->scoreboard->skin);
|
||||||
if (base) {
|
if (base) {
|
||||||
r_affinetridesc.pskin = base;
|
r_affinetridesc.pskin = base->data;
|
||||||
r_affinetridesc.skinwidth = 320;
|
r_affinetridesc.skinwidth = 320;
|
||||||
r_affinetridesc.skinheight = 200;
|
r_affinetridesc.skinheight = 200;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cl_parse.h"
|
#include "cl_parse.h"
|
||||||
|
#include "client.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
@ -58,7 +59,7 @@ cvar_t *bottomcolor;
|
||||||
|
|
||||||
char allskins[128];
|
char allskins[128];
|
||||||
|
|
||||||
skin_t skins[MAX_CACHED_SKINS];
|
skin_t skin_cache[MAX_CACHED_SKINS];
|
||||||
int numskins;
|
int numskins;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -90,8 +91,8 @@ Skin_Find (player_info_t *sc)
|
||||||
COM_StripExtension (name, name);
|
COM_StripExtension (name, name);
|
||||||
|
|
||||||
for (i = 0; i < numskins; i++) {
|
for (i = 0; i < numskins; i++) {
|
||||||
if (!strcmp (name, skins[i].name)) {
|
if (!strcmp (name, skin_cache[i].name)) {
|
||||||
sc->skin = &skins[i];
|
sc->skin = &skin_cache[i];
|
||||||
Skin_Cache (sc->skin);
|
Skin_Cache (sc->skin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ Skin_Find (player_info_t *sc)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
skin = &skins[numskins];
|
skin = &skin_cache[numskins];
|
||||||
sc->skin = skin;
|
sc->skin = skin;
|
||||||
numskins++;
|
numskins++;
|
||||||
|
|
||||||
|
@ -117,13 +118,14 @@ Skin_Find (player_info_t *sc)
|
||||||
|
|
||||||
Returns a pointer to the skin bitmap, or NULL to use the default
|
Returns a pointer to the skin bitmap, or NULL to use the default
|
||||||
*/
|
*/
|
||||||
byte *
|
tex_t *
|
||||||
Skin_Cache (skin_t *skin)
|
Skin_Cache (skin_t *skin)
|
||||||
{
|
{
|
||||||
char name[1024];
|
char name[1024];
|
||||||
byte *out;
|
tex_t *out;
|
||||||
QFile *file;
|
QFile *file;
|
||||||
tex_t *tex;
|
tex_t *tex;
|
||||||
|
int pixels;
|
||||||
|
|
||||||
if (cls.downloadtype == dl_skin)
|
if (cls.downloadtype == dl_skin)
|
||||||
return NULL; // use base until downloaded
|
return NULL; // use base until downloaded
|
||||||
|
@ -159,14 +161,15 @@ Skin_Cache (skin_t *skin)
|
||||||
Con_Printf ("Bad skin %s\n", name);
|
Con_Printf ("Bad skin %s\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
pixels = tex->width * tex->height;
|
||||||
|
|
||||||
out = Cache_Alloc (&skin->cache, 320 * 200, skin->name);
|
out = Cache_Alloc (&skin->cache, sizeof (tex_t) + pixels, skin->name);
|
||||||
if (!out)
|
if (!out)
|
||||||
Sys_Error ("Skin_Cache: couldn't allocate");
|
Sys_Error ("Skin_Cache: couldn't allocate");
|
||||||
|
|
||||||
memcpy (out, tex->data, tex->width * tex->height);
|
memcpy (out, tex, sizeof (tex_t) + pixels);
|
||||||
|
|
||||||
Skin_Process (skin, tex);
|
Skin_Process (skin, out);
|
||||||
|
|
||||||
skin->failedload = false;
|
skin->failedload = false;
|
||||||
|
|
||||||
|
@ -230,8 +233,8 @@ Skin_Skins_f (void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < numskins; i++) {
|
for (i = 0; i < numskins; i++) {
|
||||||
if (skins[i].cache.data)
|
if (skin_cache[i].cache.data)
|
||||||
Cache_Free (&skins[i].cache);
|
Cache_Free (&skin_cache[i].cache);
|
||||||
}
|
}
|
||||||
numskins = 0;
|
numskins = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue