Large PIELIGHT cleanup. Also cleans up tile drawing logic somewhat.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3006 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-12-09 00:33:03 +00:00
parent b963c15348
commit 76840b01d2
14 changed files with 168 additions and 215 deletions

View File

@ -58,15 +58,8 @@
#define OLD_TEXTURE_SIZE_FIX 256.0f #define OLD_TEXTURE_SIZE_FIX 256.0f
#define pie_MAX_POLY_SIZE 16 #define pie_MAX_POLY_SIZE 16
//Effects
#define pie_MAX_BRIGHT_LEVEL 255
#define pie_BRIGHT_LEVEL_200 200
#define pie_BRIGHT_LEVEL_180 180
#define pie_DROID_BRIGHT_LEVEL 192
//Render style flags for all pie draw functions //Render style flags for all pie draw functions
#define pie_TRANSLUCENT 0x2 #define pie_TRANSLUCENT 0x2
#define pie_ADDITIVE 0x4 #define pie_ADDITIVE 0x4
@ -83,14 +76,8 @@
#define pie_MAX_POLYGONS 512 #define pie_MAX_POLYGONS 512
#define pie_MAX_VERTICES_PER_POLYGON 6 #define pie_MAX_VERTICES_PER_POLYGON 6
#define pie_FILLRED 16
#define pie_FILLGREEN 16
#define pie_FILLBLUE 128
#define pie_FILLTRANS 128
#define MAX_UB_LIGHT ((UBYTE)255) #define MAX_UB_LIGHT ((UBYTE)255)
#define MIN_UB_LIGHT ((UBYTE)0) #define MIN_UB_LIGHT ((UBYTE)0)
#define MAX_LIGHT 0xffffffff
/***************************************************************************/ /***************************************************************************/
/* /*
@ -151,7 +138,7 @@ typedef struct {
* Global ProtoTypes * Global ProtoTypes
*/ */
/***************************************************************************/ /***************************************************************************/
extern void pie_Draw3DShape(iIMDShape *shape, int frame, int team, UDWORD colour, UDWORD specular, int pieFlag, int pieData); extern void pie_Draw3DShape(iIMDShape *shape, int frame, int team, PIELIGHT colour, PIELIGHT specular, int pieFlag, int pieData);
extern void pie_DrawImage(PIEIMAGE *image, PIERECT *dest, PIESTYLE *style); extern void pie_DrawImage(PIEIMAGE *image, PIERECT *dest, PIESTYLE *style);
void pie_DrawTerrainInit(void); void pie_DrawTerrainInit(void);

View File

@ -34,7 +34,7 @@
#include "lib/ivis_common/pieclip.h" #include "lib/ivis_common/pieclip.h"
extern UBYTE pie_ByteScale(UBYTE a, UBYTE b) WZ_DECL_CONST; extern UBYTE pie_ByteScale(UBYTE a, UBYTE b) WZ_DECL_CONST;
extern void pie_TransColouredTriangle(CLIP_VERTEX *vrt, UDWORD rgb); extern void pie_TransColouredTriangle(CLIP_VERTEX *vrt, PIELIGHT c);
extern void pie_DrawSkybox(float scale, int u, int v, int w, int h); extern void pie_DrawSkybox(float scale, int u, int v, int w, int h);
extern void pie_DrawFogBox(float left, float right, float front, float back, float height, float wider); extern void pie_DrawFogBox(float left, float right, float front, float back, float height, float wider);
extern void pie_DrawViewingWindow( Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, PIELIGHT colour); extern void pie_DrawViewingWindow( Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, PIELIGHT colour);

View File

@ -78,5 +78,6 @@ extern Uint8 pal_GetNearestColour(Uint8 r, Uint8 g, Uint8 b);
extern int pal_AddNewPalette(PIELIGHT *pal); extern int pal_AddNewPalette(PIELIGHT *pal);
extern void pal_PaletteSet(void); extern void pal_PaletteSet(void);
extern PIELIGHT *pie_GetGamePal(void); extern PIELIGHT *pie_GetGamePal(void);
extern PIELIGHT pal_SetBrightness(UBYTE brightness);
#endif #endif

View File

@ -48,6 +48,11 @@
*/ */
/***************************************************************************/ /***************************************************************************/
#define pie_FILLRED 16
#define pie_FILLGREEN 16
#define pie_FILLBLUE 128
#define pie_FILLTRANS 128
#define RADARX 128 #define RADARX 128
#define RADARY 128 #define RADARY 128

View File

@ -674,10 +674,8 @@ void pie_CleanUp( void )
scshapes = NULL; scshapes = NULL;
} }
void pie_Draw3DShape(iIMDShape *shape, int frame, int team, UDWORD col, UDWORD spec, int pieFlag, int pieFlagData) void pie_Draw3DShape(iIMDShape *shape, int frame, int team, PIELIGHT colour, PIELIGHT specular, int pieFlag, int pieFlagData)
{ {
PIELIGHT colour, specular;
pieCount++; pieCount++;
// Fix for transparent buildings and features!! // Fix for transparent buildings and features!!
@ -688,20 +686,6 @@ void pie_Draw3DShape(iIMDShape *shape, int frame, int team, UDWORD col, UDWORD s
pieFlagData = 0; pieFlagData = 0;
} }
// WARZONE light as byte passed in colour so expand
if (col <= MAX_UB_LIGHT)
{
colour.byte.a = 255;//no fog
colour.byte.r = (UBYTE)col;
colour.byte.g = (UBYTE)col;
colour.byte.b = (UBYTE)col;
}
else
{
colour.argb = col;
}
specular.argb = spec;
if (frame == 0) if (frame == 0)
{ {
frame = team; frame = team;

View File

@ -108,13 +108,10 @@ void pie_DrawViewingWindow(Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD
} }
/* ---------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------- */
void pie_TransColouredTriangle(CLIP_VERTEX *vrt, UDWORD rgb) void pie_TransColouredTriangle(CLIP_VERTEX *vrt, PIELIGHT c)
{ {
PIELIGHT c;
UDWORD i; UDWORD i;
c.argb = rgb;
pie_SetTexturePage(-1); pie_SetTexturePage(-1);
pie_SetRendMode(REND_ALPHA_ITERATED); pie_SetRendMode(REND_ALPHA_ITERATED);
@ -125,7 +122,8 @@ void pie_TransColouredTriangle(CLIP_VERTEX *vrt, UDWORD rgb)
{ {
glVertex3f(vrt[i].pos.x, vrt[i].pos.y, vrt[i].pos.z); glVertex3f(vrt[i].pos.x, vrt[i].pos.y, vrt[i].pos.z);
} }
glEnd();} glEnd();
}
/* ---------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------- */

View File

@ -168,6 +168,16 @@ void pie_SetColourDefines(void)
WZCOL_MENU_SEPARATOR.byte.b = 0xa0; WZCOL_MENU_SEPARATOR.byte.b = 0xa0;
} }
PIELIGHT pal_SetBrightness(UBYTE brightness)
{
PIELIGHT c;
c.byte.r = brightness;
c.byte.g = brightness;
c.byte.b = brightness;
c.byte.a = UBYTE_MAX;
return c;
}
void pal_ShutDown(void) void pal_ShutDown(void)
{ {
if (bPaletteInitialised) if (bPaletteInitialised)

View File

@ -26,6 +26,7 @@
#include "lib/framework/frame.h" #include "lib/framework/frame.h"
#include "lib/ivis_common/piedef.h" #include "lib/ivis_common/piedef.h"
#include "lib/ivis_opengl/piematrix.h" #include "lib/ivis_opengl/piematrix.h"
#include "lib/ivis_common/piepalette.h"
#include "lib/ivis_common/piestate.h" #include "lib/ivis_common/piestate.h"
#include "display3d.h" #include "display3d.h"
#include "display3ddef.h" #include "display3ddef.h"
@ -328,7 +329,7 @@ UDWORD i;
void renderParticle( ATPART *psPart ) void renderParticle( ATPART *psPart )
{ {
Vector3i dv; Vector3i dv;
UDWORD brightness, specular; PIELIGHT brightness;
SDWORD centreX, centreZ; SDWORD centreX, centreZ;
SDWORD x, y, z, rx, rz; SDWORD x, y, z, rx, rz;
@ -352,10 +353,11 @@ void renderParticle( ATPART *psPart )
/* Draw it... */ /* Draw it... */
centreX = player.p.x + world_coord(visibleTiles.x / 2); centreX = player.p.x + world_coord(visibleTiles.x / 2);
centreZ = player.p.z + world_coord(visibleTiles.y / 2); centreZ = player.p.z + world_coord(visibleTiles.y / 2);
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,centreX - x,centreZ - z, &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, centreX - x, centreZ - z, NULL);
pie_Draw3DShape(psPart->imd, 0, 0, brightness, 0, pie_NO_BILINEAR, 0); pie_Draw3DShape(psPart->imd, 0, 0, brightness, WZCOL_BLACK, pie_NO_BILINEAR, 0);
iV_MatrixEnd(); iV_MatrixEnd();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
/* Makes a particle wrap around - if it goes off the grid, then it returns /* Makes a particle wrap around - if it goes off the grid, then it returns
on the other side - provided it's still on world... Which it should be */ on the other side - provided it's still on world... Which it should be */

View File

@ -25,6 +25,7 @@
#include "lib/ivis_common/ivisdef.h" //ivis matrix code #include "lib/ivis_common/ivisdef.h" //ivis matrix code
#include "lib/ivis_common/piedef.h" //pie render #include "lib/ivis_common/piedef.h" //pie render
#include "lib/ivis_opengl/piematrix.h" #include "lib/ivis_opengl/piematrix.h"
#include "lib/ivis_common/piepalette.h"
#include "miscimd.h" #include "miscimd.h"
#include "effects.h" #include "effects.h"
#include "bridge.h" #include "bridge.h"
@ -147,7 +148,7 @@ BOOL renderBridgeSection(STRUCTURE *psStructure)
/* Translate */ /* Translate */
pie_TRANSLATE(rx,0,-rz); pie_TRANSLATE(rx,0,-rz);
pie_Draw3DShape(psStructure->sDisplay.imd, 0, 0, pie_DROID_BRIGHT_LEVEL, 0, 0, 0); pie_Draw3DShape(psStructure->sDisplay.imd, 0, 0, WZCOL_WHITE, WZCOL_BLACK, 0, 0);
pie_MatEnd(); pie_MatEnd();
return(TRUE); return(TRUE);

View File

@ -35,6 +35,7 @@
#include "lib/ivis_opengl/piematrix.h" #include "lib/ivis_opengl/piematrix.h"
#include "lib/ivis_common/piedef.h" //ivis matrix code #include "lib/ivis_common/piedef.h" //ivis matrix code
#include "lib/ivis_common/piestate.h" //ivis render code #include "lib/ivis_common/piestate.h" //ivis render code
#include "lib/ivis_common/piepalette.h"
#include "lighting.h" #include "lighting.h"
#include "loop.h" #include "loop.h"
@ -257,13 +258,11 @@ void displayIMDButton(iIMDShape *IMDShape, Vector3i *Rotation, Vector3i *Positio
pie_MatScale(scale); pie_MatScale(scale);
pie_SetFogStatus(FALSE); pie_SetFogStatus(FALSE);
pie_Draw3DShape(IMDShape, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); // ajl changed 0 to selectedPlayer pie_Draw3DShape(IMDShape, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
unsetMatrix(); unsetMatrix();
} }
//Watermelon:changed it to loop thru and draw all weapons //Watermelon:changed it to loop thru and draw all weapons
void displayStructureButton(STRUCTURE *psStructure, Vector3i *Rotation, Vector3i *Position, BOOL RotXYZ, SDWORD scale) void displayStructureButton(STRUCTURE *psStructure, Vector3i *Rotation, Vector3i *Position, BOOL RotXYZ, SDWORD scale)
{ {
@ -290,9 +289,9 @@ void displayStructureButton(STRUCTURE *psStructure, Vector3i *Rotation, Vector3i
/* Draw the building's base first */ /* Draw the building's base first */
baseImd = psStructure->pStructureType->pBaseIMD; baseImd = psStructure->pStructureType->pBaseIMD;
if(baseImd!=NULL) { if(baseImd!=NULL) {
pie_Draw3DShape(baseImd, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); // ajl changed 0 to selectedPlayer pie_Draw3DShape(baseImd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
} }
pie_Draw3DShape(psStructure->sDisplay.imd, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); // ajl changed 0 to selectedPlayer pie_Draw3DShape(psStructure->sDisplay.imd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
//and draw the turret //and draw the turret
if(psStructure->sDisplay.imd->nconnectors) if(psStructure->sDisplay.imd->nconnectors)
{ {
@ -382,14 +381,14 @@ void displayStructureButton(STRUCTURE *psStructure, Vector3i *Rotation, Vector3i
pie_MatRotY(DEG(-((SDWORD)psStructure->turretRotation[i]))); pie_MatRotY(DEG(-((SDWORD)psStructure->turretRotation[i])));
if (mountImd[i] != NULL) if (mountImd[i] != NULL)
{ {
pie_Draw3DShape(mountImd[i], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(mountImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
if(mountImd[i]->nconnectors) if(mountImd[i]->nconnectors)
{ {
iV_TRANSLATE(mountImd[i]->connectors->x,mountImd[i]->connectors->z,mountImd[i]->connectors->y); iV_TRANSLATE(mountImd[i]->connectors->x,mountImd[i]->connectors->z,mountImd[i]->connectors->y);
} }
} }
iV_MatrixRotateX(DEG(psStructure->turretPitch[i])); iV_MatrixRotateX(DEG(psStructure->turretPitch[i]));
pie_Draw3DShape(weaponImd[i], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(weaponImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
//we have a droid weapon so do we draw a muzzle flash //we have a droid weapon so do we draw a muzzle flash
iV_MatrixEnd(); iV_MatrixEnd();
} }
@ -401,14 +400,14 @@ void displayStructureButton(STRUCTURE *psStructure, Vector3i *Rotation, Vector3i
pie_MatRotY(DEG(-((SDWORD)psStructure->turretRotation[0]))); pie_MatRotY(DEG(-((SDWORD)psStructure->turretRotation[0])));
if (mountImd[0] != NULL) if (mountImd[0] != NULL)
{ {
pie_Draw3DShape(mountImd[0], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(mountImd[0], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
if(mountImd[0]->nconnectors) if(mountImd[0]->nconnectors)
{ {
iV_TRANSLATE(mountImd[0]->connectors->x,mountImd[0]->connectors->z,mountImd[0]->connectors->y); iV_TRANSLATE(mountImd[0]->connectors->x,mountImd[0]->connectors->z,mountImd[0]->connectors->y);
} }
} }
iV_MatrixRotateX(DEG(psStructure->turretPitch[0])); iV_MatrixRotateX(DEG(psStructure->turretPitch[0]));
pie_Draw3DShape(weaponImd[0], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(weaponImd[0], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
//we have a droid weapon so do we draw a muzzle flash //we have a droid weapon so do we draw a muzzle flash
iV_MatrixEnd(); iV_MatrixEnd();
} }
@ -441,10 +440,11 @@ void displayStructureStatButton(STRUCTURE_STATS *Stats,UDWORD Player, Vector3i *
/* Draw the building's base first */ /* Draw the building's base first */
baseImd = Stats->pBaseIMD; baseImd = Stats->pBaseIMD;
if(baseImd!=NULL) { if (baseImd != NULL)
pie_Draw3DShape(baseImd, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0);// ajl changed 0 to selectedPlayer {
pie_Draw3DShape(baseImd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
} }
pie_Draw3DShape(Stats->pIMD, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0);// ajl changed 0 to selectedPlayer pie_Draw3DShape(Stats->pIMD, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
//and draw the turret //and draw the turret
if(Stats->pIMD->nconnectors) if(Stats->pIMD->nconnectors)
@ -539,14 +539,14 @@ void displayStructureStatButton(STRUCTURE_STATS *Stats,UDWORD Player, Vector3i *
pie_MatRotY(DEG(0)); pie_MatRotY(DEG(0));
if (mountImd[i] != NULL) if (mountImd[i] != NULL)
{ {
pie_Draw3DShape(mountImd[i], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(mountImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
if(mountImd[i]->nconnectors) if(mountImd[i]->nconnectors)
{ {
iV_TRANSLATE(mountImd[i]->connectors->x,mountImd[i]->connectors->z,mountImd[i]->connectors->y); iV_TRANSLATE(mountImd[i]->connectors->x,mountImd[i]->connectors->z,mountImd[i]->connectors->y);
} }
} }
iV_MatrixRotateX(DEG(0)); iV_MatrixRotateX(DEG(0));
pie_Draw3DShape(weaponImd[i], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(weaponImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
//we have a droid weapon so do we draw a muzzle flash //we have a droid weapon so do we draw a muzzle flash
iV_MatrixEnd(); iV_MatrixEnd();
} }
@ -558,14 +558,14 @@ void displayStructureStatButton(STRUCTURE_STATS *Stats,UDWORD Player, Vector3i *
pie_MatRotY(DEG(0)); pie_MatRotY(DEG(0));
if (mountImd[0] != NULL) if (mountImd[0] != NULL)
{ {
pie_Draw3DShape(mountImd[0], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(mountImd[0], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
if(mountImd[0]->nconnectors) if(mountImd[0]->nconnectors)
{ {
iV_TRANSLATE(mountImd[0]->connectors->x,mountImd[0]->connectors->z,mountImd[0]->connectors->y); iV_TRANSLATE(mountImd[0]->connectors->x,mountImd[0]->connectors->z,mountImd[0]->connectors->y);
} }
} }
iV_MatrixRotateX(DEG(0)); iV_MatrixRotateX(DEG(0));
pie_Draw3DShape(weaponImd[0], 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); pie_Draw3DShape(weaponImd[0], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
//we have a droid weapon so do we draw a muzzle flash //we have a droid weapon so do we draw a muzzle flash
iV_MatrixEnd(); iV_MatrixEnd();
} }
@ -610,11 +610,11 @@ void displayComponentButton(BASE_STATS *Stat, Vector3i *Rotation, Vector3i *Posi
if(MountIMD) if(MountIMD)
{ {
pie_Draw3DShape(MountIMD, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0);// ajl changed 0 to selectedPlayer pie_Draw3DShape(MountIMD, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
} }
if(ComponentIMD) if(ComponentIMD)
{ {
pie_Draw3DShape(ComponentIMD, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0);// ajl changed 0 to selectedPlayer pie_Draw3DShape(ComponentIMD, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
} }
unsetMatrix(); unsetMatrix();
@ -635,9 +635,9 @@ void displayResearchButton(BASE_STATS *Stat, Vector3i *Rotation, Vector3i *Posit
pie_MatScale(scale); pie_MatScale(scale);
if(MountIMD) { if(MountIMD) {
pie_Draw3DShape(MountIMD, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); // ajl, added colourthing using selectedPlayer pie_Draw3DShape(MountIMD, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
} }
pie_Draw3DShape(ResearchIMD, 0, getPlayerColour(selectedPlayer), pie_MAX_BRIGHT_LEVEL, 0, pie_BUTTON, 0); //ajl, added colourthing using selectedPlayer pie_Draw3DShape(ResearchIMD, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, WZCOL_BLACK, pie_BUTTON, 0);
unsetMatrix(); unsetMatrix();
} }
@ -817,8 +817,7 @@ void displayComponentObject(BASE_OBJECT *psObj)
if (terrainType(psTile) != TER_WATER) if (terrainType(psTile) != TER_WATER)
{ {
frame = gameTime/BLIP_ANIM_DURATION + psDroid->id; //visible[selectedPlayer]; frame = gameTime/BLIP_ANIM_DURATION + psDroid->id; //visible[selectedPlayer];
pie_Draw3DShape(getImdFromIndex(MI_BLIP), frame, 0, pie_MAX_BRIGHT_LEVEL, 0, pie_ADDITIVE, (psDroid->visible[selectedPlayer]/2)); pie_Draw3DShape(getImdFromIndex(MI_BLIP), frame, 0, WZCOL_WHITE, WZCOL_BLACK, pie_ADDITIVE, psDroid->visible[selectedPlayer] / 2);
// pie_Draw3DShape(blipImd, frame, 0, pie_MAX_BRIGHT_LEVEL, 0, pie_TRANSLUCENT, 128);
/* set up all the screen coords stuff - need to REMOVE FROM THIS LOOP */ /* set up all the screen coords stuff - need to REMOVE FROM THIS LOOP */
} }
} }
@ -827,8 +826,6 @@ void displayComponentObject(BASE_OBJECT *psObj)
} }
/* Assumes matrix context is already set */ /* Assumes matrix context is already set */
// Watermelon:this is able to handle multiple weapon graphics now // Watermelon:this is able to handle multiple weapon graphics now
// removed mountRotation,they get such stuff from psObj directly now // removed mountRotation,they get such stuff from psObj directly now
@ -842,7 +839,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
PROPULSION_STATS *psPropStats; PROPULSION_STATS *psPropStats;
SDWORD frame; SDWORD frame;
SDWORD pieFlag, iPieData; SDWORD pieFlag, iPieData;
UDWORD brightness, specular; PIELIGHT brightness, specular;
UDWORD colour; UDWORD colour;
UDWORD bDarkSide = FALSE; UDWORD bDarkSide = FALSE;
UBYTE i; UBYTE i;
@ -871,13 +868,13 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
if(!bButton) if(!bButton)
{ {
brightness = lightDoFogAndIllumination(psDroid->illumination,getCentreX() - psDroid->x,getCentreZ() - psDroid->y, &specular); brightness = lightDoFogAndIllumination(pal_SetBrightness(psDroid->illumination), getCentreX() - psDroid->x,getCentreZ() - psDroid->y, &specular);
pieFlag = pie_SHADOW; pieFlag = pie_SHADOW;
} }
else else
{ {
brightness = pie_MAX_BRIGHT_LEVEL; brightness = WZCOL_WHITE;
specular = 0; specular = WZCOL_BLACK;
} }
/* We've got a z value here _and_ screen coords of origin */ /* We've got a z value here _and_ screen coords of origin */
@ -898,7 +895,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
psShapeTemp = (leftFirst ? getLeftPropulsionIMD(psDroid) : getRightPropulsionIMD(psDroid)); psShapeTemp = (leftFirst ? getLeftPropulsionIMD(psDroid) : getRightPropulsionIMD(psDroid));
if(psShapeTemp!=NULL) if(psShapeTemp!=NULL)
{ {
pie_Draw3DShape(psShapeTemp, 0, colour/*getPlayerColour(psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShapeTemp, 0, colour, brightness, specular, pieFlag, iPieData);
} }
/* set default components transparent */ /* set default components transparent */
@ -935,12 +932,12 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* draw body if cyborg not animating */ /* draw body if cyborg not animating */
if ( psDroid->psCurAnim == NULL || psDroid->psCurAnim->bVisible == FALSE ) if ( psDroid->psCurAnim == NULL || psDroid->psCurAnim->bVisible == FALSE )
{ {
pie_Draw3DShape(psShapeTemp, 0, colour/*getPlayerColour(psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShapeTemp, 0, colour, brightness, specular, pieFlag, iPieData);
} }
} }
else else
{ {
pie_Draw3DShape(psShapeTemp, 0, colour/*getPlayerColour(psDroid->player)*/, brightness, specular, pieFlag, iPieData ); pie_Draw3DShape(psShapeTemp, 0, colour, brightness, specular, pieFlag, iPieData);
} }
} }
@ -964,7 +961,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
if ( psJet != NULL ) if ( psJet != NULL )
{ {
pie_Draw3DShape( psJet, getStaticTimeValueRange(100,psJet->numFrames), colour /*getPlayerColour(psDroid->player)*/, brightness, specular, pie_ADDITIVE, 200); pie_Draw3DShape(psJet, getStaticTimeValueRange(100,psJet->numFrames), colour, brightness, specular, pie_ADDITIVE, 200);
} }
} }
} }
@ -1072,7 +1069,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
} }
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0, colour/*getPlayerColour(psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0, colour, brightness, specular, pieFlag, iPieData);
} }
//if(psDroid->numWeaps) already done this check above?! //if(psDroid->numWeaps) already done this check above?!
@ -1107,7 +1104,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0, colour/*getPlayerColour(psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0, colour, brightness, specular, pieFlag, iPieData);
} }
//we have a droid weapon so do we draw a muzzle flash //we have a droid weapon so do we draw a muzzle flash
if( psShape && psShape->nconnectors ) if( psShape && psShape->nconnectors )
@ -1129,7 +1126,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
{ {
if (gameTime < (psDroid->asWeaps[i].lastFired + BASE_MUZZLE_FLASH_DURATION)) if (gameTime < (psDroid->asWeaps[i].lastFired + BASE_MUZZLE_FLASH_DURATION))
{ {
pie_Draw3DShape(psShape, 0, 0, brightness, 0, pieFlag | pie_ADDITIVE, EFFECT_MUZZLE_ADDITIVE);//muzzle flash pie_Draw3DShape(psShape, 0, 0, brightness, WZCOL_BLACK, pieFlag | pie_ADDITIVE, EFFECT_MUZZLE_ADDITIVE);//muzzle flash
} }
} }
else else
@ -1137,7 +1134,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
frame = (gameTime - psDroid->asWeaps[i].lastFired)/psShape->animInterval; frame = (gameTime - psDroid->asWeaps[i].lastFired)/psShape->animInterval;
if (frame < psShape->numFrames) if (frame < psShape->numFrames)
{ {
pie_Draw3DShape(psShape, frame, 0, brightness, 0, pieFlag | pie_ADDITIVE, EFFECT_MUZZLE_ADDITIVE);//muzzle flash pie_Draw3DShape(psShape, frame, 0, brightness, WZCOL_BLACK, pieFlag | pie_ADDITIVE, EFFECT_MUZZLE_ADDITIVE);//muzzle flash
} }
} }
} }
@ -1175,7 +1172,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0,colour/*getPlayerColour( psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0,colour, brightness, specular, pieFlag, iPieData);
} }
/* Get the sensor graphic, assuming it's there */ /* Get the sensor graphic, assuming it's there */
@ -1183,7 +1180,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0,colour/*getPlayerColour( psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0,colour, brightness, specular, pieFlag, iPieData);
} }
/* Pop Matrix */ /* Pop Matrix */
pie_MatEnd(); pie_MatEnd();
@ -1215,7 +1212,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0,colour/*getPlayerColour( psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0,colour, brightness, specular, pieFlag, iPieData);
} }
/* translate for construct mount point if cyborg */ /* translate for construct mount point if cyborg */
@ -1232,7 +1229,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0,colour/*getPlayerColour( psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0,colour, brightness, specular, pieFlag, iPieData);
} }
/* Pop Matrix */ /* Pop Matrix */
pie_MatEnd(); pie_MatEnd();
@ -1262,7 +1259,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0, colour/*getPlayerColour(psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0, colour, brightness, specular, pieFlag, iPieData);
} }
/* Get the ECM graphic assuming it's there.... */ /* Get the ECM graphic assuming it's there.... */
@ -1270,7 +1267,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0, colour/*getPlayerColour(psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0, colour, brightness, specular, pieFlag, iPieData);
} }
/* Pop Matrix */ /* Pop Matrix */
pie_MatEnd(); pie_MatEnd();
@ -1301,7 +1298,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0,colour /*getPlayerColour( psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0, colour, brightness, specular, pieFlag, iPieData);
} }
/* translate for construct mount point if cyborg */ /* translate for construct mount point if cyborg */
@ -1318,7 +1315,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
/* Draw it */ /* Draw it */
if(psShape) if(psShape)
{ {
pie_Draw3DShape(psShape, 0,colour /*getPlayerColour( psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0, colour, brightness, specular, pieFlag, iPieData);
if(psShape->nconnectors && psDroid->action == DACTION_DROIDREPAIR) if(psShape->nconnectors && psDroid->action == DACTION_DROIDREPAIR)
{ {
pie_TRANSLATE( psShape->connectors[0].x, pie_TRANSLATE( psShape->connectors[0].x,
@ -1339,7 +1336,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
iV_MatrixRotateX(-player.r.x); iV_MatrixRotateX(-player.r.x);
/* Dither on software */ /* Dither on software */
pie_Draw3DShape(psShape, getStaticTimeValueRange(100,psShape->numFrames), 0, brightness, 0, pie_ADDITIVE, 140); pie_Draw3DShape(psShape, getStaticTimeValueRange(100,psShape->numFrames), 0, brightness, WZCOL_BLACK, pie_ADDITIVE, 140);
/* Dither off software */ /* Dither off software */
iV_MatrixRotateX(player.r.x); iV_MatrixRotateX(player.r.x);
@ -1376,7 +1373,7 @@ void displayCompObj(BASE_OBJECT *psObj, BOOL bButton)
psShape = (leftFirst ? getRightPropulsionIMD(psDroid) : getLeftPropulsionIMD(psDroid)); psShape = (leftFirst ? getRightPropulsionIMD(psDroid) : getLeftPropulsionIMD(psDroid));
if(psShape!=NULL) if(psShape!=NULL)
{ {
pie_Draw3DShape(psShape, 0,colour /*getPlayerColour( psDroid->player)*/, brightness, specular, pieFlag, iPieData); pie_Draw3DShape(psShape, 0, colour, brightness, specular, pieFlag, iPieData);
} }
} }

View File

@ -535,10 +535,6 @@ static void calcAverageTerrainHeight(iView *player)
static void drawTiles(iView *camera, iView *player) static void drawTiles(iView *camera, iView *player)
{ {
UDWORD i, j; UDWORD i, j;
BOOL bWaterTile = FALSE;
BOOL PushedDown = FALSE;
UBYTE TileIllum;
int shiftVal = 0;
static float angle = 0.0f; static float angle = 0.0f;
SDWORD rx, rz; SDWORD rx, rz;
@ -610,10 +606,13 @@ static void drawTiles(iView *camera, iView *player)
for (j = 0; j < (SDWORD)visibleTiles.x+1; j++) for (j = 0; j < (SDWORD)visibleTiles.x+1; j++)
{ {
Vector2i screen; Vector2i screen;
PIELIGHT TileIllum;
int shiftVal = 0;
tileScreenInfo[i][j].pos.x = world_coord(j - terrainMidX); tileScreenInfo[i][j].pos.x = world_coord(j - terrainMidX);
tileScreenInfo[i][j].pos.z = world_coord(terrainMidY - i); tileScreenInfo[i][j].pos.z = world_coord(terrainMidY - i);
tileScreenInfo[i][j].pos.y = 0; tileScreenInfo[i][j].pos.y = 0;
tileScreenInfo[i][j].bWater = FALSE;
if( playerXTile+j < 0 || if( playerXTile+j < 0 ||
playerZTile+i < 0 || playerZTile+i < 0 ||
@ -629,39 +628,22 @@ static void drawTiles(iView *camera, iView *player)
} }
else else
{ {
BOOL bEdgeTile; BOOL bEdgeTile = FALSE;
MAPTILE *psTile = mapTile(playerXTile + j, playerZTile + i); MAPTILE *psTile = mapTile(playerXTile + j, playerZTile + i);
BOOL pushedDown = FALSE;
if (terrainType(psTile) == TER_WATER)
{
tileScreenInfo[i][j].bWater = TRUE;
bWaterTile = TRUE;
}
else
{
tileScreenInfo[i][j].bWater = FALSE;
bWaterTile = FALSE;
}
tileScreenInfo[i][j].pos.y = map_TileHeight(playerXTile + j, playerZTile + i); tileScreenInfo[i][j].pos.y = map_TileHeight(playerXTile + j, playerZTile + i);
if(getRevealStatus()) if (getRevealStatus() && !godMode)
{ {
if(godMode) TileIllum = pal_SetBrightness(psTile->level == UBYTE_MAX ? 1 : psTile->level);
{
TileIllum = psTile->illumination;
} }
else else
{ {
TileIllum = (psTile->level == UBYTE_MAX ? 1 : psTile->level); // avGetTileLevel(realX,realY); TileIllum = pal_SetBrightness(psTile->illumination);
}
}
else
{
TileIllum = psTile->illumination;
} }
tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination(TileIllum, rx - tileScreenInfo[i][j].pos.x, rz - world_coord(i - terrainMidY), &tileScreenInfo[i][j].specular.argb); tileScreenInfo[i][j].light = lightDoFogAndIllumination(TileIllum, rx - tileScreenInfo[i][j].pos.x, rz - world_coord(i - terrainMidY), &tileScreenInfo[i][j].specular);
// Real fog of war - darken where we cannot see enemy units moving around // Real fog of war - darken where we cannot see enemy units moving around
if (bDisplaySensorRange && psTile && !psTile->activeSensor) if (bDisplaySensorRange && psTile && !psTile->activeSensor)
@ -689,38 +671,32 @@ static void drawTiles(iView *camera, iView *player)
{ {
bEdgeTile = TRUE; bEdgeTile = TRUE;
} }
else
{
bEdgeTile = FALSE;
}
// If it's the main water tile (has water texture) then.. // If it's the main water tile (has water texture) then..
if ( TileNumber_tile(psTile->texture) == WATER_TILE && !bEdgeTile ) if (TileNumber_tile(psTile->texture) == WATER_TILE && !bEdgeTile)
{ {
// Push the terrain down for the river bed. // Push the terrain down for the river bed.
PushedDown = TRUE;
shiftVal = WATER_DEPTH + environGetData(playerXTile+j, playerZTile+i) * 1.5f; shiftVal = WATER_DEPTH + environGetData(playerXTile+j, playerZTile+i) * 1.5f;
tileScreenInfo[i][j].pos.y -= shiftVal; tileScreenInfo[i][j].pos.y -= shiftVal;
// And darken it. // And darken it.
TileIllum = (UBYTE)(TileIllum * 0.75f); TileIllum = pal_SetBrightness(TileIllum.byte.r * 0.75f);
} pushedDown = TRUE;
else
{
PushedDown = FALSE;
} }
// If it's any water tile.. // If it's any water tile..
if (bWaterTile) if (terrainType(psTile) == TER_WATER)
{ {
// If it's the main water tile then bring it back up because it was pushed down for the river bed calc. // If it's the main water tile then bring it back up because it was pushed down for the river bed calc.
int tmp_y = tileScreenInfo[i][j].pos.y; int tmp_y = tileScreenInfo[i][j].pos.y;
Vector2i water; Vector2i water;
if (PushedDown) if (pushedDown)
{ {
tileScreenInfo[i][j].pos.y += shiftVal; tileScreenInfo[i][j].pos.y += shiftVal;
} }
tileScreenInfo[i][j].bWater = TRUE;
// Transform it into the wx,wy mesh members. // Transform it into the wx,wy mesh members.
// hack since tileScreenInfo[i][j].water is Vector3i and pie_RotateProject takes Vector2i as 2nd param // hack since tileScreenInfo[i][j].water is Vector3i and pie_RotateProject takes Vector2i as 2nd param
@ -733,7 +709,7 @@ static void drawTiles(iView *camera, iView *player)
tileScreenInfo[i][j].water_height = tileScreenInfo[i][j].pos.y; tileScreenInfo[i][j].water_height = tileScreenInfo[i][j].pos.y;
// Calc the light for modified y coord and ignore the specular component // Calc the light for modified y coord and ignore the specular component
tileScreenInfo[i][j].wlight.argb = lightDoFogAndIllumination(TileIllum, rx - tileScreenInfo[i][j].pos.x, rz - world_coord(i - terrainMidY), NULL); tileScreenInfo[i][j].wlight = lightDoFogAndIllumination(TileIllum, rx - tileScreenInfo[i][j].pos.x, rz - world_coord(i - terrainMidY), NULL);
tileScreenInfo[i][j].pos.y = tmp_y; tileScreenInfo[i][j].pos.y = tmp_y;
} }
@ -1167,7 +1143,7 @@ void renderProjectile(PROJECTILE *psCurr)
WEAPON_STATS *psStats; WEAPON_STATS *psStats;
Vector3i dv; Vector3i dv;
iIMDShape *pIMD; iIMDShape *pIMD;
UDWORD brightness, specular; PIELIGHT brightness, specular;
SDWORD rx, rz; SDWORD rx, rz;
psStats = psCurr->psWStats; psStats = psCurr->psWStats;
@ -1218,11 +1194,11 @@ void renderProjectile(PROJECTILE *psCurr)
imdRot2.x = DEG(psCurr->pitch); imdRot2.x = DEG(psCurr->pitch);
iV_MatrixRotateX(imdRot2.x); iV_MatrixRotateX(imdRot2.x);
brightness = (UDWORD)lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX()-psCurr->x,getCentreZ()-psCurr->y, &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - psCurr->x, getCentreZ() - psCurr->y, &specular);
if(psStats->weaponSubClass == WSC_ROCKET || psStats->weaponSubClass == WSC_MISSILE || if(psStats->weaponSubClass == WSC_ROCKET || psStats->weaponSubClass == WSC_MISSILE ||
psStats->weaponSubClass == WSC_SLOWROCKET || psStats->weaponSubClass == WSC_SLOWMISSILE) psStats->weaponSubClass == WSC_SLOWROCKET || psStats->weaponSubClass == WSC_SLOWMISSILE)
{ {
pie_Draw3DShape(pIMD, 0, 0, brightness, 0, pie_ADDITIVE, 164); pie_Draw3DShape(pIMD, 0, 0, brightness, WZCOL_BLACK, pie_ADDITIVE, 164);
} }
else else
{ {
@ -1261,7 +1237,7 @@ renderAnimComponent( const COMPONENT_OBJECT *psObj )
terrainMidY * TILE_UNITS - (psParentObj->y - player.p.z) terrainMidY * TILE_UNITS - (psParentObj->y - player.p.z)
}; };
SDWORD iPlayer; SDWORD iPlayer;
UDWORD brightness, specular; PIELIGHT brightness, specular;
psParentObj->sDisplay.frameNumber = currentGameFrame; psParentObj->sDisplay.frameNumber = currentGameFrame;
@ -1322,7 +1298,7 @@ renderAnimComponent( const COMPONENT_OBJECT *psObj )
Vector2i s = {0, 0}; Vector2i s = {0, 0};
STRUCTURE *psStructure = (STRUCTURE*)psParentObj; STRUCTURE *psStructure = (STRUCTURE*)psParentObj;
brightness = 200 - (100 - PERCENT(psStructure->body, structureBody(psStructure))); brightness = pal_SetBrightness(200 - (100 - PERCENT(psStructure->body, structureBody(psStructure))));
pie_RotateProject( &zero, &s ); pie_RotateProject( &zero, &s );
psStructure->sDisplay.screenX = s.x; psStructure->sDisplay.screenX = s.x;
@ -1332,15 +1308,15 @@ renderAnimComponent( const COMPONENT_OBJECT *psObj )
} }
else else
{ {
brightness = pie_MAX_BRIGHT_LEVEL; brightness = pal_SetBrightness(UBYTE_MAX);
} }
if(getRevealStatus() && !godMode) if(getRevealStatus() && !godMode)
{ {
brightness = avGetObjLightLevel((BASE_OBJECT*)psParentObj,brightness); brightness = pal_SetBrightness(avGetObjLightLevel((BASE_OBJECT*)psParentObj, brightness.byte.r));
} }
brightness = (UDWORD)lightDoFogAndIllumination((UBYTE)brightness, getCentreX()-posX, getCentreZ()-posY, &specular); brightness = lightDoFogAndIllumination(brightness, getCentreX() - posX, getCentreZ() - posY, &specular);
pie_Draw3DShape(psObj->psShape, 0, iPlayer, brightness, specular, pie_NO_BILINEAR|pie_STATIC_SHADOW, 0); pie_Draw3DShape(psObj->psShape, 0, iPlayer, brightness, specular, pie_NO_BILINEAR|pie_STATIC_SHADOW, 0);
@ -1641,7 +1617,7 @@ void renderFeature(FEATURE *psFeature)
{ {
UDWORD featX,featY; UDWORD featX,featY;
SDWORD rotation, rx, rz; SDWORD rotation, rx, rz;
UDWORD brightness, specular; PIELIGHT brightness, specular;
Vector3i dv; Vector3i dv;
Vector3f *vecTemp; Vector3f *vecTemp;
BOOL bForceDraw = ( !getRevealStatus() && psFeature->psStats->visibleAtStart); BOOL bForceDraw = ( !getRevealStatus() && psFeature->psStats->visibleAtStart);
@ -1680,7 +1656,7 @@ void renderFeature(FEATURE *psFeature)
iV_MatrixRotateY(-rotation); iV_MatrixRotateY(-rotation);
brightness = 200; //? HUH? brightness = pal_SetBrightness(200); //? HUH?
if(psFeature->psStats->subType == FEAT_SKYSCRAPER) if(psFeature->psStats->subType == FEAT_SKYSCRAPER)
{ {
@ -1689,11 +1665,11 @@ void renderFeature(FEATURE *psFeature)
if(godMode || demoGetStatus() || bForceDraw) if(godMode || demoGetStatus() || bForceDraw)
{ {
brightness = 200; brightness = pal_SetBrightness(200);
} }
else if(getRevealStatus()) else if(getRevealStatus())
{ {
brightness = avGetObjLightLevel((BASE_OBJECT*)psFeature,brightness); brightness = pal_SetBrightness(avGetObjLightLevel((BASE_OBJECT*)psFeature, brightness.byte.r));
} }
brightness = lightDoFogAndIllumination(brightness, getCentreX() - featX, getCentreZ() - featY, &specular); brightness = lightDoFogAndIllumination(brightness, getCentreX() - featX, getCentreZ() - featY, &specular);
@ -1739,7 +1715,7 @@ void renderProximityMsg(PROXIMITY_DISPLAY *psProxDisp)
VIEW_PROXIMITY *pViewProximity = NULL; VIEW_PROXIMITY *pViewProximity = NULL;
SDWORD x, y, r, rx, rz; SDWORD x, y, r, rx, rz;
iIMDShape *proxImd = NULL; iIMDShape *proxImd = NULL;
UDWORD brightness, specular; PIELIGHT brightness, specular;
//store the frame number for when deciding what has been clicked on //store the frame number for when deciding what has been clicked on
psProxDisp->frameNumber = currentGameFrame; psProxDisp->frameNumber = currentGameFrame;
@ -1776,7 +1752,7 @@ void renderProximityMsg(PROXIMITY_DISPLAY *psProxDisp)
{ {
ASSERT(!"unknown proximity display message type", "Buggered proximity message type"); ASSERT(!"unknown proximity display message type", "Buggered proximity message type");
} }
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX()-msgX,getCentreZ()-msgY, &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - msgX, getCentreZ() - msgY, &specular);
dv.x = (msgX - player.p.x) - terrainMidX*TILE_UNITS; dv.x = (msgX - player.p.x) - terrainMidX*TILE_UNITS;
dv.z = terrainMidY*TILE_UNITS - (msgY - player.p.z); dv.z = terrainMidY*TILE_UNITS - (msgY - player.p.z);
@ -1862,7 +1838,7 @@ void renderStructure(STRUCTURE *psStructure)
SDWORD playerFrame; SDWORD playerFrame;
SDWORD animFrame; SDWORD animFrame;
UDWORD nWeaponStat; UDWORD nWeaponStat;
UDWORD buildingBrightness, specular; PIELIGHT buildingBrightness, specular;
Vector3i dv; Vector3i dv;
SDWORD i; SDWORD i;
iIMDShape *lImd = NULL, *imd = NULL; iIMDShape *lImd = NULL, *imd = NULL;
@ -1983,7 +1959,7 @@ void renderStructure(STRUCTURE *psStructure)
bHitByElectronic = TRUE; bHitByElectronic = TRUE;
} }
buildingBrightness = 200 - (100 - PERCENT(psStructure->body, structureBody(psStructure))); buildingBrightness = pal_SetBrightness(200 - (100 - PERCENT(psStructure->body, structureBody(psStructure))));
/* If it's selected, then it's brighter */ /* If it's selected, then it's brighter */
if (psStructure->selected) if (psStructure->selected)
@ -2002,11 +1978,11 @@ void renderStructure(STRUCTURE *psStructure)
{ {
brightVar = 55; brightVar = 55;
} }
buildingBrightness = 200 + brightVar; buildingBrightness = pal_SetBrightness(200 + brightVar);
} }
if (!godMode && !demoGetStatus() && getRevealStatus()) if (!godMode && !demoGetStatus() && getRevealStatus())
{ {
buildingBrightness = avGetObjLightLevel((BASE_OBJECT*)psStructure, buildingBrightness); buildingBrightness = pal_SetBrightness(avGetObjLightLevel((BASE_OBJECT*)psStructure, buildingBrightness.byte.r));
} }
buildingBrightness = lightDoFogAndIllumination(buildingBrightness, getCentreX() - psStructure->x, getCentreZ() - psStructure->y, &specular); buildingBrightness = lightDoFogAndIllumination(buildingBrightness, getCentreX() - psStructure->x, getCentreZ() - psStructure->y, &specular);
@ -2023,7 +1999,7 @@ void renderStructure(STRUCTURE *psStructure)
// override // override
if(bHitByElectronic) if(bHitByElectronic)
{ {
buildingBrightness = 150; buildingBrightness = pal_SetBrightness(150);
} }
imd = psStructure->sDisplay.imd; imd = psStructure->sDisplay.imd;
@ -2175,7 +2151,7 @@ void renderStructure(STRUCTURE *psStructure)
iV_MatrixRotateY(-player.r.y); iV_MatrixRotateY(-player.r.y);
iV_MatrixRotateX(-player.r.x); iV_MatrixRotateX(-player.r.x);
pie_Draw3DShape(pRepImd, getStaticTimeValueRange(100,pRepImd->numFrames), 0, buildingBrightness, 0, pie_ADDITIVE, 192); pie_Draw3DShape(pRepImd, getStaticTimeValueRange(100,pRepImd->numFrames), 0, buildingBrightness, WZCOL_BLACK, pie_ADDITIVE, 192);
iV_MatrixRotateX(player.r.x); iV_MatrixRotateX(player.r.x);
iV_MatrixRotateY(player.r.y); iV_MatrixRotateY(player.r.y);
@ -2298,7 +2274,7 @@ void renderDeliveryPoint(FLAG_POSITION *psPosition)
Vector3i dv; Vector3i dv;
SDWORD x, y, r, rx, rz; SDWORD x, y, r, rx, rz;
Vector3f *temp = NULL; Vector3f *temp = NULL;
SDWORD buildingBrightness, specular; PIELIGHT buildingBrightness, specular;
//store the frame number for when deciding what has been clicked on //store the frame number for when deciding what has been clicked on
psPosition->frameNumber = currentGameFrame; psPosition->frameNumber = currentGameFrame;
@ -2330,8 +2306,7 @@ void renderDeliveryPoint(FLAG_POSITION *psPosition)
pie_MatScale(50); // they are all big now so make this one smaller too pie_MatScale(50); // they are all big now so make this one smaller too
buildingBrightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL, buildingBrightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - psPosition->coords.x, getCentreZ() - psPosition->coords.y, &specular);
getCentreX() - psPosition->coords.x, getCentreZ() - psPosition->coords.y, (UDWORD*)&specular);
pie_Draw3DShape(pAssemblyPointIMDs[psPosition->factoryType][psPosition->factoryInc], 0, 0, buildingBrightness, specular, pie_NO_BILINEAR, 0); pie_Draw3DShape(pAssemblyPointIMDs[psPosition->factoryType][psPosition->factoryInc], 0, 0, buildingBrightness, specular, pie_NO_BILINEAR, 0);
@ -2352,13 +2327,12 @@ void renderDeliveryPoint(FLAG_POSITION *psPosition)
static BOOL renderWallSection(STRUCTURE *psStructure) static BOOL renderWallSection(STRUCTURE *psStructure)
{ {
SDWORD structX, structY, rx, rz; SDWORD structX, structY, rx, rz;
UDWORD brightness; PIELIGHT brightness, specular, buildingBrightness;
iIMDShape *imd; iIMDShape *imd;
SDWORD rotation; SDWORD rotation;
Vector3i dv; Vector3i dv;
UDWORD i; UDWORD i;
Vector3f *temp; Vector3f *temp;
UDWORD buildingBrightness, specular;
iIMDShape *originalDirection = NULL; iIMDShape *originalDirection = NULL;
if(psStructure->visible[selectedPlayer] || godMode || demoGetStatus()) if(psStructure->visible[selectedPlayer] || godMode || demoGetStatus())
@ -2369,7 +2343,7 @@ static BOOL renderWallSection(STRUCTURE *psStructure)
structY = psStructure->y; structY = psStructure->y;
// centreX = ( player.p.x + world_coord(visibleTiles.x / 2) ); // centreX = ( player.p.x + world_coord(visibleTiles.x / 2) );
// centreZ = ( player.p.z + world_coord(visibleTiles.y / 2) ); // centreZ = ( player.p.z + world_coord(visibleTiles.y / 2) );
buildingBrightness = 200 - (100-PERCENT( psStructure->body , structureBody(psStructure))); buildingBrightness = pal_SetBrightness(200 - (100 - PERCENT(psStructure->body, structureBody(psStructure))));
if(psStructure->selected) if(psStructure->selected)
{ {
@ -2386,7 +2360,7 @@ static BOOL renderWallSection(STRUCTURE *psStructure)
} }
buildingBrightness = 200 + brightVar; buildingBrightness = pal_SetBrightness(200 + brightVar);
} }
if(godMode || demoGetStatus()) if(godMode || demoGetStatus())
@ -2395,10 +2369,10 @@ static BOOL renderWallSection(STRUCTURE *psStructure)
} }
else if(getRevealStatus()) else if(getRevealStatus())
{ {
buildingBrightness = avGetObjLightLevel((BASE_OBJECT*)psStructure,buildingBrightness); buildingBrightness = pal_SetBrightness(avGetObjLightLevel((BASE_OBJECT*)psStructure, buildingBrightness.byte.r));
} }
brightness = lightDoFogAndIllumination((UBYTE)buildingBrightness,getCentreX()-structX,getCentreZ()-structY, &specular); brightness = lightDoFogAndIllumination(buildingBrightness, getCentreX() - structX, getCentreZ() - structY, &specular);
/* /*
Right, now the tricky bit, we need to bugger about with the coordinates of the imd to make it Right, now the tricky bit, we need to bugger about with the coordinates of the imd to make it
@ -2480,7 +2454,7 @@ static BOOL renderWallSection(STRUCTURE *psStructure)
(psStructure->status == SS_BEING_DEMOLISHED ) || (psStructure->status == SS_BEING_DEMOLISHED ) ||
(psStructure->status == SS_BEING_BUILT && psStructure->pStructureType->type == REF_RESOURCE_EXTRACTOR) ) (psStructure->status == SS_BEING_BUILT && psStructure->pStructureType->type == REF_RESOURCE_EXTRACTOR) )
{ {
pie_Draw3DShape( psStructure->sDisplay.imd, 0, getPlayerColour(psStructure->player), pie_Draw3DShape(psStructure->sDisplay.imd, 0, getPlayerColour(psStructure->player),
brightness, specular, pie_HEIGHT_SCALED|pie_SHADOW, brightness, specular, pie_HEIGHT_SCALED|pie_SHADOW,
(SDWORD)(structHeightScale(psStructure) * pie_RAISE_SCALE) ); (SDWORD)(structHeightScale(psStructure) * pie_RAISE_SCALE) );
} }
@ -2518,7 +2492,7 @@ void renderShadow( DROID *psDroid, iIMDShape *psShadowIMD )
Vector3i dv; Vector3i dv;
Vector3f *pVecTemp; Vector3f *pVecTemp;
SDWORD shadowScale, rx, rz; SDWORD shadowScale, rx, rz;
UDWORD brightness, specular; PIELIGHT brightness, specular;
dv.x = (psDroid->x - player.p.x) - terrainMidX*TILE_UNITS; dv.x = (psDroid->x - player.p.x) - terrainMidX*TILE_UNITS;
if(psDroid->droidType == DROID_TRANSPORTER) if(psDroid->droidType == DROID_TRANSPORTER)
@ -2559,9 +2533,9 @@ void renderShadow( DROID *psDroid, iIMDShape *psShadowIMD )
pie_MatRotZ( DEG( psDroid->roll ) ); pie_MatRotZ( DEG( psDroid->roll ) );
} }
brightness = (UDWORD)lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX()-psDroid->x,getCentreZ()-psDroid->y, &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - psDroid->x, getCentreZ() - psDroid->y, &specular);
pie_Draw3DShape( psShadowIMD, 0, 0, brightness, specular, pie_TRANSLUCENT, 128); pie_Draw3DShape(psShadowIMD, 0, 0, brightness, specular, pie_TRANSLUCENT, 128);
psShadowIMD->points = pVecTemp; psShadowIMD->points = pVecTemp;
iV_MatrixEnd(); iV_MatrixEnd();
@ -4774,8 +4748,7 @@ static void addConstructionLine(DROID *psDroid, STRUCTURE *psStructure)
SDWORD realY; SDWORD realY;
Vector3i null, vec; Vector3i null, vec;
SDWORD rx,rz; SDWORD rx,rz;
UDWORD colour; PIELIGHT colour, specular;
UDWORD specular;
null.x = null.y = null.z = 0; null.x = null.y = null.z = 0;
each.x = psDroid->x; each.x = psDroid->x;
@ -4835,13 +4808,16 @@ static void addConstructionLine(DROID *psDroid, STRUCTURE *psStructure)
pts[2].pos.z = vec.z - rz; pts[2].pos.z = vec.z - rz;
// set the colour // set the colour
colour = UBYTE_MAX; colour = pal_SetBrightness(UBYTE_MAX);
colour = lightDoFogAndIllumination(colour,getCentreX() - psDroid->x, getCentreZ() - psDroid->y,&specular); colour = lightDoFogAndIllumination(colour, getCentreX() - psDroid->x, getCentreZ() - psDroid->y, &specular);
colour &= 0xff; if (psDroid->action == DACTION_DEMOLISH || psDroid->action == DACTION_CLEARWRECK)
if ((psDroid->action == DACTION_DEMOLISH) || {
(psDroid->action == DACTION_CLEARWRECK) ) { colour.byte.g = 0;
colour <<= 16;//red colour.byte.b = 0;
} else {
colour.byte.r = 0;
colour.byte.g = 0;
} }
pts[0].light.argb = 0xff000000; pts[0].light.argb = 0xff000000;
pts[1].light.argb = 0xff000000; pts[1].light.argb = 0xff000000;

View File

@ -46,6 +46,7 @@
#include "lib/ivis_common/ivisdef.h" //ivis matrix code #include "lib/ivis_common/ivisdef.h" //ivis matrix code
#include "lib/ivis_common/piedef.h" //ivis matrix code #include "lib/ivis_common/piedef.h" //ivis matrix code
#include "lib/ivis_common/piepalette.h"
#include "lib/ivis_common/piestate.h" #include "lib/ivis_common/piestate.h"
#include "lib/ivis_opengl/piematrix.h" #include "lib/ivis_opengl/piematrix.h"
#include "lib/gamelib/gtime.h" #include "lib/gamelib/gtime.h"
@ -1599,22 +1600,21 @@ void renderEffect(EFFECT *psEffect)
/* drawing func for wapypoints . AJL. */ /* drawing func for wapypoints . AJL. */
void renderWaypointEffect(EFFECT *psEffect) void renderWaypointEffect(EFFECT *psEffect)
{ {
UDWORD brightness, specular; PIELIGHT brightness, specular;
positionEffect(psEffect); positionEffect(psEffect);
// set up lighting // set up lighting
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX() - MAKEINT(psEffect->position.x),getCentreZ() - MAKEINT(psEffect->position.z), &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x), getCentreZ() - MAKEINT(psEffect->position.z), &specular);
pie_Draw3DShape(psEffect->imd, 0, 0, brightness, specular, 0, 0); pie_Draw3DShape(psEffect->imd, 0, 0, brightness, specular, 0, 0);
iV_MatrixEnd(); iV_MatrixEnd();
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void renderFirework(EFFECT *psEffect) void renderFirework(EFFECT *psEffect)
{ {
UDWORD brightness, specular; PIELIGHT brightness, specular;
/* these don't get rendered */ /* these don't get rendered */
if(psEffect->type == FIREWORK_TYPE_LAUNCHER) if(psEffect->type == FIREWORK_TYPE_LAUNCHER)
@ -1627,10 +1627,10 @@ void renderFirework(EFFECT *psEffect)
iV_MatrixRotateY(-player.r.y); iV_MatrixRotateY(-player.r.y);
iV_MatrixRotateX(-player.r.x); iV_MatrixRotateX(-player.r.x);
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX() - MAKEINT(psEffect->position.x),getCentreZ() - MAKEINT(psEffect->position.z), &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x), getCentreZ() - MAKEINT(psEffect->position.z), &specular);
pie_MatScale(psEffect->size); pie_MatScale(psEffect->size);
pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, 0, pie_ADDITIVE, EFFECT_EXPLOSION_ADDITIVE); pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, WZCOL_BLACK, pie_ADDITIVE, EFFECT_EXPLOSION_ADDITIVE);
iV_MatrixEnd(); iV_MatrixEnd();
} }
@ -1638,7 +1638,7 @@ void renderFirework(EFFECT *psEffect)
/* drawing func for blood. */ /* drawing func for blood. */
void renderBloodEffect(EFFECT *psEffect) void renderBloodEffect(EFFECT *psEffect)
{ {
UDWORD brightness, specular; PIELIGHT brightness, specular;
positionEffect(psEffect); positionEffect(psEffect);
@ -1647,7 +1647,7 @@ void renderBloodEffect(EFFECT *psEffect)
pie_MatScale(psEffect->size); pie_MatScale(psEffect->size);
// set up lighting // set up lighting
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX() - MAKEINT(psEffect->position.x),getCentreZ() - MAKEINT(psEffect->position.z), &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x), getCentreZ() - MAKEINT(psEffect->position.z), &specular);
pie_Draw3DShape(getImdFromIndex(MI_BLOOD), psEffect->frameNumber, 0, brightness, specular, pie_TRANSLUCENT, EFFECT_BLOOD_TRANSPARENCY); pie_Draw3DShape(getImdFromIndex(MI_BLOOD), psEffect->frameNumber, 0, brightness, specular, pie_TRANSLUCENT, EFFECT_BLOOD_TRANSPARENCY);
iV_MatrixEnd(); iV_MatrixEnd();
@ -1658,7 +1658,7 @@ void renderDestructionEffect(EFFECT *psEffect)
{ {
float div; float div;
SDWORD percent; SDWORD percent;
UDWORD brightness,specular; PIELIGHT brightness,specular;
if(psEffect->type!=DESTRUCTION_TYPE_SKYSCRAPER) if(psEffect->type!=DESTRUCTION_TYPE_SKYSCRAPER)
{ {
@ -1675,8 +1675,7 @@ void renderDestructionEffect(EFFECT *psEffect)
} }
//get fog value //get fog value
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL, brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x), getCentreZ() - MAKEINT(psEffect->position.z), &specular);
getCentreX() - MAKEINT(psEffect->position.x),getCentreZ() - MAKEINT(psEffect->position.z), &specular);
if(!gamePaused()) if(!gamePaused())
{ {
@ -1684,7 +1683,7 @@ void renderDestructionEffect(EFFECT *psEffect)
iV_MatrixRotateY(SKY_SHIMMY); iV_MatrixRotateY(SKY_SHIMMY);
iV_MatrixRotateZ(SKY_SHIMMY); iV_MatrixRotateZ(SKY_SHIMMY);
} }
pie_Draw3DShape(psEffect->imd, 0, 0, brightness, 0,pie_RAISE, percent); pie_Draw3DShape(psEffect->imd, 0, 0, brightness, WZCOL_BLACK, pie_RAISE, percent);
iV_MatrixEnd(); iV_MatrixEnd();
} }
@ -1722,7 +1721,7 @@ UDWORD timeSlice;
void renderExplosionEffect(EFFECT *psEffect) void renderExplosionEffect(EFFECT *psEffect)
{ {
SDWORD percent; SDWORD percent;
UDWORD brightness, specular; PIELIGHT brightness, specular;
if(psEffect->type == EXPLOSION_TYPE_LAND_LIGHT) if(psEffect->type == EXPLOSION_TYPE_LAND_LIGHT)
{ {
@ -1760,20 +1759,19 @@ void renderExplosionEffect(EFFECT *psEffect)
pie_MatScale(psEffect->size); pie_MatScale(psEffect->size);
} }
//get fog value //get fog value
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX() - MAKEINT(psEffect->position.x),getCentreZ() - MAKEINT(psEffect->position.z), &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x), getCentreZ() - MAKEINT(psEffect->position.z), &specular);
if(psEffect->type == EXPLOSION_TYPE_PLASMA) if(psEffect->type == EXPLOSION_TYPE_PLASMA)
{ {
pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, 0, pie_ADDITIVE, EFFECT_PLASMA_ADDITIVE); pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, WZCOL_BLACK, pie_ADDITIVE, EFFECT_PLASMA_ADDITIVE);
} }
else if(psEffect->type == EXPLOSION_TYPE_KICKUP) else if(psEffect->type == EXPLOSION_TYPE_KICKUP)
{ {
/* not transparent */ pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, WZCOL_BLACK, pie_TRANSLUCENT, 128);
pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, pie_TRANSLUCENT,128, 0, 0);
} }
else else
{ {
pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, 0, pie_ADDITIVE, EFFECT_EXPLOSION_ADDITIVE); pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, WZCOL_BLACK, pie_ADDITIVE, EFFECT_EXPLOSION_ADDITIVE);
} }
iV_MatrixEnd(); iV_MatrixEnd();
@ -1782,7 +1780,7 @@ void renderExplosionEffect(EFFECT *psEffect)
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void renderGravitonEffect(EFFECT *psEffect) void renderGravitonEffect(EFFECT *psEffect)
{ {
UDWORD brightness, specular; PIELIGHT brightness, specular;
positionEffect(psEffect); positionEffect(psEffect);
@ -1800,8 +1798,8 @@ void renderGravitonEffect(EFFECT *psEffect)
{ {
pie_MatScale(100); pie_MatScale(100);
} }
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX()-MAKEINT(psEffect->position.x), brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x),
getCentreZ()-MAKEINT(psEffect->position.z), &specular); getCentreZ() - MAKEINT(psEffect->position.z), &specular);
pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, specular, 0, 0); pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, specular, 0, 0);
@ -1819,7 +1817,7 @@ void renderConstructionEffect(EFFECT *psEffect)
SDWORD percent; SDWORD percent;
UDWORD translucency; UDWORD translucency;
UDWORD size; UDWORD size;
UDWORD brightness, specular; PIELIGHT brightness, specular;
/* No rotation about arbitrary axis */ /* No rotation about arbitrary axis */
null.x = null.y = null.z = 0; null.x = null.y = null.z = 0;
@ -1853,7 +1851,7 @@ void renderConstructionEffect(EFFECT *psEffect)
pie_MatScale(size); pie_MatScale(size);
// set up lighting // set up lighting
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX() - MAKEINT(psEffect->position.x),getCentreZ() - MAKEINT(psEffect->position.z), &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x), getCentreZ() - MAKEINT(psEffect->position.z), &specular);
pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, specular, pie_TRANSLUCENT, (UBYTE)(translucency)); pie_Draw3DShape(psEffect->imd, psEffect->frameNumber, 0, brightness, specular, pie_TRANSLUCENT, (UBYTE)(translucency));
@ -1870,7 +1868,7 @@ void renderSmokeEffect(EFFECT *psEffect)
{ {
UDWORD percent; UDWORD percent;
UDWORD transparency = 0; UDWORD transparency = 0;
UDWORD brightness, specular; PIELIGHT brightness, specular;
positionEffect(psEffect); positionEffect(psEffect);
@ -1907,7 +1905,7 @@ void renderSmokeEffect(EFFECT *psEffect)
} }
// set up lighting // set up lighting
brightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,getCentreX() - MAKEINT(psEffect->position.x),getCentreZ() - MAKEINT(psEffect->position.z), &specular); brightness = lightDoFogAndIllumination(WZCOL_WHITE, getCentreX() - MAKEINT(psEffect->position.x), getCentreZ() - MAKEINT(psEffect->position.z), &specular);
transparency = (transparency * 3) / 2; //JPS smoke strength increased for d3d 12 may 99 transparency = (transparency * 3) / 2; //JPS smoke strength increased for d3d 12 may 99

View File

@ -28,6 +28,7 @@
#include "lib/ivis_common/piestate.h" //ivis matrix code #include "lib/ivis_common/piestate.h" //ivis matrix code
#include "lib/ivis_common/piefunc.h" //ivis matrix code #include "lib/ivis_common/piefunc.h" //ivis matrix code
#include "lib/ivis_opengl/piematrix.h" #include "lib/ivis_opengl/piematrix.h"
#include "lib/ivis_common/piepalette.h"
#include "map.h" #include "map.h"
#include "lighting.h" #include "lighting.h"
#include "display3d.h" #include "display3d.h"
@ -517,8 +518,7 @@ float fraction,adjust;
} }
PIELIGHT lightDoFogAndIllumination(PIELIGHT brightness, SDWORD dx, SDWORD dz, PIELIGHT *pSpecular)
UDWORD lightDoFogAndIllumination(UBYTE brightness, SDWORD dx, SDWORD dz, UDWORD* pSpecular)
{ {
SDWORD umbraRadius; // Distance to start of light falloff SDWORD umbraRadius; // Distance to start of light falloff
SDWORD penumbraRadius; // radius of area of obscurity SDWORD penumbraRadius; // radius of area of obscurity
@ -609,42 +609,36 @@ UDWORD lightDoFogAndIllumination(UBYTE brightness, SDWORD dx, SDWORD dz, UDWORD*
} }
else else
{ {
brightness = (UBYTE)pie_ByteScale((UBYTE)brightness, (UBYTE)umbra); brightness = pal_SetBrightness(pie_ByteScale(brightness.byte.r, (UBYTE)umbra));
} }
if (fog == 0) if (fog == 0)
{ {
if (pSpecular != NULL) if (pSpecular != NULL)
{ {
*pSpecular = 0; *pSpecular = WZCOL_BLACK;
} }
lighting.byte.a = UBYTE_MAX; lighting = brightness;
lighting.byte.r = brightness;
lighting.byte.g = brightness;
lighting.byte.b = brightness;
} }
else else
{ {
if (pSpecular != NULL) if (pSpecular != NULL)
{ {
fogColour = pie_GetFogColour(); fogColour = pie_GetFogColour();
specular.byte.a = (UBYTE)fog; specular.byte.a = fog;
specular.byte.r = pie_ByteScale((UBYTE)fog, fogColour.byte.r); specular.byte.r = pie_ByteScale(fog, fogColour.byte.r);
specular.byte.g = pie_ByteScale((UBYTE)fog, fogColour.byte.g); specular.byte.g = pie_ByteScale(fog, fogColour.byte.g);
specular.byte.b = pie_ByteScale((UBYTE)fog, fogColour.byte.b); specular.byte.b = pie_ByteScale(fog, fogColour.byte.b);
*pSpecular = specular.argb; *pSpecular = specular;
} }
//calculate new brightness //calculate new brightness
colour = 256 - fog; colour = 256 - fog;
brightness = (UBYTE)pie_ByteScale((UBYTE)colour, (UBYTE)brightness); brightness = pal_SetBrightness(pie_ByteScale(colour, brightness.byte.r));
lighting.byte.a = UBYTE_MAX; lighting = brightness;
lighting.byte.r = brightness;
lighting.byte.g = brightness;
lighting.byte.b = brightness;
} }
return lighting.argb; return lighting;
} }
void doBuildingLights( void ) void doBuildingLights( void )

View File

@ -53,7 +53,7 @@ extern void lightValueForTile(UDWORD tileX, UDWORD tileY);
extern void calcTileIllum(UDWORD tileX, UDWORD tileY); extern void calcTileIllum(UDWORD tileX, UDWORD tileY);
extern void doBuildingLights( void ); extern void doBuildingLights( void );
extern void UpdateFogDistance(float distance); extern void UpdateFogDistance(float distance);
extern UDWORD lightDoFogAndIllumination(UBYTE brightness, SDWORD dx, SDWORD dz, UDWORD* pSpecular); extern PIELIGHT lightDoFogAndIllumination(PIELIGHT brightness, SDWORD dx, SDWORD dz, PIELIGHT *pSpecular);
extern void calcDroidIllumination(DROID *psDroid); extern void calcDroidIllumination(DROID *psDroid);
//darkens down the tiles that are outside the scroll limits //darkens down the tiles that are outside the scroll limits
extern void setScrollLimitLighting(void); extern void setScrollLimitLighting(void);