Skip to content

Commit

Permalink
Added (all games): Crosshair vitality. Colour the crosshair according…
Browse files Browse the repository at this point in the history
… to how near the player is to death.
  • Loading branch information
danij committed Jan 26, 2009
1 parent f3d95cd commit 00e8491
Show file tree
Hide file tree
Showing 47 changed files with 264 additions and 242 deletions.
5 changes: 3 additions & 2 deletions doomsday/engine/api/doomsday.def
@@ -1,7 +1,7 @@
NAME "DOOMSDAY"

; Highest ordinal is currently
; --> 438 <--
; --> 439 <--
; Other free ordinals:
; 43 formerly P_RegisterPlayerControl
; 44 formerly B_FormEventString
Expand Down Expand Up @@ -330,6 +330,8 @@ EXPORTS
R_PointInSubsector @102 NONAME
R_CreateAnimGroup @241 NONAME
R_AddToAnimGroup @242 NONAME
R_PalIdxToRGB @423 NONAME
R_HSVToRGB @439 NONAME

; DGL.
DGL_SetMaterial @117 NONAME
Expand Down Expand Up @@ -398,7 +400,6 @@ EXPORTS
GL_GrabScreen @109 NONAME
GL_LoadGraphics @244 NONAME
GL_NewTextureWithParams3 @329 NONAME
GL_PalIdxToRGB @423 NONAME
GL_SetFilter @132 NONAME

; Graphics: 2D drawing.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -414,7 +414,8 @@ extern "C" {
void R_GetPatchInfo(lumpnum_t lump, patchinfo_t* info);
int R_CreateAnimGroup(int flags);
void R_AddToAnimGroup(int groupNum, materialnum_t num, int tics, int randomTics);

void R_PalIdxToRGB(int idx, float* rgb);
void R_HSVToRGB(float* rgb, float h, float s, float v);
angle_t R_PointToAngle2(float x1, float y1, float x2,
float y2);
struct subsector_s* R_PointInSubsector(float x, float y);
Expand All @@ -431,7 +432,6 @@ extern "C" {
int flags, int minFilter, int magFilter, int anisoFilter,
int wrapS, int wrapT);
void GL_SetFilter(int filter_rgba);
void GL_PalIdxToRGB(int idx, float* rgb);

// Graphics: 2D drawing.
void GL_DrawPatch(int x, int y, lumpnum_t lump);
Expand Down
1 change: 0 additions & 1 deletion doomsday/engine/portable/include/gl_tex.h
Expand Up @@ -55,7 +55,6 @@ void pixBlt(byte *src, int srcWidth, int srcHeight, byte *dest,
int destWidth, int destHeight, int alpha, int srcRegX,
int srcRegY, int destRegX, int destRegY, int regWidth,
int regHeight);
void GL_PalIdxToRGB(int idx, float* rgba);
void averageColorIdx(rgbcol_t col, byte *data, int w, int h,
byte *palette, boolean hasAlpha);
void averageColorRGB(rgbcol_t col, byte *data, int w, int h);
Expand Down
2 changes: 2 additions & 0 deletions doomsday/engine/portable/include/r_util.h
Expand Up @@ -42,6 +42,8 @@ boolean R_IsPointInSector(const float x, const float y,
boolean R_IsPointInSector2(const float x, const float y,
const sector_t* sector);
void R_ScaleAmbientRGB(float* out, const float* in, float mul);
void R_PalIdxToRGB(int idx, float* rgba);
void R_HSVToRGB(float* rgb, float h, float s, float v);
sector_t* R_GetSectorForOrigin(const void* ddMobjBase);

#endif
1 change: 0 additions & 1 deletion doomsday/engine/portable/include/rend_bias.h
Expand Up @@ -105,6 +105,5 @@ source_t* SB_GetSource(int which);
int SB_ToIndex(source_t* source);

void SB_SetColor(float* dest, float* src);
void HSVtoRGB(float* rgb, float h, float s, float v);

#endif
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/edit_bias.c
Expand Up @@ -223,7 +223,7 @@ static void SBE_GetHueColor(float *color, float *angle, float *sat)
if(sat)
*sat = 0;

HSVtoRGB(color, 0, 0, 1);
R_HSVToRGB(color, 0, 0, 1);
return;
}

Expand Down Expand Up @@ -253,7 +253,7 @@ static void SBE_GetHueColor(float *color, float *angle, float *sat)

//Con_Printf("sat=%f, hue=%f\n", saturation, hue);

HSVtoRGB(color, hue, saturation, 1);
R_HSVToRGB(color, hue, saturation, 1);
}

void SBE_EndFrame(void)
Expand Down Expand Up @@ -970,7 +970,7 @@ static void SBE_DrawHue(void)
angle = 2*PI * i/steps;

// Calculate the hue color for this angle.
HSVtoRGB(color, i/steps, 1, 1);
R_HSVToRGB(color, i/steps, 1, 1);
color[3] = .5f;

SBE_HueOffset(angle, off);
Expand Down Expand Up @@ -1012,7 +1012,7 @@ static void SBE_DrawHue(void)
SBE_HueOffset(2*PI * (i + 1)/steps, off2);

// Calculate the hue color for this angle.
HSVtoRGB(color, i/steps, 1, 1);
R_HSVToRGB(color, i/steps, 1, 1);
color[3] = 1;

glColor4fv(color);
Expand Down
25 changes: 0 additions & 25 deletions doomsday/engine/portable/src/gl_tex.c
Expand Up @@ -153,31 +153,6 @@ void CalculatePal18to8(byte *dest, byte *palette)
}
}

/**
* Given a color palette index, calculate the equivilent RGB color.
*
* @param idx Color Palette, color index.
* @param rgb Ptr to the
*/
void GL_PalIdxToRGB(int idx, float* rgb)
{
if(rgb)
{
if(!(idx < 0))
{
int c;
byte* pal = GL_GetPalette();

idx = MIN_OF(idx, 255);
for(c = 0; c < 3; ++c)
rgb[c] = gammaTable[pal[idx * 3 + c]] * reciprocal255;
return;
}

rgb[CR] = rgb[CG] = rgb[CB] = 0;
}
}

/**
* in/out format:
* 1 = palette indices
Expand Down
93 changes: 93 additions & 0 deletions doomsday/engine/portable/src/r_util.c
Expand Up @@ -415,6 +415,99 @@ void R_ScaleAmbientRGB(float *out, const float *in, float mul)
}
}

/**
* Given a color palette index, calculate the equivilent RGB color.
*
* @param idx Color Palette, color index.
* @param rgb Ptr to the
*/
void R_PalIdxToRGB(int idx, float* rgb)
{
if(rgb)
{
if(!(idx < 0))
{
int c;
byte* pal = GL_GetPalette();

idx = MIN_OF(idx, 255);
for(c = 0; c < 3; ++c)
rgb[c] = gammaTable[pal[idx * 3 + c]] * reciprocal255;
return;
}

rgb[CR] = rgb[CG] = rgb[CB] = 0;
}
}

/**
* Conversion from HSV to RGB. Everything is [0,1].
*/
void R_HSVToRGB(float* rgb, float h, float s, float v)
{
int i;
float f, p, q, t;

if(!rgb)
return;

if(s == 0)
{
// achromatic (grey)
rgb[0] = rgb[1] = rgb[2] = v;
return;
}

if(h >= 1)
h -= 1;

h *= 6; // sector 0 to 5
i = floor(h);
f = h - i; // factorial part of h
p = v * (1 - s);
q = v * (1 - s * f);
t = v * (1 - s * (1 - f));

switch(i)
{
case 0:
rgb[0] = v;
rgb[1] = t;
rgb[2] = p;
break;

case 1:
rgb[0] = q;
rgb[1] = v;
rgb[2] = p;
break;

case 2:
rgb[0] = p;
rgb[1] = v;
rgb[2] = t;
break;

case 3:
rgb[0] = p;
rgb[1] = q;
rgb[2] = v;
break;

case 4:
rgb[0] = t;
rgb[1] = p;
rgb[2] = v;
break;

default:
rgb[0] = v;
rgb[1] = p;
rgb[2] = q;
break;
}
}

/**
* Returns a ptr to the sector which owns the given ddmobj_base_t.
*
Expand Down
65 changes: 0 additions & 65 deletions doomsday/engine/portable/src/rend_bias.c
Expand Up @@ -295,71 +295,6 @@ void SB_SetColor(float* dest, float* src)
}
}

/**
* Conversion from HSV to RGB. Everything is [0,1].
*/
void HSVtoRGB(float *rgb, float h, float s, float v)
{
int i;
float f, p, q, t;

if(s == 0)
{
// achromatic (grey)
rgb[0] = rgb[1] = rgb[2] = v;
return;
}

if(h >= 1)
h -= 1;

h *= 6; // sector 0 to 5
i = floor(h);
f = h - i; // factorial part of h
p = v * (1 - s);
q = v * (1 - s * f);
t = v * (1 - s * (1 - f));

switch(i)
{
case 0:
rgb[0] = v;
rgb[1] = t;
rgb[2] = p;
break;

case 1:
rgb[0] = q;
rgb[1] = v;
rgb[2] = p;
break;

case 2:
rgb[0] = p;
rgb[1] = v;
rgb[2] = t;
break;

case 3:
rgb[0] = p;
rgb[1] = q;
rgb[2] = v;
break;

case 4:
rgb[0] = t;
rgb[1] = p;
rgb[2] = v;
break;

default:
rgb[0] = v;
rgb[1] = p;
rgb[2] = q;
break;
}
}

static void SB_AddAffected(affection_t* aff, uint k, float intensity)
{
uint i, worst;
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/common/include/p_user.h
Expand Up @@ -36,8 +36,9 @@

extern boolean onground;

#if __JDOOM__ || __JDOOM64__
extern int maxHealth;

#if __JDOOM__ || __JDOOM64__
extern int healthLimit;
extern int godModeHealth;
extern int soulSphereLimit;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/include/x_hair.h
Expand Up @@ -4,7 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2008 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2009 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2008-2009 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -31,6 +31,6 @@

#define NUM_XHAIRS (6)

void X_Drawer(void);
void X_Drawer(int player);
void X_Register(void);
#endif
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/am_map.c
Expand Up @@ -2946,7 +2946,7 @@ static void renderLineCharacter(vectorgrap_t* vg, float x, float y,
automap_t* map = &automaps[mapviewplayer];
float oldLineWidth, rgba[4];

GL_PalIdxToRGB(color, rgba);
R_PalIdxToRGB(color, rgba);
rgba[3] = MINMAX_OF(0.f, alpha, 1.f);

oldLineWidth = DGL_GetFloat(DGL_LINE_WIDTH);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/g_controls.c
Expand Up @@ -878,7 +878,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, int pnum,
cmd->arti = NUM_ARTIFACT_TYPES;
}
else if(plr->plr->mo && PLAYER_ACTION(pnum, A_HEALTH) &&
!cmd->arti && (plr->plr->mo->health < MAXHEALTH))
!cmd->arti && (plr->plr->mo->health < maxHealth))
{
PLAYER_ACTION(pnum, A_HEALTH) = false;
cmd->arti = AFT_HEALTH;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/g_game.c
Expand Up @@ -1226,7 +1226,7 @@ void G_PlayerReborn(int player)
#endif
p->useDown = p->attackDown = true; // Don't do anything immediately.
p->playerState = PST_LIVE;
p->health = MAXHEALTH;
p->health = maxHealth;

#if __JDOOM__ || __JDOOM64__
p->readyWeapon = p->pendingWeapon = WT_SECOND;
Expand Down

0 comments on commit 00e8491

Please sign in to comment.