fixed coloring of tees

This commit is contained in:
Magnus Auvinen 2007-11-26 22:26:33 +00:00
parent ad5523dac4
commit 8f72a35dbb
3 changed files with 69 additions and 17 deletions

View file

@ -45,6 +45,43 @@ static void skinscan(const char *name, int is_dir, void *user)
d[i*step+2] = v;
}
if(1)
{
int bs = 96; // body size
int pitch = info.width*4;
int freq[256] = {0};
for(int y = 0; y < bs; y++)
for(int x = 0; x < bs; x++)
{
if(d[y*pitch+x*4+3] > 128)
freq[d[y*pitch+x*4]]++;
}
int org_weight = 0;
int new_weight = 192;
for(int i = 1; i < 256; i++)
{
if(freq[org_weight] < freq[i])
org_weight = i;
}
int inv_org_weight = 255-org_weight;
int inv_new_weight = 255-new_weight;
for(int y = 0; y < bs; y++)
for(int x = 0; x < bs; x++)
{
int v = d[y*pitch+x*4];
if(v <= org_weight)
v = (int)(((v/(float)org_weight) * new_weight));
else
v = (int)(((v-org_weight)/(float)inv_org_weight)*inv_new_weight + new_weight);
d[y*pitch+x*4] = v;
d[y*pitch+x*4+1] = v;
d[y*pitch+x*4+2] = v;
}
}
skins[num_skins].color_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data);
mem_free(info.data);

View file

@ -1439,23 +1439,38 @@ static void menu2_render_game(RECT main_view)
int menu2_render()
{
/*
gfx_mapscreen(0,0,2*4/3.0f,2);
gfx_clear(gui_color.r, gui_color.g, gui_color.b);
animstate state;
anim_eval(&data->animations[ANIM_BASE], 0, &state);
//anim_eval_add(&idlestate, &data->animations[ANIM_IDLE], 0, 1.0f);
anim_eval_add(&state, &data->animations[ANIM_WALK], fmod(client_localtime(), 1.0f), 1.0f);
if(1)
{
gfx_mapscreen(0,0,10*4/3.0f,10);
gfx_clear(gui_color.r, gui_color.g, gui_color.b);
tee_render_info info;
info.texture = skin_get(1)->org_texture;
info.color = vec4(1,1,1,1);
info.size = 1.0f; //ui2_scale()*16.0f;
render_tee(&state, &info, 0, vec2(sinf(client_localtime()*3), cosf(client_localtime()*3)), vec2(1,1));
return 0;
*/
animstate state;
anim_eval(&data->animations[ANIM_BASE], 0, &state);
anim_eval_add(&state, &data->animations[ANIM_IDLE], 0, 1.0f);
//anim_eval_add(&state, &data->animations[ANIM_WALK], fmod(client_localtime(), 1.0f), 1.0f);
for(int i = 0; i < skin_num(); i++)
{
float x = (i/8)*3;
float y = (i%8);
for(int c = 0; c < 2; c++)
{
//int colors[2] = {54090, 10998628};
//int colors[2] = {65432, 9895832}; // NEW
int colors[2] = {65387, 10223467}; // NEW
tee_render_info info;
info.texture = skin_get(i)->color_texture;
info.color_feet = info.color_body = skin_get_color(colors[c]);
//info.color_feet = info.color_body = vec4(1,1,1,1);
info.size = 1.0f; //ui2_scale()*16.0f;
//render_tee(&state, &info, 0, vec2(sinf(client_localtime()*3), cosf(client_localtime()*3)), vec2(1+x+c,1+y));
render_tee(&state, &info, 0, vec2(1,0), vec2(1+x+c,1+y));
}
}
return 0;
}
gfx_mapscreen(0,0,800,600);

View file

@ -115,7 +115,7 @@ void gameobject::post_reset()
void gameobject::on_player_info_change(class player *p)
{
const int team_colors[2] = {54090, 10998628};
const int team_colors[2] = {65387, 10223467};
if(is_teamplay)
{
if(p->team >= 0 || p->team <= 1)