CRLF to LF

This commit is contained in:
Alibek Omarov 2020-08-31 19:50:41 +03:00
parent 0455f5d6e2
commit 5cc388c45e
737 changed files with 336797 additions and 336797 deletions

View File

@ -1,124 +1,124 @@
/* /*
bspfile.h - BSP format included q1, hl1 support bspfile.h - BSP format included q1, hl1 support
Copyright (C) 2010 Uncle Mike Copyright (C) 2010 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef BSPEXTRAFILE_H #ifndef BSPEXTRAFILE_H
#define BSPEXTRAFILE_H #define BSPEXTRAFILE_H
/* /*
============================================================================== ==============================================================================
EXTRA BSP INFO EXTRA BSP INFO
============================================================================== ==============================================================================
*/ */
#define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH" #define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH"
#define EXTRA_VERSION 3 // ver. 1 was occupied by old versions of XashXT, ver. 2 was occupied by old vesrions of P2:savior #define EXTRA_VERSION 3 // ver. 1 was occupied by old versions of XashXT, ver. 2 was occupied by old vesrions of P2:savior
#define MAX_MAP_CUBEMAPS 1024 #define MAX_MAP_CUBEMAPS 1024
#define MAX_MAP_LANDSCAPES 8192 // can be increased but not needs #define MAX_MAP_LANDSCAPES 8192 // can be increased but not needs
#define MAX_MAP_LEAFLIGHTS 0x40000 // can be increased but not needs #define MAX_MAP_LEAFLIGHTS 0x40000 // can be increased but not needs
#define MAX_MAP_WORLDLIGHTS 65535 // including a light surfaces too #define MAX_MAP_WORLDLIGHTS 65535 // including a light surfaces too
#define LUMP_VERTNORMALS 0 // phong shaded vertex normals #define LUMP_VERTNORMALS 0 // phong shaded vertex normals
#define LUMP_LIGHTVECS 1 // deluxemap data #define LUMP_LIGHTVECS 1 // deluxemap data
#define LUMP_CUBEMAPS 2 // cubemap description #define LUMP_CUBEMAPS 2 // cubemap description
#define LUMP_LANDSCAPES 3 // landscape and lightmap resolution info #define LUMP_LANDSCAPES 3 // landscape and lightmap resolution info
#define LUMP_LEAF_LIGHTING 4 // contain compressed light cubes per empty leafs #define LUMP_LEAF_LIGHTING 4 // contain compressed light cubes per empty leafs
#define LUMP_WORLDLIGHTS 5 // list of all the virtual and real lights (used to relight models in-game) #define LUMP_WORLDLIGHTS 5 // list of all the virtual and real lights (used to relight models in-game)
#define LUMP_COLLISION 6 // physics engine collision hull dump #define LUMP_COLLISION 6 // physics engine collision hull dump
#define LUMP_AINODEGRAPH 7 // node graph that stored into the bsp #define LUMP_AINODEGRAPH 7 // node graph that stored into the bsp
#define EXTRA_LUMPS 8 // count of the extra lumps #define EXTRA_LUMPS 8 // count of the extra lumps
#define LM_ENVIRONMENT_STYLE 20 // light_environment always handle into separate style, so we can ignore it #define LM_ENVIRONMENT_STYLE 20 // light_environment always handle into separate style, so we can ignore it
typedef struct typedef struct
{ {
int id; // must be little endian XASH int id; // must be little endian XASH
int version; int version;
dlump_t lumps[EXTRA_LUMPS]; dlump_t lumps[EXTRA_LUMPS];
} dextrahdr_t; } dextrahdr_t;
// MODIFIED: int flags -> short flags, short landscape (total struct size not changed!) // MODIFIED: int flags -> short flags, short landscape (total struct size not changed!)
typedef struct typedef struct
{ {
float vecs[2][4]; // texmatrix [s/t][xyz offset] float vecs[2][4]; // texmatrix [s/t][xyz offset]
int miptex; int miptex;
short flags; short flags;
short landscape; short landscape;
} dtexinfo_t; } dtexinfo_t;
//============================================================================ //============================================================================
typedef struct typedef struct
{ {
float normal[3]; float normal[3];
} dnormal_t; } dnormal_t;
typedef struct typedef struct
{ {
short origin[3]; // position of light snapped to the nearest integer short origin[3]; // position of light snapped to the nearest integer
short size; // cubemap side size short size; // cubemap side size
} dcubemap_t; } dcubemap_t;
typedef struct typedef struct
{ {
byte color[6][3]; // 6 sides 1x1 (single pixel per side) byte color[6][3]; // 6 sides 1x1 (single pixel per side)
} dsample_t; } dsample_t;
typedef struct typedef struct
{ {
dsample_t cube; dsample_t cube;
short origin[3]; short origin[3];
short leafnum; // leaf that contain this sample short leafnum; // leaf that contain this sample
} dleafambient_t; } dleafambient_t;
typedef struct typedef struct
{ {
char landname[16]; // name of decsription in mapname_land.txt char landname[16]; // name of decsription in mapname_land.txt
word texture_step; // default is 16, pixels\luxels ratio word texture_step; // default is 16, pixels\luxels ratio
word max_extent; // default is 16, subdivision step ((texture_step * max_extent) - texture_step) word max_extent; // default is 16, subdivision step ((texture_step * max_extent) - texture_step)
short groupid; // to determine equal landscapes from various groups short groupid; // to determine equal landscapes from various groups
} dlandscape_t; } dlandscape_t;
typedef enum typedef enum
{ {
emit_surface, emit_surface,
emit_point, emit_point,
emit_spotlight, emit_spotlight,
emit_skylight emit_skylight
} emittype_t; } emittype_t;
#define VERTEXNORMAL_CONE_INNER_ANGLE DEG2RAD( 7.275 ) #define VERTEXNORMAL_CONE_INNER_ANGLE DEG2RAD( 7.275 )
#define DWL_FLAGS_INAMBIENTCUBE 0x0001 // This says that the light was put into the per-leaf ambient cubes. #define DWL_FLAGS_INAMBIENTCUBE 0x0001 // This says that the light was put into the per-leaf ambient cubes.
typedef struct typedef struct
{ {
byte emittype; byte emittype;
byte style; byte style;
byte flags; // will be set in ComputeLeafAmbientLighting byte flags; // will be set in ComputeLeafAmbientLighting
short origin[3]; // light abs origin short origin[3]; // light abs origin
float intensity[3]; // RGB float intensity[3]; // RGB
float normal[3]; // for surfaces and spotlights float normal[3]; // for surfaces and spotlights
float stopdot; // for spotlights float stopdot; // for spotlights
float stopdot2; // for spotlights float stopdot2; // for spotlights
float fade; // falloff scaling for linear and inverse square falloff 1.0 = normal, 0.5 = farther, 2.0 = shorter etc float fade; // falloff scaling for linear and inverse square falloff 1.0 = normal, 0.5 = farther, 2.0 = shorter etc
float radius; // light radius float radius; // light radius
short leafnum; // light linked into this leaf short leafnum; // light linked into this leaf
byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square (arghrad compat) byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square (arghrad compat)
word facenum; // face number for emit_surface word facenum; // face number for emit_surface
short modelnumber; // g-cont. we can't link lights with entities by entity number so we link it by bmodel number short modelnumber; // g-cont. we can't link lights with entities by entity number so we link it by bmodel number
} dworldlight_t; } dworldlight_t;
#endif//BSPFILE_H #endif//BSPFILE_H

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,64 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef __AMMO_H__ #ifndef __AMMO_H__
#define __AMMO_H__ #define __AMMO_H__
#define MAX_WEAPON_NAME 128 #define MAX_WEAPON_NAME 128
#define WEAPON_FLAGS_SELECTONEMPTY 1 #define WEAPON_FLAGS_SELECTONEMPTY 1
#define WEAPON_IS_ONTARGET 0x40 #define WEAPON_IS_ONTARGET 0x40
struct WEAPON struct WEAPON
{ {
char szName[MAX_WEAPON_NAME]; char szName[MAX_WEAPON_NAME];
int iAmmoType; int iAmmoType;
int iAmmo2Type; int iAmmo2Type;
int iMax1; int iMax1;
int iMax2; int iMax2;
int iSlot; int iSlot;
int iSlotPos; int iSlotPos;
int iFlags; int iFlags;
int iId; int iId;
int iClip; int iClip;
int iCount; // # of itesm in plist int iCount; // # of itesm in plist
HSPRITE hActive; HSPRITE hActive;
wrect_t rcActive; wrect_t rcActive;
HSPRITE hInactive; HSPRITE hInactive;
wrect_t rcInactive; wrect_t rcInactive;
HSPRITE hNoAmmo; // buz HSPRITE hNoAmmo; // buz
wrect_t rcNoAmmo; // buz wrect_t rcNoAmmo; // buz
HSPRITE hAmmo; HSPRITE hAmmo;
wrect_t rcAmmo; wrect_t rcAmmo;
HSPRITE hAmmo2; HSPRITE hAmmo2;
wrect_t rcAmmo2; wrect_t rcAmmo2;
HSPRITE hCrosshair; HSPRITE hCrosshair;
wrect_t rcCrosshair; wrect_t rcCrosshair;
HSPRITE hAutoaim; HSPRITE hAutoaim;
wrect_t rcAutoaim; wrect_t rcAutoaim;
HSPRITE hZoomedCrosshair; HSPRITE hZoomedCrosshair;
wrect_t rcZoomedCrosshair; wrect_t rcZoomedCrosshair;
HSPRITE hZoomedAutoaim; HSPRITE hZoomedAutoaim;
wrect_t rcZoomedAutoaim; wrect_t rcZoomedAutoaim;
}; };
typedef int AMMO; typedef int AMMO;
#endif #endif

View File

@ -1,159 +1,159 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// ammo_secondary.cpp // ammo_secondary.cpp
// //
// implementation of CHudAmmoSecondary class // implementation of CHudAmmoSecondary class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal ); DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon ); DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
int CHudAmmoSecondary :: Init( void ) int CHudAmmoSecondary :: Init( void )
{ {
HOOK_MESSAGE( SecAmmoVal ); HOOK_MESSAGE( SecAmmoVal );
HOOK_MESSAGE( SecAmmoIcon ); HOOK_MESSAGE( SecAmmoIcon );
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
m_HUD_ammoicon = 0; m_HUD_ammoicon = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
Reset(); Reset();
return 1; return 1;
} }
void CHudAmmoSecondary :: Reset( void ) void CHudAmmoSecondary :: Reset( void )
{ {
m_fFade = 0; m_fFade = 0;
} }
int CHudAmmoSecondary :: VidInit( void ) int CHudAmmoSecondary :: VidInit( void )
{ {
return 1; return 1;
} }
int CHudAmmoSecondary :: Draw(float flTime) int CHudAmmoSecondary :: Draw(float flTime)
{ {
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) ) if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
return 1; return 1;
// draw secondary ammo icons above normal ammo readout // draw secondary ammo icons above normal ammo readout
int a, x, y, r, g, b, AmmoWidth; int a, x, y, r, g, b, AmmoWidth;
UnpackRGB( r, g, b, gHUD.m_iHUDColor ); //LRC UnpackRGB( r, g, b, gHUD.m_iHUDColor ); //LRC
a = (int) max( MIN_ALPHA, m_fFade ); a = (int) max( MIN_ALPHA, m_fFade );
if (m_fFade > 0) if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
ScaleColors( r, g, b, a ); ScaleColors( r, g, b, a );
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values
x = ScreenWidth - AmmoWidth; x = ScreenWidth - AmmoWidth;
if ( m_HUD_ammoicon ) if ( m_HUD_ammoicon )
{ {
// Draw the ammo icon // Draw the ammo icon
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left); x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left);
y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom); y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b ); SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
} }
else else
{ // move the cursor by the '0' char instead, since we don't have an icon to work with { // move the cursor by the '0' char instead, since we don't have an icon to work with
x -= AmmoWidth; x -= AmmoWidth;
y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom); y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom);
} }
// draw the ammo counts, in reverse order, from right to left // draw the ammo counts, in reverse order, from right to left
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- ) for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
{ {
if ( m_iAmmoAmounts[i] < 0 ) if ( m_iAmmoAmounts[i] < 0 )
continue; // negative ammo amounts imply that they shouldn't be drawn continue; // negative ammo amounts imply that they shouldn't be drawn
// half a char gap between the ammo number and the previous pic // half a char gap between the ammo number and the previous pic
x -= (AmmoWidth / 2); x -= (AmmoWidth / 2);
// draw the number, right-aligned // draw the number, right-aligned
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth); x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b ); gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
if ( i != 0 ) if ( i != 0 )
{ {
// draw the divider bar // draw the divider bar
x -= (AmmoWidth / 2); x -= (AmmoWidth / 2);
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a); FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
} }
} }
return 1; return 1;
} }
// Message handler for Secondary Ammo Value // Message handler for Secondary Ammo Value
// accepts one value: // accepts one value:
// string: sprite name // string: sprite name
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf ) int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() ); m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
return 1; return 1;
} }
// Message handler for Secondary Ammo Icon // Message handler for Secondary Ammo Icon
// Sets an ammo value // Sets an ammo value
// takes two values: // takes two values:
// byte: ammo index // byte: ammo index
// byte: ammo value // byte: ammo value
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf ) int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int index = READ_BYTE(); int index = READ_BYTE();
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES ) if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
return 1; return 1;
m_iAmmoAmounts[index] = READ_BYTE(); m_iAmmoAmounts[index] = READ_BYTE();
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
// check to see if there is anything left to draw // check to see if there is anything left to draw
int count = 0; int count = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
{ {
count += max( 0, m_iAmmoAmounts[i] ); count += max( 0, m_iAmmoAmounts[i] );
} }
if ( count == 0 ) if ( count == 0 )
{ // the ammo fields are all empty, so turn off this hud area { // the ammo fields are all empty, so turn off this hud area
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; return 1;
} }
// make the icons light up // make the icons light up
m_fFade = 200.0f; m_fFade = 200.0f;
return 1; return 1;
} }

View File

@ -1,190 +1,190 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// ammohistory.cpp // ammohistory.cpp
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "ammohistory.h" #include "ammohistory.h"
HistoryResource gHR; HistoryResource gHR;
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5) #define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2)) #define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100) #define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
#define MAX_ITEM_NAME 32 #define MAX_ITEM_NAME 32
int HISTORY_DRAW_TIME = 5; int HISTORY_DRAW_TIME = 5;
// keep a list of items // keep a list of items
struct ITEM_INFO struct ITEM_INFO
{ {
char szName[MAX_ITEM_NAME]; char szName[MAX_ITEM_NAME];
HSPRITE spr; HSPRITE spr;
wrect_t rect; wrect_t rect;
}; };
void HistoryResource :: AddToHistory( int iType, int iId, int iCount ) void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
{ {
if ( iType == HISTSLOT_AMMO && !iCount ) if ( iType == HISTSLOT_AMMO && !iCount )
return; // no amount, so don't add return; // no amount, so don't add
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
{ // the pic would have to be drawn too high { // the pic would have to be drawn too high
// so start from the bottom // so start from the bottom
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" ); HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
freeslot->type = iType; freeslot->type = iType;
freeslot->iId = iId; freeslot->iId = iId;
freeslot->iCount = iCount; freeslot->iCount = iCount;
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
} }
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount ) void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
{ {
if ( iType != HISTSLOT_ITEM ) if ( iType != HISTSLOT_ITEM )
return; return;
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
{ // the pic would have to be drawn too high { // the pic would have to be drawn too high
// so start from the bottom // so start from the bottom
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
// I am really unhappy with all the code in this file // I am really unhappy with all the code in this file
int i = gHUD.GetSpriteIndex( szName ); int i = gHUD.GetSpriteIndex( szName );
if ( i == -1 ) if ( i == -1 )
return; // unknown sprite name, don't add it to history return; // unknown sprite name, don't add it to history
freeslot->iId = i; freeslot->iId = i;
freeslot->type = iType; freeslot->type = iType;
freeslot->iCount = iCount; freeslot->iCount = iCount;
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" ); HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
} }
void HistoryResource :: CheckClearHistory( void ) void HistoryResource :: CheckClearHistory( void )
{ {
for ( int i = 0; i < MAX_HISTORY; i++ ) for ( int i = 0; i < MAX_HISTORY; i++ )
{ {
if ( rgAmmoHistory[i].type ) if ( rgAmmoHistory[i].type )
return; return;
} }
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
// //
// Draw Ammo pickup history // Draw Ammo pickup history
// //
int HistoryResource :: DrawAmmoHistory( float flTime ) int HistoryResource :: DrawAmmoHistory( float flTime )
{ {
for ( int i = 0; i < MAX_HISTORY; i++ ) for ( int i = 0; i < MAX_HISTORY; i++ )
{ {
if ( rgAmmoHistory[i].type ) if ( rgAmmoHistory[i].type )
{ {
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME ); rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
if ( rgAmmoHistory[i].DisplayTime <= flTime ) if ( rgAmmoHistory[i].DisplayTime <= flTime )
{ // pic drawing time has expired { // pic drawing time has expired
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) ); memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
CheckClearHistory(); CheckClearHistory();
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO ) else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
{ {
wrect_t rcPic; wrect_t rcPic;
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic ); HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
int r, g, b; int r, g, b;
UnpackRGB(r,g,b, gHUD.m_iHUDColor); UnpackRGB(r,g,b, gHUD.m_iHUDColor);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors(r, g, b, min(scale, 255) );
// Draw the pic // Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - 24; int xpos = ScreenWidth - 24;
if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
{ // the dll has to make sure it has sent info the weapons you need { // the dll has to make sure it has sent info the weapons you need
SPR_Set( *spr, r, g, b ); SPR_Set( *spr, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rcPic ); SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
} }
// Draw the number // Draw the number
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b ); gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP ) else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
{ {
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId ); WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
if ( !weap ) if ( !weap )
return 1; // we don't know about the weapon yet, so don't draw anything return 1; // we don't know about the weapon yet, so don't draw anything
int r, g, b; int r, g, b;
UnpackRGB(r,g,b, gHUD.m_iHUDColor); UnpackRGB(r,g,b, gHUD.m_iHUDColor);
if ( !gWR.HasAmmo( weap ) ) if ( !gWR.HasAmmo( weap ) )
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors(r, g, b, min(scale, 255) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left); int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
SPR_Set( weap->hInactive, r, g, b ); SPR_Set( weap->hInactive, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive ); SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM ) else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
{ {
int r, g, b; int r, g, b;
if ( !rgAmmoHistory[i].iId ) if ( !rgAmmoHistory[i].iId )
continue; // sprite not loaded continue; // sprite not loaded
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId ); wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
UnpackRGB(r,g,b, gHUD.m_iHUDColor); UnpackRGB(r,g,b, gHUD.m_iHUDColor);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors(r, g, b, min(scale, 255) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (rect.right - rect.left) - 10; int xpos = ScreenWidth - (rect.right - rect.left) - 10;
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b ); SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rect ); SPR_DrawAdditive( 0, xpos, ypos, &rect );
} }
} }
} }
return 1; return 1;
} }

View File

@ -1,154 +1,154 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// ammohistory.h // ammohistory.h
// //
// this is the max number of items in each bucket // this is the max number of items in each bucket
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS #define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
extern WEAPON *gpActiveSel; extern WEAPON *gpActiveSel;
class WeaponsResource class WeaponsResource
{ {
public: // buz: made public to access from drawing code (valves idea about WR is suxx) public: // buz: made public to access from drawing code (valves idea about WR is suxx)
// Information about weapons & ammo // Information about weapons & ammo
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
// counts of weapons * ammo // counts of weapons * ammo
WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
int riAmmo[MAX_AMMO_SLOTS]; // count of each ammo type int riAmmo[MAX_AMMO_SLOTS]; // count of each ammo type
public: public:
void Init( void ) void Init( void )
{ {
memset( rgWeapons, 0, sizeof rgWeapons ); memset( rgWeapons, 0, sizeof rgWeapons );
Reset(); Reset();
} }
void Reset( void ) void Reset( void )
{ {
iOldWeaponBits = 0; iOldWeaponBits = 0;
m_iSelectedColumn = -1; m_iSelectedColumn = -1;
memset( rgSlots, 0, sizeof rgSlots ); memset( rgSlots, 0, sizeof rgSlots );
memset( riAmmo, 0, sizeof riAmmo ); memset( riAmmo, 0, sizeof riAmmo );
} }
///// WEAPON ///// ///// WEAPON /////
int iOldWeaponBits; int iOldWeaponBits;
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; } WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
void AddWeapon( WEAPON *wp ) void AddWeapon( WEAPON *wp )
{ {
rgWeapons[ wp->iId ] = *wp; rgWeapons[ wp->iId ] = *wp;
LoadWeaponSprites( &rgWeapons[ wp->iId ] ); LoadWeaponSprites( &rgWeapons[ wp->iId ] );
} }
void PickupWeapon( WEAPON *wp ) void PickupWeapon( WEAPON *wp )
{ {
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp; rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
if ((m_iSelectedColumn == wp->iSlot) && !gpActiveSel) // buz: menu active, but no weapons in this category if ((m_iSelectedColumn == wp->iSlot) && !gpActiveSel) // buz: menu active, but no weapons in this category
gpActiveSel = wp; gpActiveSel = wp;
} }
void DropWeapon( WEAPON *wp ) void DropWeapon( WEAPON *wp )
{ {
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL; rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
if (wp == gpActiveSel) // buz: removed current weapon if (wp == gpActiveSel) // buz: removed current weapon
gpActiveSel = GetFirstPos( wp->iSlot ); gpActiveSel = GetFirstPos( wp->iSlot );
} }
void DropAllWeapons( void ) void DropAllWeapons( void )
{ {
for ( int i = 0; i < MAX_WEAPONS; i++ ) for ( int i = 0; i < MAX_WEAPONS; i++ )
{ {
if ( rgWeapons[i].iId ) if ( rgWeapons[i].iId )
DropWeapon( &rgWeapons[i] ); DropWeapon( &rgWeapons[i] );
} }
} }
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; } WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
void LoadWeaponSprites( WEAPON* wp ); void LoadWeaponSprites( WEAPON* wp );
void LoadAllWeaponSprites( void ); void LoadAllWeaponSprites( void );
WEAPON* GetFirstPos( int iSlot ); WEAPON* GetFirstPos( int iSlot );
WEAPON* GetLastPos( int iSlot ); // buz WEAPON* GetLastPos( int iSlot ); // buz
void SelectSlot( int iSlot, int fAdvance, int iDirection ); void SelectSlot( int iSlot, int fAdvance, int iDirection );
WEAPON* GetNextActivePos( int iSlot, int iSlotPos ); WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
WEAPON* GetPrevActivePos( int iSlot, int iSlotPos ); // buz WEAPON* GetPrevActivePos( int iSlot, int iSlotPos ); // buz
int HasAmmo( WEAPON *p ); int HasAmmo( WEAPON *p );
///// AMMO ///// ///// AMMO /////
AMMO GetAmmo( int iId ) { return iId; } AMMO GetAmmo( int iId ) { return iId; }
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; } void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
int CountAmmo( int iId ); int CountAmmo( int iId );
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect ); HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
int m_iSelectedColumn; // buz: -1 means menu inactive int m_iSelectedColumn; // buz: -1 means menu inactive
float m_rgColumnSizes[MAX_WEAPON_SLOTS]; // buz float m_rgColumnSizes[MAX_WEAPON_SLOTS]; // buz
}; };
extern WeaponsResource gWR; extern WeaponsResource gWR;
#define MAX_HISTORY 12 #define MAX_HISTORY 12
enum { enum {
HISTSLOT_EMPTY, HISTSLOT_EMPTY,
HISTSLOT_AMMO, HISTSLOT_AMMO,
HISTSLOT_WEAP, HISTSLOT_WEAP,
HISTSLOT_ITEM, HISTSLOT_ITEM,
}; };
class HistoryResource class HistoryResource
{ {
private: private:
struct HIST_ITEM { struct HIST_ITEM {
int type; int type;
float DisplayTime; // the time at which this item should be removed from the history float DisplayTime; // the time at which this item should be removed from the history
int iCount; int iCount;
int iId; int iId;
}; };
HIST_ITEM rgAmmoHistory[MAX_HISTORY]; HIST_ITEM rgAmmoHistory[MAX_HISTORY];
public: public:
void Init( void ) void Init( void )
{ {
Reset(); Reset();
} }
void Reset( void ) void Reset( void )
{ {
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory ); memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
} }
int iHistoryGap; int iHistoryGap;
int iCurrentHistorySlot; int iCurrentHistorySlot;
void AddToHistory( int iType, int iId, int iCount = 0 ); void AddToHistory( int iType, int iId, int iCount = 0 );
void AddToHistory( int iType, const char *szName, int iCount = 0 ); void AddToHistory( int iType, const char *szName, int iCount = 0 );
void CheckClearHistory( void ); void CheckClearHistory( void );
int DrawAmmoHistory( float flTime ); int DrawAmmoHistory( float flTime );
}; };
extern HistoryResource gHR; extern HistoryResource gHR;

View File

@ -1,145 +1,145 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// battery.cpp // battery.cpp
// //
// implementation of CHudBattery class // implementation of CHudBattery class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "vgui_TeamFortressViewport.h" // buz #include "vgui_TeamFortressViewport.h" // buz
#include "vgui_hud.h" // buz #include "vgui_hud.h" // buz
DECLARE_MESSAGE(m_Battery, Battery) DECLARE_MESSAGE(m_Battery, Battery)
int CHudBattery::Init(void) int CHudBattery::Init(void)
{ {
m_iBat = 0; m_iBat = 0;
m_fFade = 0; m_fFade = 0;
m_iFlags = 0; m_iFlags = 0;
HOOK_MESSAGE(Battery); HOOK_MESSAGE(Battery);
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
return 1; return 1;
}; };
int CHudBattery::VidInit(void) int CHudBattery::VidInit(void)
{ {
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" ); int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" ); int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" );
m_hSprite1 = m_hSprite2 = 0; // delaying get sprite handles until we know the sprites are loaded m_hSprite1 = m_hSprite2 = 0; // delaying get sprite handles until we know the sprites are loaded
m_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty ); m_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full ); m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
m_iHeight = m_prc2->bottom - m_prc1->top; m_iHeight = m_prc2->bottom - m_prc1->top;
m_fFade = 0; m_fFade = 0;
return 1; return 1;
}; };
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
{ {
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int x = READ_SHORT(); int x = READ_SHORT();
if( x != m_iBat ) if( x != m_iBat )
{ {
m_fFade = FADE_TIME; m_fFade = FADE_TIME;
m_iBat = x; m_iBat = x;
} }
gViewPort->m_pHud2->UpdateArmor(x); // buz gViewPort->m_pHud2->UpdateArmor(x); // buz
return 1; return 1;
} }
int CHudBattery::Draw(float flTime) int CHudBattery::Draw(float flTime)
{ {
return 1; // buz: dont draw battery.. return 1; // buz: dont draw battery..
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
return 1; return 1;
int r, g, b, x, y, a; int r, g, b, x, y, a;
wrect_t rc; wrect_t rc;
rc = *m_prc2; rc = *m_prc2;
rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
UnpackRGB(r,g,b, gHUD.m_iHUDColor); UnpackRGB(r,g,b, gHUD.m_iHUDColor);
if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT )) if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT ))
return 1; return 1;
// Has health changed? Flash the health # // Has health changed? Flash the health #
if (m_fFade) if (m_fFade)
{ {
if (m_fFade > FADE_TIME) if (m_fFade > FADE_TIME)
m_fFade = FADE_TIME; m_fFade = FADE_TIME;
m_fFade -= (gHUD.m_flTimeDelta * 20); m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0) if (m_fFade <= 0)
{ {
a = 128; a = 128;
m_fFade = 0; m_fFade = 0;
} }
// Fade the health number back to dim // Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128; a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
} }
else else
a = MIN_ALPHA; a = MIN_ALPHA;
ScaleColors(r, g, b, a ); ScaleColors(r, g, b, a );
int iOffset = (m_prc1->bottom - m_prc1->top)/6; int iOffset = (m_prc1->bottom - m_prc1->top)/6;
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = ScreenWidth/5; x = ScreenWidth/5;
// make sure we have the right sprite handles // make sure we have the right sprite handles
if ( !m_hSprite1 ) if ( !m_hSprite1 )
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) ); m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
if ( !m_hSprite2 ) if ( !m_hSprite2 )
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) ); m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
SPR_Set(m_hSprite1, r, g, b ); SPR_Set(m_hSprite1, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1); SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
if (rc.bottom > rc.top) if (rc.bottom > rc.top)
{ {
SPR_Set(m_hSprite2, r, g, b ); SPR_Set(m_hSprite2, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc); SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
} }
x += (m_prc1->right - m_prc1->left); x += (m_prc1->right - m_prc1->left);
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b); x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
return 1; return 1;
} }

View File

@ -1,24 +1,24 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
// Camera.h -- defines and such for a 3rd person camera // Camera.h -- defines and such for a 3rd person camera
// NOTE: must include quakedef.h first // NOTE: must include quakedef.h first
#ifndef _CAMERA_H_ #ifndef _CAMERA_H_
#define _CAMEA_H_ #define _CAMEA_H_
// pitch, yaw, dist // pitch, yaw, dist
extern vec3_t cam_ofs; extern vec3_t cam_ofs;
// Using third person camera // Using third person camera
extern int cam_thirdperson; extern int cam_thirdperson;
void CAM_Init( void ); void CAM_Init( void );
void CAM_ClearStates( void ); void CAM_ClearStates( void );
void CAM_StartMouseMove(void); void CAM_StartMouseMove(void);
void CAM_EndMouseMove(void); void CAM_EndMouseMove(void);
#endif // _CAMERA_H_ #endif // _CAMERA_H_

View File

@ -1,344 +1,344 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cdll_int.c // cdll_int.c
// //
// this implementation handles the linking of the engine to the DLL // this implementation handles the linking of the engine to the DLL
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "netadr.h" #include "netadr.h"
#include "vgui_schememanager.h" #include "vgui_schememanager.h"
#include "pm_shared.h" #include "pm_shared.h"
#include "pm_defs.h" #include "pm_defs.h"
#include <string.h> #include <string.h>
#include "hud_servers.h" #include "hud_servers.h"
#include "vgui_int.h" #include "vgui_int.h"
int developer_level; int developer_level;
int g_iXashEngineBuildNumber; int g_iXashEngineBuildNumber;
BOOL g_fRenderInitialized = FALSE; BOOL g_fRenderInitialized = FALSE;
BOOL g_fRenderInterfaceValid = FALSE; BOOL g_fRenderInterfaceValid = FALSE;
BOOL g_fXashEngine = FALSE; BOOL g_fXashEngine = FALSE;
cl_enginefunc_t gEngfuncs; cl_enginefunc_t gEngfuncs;
render_api_t gRenderfuncs; render_api_t gRenderfuncs;
CHud gHUD; CHud gHUD;
TeamFortressViewport *gViewPort = NULL; TeamFortressViewport *gViewPort = NULL;
void InitInput( void ); void InitInput( void );
void ShutdownInput( void ); void ShutdownInput( void );
void EV_HookEvents( void ); void EV_HookEvents( void );
void IN_Commands( void ); void IN_Commands( void );
/* /*
========================== ==========================
Initialize Initialize
Called when the DLL is first loaded. Called when the DLL is first loaded.
========================== ==========================
*/ */
extern "C" extern "C"
{ {
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ); int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int DLLEXPORT HUD_VidInit( void ); int DLLEXPORT HUD_VidInit( void );
void DLLEXPORT HUD_Init( void ); void DLLEXPORT HUD_Init( void );
void DLLEXPORT HUD_Shutdown( void ); void DLLEXPORT HUD_Shutdown( void );
int DLLEXPORT HUD_Redraw( float flTime, int intermission ); int DLLEXPORT HUD_Redraw( float flTime, int intermission );
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime ); int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
void DLLEXPORT HUD_Reset ( void ); void DLLEXPORT HUD_Reset ( void );
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server ); void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove ); void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char DLLEXPORT HUD_PlayerMoveTexture( char *name ); char DLLEXPORT HUD_PlayerMoveTexture( char *name );
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
void DLLEXPORT HUD_PostRunCmd( local_state_t *from, local_state_t *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int seed ); void DLLEXPORT HUD_PostRunCmd( local_state_t *from, local_state_t *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int seed );
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ); int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void DLLEXPORT HUD_Frame( double time ); void DLLEXPORT HUD_Frame( double time );
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking); void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf ); void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
void DLLEXPORT HUD_ClipMoveToEntity( physent_t *pe, const float *start, float *mins, float *maxs, const float *end, pmtrace_t *tr ); void DLLEXPORT HUD_ClipMoveToEntity( physent_t *pe, const float *start, float *mins, float *maxs, const float *end, pmtrace_t *tr );
} }
/* /*
================================ ================================
HUD_GetHullBounds HUD_GetHullBounds
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist. Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
================================ ================================
*/ */
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ) int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
{ {
int iret = 0; int iret = 0;
switch ( hullnumber ) switch ( hullnumber )
{ {
case 0: // Normal player case 0: // Normal player
mins = Vector(-16, -16, -36); mins = Vector(-16, -16, -36);
maxs = Vector(16, 16, 36); maxs = Vector(16, 16, 36);
iret = 1; iret = 1;
break; break;
case 1: // Crouched player case 1: // Crouched player
mins = Vector(-16, -16, -18 ); mins = Vector(-16, -16, -18 );
maxs = Vector(16, 16, 18 ); maxs = Vector(16, 16, 18 );
iret = 1; iret = 1;
break; break;
case 2: // Point based hull case 2: // Point based hull
mins = Vector( 0, 0, 0 ); mins = Vector( 0, 0, 0 );
maxs = Vector( 0, 0, 0 ); maxs = Vector( 0, 0, 0 );
iret = 1; iret = 1;
break; break;
} }
return iret; return iret;
} }
/* /*
================================ ================================
HUD_ConnectionlessPacket HUD_ConnectionlessPacket
Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
size of the response_buffer, so you must zero it out if you choose not to respond. size of the response_buffer, so you must zero it out if you choose not to respond.
================================ ================================
*/ */
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
{ {
// Parse stuff from args // Parse stuff from args
int max_buffer_size = *response_buffer_size; int max_buffer_size = *response_buffer_size;
// Zero it out since we aren't going to respond. // Zero it out since we aren't going to respond.
// If we wanted to response, we'd write data into response_buffer // If we wanted to response, we'd write data into response_buffer
*response_buffer_size = 0; *response_buffer_size = 0;
// Since we don't listen for anything here, just respond that it's a bogus message // Since we don't listen for anything here, just respond that it's a bogus message
// If we didn't reject the message, we'd return 1 for success instead. // If we didn't reject the message, we'd return 1 for success instead.
return 0; return 0;
} }
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove ) void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
{ {
PM_Init( ppmove ); PM_Init( ppmove );
} }
char DLLEXPORT HUD_PlayerMoveTexture( char *name ) char DLLEXPORT HUD_PlayerMoveTexture( char *name )
{ {
return (char)0; return (char)0;
} }
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server ) void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
{ {
PM_Move( ppmove, server ); PM_Move( ppmove, server );
} }
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ) int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{ {
gEngfuncs = *pEnginefuncs; gEngfuncs = *pEnginefuncs;
if( iVersion != CLDLL_INTERFACE_VERSION ) if( iVersion != CLDLL_INTERFACE_VERSION )
return 0; return 0;
memcpy( &gEngfuncs, pEnginefuncs, sizeof( cl_enginefunc_t )); memcpy( &gEngfuncs, pEnginefuncs, sizeof( cl_enginefunc_t ));
// get developer level // get developer level
developer_level = (int)CVAR_GET_FLOAT( "developer" ); developer_level = (int)CVAR_GET_FLOAT( "developer" );
if( CVAR_GET_POINTER( "host_clientloaded" ) != NULL ) if( CVAR_GET_POINTER( "host_clientloaded" ) != NULL )
g_fXashEngine = TRUE; g_fXashEngine = TRUE;
g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "build" ); // 0 for old builds or GoldSrc g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "build" ); // 0 for old builds or GoldSrc
if( g_iXashEngineBuildNumber <= 0 ) if( g_iXashEngineBuildNumber <= 0 )
g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "buildnum" ); g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "buildnum" );
EV_HookEvents(); EV_HookEvents();
return 1; return 1;
} }
/* /*
========================== ==========================
HUD_VidInit HUD_VidInit
Called when the game initializes Called when the game initializes
and whenever the vid_mode is changed and whenever the vid_mode is changed
so the HUD can reinitialize itself. so the HUD can reinitialize itself.
========================== ==========================
*/ */
int DLLEXPORT HUD_VidInit( void ) int DLLEXPORT HUD_VidInit( void )
{ {
gHUD.VidInit(); gHUD.VidInit();
VGui_Startup(); VGui_Startup();
if( g_fXashEngine && g_fRenderInitialized ) if( g_fXashEngine && g_fRenderInitialized )
R_VidInit(); R_VidInit();
return 1; return 1;
} }
/* /*
========================== ==========================
HUD_Init HUD_Init
Called whenever the client connects Called whenever the client connects
to a server. Reinitializes all to a server. Reinitializes all
the hud variables. the hud variables.
========================== ==========================
*/ */
void DLLEXPORT HUD_Init( void ) void DLLEXPORT HUD_Init( void )
{ {
InitInput(); InitInput();
if( g_fXashEngine && g_fRenderInitialized ) if( g_fXashEngine && g_fRenderInitialized )
GL_Init(); GL_Init();
gHUD.Init(); gHUD.Init();
Scheme_Init(); Scheme_Init();
} }
void DLLEXPORT HUD_Shutdown( void ) void DLLEXPORT HUD_Shutdown( void )
{ {
ShutdownInput(); ShutdownInput();
if( g_fXashEngine && g_fRenderInitialized ) if( g_fXashEngine && g_fRenderInitialized )
GL_Shutdown(); GL_Shutdown();
} }
/* /*
========================== ==========================
HUD_Redraw HUD_Redraw
called every screen frame to called every screen frame to
redraw the HUD. redraw the HUD.
=========================== ===========================
*/ */
int DLLEXPORT HUD_Redraw( float time, int intermission ) int DLLEXPORT HUD_Redraw( float time, int intermission )
{ {
return gHUD.Redraw( time, intermission ); return gHUD.Redraw( time, intermission );
} }
/* /*
========================== ==========================
HUD_UpdateClientData HUD_UpdateClientData
called every time shared client called every time shared client
dll/engine data gets changed, dll/engine data gets changed,
and gives the cdll a chance and gives the cdll a chance
to modify the data. to modify the data.
returns 1 if anything has been changed, 0 otherwise. returns 1 if anything has been changed, 0 otherwise.
========================== ==========================
*/ */
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime ) int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
{ {
IN_Commands(); IN_Commands();
return gHUD.UpdateClientData(pcldata, flTime ); return gHUD.UpdateClientData(pcldata, flTime );
} }
/* /*
========================== ==========================
HUD_Reset HUD_Reset
Called at start and end of demos to restore to "non"HUD state. Called at start and end of demos to restore to "non"HUD state.
========================== ==========================
*/ */
void DLLEXPORT HUD_Reset( void ) void DLLEXPORT HUD_Reset( void )
{ {
gHUD.VidInit(); gHUD.VidInit();
} }
/* /*
========================== ==========================
HUD_Frame HUD_Frame
Called by engine every frame that client .dll is loaded Called by engine every frame that client .dll is loaded
========================== ==========================
*/ */
void DLLEXPORT HUD_Frame( double time ) void DLLEXPORT HUD_Frame( double time )
{ {
ServersThink( time ); ServersThink( time );
GetClientVoiceMgr()->Frame(time); GetClientVoiceMgr()->Frame(time);
} }
/* /*
========================== ==========================
HUD_VoiceStatus HUD_VoiceStatus
Called when a player starts or stops talking. Called when a player starts or stops talking.
========================== ==========================
*/ */
void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking ) void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking )
{ {
GetClientVoiceMgr()->UpdateSpeakerStatus( entindex, bTalking ); GetClientVoiceMgr()->UpdateSpeakerStatus( entindex, bTalking );
} }
/* /*
========================== ==========================
HUD_DirectorEvent HUD_DirectorEvent
Called when a director event message was received Called when a director event message was received
========================== ==========================
*/ */
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf ) void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
{ {
gHUD.m_Spectator.DirectorMessage( iSize, pbuf ); gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
} }
void DLLEXPORT HUD_PostRunCmd( local_state_t *from, local_state_t *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int seed ) void DLLEXPORT HUD_PostRunCmd( local_state_t *from, local_state_t *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int seed )
{ {
to->client.fov = 0;//g_lastFOV; buz to->client.fov = 0;//g_lastFOV; buz
} }
/* /*
========================== ==========================
HUD_ClipMoveToEntity HUD_ClipMoveToEntity
This called only for non-local clients (multiplayer) This called only for non-local clients (multiplayer)
========================== ==========================
*/ */
void DLLEXPORT HUD_ClipMoveToEntity( physent_t *pe, const float *start, float *mins, float *maxs, const float *end, pmtrace_t *tr ) void DLLEXPORT HUD_ClipMoveToEntity( physent_t *pe, const float *start, float *mins, float *maxs, const float *end, pmtrace_t *tr )
{ {
// convert physent_t to cl_entity_t // convert physent_t to cl_entity_t
cl_entity_t *pTouch = gEngfuncs.GetEntityByIndex( pe->info ); cl_entity_t *pTouch = gEngfuncs.GetEntityByIndex( pe->info );
trace_t trace; trace_t trace;
if( !pTouch ) if( !pTouch )
{ {
// removed entity? // removed entity?
tr->allsolid = false; tr->allsolid = false;
return; return;
} }
// make trace default // make trace default
memset( &trace, 0, sizeof( trace )); memset( &trace, 0, sizeof( trace ));
trace.allsolid = true; trace.allsolid = true;
trace.fraction = 1.0f; trace.fraction = 1.0f;
trace.endpos = end; trace.endpos = end;
Physic_SweepTest( pTouch, start, mins, maxs, end, &trace ); Physic_SweepTest( pTouch, start, mins, maxs, end, &trace );
// convert trace_t into pmtrace_t // convert trace_t into pmtrace_t
memcpy( tr, &trace, 48 ); memcpy( tr, &trace, 48 );
tr->surf = trace.surf; tr->surf = trace.surf;
if( trace.ent != NULL && PM_GetPlayerMove( )) if( trace.ent != NULL && PM_GetPlayerMove( ))
tr->ent = pe - PM_GetPlayerMove()->physents; tr->ent = pe - PM_GetPlayerMove()->physents;
else tr->ent = -1; else tr->ent = -1;
} }

View File

@ -1,49 +1,49 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cl_dll.h // cl_dll.h
// //
// 4-23-98 JOHN // 4-23-98 JOHN
// //
// This DLL is linked by the client when they first initialize. // This DLL is linked by the client when they first initialize.
// This DLL is responsible for the following tasks: // This DLL is responsible for the following tasks:
// - Loading the HUD graphics upon initialization // - Loading the HUD graphics upon initialization
// - Drawing the HUD graphics every frame // - Drawing the HUD graphics every frame
// - Handling the custum HUD-update packets // - Handling the custum HUD-update packets
// //
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned short word; typedef unsigned short word;
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#include <vector.h> #include <vector.h>
#define EXPORT _declspec( dllexport ) #define EXPORT _declspec( dllexport )
#include "../engine/cdll_int.h" #include "../engine/cdll_int.h"
#include "cdll_dll.h" #include "cdll_dll.h"
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
#define CONPRINT (gEngfuncs.Con_Printf) //LRC - I can't live without printf! #define CONPRINT (gEngfuncs.Con_Printf) //LRC - I can't live without printf!
// //
// gl_export.cpp // gl_export.cpp
// //
bool GL_Init( void ); bool GL_Init( void );
void GL_MapChanged( void ); void GL_MapChanged( void );
void GL_Shutdown( void ); void GL_Shutdown( void );
bool GL_Support( int r_ext ); bool GL_Support( int r_ext );
void R_VidInit( void ); void R_VidInit( void );

View File

@ -1,319 +1,319 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cl_util.h // cl_util.h
// //
#include "cvardef.h" #include "cvardef.h"
#define EXPORT _declspec( dllexport ) #define EXPORT _declspec( dllexport )
#define DLLEXPORT __declspec( dllexport ) #define DLLEXPORT __declspec( dllexport )
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
#endif #endif
extern int developer_level; extern int developer_level;
extern int r_currentMessageNum; extern int r_currentMessageNum;
extern int g_iXashEngineBuildNumber; extern int g_iXashEngineBuildNumber;
extern BOOL g_fRenderInitialized; extern BOOL g_fRenderInitialized;
extern BOOL g_fRenderInterfaceValid; extern BOOL g_fRenderInterfaceValid;
extern BOOL g_fXashEngine; extern BOOL g_fXashEngine;
enum enum
{ {
DEV_NONE = 0, DEV_NONE = 0,
DEV_NORMAL, DEV_NORMAL,
DEV_EXTENDED DEV_EXTENDED
}; };
typedef HMODULE dllhandle_t; typedef HMODULE dllhandle_t;
typedef struct dllfunc_s typedef struct dllfunc_s
{ {
const char *name; const char *name;
void **func; void **func;
} dllfunc_t; } dllfunc_t;
// misc cvars // misc cvars
extern cvar_t *r_test; // just cvar for testify new effects extern cvar_t *r_test; // just cvar for testify new effects
extern cvar_t *r_stencilbits; extern cvar_t *r_stencilbits;
extern cvar_t *r_drawentities; extern cvar_t *r_drawentities;
extern cvar_t *gl_extensions; extern cvar_t *gl_extensions;
extern cvar_t *cv_dynamiclight; extern cvar_t *cv_dynamiclight;
extern cvar_t *r_detailtextures; extern cvar_t *r_detailtextures;
extern cvar_t *r_lighting_ambient; extern cvar_t *r_lighting_ambient;
extern cvar_t *r_lighting_modulate; extern cvar_t *r_lighting_modulate;
extern cvar_t *r_lightstyle_lerping; extern cvar_t *r_lightstyle_lerping;
extern cvar_t *r_lighting_extended; extern cvar_t *r_lighting_extended;
extern cvar_t *r_occlusion_culling; extern cvar_t *r_occlusion_culling;
extern cvar_t *r_show_lightprobes; extern cvar_t *r_show_lightprobes;
extern cvar_t *r_show_cubemaps; extern cvar_t *r_show_cubemaps;
extern cvar_t *r_show_viewleaf; extern cvar_t *r_show_viewleaf;
extern cvar_t *cv_crosshair; extern cvar_t *cv_crosshair;
extern cvar_t *r_shadows; extern cvar_t *r_shadows;
extern cvar_t *r_fullbright; extern cvar_t *r_fullbright;
extern cvar_t *r_draw_beams; extern cvar_t *r_draw_beams;
extern cvar_t *r_overview; extern cvar_t *r_overview;
extern cvar_t *r_novis; extern cvar_t *r_novis;
extern cvar_t *r_nocull; extern cvar_t *r_nocull;
extern cvar_t *r_lockpvs; extern cvar_t *r_lockpvs;
extern cvar_t *r_dof; extern cvar_t *r_dof;
extern cvar_t *r_dof_hold_time; extern cvar_t *r_dof_hold_time;
extern cvar_t *r_dof_change_time; extern cvar_t *r_dof_change_time;
extern cvar_t *r_dof_focal_length; extern cvar_t *r_dof_focal_length;
extern cvar_t *r_dof_fstop; extern cvar_t *r_dof_fstop;
extern cvar_t *r_dof_debug; extern cvar_t *r_dof_debug;
extern cvar_t *r_allow_mirrors; extern cvar_t *r_allow_mirrors;
extern cvar_t *cv_renderer; extern cvar_t *cv_renderer;
extern cvar_t *cv_brdf; extern cvar_t *cv_brdf;
extern cvar_t *cv_bump; extern cvar_t *cv_bump;
extern cvar_t *cv_specular; extern cvar_t *cv_specular;
extern cvar_t *cv_parallax; extern cvar_t *cv_parallax;
extern cvar_t *cv_decals; extern cvar_t *cv_decals;
extern cvar_t *cv_realtime_puddles; extern cvar_t *cv_realtime_puddles;
extern cvar_t *cv_shadow_offset; extern cvar_t *cv_shadow_offset;
extern cvar_t *cv_cubemaps; extern cvar_t *cv_cubemaps;
extern cvar_t *cv_deferred; extern cvar_t *cv_deferred;
extern cvar_t *cv_deferred_full; extern cvar_t *cv_deferred_full;
extern cvar_t *cv_deferred_maxlights; extern cvar_t *cv_deferred_maxlights;
extern cvar_t *cv_deferred_tracebmodels; extern cvar_t *cv_deferred_tracebmodels;
extern cvar_t *cv_cube_lod_bias; extern cvar_t *cv_cube_lod_bias;
extern cvar_t *cv_gamma; extern cvar_t *cv_gamma;
extern cvar_t *cv_brightness; extern cvar_t *cv_brightness;
extern cvar_t *cv_water; extern cvar_t *cv_water;
extern cvar_t *cv_decalsdebug; extern cvar_t *cv_decalsdebug;
extern cvar_t *cv_show_tbn; extern cvar_t *cv_show_tbn;
extern cvar_t *cv_nosort; extern cvar_t *cv_nosort;
extern cvar_t *r_lightmap; extern cvar_t *r_lightmap;
extern cvar_t *r_speeds; extern cvar_t *r_speeds;
extern cvar_t *r_decals; extern cvar_t *r_decals;
extern cvar_t *r_studio_decals; extern cvar_t *r_studio_decals;
extern cvar_t *r_hand; extern cvar_t *r_hand;
extern cvar_t *r_sunshadows; extern cvar_t *r_sunshadows;
extern cvar_t *r_sun_allowed; extern cvar_t *r_sun_allowed;
extern cvar_t *r_shadow_split_weight; extern cvar_t *r_shadow_split_weight;
extern cvar_t *r_wireframe; extern cvar_t *r_wireframe;
extern cvar_t *r_lightstyles; extern cvar_t *r_lightstyles;
extern cvar_t *r_polyoffset; extern cvar_t *r_polyoffset;
extern cvar_t *r_dynamic; extern cvar_t *r_dynamic;
extern cvar_t *r_finish; extern cvar_t *r_finish;
extern cvar_t *r_clear; extern cvar_t *r_clear;
extern cvar_t *r_grass; extern cvar_t *r_grass;
extern cvar_t *r_grass_alpha; extern cvar_t *r_grass_alpha;
extern cvar_t *r_grass_lighting; extern cvar_t *r_grass_lighting;
extern cvar_t *r_grass_shadows; extern cvar_t *r_grass_shadows;
extern cvar_t *r_grass_fade_start; extern cvar_t *r_grass_fade_start;
extern cvar_t *r_grass_fade_dist; extern cvar_t *r_grass_fade_dist;
extern cvar_t *r_scissor_glass_debug; extern cvar_t *r_scissor_glass_debug;
extern cvar_t *r_scissor_light_debug; extern cvar_t *r_scissor_light_debug;
extern cvar_t *r_showlightmaps; extern cvar_t *r_showlightmaps;
extern cvar_t *r_recursion_depth; extern cvar_t *r_recursion_depth;
extern cvar_t *r_shadowmap_size; extern cvar_t *r_shadowmap_size;
extern cvar_t *r_pssm_show_split; extern cvar_t *r_pssm_show_split;
extern cvar_t *v_sunshafts; extern cvar_t *v_sunshafts;
extern cvar_t *v_glows; extern cvar_t *v_glows;
extern "C" void DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity ); extern "C" void DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
// Macros to hook function calls into the HUD object // Macros to hook function calls into the HUD object
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x ); #define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \ #define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
{ \ { \
return gHUD.##y.MsgFunc_##x(pszName, iSize, pbuf ); \ return gHUD.##y.MsgFunc_##x(pszName, iSize, pbuf ); \
} }
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y ); #define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \ #define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
{ \ { \
gHUD.##y.UserCmd_##x( ); \ gHUD.##y.UserCmd_##x( ); \
} }
#define SPR_Set (*gEngfuncs.pfnSPR_Set) #define SPR_Set (*gEngfuncs.pfnSPR_Set)
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames) #define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
client_sprite_t *SPR2_GetList( char *psz, int *piCount ); // new version client_sprite_t *SPR2_GetList( char *psz, int *piCount ); // new version
// SPR_Draw draws a the current sprite as solid // SPR_Draw draws a the current sprite as solid
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw) #define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent) // SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles) #define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency) // SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive) #define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive)
// SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen. // SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen.
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor) #define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
// SPR_DisableScissor disables the clipping rect // SPR_DisableScissor disables the clipping rect
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor) #define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
// //
#define FillRGBA (*gEngfuncs.pfnFillRGBA) #define FillRGBA (*gEngfuncs.pfnFillRGBA)
// ScreenHeight returns the height of the screen, in pixels // ScreenHeight returns the height of the screen, in pixels
#define ScreenHeight (gHUD.m_scrinfo.iHeight) #define ScreenHeight (gHUD.m_scrinfo.iHeight)
// ScreenWidth returns the width of the screen, in pixels // ScreenWidth returns the width of the screen, in pixels
#define ScreenWidth (gHUD.m_scrinfo.iWidth) #define ScreenWidth (gHUD.m_scrinfo.iWidth)
// Use this to set any co-ords in 640x480 space // Use this to set any co-ords in 640x480 space
#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f)) #define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f))
#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f)) #define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f))
// use this to project world coordinates to screen coordinates // use this to project world coordinates to screen coordinates
#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f ) #define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f )
#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f ) #define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f )
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo) #define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
#define ServerCmd (*gEngfuncs.pfnServerCmd) #define ServerCmd (*gEngfuncs.pfnServerCmd)
#define ClientCmd (*gEngfuncs.pfnClientCmd) #define ClientCmd (*gEngfuncs.pfnClientCmd)
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair) #define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
#define AngleVectors (*gEngfuncs.pfnAngleVectors) #define AngleVectors (*gEngfuncs.pfnAngleVectors)
inline int ConsoleStringLen( const char *string ) inline int ConsoleStringLen( const char *string )
{ {
int _width, _height; int _width, _height;
GetConsoleStringSize( string, &_width, &_height ); GetConsoleStringSize( string, &_width, &_height );
return _width; return _width;
} }
// returns the players name of entity no. // returns the players name of entity no.
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo) #define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
#define max(a, b) (((a) > (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b))
#define fabs(x) ((x) > 0 ? (x) : 0 - (x)) #define fabs(x) ((x) > 0 ? (x) : 0 - (x))
void ScaleColors( int &r, int &g, int &b, int a ); void ScaleColors( int &r, int &g, int &b, int a );
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} #define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} #define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) #define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;} inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;}
float Length(const float *v); float Length(const float *v);
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc); void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
void VectorScale (const float *in, float scale, float *out); void VectorScale (const float *in, float scale, float *out);
float VectorNormalize (float *v); float VectorNormalize (float *v);
extern vec3_t vec3_origin; extern vec3_t vec3_origin;
extern struct ref_params_s *g_pViewParams; extern struct ref_params_s *g_pViewParams;
// disable 'possible loss of data converting float to int' warning message // disable 'possible loss of data converting float to int' warning message
#pragma warning( disable: 4244 ) #pragma warning( disable: 4244 )
// disable 'truncation from 'const double' to 'float' warning message // disable 'truncation from 'const double' to 'float' warning message
#pragma warning( disable: 4305 ) #pragma warning( disable: 4305 )
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\ inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
{\ {\
r = (ulRGB & 0xFF0000) >>16;\ r = (ulRGB & 0xFF0000) >>16;\
g = (ulRGB & 0xFF00) >> 8;\ g = (ulRGB & 0xFF00) >> 8;\
b = ulRGB & 0xFF;\ b = ulRGB & 0xFF;\
} }
inline unsigned int PackRGBA( int r, int g, int b, int a ) inline unsigned int PackRGBA( int r, int g, int b, int a )
{ {
r = bound( 0, r, 255 ); r = bound( 0, r, 255 );
g = bound( 0, g, 255 ); g = bound( 0, g, 255 );
b = bound( 0, b, 255 ); b = bound( 0, b, 255 );
a = bound( 0, a, 255 ); a = bound( 0, a, 255 );
return ((a)<<24|(r)<<16|(g)<<8|(b)); return ((a)<<24|(r)<<16|(g)<<8|(b));
} }
inline void UnpackRGBA( int &r, int &g, int &b, int &a, unsigned int ulRGBA ) inline void UnpackRGBA( int &r, int &g, int &b, int &a, unsigned int ulRGBA )
{ {
a = (ulRGBA & 0xFF000000) >> 24; a = (ulRGBA & 0xFF000000) >> 24;
r = (ulRGBA & 0xFF0000) >> 16; r = (ulRGBA & 0xFF0000) >> 16;
g = (ulRGBA & 0xFF00) >> 8; g = (ulRGBA & 0xFF00) >> 8;
b = (ulRGBA & 0xFF) >> 0; b = (ulRGBA & 0xFF) >> 0;
} }
float PackColor( const color24 &color ); float PackColor( const color24 &color );
color24 UnpackColor( float pack ); color24 UnpackColor( float pack );
HSPRITE LoadSprite(const char *pszName); HSPRITE LoadSprite(const char *pszName);
#define CHECKVISBIT( vis, b ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] & (1 << ((b) & 7))) : (byte)false ) #define CHECKVISBIT( vis, b ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] & (1 << ((b) & 7))) : (byte)false )
#define SETVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] |= (1 << ((b) & 7))) : (byte)false ) #define SETVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] |= (1 << ((b) & 7))) : (byte)false )
#define CLEARVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] &= ~(1 << ((b) & 7))) : (byte)false ) #define CLEARVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] &= ~(1 << ((b) & 7))) : (byte)false )
typedef struct leaflist_s typedef struct leaflist_s
{ {
int count; int count;
int maxcount; int maxcount;
bool overflowed; bool overflowed;
short *list; short *list;
Vector mins, maxs; Vector mins, maxs;
struct mnode_s *headnode; // for overflows where each leaf can't be stored individually struct mnode_s *headnode; // for overflows where each leaf can't be stored individually
} leaflist_t; } leaflist_t;
struct mleaf_s *Mod_PointInLeaf( const Vector &p, struct mnode_s *node ); struct mleaf_s *Mod_PointInLeaf( const Vector &p, struct mnode_s *node );
byte *Mod_LeafPVS( struct mleaf_s *leaf, struct model_s *model ); byte *Mod_LeafPVS( struct mleaf_s *leaf, struct model_s *model );
byte *Mod_GetCurrentVis( void ); byte *Mod_GetCurrentVis( void );
bool Mod_BoxVisible( const Vector &mins, const Vector &maxs, const byte *visbits ); bool Mod_BoxVisible( const Vector &mins, const Vector &maxs, const byte *visbits );
bool Mod_CheckEntityPVS( cl_entity_t *ent ); bool Mod_CheckEntityPVS( cl_entity_t *ent );
bool Mod_CheckTempEntityPVS( struct tempent_s *pTemp ); bool Mod_CheckTempEntityPVS( struct tempent_s *pTemp );
bool Mod_CheckEntityLeafPVS( const Vector &absmin, const Vector &absmax, struct mleaf_s *leaf ); bool Mod_CheckEntityLeafPVS( const Vector &absmin, const Vector &absmax, struct mleaf_s *leaf );
bool Mod_CheckBoxVisible( const Vector &absmin, const Vector &absmax ); bool Mod_CheckBoxVisible( const Vector &absmin, const Vector &absmax );
void Mod_GetFrames( int modelIndex, int &numFrames ); void Mod_GetFrames( int modelIndex, int &numFrames );
struct model_s *Mod_Handle( int modelIndex ); struct model_s *Mod_Handle( int modelIndex );
bool Mod_PointInSolid( const Vector &p ); bool Mod_PointInSolid( const Vector &p );
int Mod_GetType( int modelIndex ); int Mod_GetType( int modelIndex );
extern void ParseRain( void ); extern void ParseRain( void );
extern int CL_IsDead( void ); extern int CL_IsDead( void );
void SetDLightVis( struct mworldlight_s *wl, int leafnum ); void SetDLightVis( struct mworldlight_s *wl, int leafnum );
void MergeDLightVis( struct mworldlight_s *wl, int leafnum ); void MergeDLightVis( struct mworldlight_s *wl, int leafnum );
bool UTIL_IsPlayer( int idx ); bool UTIL_IsPlayer( int idx );
bool UTIL_IsLocal( int idx ); bool UTIL_IsLocal( int idx );
void UTIL_WeaponAnimation( int iAnim, float framerate ); void UTIL_WeaponAnimation( int iAnim, float framerate );
void UTIL_StudioDecal( const char *pDecalName, struct pmtrace_s *pTrace, const Vector &vecSrc ); void UTIL_StudioDecal( const char *pDecalName, struct pmtrace_s *pTrace, const Vector &vecSrc );
bool R_ScissorForAABB( const Vector &absmin, const Vector &absmax, float *x, float *y, float *w, float *h ); bool R_ScissorForAABB( const Vector &absmin, const Vector &absmax, float *x, float *y, float *w, float *h );
bool R_AABBToScreen( const Vector &absmin, const Vector &absmax, Vector2D &scrmin, Vector2D &scrmax, wrect_t *rect = NULL ); bool R_AABBToScreen( const Vector &absmin, const Vector &absmax, Vector2D &scrmin, Vector2D &scrmax, wrect_t *rect = NULL );
bool R_ScissorForFrustum( class CFrustum *frustum, float *x, float *y, float *w, float *h ); bool R_ScissorForFrustum( class CFrustum *frustum, float *x, float *y, float *w, float *h );
void R_DrawScissorRectangle( float x, float y, float w, float h ); void R_DrawScissorRectangle( float x, float y, float w, float h );
int WorldToScreen( const Vector &world, Vector &screen ); int WorldToScreen( const Vector &world, Vector &screen );
void R_TransformWorldToDevice( const Vector &world, Vector &ndc ); void R_TransformWorldToDevice( const Vector &world, Vector &ndc );
void R_TransformDeviceToScreen( const Vector &ndc, Vector &screen ); void R_TransformDeviceToScreen( const Vector &ndc, Vector &screen );
float ComputePixelWidthOfSphere( const Vector& vecOrigin, float flRadius ); float ComputePixelWidthOfSphere( const Vector& vecOrigin, float flRadius );
bool R_SkyIsVisible( void ); bool R_SkyIsVisible( void );
bool R_ClipPolygon( int numPoints, Vector *points, const struct mplane_s *plane, int *numClipped, Vector *clipped ); bool R_ClipPolygon( int numPoints, Vector *points, const struct mplane_s *plane, int *numClipped, Vector *clipped );
void R_SplitPolygon( int numPoints, Vector *points, const struct mplane_s *plane, int *numFront, Vector *front, int *numBack, Vector *back ); void R_SplitPolygon( int numPoints, Vector *points, const struct mplane_s *plane, int *numFront, Vector *front, int *numBack, Vector *back );
// dll managment // dll managment
bool Sys_LoadLibrary( const char *dllname, dllhandle_t *handle, const dllfunc_t *fcts = NULL ); bool Sys_LoadLibrary( const char *dllname, dllhandle_t *handle, const dllfunc_t *fcts = NULL );
void *Sys_GetProcAddress( dllhandle_t handle, const char *name ); void *Sys_GetProcAddress( dllhandle_t handle, const char *name );
void Sys_FreeLibrary( dllhandle_t *handle ); void Sys_FreeLibrary( dllhandle_t *handle );
bool Sys_RemoveFile( const char *path ); bool Sys_RemoveFile( const char *path );
void UTIL_CreateAurora( cl_entity_t *ent, const char *file, int attachment, float lifetime = 0.0f ); void UTIL_CreateAurora( cl_entity_t *ent, const char *file, int attachment, float lifetime = 0.0f );
void UTIL_RemoveAurora( cl_entity_t *ent ); void UTIL_RemoveAurora( cl_entity_t *ent );
extern void AngleMatrix (const float *angles, float (*matrix)[4] ); extern void AngleMatrix (const float *angles, float (*matrix)[4] );
extern void VectorTransform (const float *in1, float in2[3][4], float *out); extern void VectorTransform (const float *in1, float in2[3][4], float *out);
extern void SetPoint( float x, float y, float z, float (*matrix)[4]); extern void SetPoint( float x, float y, float z, float (*matrix)[4]);
extern void CreateDecal( const Vector &p, const Vector &n, float ang, const char *sz, int flags = 0, int eIdx = 0, int mIdx = 0, bool source = true ); extern void CreateDecal( const Vector &p, const Vector &n, float ang, const char *sz, int flags = 0, int eIdx = 0, int mIdx = 0, bool source = true );
extern void CreateDecal( struct pmtrace_s *tr, const char *name, float angle, bool visent = false ); extern void CreateDecal( struct pmtrace_s *tr, const char *name, float angle, bool visent = false );
extern void Physic_SweepTest( struct cl_entity_s *pTouch, const Vector &start, const Vector &mins, const Vector &maxs, const Vector &end, trace_t *tr ); extern void Physic_SweepTest( struct cl_entity_s *pTouch, const Vector &start, const Vector &mins, const Vector &maxs, const Vector &end, trace_t *tr );
extern void BuildGammaTable( void ); extern void BuildGammaTable( void );
extern float TextureToLinear( int c ); extern float TextureToLinear( int c );
extern int LinearToTexture( float f ); extern int LinearToTexture( float f );
extern void GL_GpuMemUsage_f( void ); extern void GL_GpuMemUsage_f( void );

View File

@ -1,108 +1,108 @@
/************************************ /************************************
simple memory allocator simple memory allocator
by BUzer by BUzer
************************************/ ************************************/
template <class T> template <class T>
class MemBlock class MemBlock
{ {
typedef struct chunk_s { typedef struct chunk_s {
int next; int next;
T data; T data;
} chunk_t; } chunk_t;
public: public:
MemBlock(int numElements) MemBlock(int numElements)
{ {
// ýëåìåíò 0 èñïîëüçóåòñÿ â êà÷åñòâå íà÷àëà ñïèñêà çàíÿòûõ ÿ÷ååê // ýëåìåíò 0 èñïîëüçóåòñÿ â êà÷åñòâå íà÷àëà ñïèñêà çàíÿòûõ ÿ÷ååê
m_iArraySize = numElements + 1; m_iArraySize = numElements + 1;
m_pArray = new chunk_t[m_iArraySize]; m_pArray = new chunk_t[m_iArraySize];
if (!m_pArray) if (!m_pArray)
{ {
m_iArraySize = 1; m_iArraySize = 1;
m_iFirstFree = m_iArraySize; m_iFirstFree = m_iArraySize;
return; return;
} }
Clear(); Clear();
} }
~MemBlock() ~MemBlock()
{ {
delete[] m_pArray; delete[] m_pArray;
m_pArray = NULL; m_pArray = NULL;
} }
void Clear( void ) void Clear( void )
{ {
if (m_iArraySize > 1) if (m_iArraySize > 1)
{ {
m_pArray[0].next = 0; // åñëè îí ññûëàåòñÿ ñàì íà ñåáÿ, çíà÷èò ñïèñîê çàíÿòûõ ïóñò m_pArray[0].next = 0; // åñëè îí ññûëàåòñÿ ñàì íà ñåáÿ, çíà÷èò ñïèñîê çàíÿòûõ ïóñò
m_iFirstFree = 1; m_iFirstFree = 1;
for (int i = 1; i < m_iArraySize; ++i) for (int i = 1; i < m_iArraySize; ++i)
m_pArray[i].next = i + 1; m_pArray[i].next = i + 1;
} }
} }
T* Allocate( void ) T* Allocate( void )
{ {
if (m_iFirstFree != m_iArraySize) if (m_iFirstFree != m_iArraySize)
{ {
int savedFirstFree = m_pArray[m_iFirstFree].next; int savedFirstFree = m_pArray[m_iFirstFree].next;
m_pArray[m_iFirstFree].next = m_pArray[0].next; // äîáàâëÿåì ñâîáîäíóþ ÿ÷åéêó â m_pArray[m_iFirstFree].next = m_pArray[0].next; // äîáàâëÿåì ñâîáîäíóþ ÿ÷åéêó â
m_pArray[0].next = m_iFirstFree; // ñïèñîê çàíÿòûõ m_pArray[0].next = m_iFirstFree; // ñïèñîê çàíÿòûõ
m_iFirstFree = savedFirstFree; // èñêëþ÷àåì ÿ÷åéêó èç ñïèñêà ñâîáîäíûõ m_iFirstFree = savedFirstFree; // èñêëþ÷àåì ÿ÷åéêó èç ñïèñêà ñâîáîäíûõ
return &(m_pArray[m_pArray[0].next].data); return &(m_pArray[m_pArray[0].next].data);
} }
else else
return NULL; return NULL;
} }
bool IsClear( void ) bool IsClear( void )
{ {
return m_pArray[0].next ? false : true; return m_pArray[0].next ? false : true;
} }
bool StartPass( void ) bool StartPass( void )
{ {
m_iCurrent = 0; // íà÷èíàåì îáõîä ñ íóëåâîãî ýëåìåíòà m_iCurrent = 0; // íà÷èíàåì îáõîä ñ íóëåâîãî ýëåìåíòà
if (m_iArraySize > 1) if (m_iArraySize > 1)
return true; return true;
else else
return false; return false;
} }
T* GetCurrent( void ) T* GetCurrent( void )
{ {
int retindex = m_pArray[m_iCurrent].next; int retindex = m_pArray[m_iCurrent].next;
if (!retindex) if (!retindex)
return NULL; return NULL;
return &(m_pArray[retindex].data); return &(m_pArray[retindex].data);
} }
void MoveNext( void ) void MoveNext( void )
{ {
m_iCurrent = m_pArray[m_iCurrent].next; m_iCurrent = m_pArray[m_iCurrent].next;
} }
void DeleteCurrent( void ) void DeleteCurrent( void )
{ {
int delindex = m_pArray[m_iCurrent].next; int delindex = m_pArray[m_iCurrent].next;
m_pArray[m_iCurrent].next = m_pArray[delindex].next; // âûáðàñûâàåì ýëåìåíò èç öåïè çàíÿòûõ m_pArray[m_iCurrent].next = m_pArray[delindex].next; // âûáðàñûâàåì ýëåìåíò èç öåïè çàíÿòûõ
m_pArray[delindex].next = m_iFirstFree; m_pArray[delindex].next = m_iFirstFree;
m_iFirstFree = delindex; // âêëþ÷àåì ýëåìåíò â íà÷àëî öåïè ñâîáîäíûõ m_iFirstFree = delindex; // âêëþ÷àåì ýëåìåíò â íà÷àëî öåïè ñâîáîäíûõ
} }
private: private:
chunk_t *m_pArray; chunk_t *m_pArray;
int m_iArraySize; int m_iArraySize;
int m_iCurrent; // äëÿ ïðîõîæäåíèÿ ÷åðåç ìàññèâ int m_iCurrent; // äëÿ ïðîõîæäåíèÿ ÷åðåç ìàññèâ
int m_iFirstFree; // íà÷àëî ñïèñêà ñâîáîäíûõ ýëåìåíòîâ int m_iFirstFree; // íà÷àëî ñïèñêà ñâîáîäíûõ ýëåìåíòîâ
}; };

View File

@ -1,297 +1,297 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// death notice // death notice
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "vgui_TeamFortressViewport.h" #include "vgui_TeamFortressViewport.h"
DECLARE_MESSAGE( m_DeathNotice, DeathMsg ); DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
struct DeathNoticeItem { struct DeathNoticeItem {
char szKiller[MAX_PLAYER_NAME_LENGTH*2]; char szKiller[MAX_PLAYER_NAME_LENGTH*2];
char szVictim[MAX_PLAYER_NAME_LENGTH*2]; char szVictim[MAX_PLAYER_NAME_LENGTH*2];
int iId; // the index number of the associated sprite int iId; // the index number of the associated sprite
int iSuicide; int iSuicide;
int iTeamKill; int iTeamKill;
int iNonPlayerKill; int iNonPlayerKill;
float flDisplayTime; float flDisplayTime;
float *KillerColor; float *KillerColor;
float *VictimColor; float *VictimColor;
}; };
#define MAX_DEATHNOTICES 4 #define MAX_DEATHNOTICES 4
static int DEATHNOTICE_DISPLAY_TIME = 6; static int DEATHNOTICE_DISPLAY_TIME = 6;
#define DEATHNOTICE_TOP 32 #define DEATHNOTICE_TOP 32
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ]; DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 }; float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
float g_ColorRed[3] = { 1.0, 0.25, 0.25 }; float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 }; float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 }; float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 }; float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
float *GetClientColor( int clientIndex ) float *GetClientColor( int clientIndex )
{ {
switch ( g_PlayerExtraInfo[clientIndex].teamnumber ) switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
{ {
case 1: return g_ColorBlue; case 1: return g_ColorBlue;
case 2: return g_ColorRed; case 2: return g_ColorRed;
case 3: return g_ColorYellow; case 3: return g_ColorYellow;
case 4: return g_ColorGreen; case 4: return g_ColorGreen;
case 0: return g_ColorYellow; case 0: return g_ColorYellow;
default : return g_ColorGrey; default : return g_ColorGrey;
} }
return NULL; return NULL;
} }
int CHudDeathNotice :: Init( void ) int CHudDeathNotice :: Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
HOOK_MESSAGE( DeathMsg ); HOOK_MESSAGE( DeathMsg );
CVAR_REGISTER( "hud_deathnotice_time", "6", 0 ); CVAR_REGISTER( "hud_deathnotice_time", "6", 0 );
return 1; return 1;
} }
void CHudDeathNotice :: InitHUDData( void ) void CHudDeathNotice :: InitHUDData( void )
{ {
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) ); memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
} }
int CHudDeathNotice :: VidInit( void ) int CHudDeathNotice :: VidInit( void )
{ {
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" ); m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
return 1; return 1;
} }
int CHudDeathNotice :: Draw( float flTime ) int CHudDeathNotice :: Draw( float flTime )
{ {
int x, y, r, g, b; int x, y, r, g, b;
for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
{ {
if ( rgDeathNoticeList[i].iId == 0 ) if ( rgDeathNoticeList[i].iId == 0 )
break; // we've gone through them all break; // we've gone through them all
if ( rgDeathNoticeList[i].flDisplayTime < flTime ) if ( rgDeathNoticeList[i].flDisplayTime < flTime )
{ // display time has expired { // display time has expired
// remove the current item from the list // remove the current item from the list
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) ); memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
i--; // continue on the next item; stop the counter getting incremented i--; // continue on the next item; stop the counter getting incremented
continue; continue;
} }
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME ); rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
// Only draw if the viewport will let me // Only draw if the viewport will let me
if ( gViewPort && gViewPort->AllowedToPrintText() ) if ( gViewPort && gViewPort->AllowedToPrintText() )
{ {
// Draw the death notice // Draw the death notice
y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!! y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!!
int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId;
x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
if ( !rgDeathNoticeList[i].iSuicide ) if ( !rgDeathNoticeList[i].iSuicide )
{ {
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
// Draw killers name // Draw killers name
if ( rgDeathNoticeList[i].KillerColor ) if ( rgDeathNoticeList[i].KillerColor )
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] ); gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller ); x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
} }
r = 255; g = 80; b = 0; r = 255; g = 80; b = 0;
if ( rgDeathNoticeList[i].iTeamKill ) if ( rgDeathNoticeList[i].iTeamKill )
{ {
r = 10; g = 240; b = 10; // display it in sickly green r = 10; g = 240; b = 10; // display it in sickly green
} }
// Draw death weapon // Draw death weapon
SPR_Set( gHUD.GetSprite(id), r, g, b ); SPR_Set( gHUD.GetSprite(id), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
// Draw victims name (if it was a player that was killed) // Draw victims name (if it was a player that was killed)
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE) if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
{ {
if ( rgDeathNoticeList[i].VictimColor ) if ( rgDeathNoticeList[i].VictimColor )
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] ); gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim ); x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
} }
} }
} }
return 1; return 1;
} }
// This message handler may be better off elsewhere // This message handler may be better off elsewhere
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf ) int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
{ {
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int killer = READ_BYTE(); int killer = READ_BYTE();
int victim = READ_BYTE(); int victim = READ_BYTE();
char killedwith[32]; char killedwith[32];
strcpy( killedwith, "d_" ); strcpy( killedwith, "d_" );
strncat( killedwith, READ_STRING(), 32 ); strncat( killedwith, READ_STRING(), 32 );
if (gViewPort) if (gViewPort)
gViewPort->DeathMsg( killer, victim ); gViewPort->DeathMsg( killer, victim );
gHUD.m_Spectator.DeathMessage(victim); gHUD.m_Spectator.DeathMessage(victim);
for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
{ {
if ( rgDeathNoticeList[i].iId == 0 ) if ( rgDeathNoticeList[i].iId == 0 )
break; break;
} }
if ( i == MAX_DEATHNOTICES ) if ( i == MAX_DEATHNOTICES )
{ // move the rest of the list forward to make room for this item { // move the rest of the list forward to make room for this item
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES ); memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
i = MAX_DEATHNOTICES - 1; i = MAX_DEATHNOTICES - 1;
} }
if (gViewPort) if (gViewPort)
gViewPort->GetAllPlayersInfo(); gViewPort->GetAllPlayersInfo();
// Get the Killer's name // Get the Killer's name
char *killer_name = g_PlayerInfoList[ killer ].name; char *killer_name = g_PlayerInfoList[ killer ].name;
if ( !killer_name ) if ( !killer_name )
{ {
killer_name = ""; killer_name = "";
rgDeathNoticeList[i].szKiller[0] = 0; rgDeathNoticeList[i].szKiller[0] = 0;
} }
else else
{ {
rgDeathNoticeList[i].KillerColor = GetClientColor( killer ); rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH ); strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0; rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
} }
// Get the Victim's name // Get the Victim's name
char *victim_name = NULL; char *victim_name = NULL;
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun) // If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
if ( ((char)victim) != -1 ) if ( ((char)victim) != -1 )
victim_name = g_PlayerInfoList[ victim ].name; victim_name = g_PlayerInfoList[ victim ].name;
if ( !victim_name ) if ( !victim_name )
{ {
victim_name = ""; victim_name = "";
rgDeathNoticeList[i].szVictim[0] = 0; rgDeathNoticeList[i].szVictim[0] = 0;
} }
else else
{ {
rgDeathNoticeList[i].VictimColor = GetClientColor( victim ); rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH ); strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0; rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
} }
// Is it a non-player object kill? // Is it a non-player object kill?
if ( ((char)victim) == -1 ) if ( ((char)victim) == -1 )
{ {
rgDeathNoticeList[i].iNonPlayerKill = TRUE; rgDeathNoticeList[i].iNonPlayerKill = TRUE;
// Store the object's name in the Victim slot (skip the d_ bit) // Store the object's name in the Victim slot (skip the d_ bit)
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 ); strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 );
} }
else else
{ {
if ( killer == victim || killer == 0 ) if ( killer == victim || killer == 0 )
rgDeathNoticeList[i].iSuicide = TRUE; rgDeathNoticeList[i].iSuicide = TRUE;
if ( !strcmp( killedwith, "d_teammate" ) ) if ( !strcmp( killedwith, "d_teammate" ) )
rgDeathNoticeList[i].iTeamKill = TRUE; rgDeathNoticeList[i].iTeamKill = TRUE;
} }
// Find the sprite in the list // Find the sprite in the list
int spr = gHUD.GetSpriteIndex( killedwith ); int spr = gHUD.GetSpriteIndex( killedwith );
rgDeathNoticeList[i].iId = spr; rgDeathNoticeList[i].iId = spr;
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" ); DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME; rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
if (rgDeathNoticeList[i].iNonPlayerKill) if (rgDeathNoticeList[i].iNonPlayerKill)
{ {
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed a " ); ConsolePrint( " killed a " );
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint( "\n" ); ConsolePrint( "\n" );
} }
else else
{ {
// record the death notice in the console // record the death notice in the console
if ( rgDeathNoticeList[i].iSuicide ) if ( rgDeathNoticeList[i].iSuicide )
{ {
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
if ( !strcmp( killedwith, "d_world" ) ) if ( !strcmp( killedwith, "d_world" ) )
{ {
ConsolePrint( " died" ); ConsolePrint( " died" );
} }
else else
{ {
ConsolePrint( " killed self" ); ConsolePrint( " killed self" );
} }
} }
else if ( rgDeathNoticeList[i].iTeamKill ) else if ( rgDeathNoticeList[i].iTeamKill )
{ {
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed his teammate " ); ConsolePrint( " killed his teammate " );
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
} }
else else
{ {
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed " ); ConsolePrint( " killed " );
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
} }
if ( killedwith && *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill ) if ( killedwith && *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
{ {
ConsolePrint( " with " ); ConsolePrint( " with " );
ConsolePrint( killedwith+2 ); // skip over the "d_" part ConsolePrint( killedwith+2 ); // skip over the "d_" part
} }
ConsolePrint( "\n" ); ConsolePrint( "\n" );
} }
return 1; return 1;
} }

View File

@ -1,103 +1,103 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "demo.h" #include "demo.h"
#include "demo_api.h" #include "demo_api.h"
#include <memory.h> #include <memory.h>
#define DLLEXPORT __declspec( dllexport ) #define DLLEXPORT __declspec( dllexport )
int g_demosniper = 0; int g_demosniper = 0;
int g_demosniperdamage = 0; int g_demosniperdamage = 0;
float g_demosniperorg[3]; float g_demosniperorg[3];
float g_demosniperangles[3]; float g_demosniperangles[3];
float g_demozoom; float g_demozoom;
// FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap. // FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap.
extern "C" extern "C"
{ {
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer ); void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
} }
/* /*
===================== =====================
Demo_WriteBuffer Demo_WriteBuffer
Write some data to the demo stream Write some data to the demo stream
===================== =====================
*/ */
void Demo_WriteBuffer( int type, int size, unsigned char *buffer ) void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
{ {
int pos = 0; int pos = 0;
unsigned char buf[ 32 * 1024 ]; unsigned char buf[ 32 * 1024 ];
*( int * )&buf[pos] = type; *( int * )&buf[pos] = type;
pos+=sizeof( int ); pos+=sizeof( int );
memcpy( &buf[pos], buffer, size ); memcpy( &buf[pos], buffer, size );
// Write full buffer out // Write full buffer out
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf ); gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
} }
/* /*
===================== =====================
Demo_ReadBuffer Demo_ReadBuffer
Engine wants us to parse some data from the demo stream Engine wants us to parse some data from the demo stream
===================== =====================
*/ */
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer ) void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
{ {
int type; int type;
int i = 0; int i = 0;
type = *( int * )buffer; type = *( int * )buffer;
i += sizeof( int ); i += sizeof( int );
switch ( type ) switch ( type )
{ {
case TYPE_SNIPERDOT: case TYPE_SNIPERDOT:
g_demosniper = *(int * )&buffer[ i ]; g_demosniper = *(int * )&buffer[ i ];
i += sizeof( int ); i += sizeof( int );
if ( g_demosniper ) if ( g_demosniper )
{ {
g_demosniperdamage = *( int * )&buffer[ i ]; g_demosniperdamage = *( int * )&buffer[ i ];
i += sizeof( int ); i += sizeof( int );
g_demosniperangles[ 0 ] = *(float *)&buffer[i]; g_demosniperangles[ 0 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperangles[ 1 ] = *(float *)&buffer[i]; g_demosniperangles[ 1 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperangles[ 2 ] = *(float *)&buffer[i]; g_demosniperangles[ 2 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperorg[ 0 ] = *(float *)&buffer[i]; g_demosniperorg[ 0 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperorg[ 1 ] = *(float *)&buffer[i]; g_demosniperorg[ 1 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperorg[ 2 ] = *(float *)&buffer[i]; g_demosniperorg[ 2 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
} }
break; break;
case TYPE_ZOOM: case TYPE_ZOOM:
g_demozoom = *(float * )&buffer[ i ]; g_demozoom = *(float * )&buffer[ i ];
i += sizeof( float ); i += sizeof( float );
break; break;
default: default:
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" ); gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
break; break;
} }
} }

View File

@ -1,27 +1,27 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#if !defined( DEMOH ) #if !defined( DEMOH )
#define DEMOH #define DEMOH
#pragma once #pragma once
// Types of demo messages we can write/parse // Types of demo messages we can write/parse
enum enum
{ {
TYPE_SNIPERDOT = 0, TYPE_SNIPERDOT = 0,
TYPE_ZOOM TYPE_ZOOM
}; };
void Demo_WriteBuffer( int type, int size, unsigned char *buffer ); void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
extern int g_demosniper; extern int g_demosniper;
extern int g_demosniperdamage; extern int g_demosniperdamage;
extern float g_demosniperorg[3]; extern float g_demosniperorg[3];
extern float g_demosniperangles[3]; extern float g_demosniperangles[3];
extern float g_demozoom; extern float g_demozoom;
#endif #endif

View File

@ -1,173 +1,173 @@
/* /*
enginecallback.h - actual engine callbacks enginecallback.h - actual engine callbacks
Copyright (C) 2011 Uncle Mike Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef ENGINECALLBACK_H #ifndef ENGINECALLBACK_H
#define ENGINECALLBACK_H #define ENGINECALLBACK_H
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
extern render_api_t gRenderfuncs; extern render_api_t gRenderfuncs;
#define GET_CLIENT_TIME (*gEngfuncs.GetClientTime) #define GET_CLIENT_TIME (*gEngfuncs.GetClientTime)
#define GET_CLIENT_OLDTIME (*gEngfuncs.GetClientOldTime) #define GET_CLIENT_OLDTIME (*gEngfuncs.GetClientOldTime)
#define CVAR_REGISTER (*gEngfuncs.pfnRegisterVariable) #define CVAR_REGISTER (*gEngfuncs.pfnRegisterVariable)
#define CVAR_GET_FLOAT (*gEngfuncs.pfnGetCvarFloat) #define CVAR_GET_FLOAT (*gEngfuncs.pfnGetCvarFloat)
#define CVAR_GET_STRING (*gEngfuncs.pfnGetCvarString) #define CVAR_GET_STRING (*gEngfuncs.pfnGetCvarString)
#define CVAR_SET_FLOAT (*gEngfuncs.Cvar_SetValue) #define CVAR_SET_FLOAT (*gEngfuncs.Cvar_SetValue)
//#define CVAR_SET_STRING (*gEngfuncs.pfnCVarSetString) // not implemented //#define CVAR_SET_STRING (*gEngfuncs.pfnCVarSetString) // not implemented
#define CVAR_GET_POINTER (*gEngfuncs.pfnGetCvarPointer) #define CVAR_GET_POINTER (*gEngfuncs.pfnGetCvarPointer)
#define ADD_COMMAND (*gEngfuncs.pfnAddCommand) #define ADD_COMMAND (*gEngfuncs.pfnAddCommand)
#define CMD_ARGC (*gEngfuncs.Cmd_Argc) #define CMD_ARGC (*gEngfuncs.Cmd_Argc)
#define CMD_ARGV (*gEngfuncs.Cmd_Argv) #define CMD_ARGV (*gEngfuncs.Cmd_Argv)
#define Msg (*gEngfuncs.Con_Printf) #define Msg (*gEngfuncs.Con_Printf)
#define GET_LOCAL_PLAYER (*gEngfuncs.GetLocalPlayer) #define GET_LOCAL_PLAYER (*gEngfuncs.GetLocalPlayer)
#define GET_VIEWMODEL (*gEngfuncs.GetViewModel) #define GET_VIEWMODEL (*gEngfuncs.GetViewModel)
#define GET_ENTITY (*gEngfuncs.GetEntityByIndex) #define GET_ENTITY (*gEngfuncs.GetEntityByIndex)
#define POINT_CONTENTS( p ) (*gEngfuncs.PM_PointContents)( p, NULL ) #define POINT_CONTENTS( p ) (*gEngfuncs.PM_PointContents)( p, NULL )
#define WATER_ENTITY (*gEngfuncs.PM_WaterEntity) #define WATER_ENTITY (*gEngfuncs.PM_WaterEntity)
#define RANDOM_LONG (*gEngfuncs.pfnRandomLong) #define RANDOM_LONG (*gEngfuncs.pfnRandomLong)
#define RANDOM_FLOAT (*gEngfuncs.pfnRandomFloat) #define RANDOM_FLOAT (*gEngfuncs.pfnRandomFloat)
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo) #define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
#define ServerCmd (*gEngfuncs.pfnServerCmd) #define ServerCmd (*gEngfuncs.pfnServerCmd)
#define ClientCmd (*gEngfuncs.pfnClientCmd) #define ClientCmd (*gEngfuncs.pfnClientCmd)
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair) #define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
#define AngleVectors (*gEngfuncs.pfnAngleVectors) #define AngleVectors (*gEngfuncs.pfnAngleVectors)
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo) #define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
#define SPR_Load (*gEngfuncs.pfnSPR_Load) #define SPR_Load (*gEngfuncs.pfnSPR_Load)
#define SPR_Set (*gEngfuncs.pfnSPR_Set) #define SPR_Set (*gEngfuncs.pfnSPR_Set)
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames) #define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw) #define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles) #define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive) #define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive)
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor) #define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor) #define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
#define FillRGBA (*gEngfuncs.pfnFillRGBA) #define FillRGBA (*gEngfuncs.pfnFillRGBA)
#define SPR_Height (*gEngfuncs.pfnSPR_Height) #define SPR_Height (*gEngfuncs.pfnSPR_Height)
#define SPR_Width (*gEngfuncs.pfnSPR_Width) #define SPR_Width (*gEngfuncs.pfnSPR_Width)
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList) #define SPR_GetList (*gEngfuncs.pfnSPR_GetList)
#define SPR_LoadEx (*gRenderfuncs.SPR_LoadExt) #define SPR_LoadEx (*gRenderfuncs.SPR_LoadExt)
#define ConsolePrint (*gEngfuncs.pfnConsolePrint) #define ConsolePrint (*gEngfuncs.pfnConsolePrint)
#define CenterPrint (*gEngfuncs.pfnCenterPrint) #define CenterPrint (*gEngfuncs.pfnCenterPrint)
#define TextMessageGet (*gEngfuncs.pfnTextMessageGet) #define TextMessageGet (*gEngfuncs.pfnTextMessageGet)
#define TextMessageDrawChar (*gEngfuncs.pfnDrawCharacter) #define TextMessageDrawChar (*gEngfuncs.pfnDrawCharacter)
#define DrawConsoleString (*gEngfuncs.pfnDrawConsoleString) #define DrawConsoleString (*gEngfuncs.pfnDrawConsoleString)
#define GetConsoleStringSize (*gEngfuncs.pfnDrawConsoleStringLen) #define GetConsoleStringSize (*gEngfuncs.pfnDrawConsoleStringLen)
#define DrawSetTextColor (*gEngfuncs.pfnDrawSetTextColor) #define DrawSetTextColor (*gEngfuncs.pfnDrawSetTextColor)
#define LOAD_FILE( x, y ) (*gEngfuncs.COM_LoadFile)( x, 5, y ) #define LOAD_FILE( x, y ) (*gEngfuncs.COM_LoadFile)( x, 5, y )
#define FREE_FILE (*gEngfuncs.COM_FreeFile) #define FREE_FILE (*gEngfuncs.COM_FreeFile)
#define SAVE_FILE (*gRenderfuncs.pfnSaveFile) #define SAVE_FILE (*gRenderfuncs.pfnSaveFile)
#define Sys_DoubleTime (*gRenderfuncs.pfnTime) #define Sys_DoubleTime (*gRenderfuncs.pfnTime)
// sound functions (we can't use macroses - this names is collide with standard windows methods) // sound functions (we can't use macroses - this names is collide with standard windows methods)
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); } inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
// render api callbacks // render api callbacks
#define RENDER_GET_PARM (*gRenderfuncs.RenderGetParm) #define RENDER_GET_PARM (*gRenderfuncs.RenderGetParm)
#define SET_CURRENT_ENTITY (*gRenderfuncs.R_SetCurrentEntity) #define SET_CURRENT_ENTITY (*gRenderfuncs.R_SetCurrentEntity)
#define SET_CURRENT_MODEL (*gRenderfuncs.R_SetCurrentModel) #define SET_CURRENT_MODEL (*gRenderfuncs.R_SetCurrentModel)
#define ENGINE_SET_PVS (*gRenderfuncs.R_FatPVS) #define ENGINE_SET_PVS (*gRenderfuncs.R_FatPVS)
#define HOST_ERROR (*gRenderfuncs.Host_Error) #define HOST_ERROR (*gRenderfuncs.Host_Error)
#define GET_LIGHTSTYLE (*gRenderfuncs.GetLightStyle) #define GET_LIGHTSTYLE (*gRenderfuncs.GetLightStyle)
#define GET_DYNAMIC_LIGHT (*gRenderfuncs.GetDynamicLight) #define GET_DYNAMIC_LIGHT (*gRenderfuncs.GetDynamicLight)
#define GET_ENTITY_LIGHT (*gRenderfuncs.GetEntityLight) #define GET_ENTITY_LIGHT (*gRenderfuncs.GetEntityLight)
#define TEXTURE_TO_TEXGAMMA (*gRenderfuncs.LightToTexGamma) #define TEXTURE_TO_TEXGAMMA (*gRenderfuncs.LightToTexGamma)
#define GET_FRAMETIME (*gRenderfuncs.GetFrameTime) #define GET_FRAMETIME (*gRenderfuncs.GetFrameTime)
#define DRAW_SINGLE_DECAL (*gRenderfuncs.DrawSingleDecal) #define DRAW_SINGLE_DECAL (*gRenderfuncs.DrawSingleDecal)
#define DECAL_SETUP_VERTS (*gRenderfuncs.R_DecalSetupVerts) #define DECAL_SETUP_VERTS (*gRenderfuncs.R_DecalSetupVerts)
#define GET_DETAIL_SCALE (*gRenderfuncs.GetDetailScaleForTexture) #define GET_DETAIL_SCALE (*gRenderfuncs.GetDetailScaleForTexture)
#define GET_EXTRA_PARAMS (*gRenderfuncs.GetExtraParmsForTexture) #define GET_EXTRA_PARAMS (*gRenderfuncs.GetExtraParmsForTexture)
#define CREATE_TEXTURE (*gRenderfuncs.GL_CreateTexture) #define CREATE_TEXTURE (*gRenderfuncs.GL_CreateTexture)
#define FIND_TEXTURE (*gRenderfuncs.GL_FindTexture) #define FIND_TEXTURE (*gRenderfuncs.GL_FindTexture)
#define FREE_TEXTURE (*gRenderfuncs.GL_FreeTexture) #define FREE_TEXTURE (*gRenderfuncs.GL_FreeTexture)
#define CREATE_TEXTURE_ARRAY (*gRenderfuncs.GL_CreateTextureArray) #define CREATE_TEXTURE_ARRAY (*gRenderfuncs.GL_CreateTextureArray)
#define STORE_EFRAGS (*gRenderfuncs.R_StoreEfrags) #define STORE_EFRAGS (*gRenderfuncs.R_StoreEfrags)
#define INIT_BEAMCHAINS (*gRenderfuncs.GetBeamChains) #define INIT_BEAMCHAINS (*gRenderfuncs.GetBeamChains)
#define DRAW_PARTICLES (*gRenderfuncs.GL_DrawParticles) #define DRAW_PARTICLES (*gRenderfuncs.GL_DrawParticles)
#define SET_ENGINE_WORLDVIEW_MATRIX (*gRenderfuncs.GL_SetWorldviewProjectionMatrix) #define SET_ENGINE_WORLDVIEW_MATRIX (*gRenderfuncs.GL_SetWorldviewProjectionMatrix)
#define GET_FOG_PARAMS (*gRenderfuncs.GetExtraParmsForTexture) #define GET_FOG_PARAMS (*gRenderfuncs.GetExtraParmsForTexture)
#define GET_TEXTURE_NAME (*gRenderfuncs.GL_TextureName) #define GET_TEXTURE_NAME (*gRenderfuncs.GL_TextureName)
#define GET_TEXTURE_DATA (*gRenderfuncs.GL_TextureData) #define GET_TEXTURE_DATA (*gRenderfuncs.GL_TextureData)
#define COMPARE_FILE_TIME (*gRenderfuncs.COM_CompareFileTime) #define COMPARE_FILE_TIME (*gRenderfuncs.COM_CompareFileTime)
#define REMOVE_BSP_DECALS (*gRenderfuncs.R_EntityRemoveDecals) #define REMOVE_BSP_DECALS (*gRenderfuncs.R_EntityRemoveDecals)
#define STUDIO_GET_TEXTURE (*gRenderfuncs.StudioGetTexture) #define STUDIO_GET_TEXTURE (*gRenderfuncs.StudioGetTexture)
#define GET_OVERVIEW_PARMS (*gRenderfuncs.GetOverviewParms) #define GET_OVERVIEW_PARMS (*gRenderfuncs.GetOverviewParms)
#define FS_SEARCH (*gRenderfuncs.pfnGetFilesList) #define FS_SEARCH (*gRenderfuncs.pfnGetFilesList)
#define ENV_SHOT (*gRenderfuncs.EnvShot) #define ENV_SHOT (*gRenderfuncs.EnvShot)
#define LOAD_TEXTURE (*gRenderfuncs.GL_LoadTexture) #define LOAD_TEXTURE (*gRenderfuncs.GL_LoadTexture)
#define LOAD_TEXTURE_ARRAY (*gRenderfuncs.GL_LoadTextureArray) #define LOAD_TEXTURE_ARRAY (*gRenderfuncs.GL_LoadTextureArray)
// AVIKit interface // AVIKit interface
#define OPEN_CINEMATIC (*gRenderfuncs.AVI_LoadVideo) #define OPEN_CINEMATIC (*gRenderfuncs.AVI_LoadVideo)
#define FREE_CINEMATIC (*gRenderfuncs.AVI_FreeVideo) #define FREE_CINEMATIC (*gRenderfuncs.AVI_FreeVideo)
#define CIN_IS_ACTIVE (*gRenderfuncs.AVI_IsActive) #define CIN_IS_ACTIVE (*gRenderfuncs.AVI_IsActive)
#define CIN_GET_VIDEO_INFO (*gRenderfuncs.AVI_GetVideoInfo) #define CIN_GET_VIDEO_INFO (*gRenderfuncs.AVI_GetVideoInfo)
#define CIN_GET_FRAME_NUMBER (*gRenderfuncs.AVI_GetVideoFrameNumber) #define CIN_GET_FRAME_NUMBER (*gRenderfuncs.AVI_GetVideoFrameNumber)
#define CIN_GET_FRAMEDATA (*gRenderfuncs.AVI_GetVideoFrame) #define CIN_GET_FRAMEDATA (*gRenderfuncs.AVI_GetVideoFrame)
#define CIN_UPLOAD_FRAME (*gRenderfuncs.AVI_UploadRawFrame) #define CIN_UPLOAD_FRAME (*gRenderfuncs.AVI_UploadRawFrame)
#define CIN_UPDATE_SOUND (*gRenderfuncs.AVI_StreamSound) #define CIN_UPDATE_SOUND (*gRenderfuncs.AVI_StreamSound)
// glcommands // glcommands
#define GL_BindTexture (*gRenderfuncs.GL_Bind) #define GL_BindTexture (*gRenderfuncs.GL_Bind)
#define GL_SelectTexture (*gRenderfuncs.GL_SelectTexture) #define GL_SelectTexture (*gRenderfuncs.GL_SelectTexture)
#define GL_TexGen (*gRenderfuncs.GL_TexGen) #define GL_TexGen (*gRenderfuncs.GL_TexGen)
#define GL_LoadTextureMatrix (*gRenderfuncs.GL_LoadTextureMatrix) #define GL_LoadTextureMatrix (*gRenderfuncs.GL_LoadTextureMatrix)
#define GL_LoadIdentityTexMatrix (*gRenderfuncs.GL_TexMatrixIdentity) #define GL_LoadIdentityTexMatrix (*gRenderfuncs.GL_TexMatrixIdentity)
#define GL_CleanUpTextureUnits (*gRenderfuncs.GL_CleanUpTextureUnits) #define GL_CleanUpTextureUnits (*gRenderfuncs.GL_CleanUpTextureUnits)
#define GL_TexCoordArrayMode (*gRenderfuncs.GL_TexCoordArrayMode) #define GL_TexCoordArrayMode (*gRenderfuncs.GL_TexCoordArrayMode)
#define GL_TextureTarget (*gRenderfuncs.GL_TextureTarget) #define GL_TextureTarget (*gRenderfuncs.GL_TextureTarget)
#define GL_UpdateTexSize (*gRenderfuncs.GL_UpdateTexSize) #define GL_UpdateTexSize (*gRenderfuncs.GL_UpdateTexSize)
#define RANDOM_SEED (*gRenderfuncs.SetRandomSeed) #define RANDOM_SEED (*gRenderfuncs.SetRandomSeed)
#define MUSIC_FADE_VOLUME (*gRenderfuncs.S_FadeMusicVolume) #define MUSIC_FADE_VOLUME (*gRenderfuncs.S_FadeMusicVolume)
#define GL_GetProcAddress (*gRenderfuncs.GL_GetProcAddress) #define GL_GetProcAddress (*gRenderfuncs.GL_GetProcAddress)
#define MODEL_HANDLE (*gRenderfuncs.pfnGetModel) #define MODEL_HANDLE (*gRenderfuncs.pfnGetModel)
// built-in memory manager // built-in memory manager
#define Mem_Alloc( x ) (*gRenderfuncs.pfnMemAlloc)( x, __FILE__, __LINE__ ) #define Mem_Alloc( x ) (*gRenderfuncs.pfnMemAlloc)( x, __FILE__, __LINE__ )
#define Mem_Free( x ) (*gRenderfuncs.pfnMemFree)( x, __FILE__, __LINE__ ) #define Mem_Free( x ) (*gRenderfuncs.pfnMemFree)( x, __FILE__, __LINE__ )
#define _Mem_Alloc (*gRenderfuncs.pfnMemAlloc) #define _Mem_Alloc (*gRenderfuncs.pfnMemAlloc)
#define _Mem_Free (*gRenderfuncs.pfnMemFree) #define _Mem_Free (*gRenderfuncs.pfnMemFree)
#define ASSERT( exp ) if(!( exp )) HOST_ERROR( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define ASSERT( exp ) if(!( exp )) HOST_ERROR( "assert failed at %s:%i\n", __FILE__, __LINE__ )
#define IMAGE_EXISTS( path ) ( FILE_EXISTS( va( "%s.tga", path )) || FILE_EXISTS( va( "%s.dds", path ))) #define IMAGE_EXISTS( path ) ( FILE_EXISTS( va( "%s.tga", path )) || FILE_EXISTS( va( "%s.dds", path )))
extern void ALERT( ALERT_TYPE level, char *szFmt, ... ); extern void ALERT( ALERT_TYPE level, char *szFmt, ... );
inline bool FILE_EXISTS( const char *filename ) inline bool FILE_EXISTS( const char *filename )
{ {
int iCompare; int iCompare;
// verify file exists // verify file exists
// g-cont. idea! use COMPARE_FILE_TIME instead of COM_LoadFile // g-cont. idea! use COMPARE_FILE_TIME instead of COM_LoadFile
if( COMPARE_FILE_TIME( filename, filename, &iCompare )) if( COMPARE_FILE_TIME( filename, filename, &iCompare ))
return true; return true;
return false; return false;
} }
#define FILE_CRC32 (*gRenderfuncs.pfnFileBufferCRC32) #define FILE_CRC32 (*gRenderfuncs.pfnFileBufferCRC32)
#define GET_MAX_CLIENTS (*gEngfuncs.GetMaxClients) #define GET_MAX_CLIENTS (*gEngfuncs.GetMaxClients)
#endif//ENGINECALLBACK_H #endif//ENGINECALLBACK_H

File diff suppressed because it is too large Load Diff

View File

@ -1,205 +1,205 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// shared event functions // shared event functions
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "cl_entity.h" #include "cl_entity.h"
#include "r_efx.h" #include "r_efx.h"
#include "eventscripts.h" #include "eventscripts.h"
#include "event_api.h" #include "event_api.h"
#include "pm_shared.h" #include "pm_shared.h"
#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) ) #define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) )
/* /*
================= =================
GetEntity GetEntity
Return's the requested cl_entity_t Return's the requested cl_entity_t
================= =================
*/ */
struct cl_entity_s *GetEntity( int idx ) struct cl_entity_s *GetEntity( int idx )
{ {
return gEngfuncs.GetEntityByIndex( idx ); return gEngfuncs.GetEntityByIndex( idx );
} }
/* /*
================= =================
GetViewEntity GetViewEntity
Return's the current weapon/view model Return's the current weapon/view model
================= =================
*/ */
struct cl_entity_s *GetViewEntity( void ) struct cl_entity_s *GetViewEntity( void )
{ {
return gEngfuncs.GetViewModel(); return gEngfuncs.GetViewModel();
} }
/* /*
================= =================
EV_CreateTracer EV_CreateTracer
Creates a tracer effect Creates a tracer effect
================= =================
*/ */
void EV_CreateTracer( float *start, float *end ) void EV_CreateTracer( float *start, float *end )
{ {
gEngfuncs.pEfxAPI->R_TracerEffect( start, end ); gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
} }
/* /*
================= =================
EV_IsPlayer EV_IsPlayer
Is the entity's index in the player range? Is the entity's index in the player range?
================= =================
*/ */
qboolean EV_IsPlayer( int idx ) qboolean EV_IsPlayer( int idx )
{ {
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() ) if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
return true; return true;
return false; return false;
} }
/* /*
================= =================
EV_IsLocal EV_IsLocal
Is the entity == the local player Is the entity == the local player
================= =================
*/ */
qboolean EV_IsLocal( int idx ) qboolean EV_IsLocal( int idx )
{ {
// check if we are in some way in first person spec mode // check if we are in some way in first person spec mode
if ( IS_FIRSTPERSON_SPEC ) if ( IS_FIRSTPERSON_SPEC )
return (g_iUser2 == idx); return (g_iUser2 == idx);
else else
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false; return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
} }
/* /*
================= =================
EV_GetGunPosition EV_GetGunPosition
Figure out the height of the gun Figure out the height of the gun
================= =================
*/ */
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin ) void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
{ {
int idx; int idx;
vec3_t view_ofs; vec3_t view_ofs;
idx = args->entindex; idx = args->entindex;
VectorClear( view_ofs ); VectorClear( view_ofs );
view_ofs[2] = DEFAULT_VIEWHEIGHT; view_ofs[2] = DEFAULT_VIEWHEIGHT;
if ( EV_IsPlayer( idx ) ) if ( EV_IsPlayer( idx ) )
{ {
// in spec mode use entity viewheigh, not own // in spec mode use entity viewheigh, not own
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC ) if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
{ {
// Grab predicted result for local player // Grab predicted result for local player
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
} }
else if ( args->ducking == 1 ) else if ( args->ducking == 1 )
{ {
view_ofs[2] = VEC_DUCK_VIEW; view_ofs[2] = VEC_DUCK_VIEW;
} }
} }
VectorAdd( origin, view_ofs, pos ); VectorAdd( origin, view_ofs, pos );
} }
/* /*
================= =================
EV_EjectBrass EV_EjectBrass
Bullet shell casings Bullet shell casings
================= =================
*/ */
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype ) void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
{ {
Vector endpos = Vector( 0.0f, rotation, 0.0f ); Vector endpos = Vector( 0.0f, rotation, 0.0f );
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, RANDOM_FLOAT( 1.5f, 3.0f ), model, soundtype ); gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, RANDOM_FLOAT( 1.5f, 3.0f ), model, soundtype );
} }
/* /*
================= =================
EV_GetDefaultShellInfo EV_GetDefaultShellInfo
Determine where to eject shells from Determine where to eject shells from
================= =================
*/ */
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale ) void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale )
{ {
int i; int i;
vec3_t view_ofs; vec3_t view_ofs;
float fR, fU; float fR, fU;
int idx; int idx;
idx = args->entindex; idx = args->entindex;
VectorClear( view_ofs ); VectorClear( view_ofs );
view_ofs[2] = DEFAULT_VIEWHEIGHT; view_ofs[2] = DEFAULT_VIEWHEIGHT;
if ( EV_IsPlayer( idx ) ) if ( EV_IsPlayer( idx ) )
{ {
if ( EV_IsLocal( idx ) ) if ( EV_IsLocal( idx ) )
{ {
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
} }
else if ( args->ducking == 1 ) else if ( args->ducking == 1 )
{ {
view_ofs[2] = VEC_DUCK_VIEW; view_ofs[2] = VEC_DUCK_VIEW;
} }
} }
// fR = gEngfuncs.pfnRandomFloat( 50, 70 ); // fR = gEngfuncs.pfnRandomFloat( 50, 70 );
// fU = gEngfuncs.pfnRandomFloat( 100, 150 ); // fU = gEngfuncs.pfnRandomFloat( 100, 150 );
fR = gEngfuncs.pfnRandomFloat( 80, 120 ); fR = gEngfuncs.pfnRandomFloat( 80, 120 );
fU = gEngfuncs.pfnRandomFloat( 10, 30 ); // buz fU = gEngfuncs.pfnRandomFloat( 10, 30 ); // buz
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
{ {
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25; ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale; ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
} }
} }
/* /*
================= =================
EV_MuzzleFlash EV_MuzzleFlash
Flag weapon/view model for muzzle flash Flag weapon/view model for muzzle flash
================= =================
*/ */
void EV_MuzzleFlash( void ) void EV_MuzzleFlash( void )
{ {
// Add muzzle flash to current weapon model // Add muzzle flash to current weapon model
cl_entity_t *ent = GetViewEntity(); cl_entity_t *ent = GetViewEntity();
if ( !ent ) if ( !ent )
{ {
return; return;
} }
// Or in the muzzle flash // Or in the muzzle flash
ent->curstate.effects |= EF_MUZZLEFLASH; ent->curstate.effects |= EF_MUZZLEFLASH;
} }

View File

@ -1,44 +1,44 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "../hud.h" #include "../hud.h"
#include "../cl_util.h" #include "../cl_util.h"
#include "event_api.h" #include "event_api.h"
extern "C" extern "C"
{ {
void EV_FireGeneric( struct event_args_s *args ); void EV_FireGeneric( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args );
void EV_SmokePuff( struct event_args_s *args ); void EV_SmokePuff( struct event_args_s *args );
} }
/* /*
====================== ======================
Game_HookEvents Game_HookEvents
Associate script file name with callback functions. Callback's must be extern "C" so Associate script file name with callback functions. Callback's must be extern "C" so
the engine doesn't get confused about name mangling stuff. Note that the format is the engine doesn't get confused about name mangling stuff. Note that the format is
always the same. Of course, a clever mod team could actually embed parameters, behavior always the same. Of course, a clever mod team could actually embed parameters, behavior
into the actual .sc files and create a .sc file parser and hook their functionality through into the actual .sc files and create a .sc file parser and hook their functionality through
that.. i.e., a scripting system. that.. i.e., a scripting system.
That was what we were going to do, but we ran out of time...oh well. That was what we were going to do, but we ran out of time...oh well.
====================== ======================
*/ */
void Game_HookEvents( void ) void Game_HookEvents( void )
{ {
gEngfuncs.pfnHookEvent( "evTrainSound", EV_TrainPitchAdjust ); gEngfuncs.pfnHookEvent( "evTrainSound", EV_TrainPitchAdjust );
gEngfuncs.pfnHookEvent( "evSmokePuff", EV_SmokePuff ); gEngfuncs.pfnHookEvent( "evSmokePuff", EV_SmokePuff );
gEngfuncs.pfnHookEvent( "evFireGeneric", EV_FireGeneric ); gEngfuncs.pfnHookEvent( "evFireGeneric", EV_FireGeneric );
} }

View File

@ -1,418 +1,418 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "cl_entity.h" #include "cl_entity.h"
#include "entity_types.h" #include "entity_types.h"
#include "usercmd.h" #include "usercmd.h"
#include "pm_defs.h" #include "pm_defs.h"
#include "eventscripts.h" #include "eventscripts.h"
#include "ev_hldm.h" #include "ev_hldm.h"
#include "r_efx.h" #include "r_efx.h"
#include "event_api.h" #include "event_api.h"
#include "event_args.h" #include "event_args.h"
#include "in_defs.h" #include "in_defs.h"
#include "gl_rpart.h" #include "gl_rpart.h"
#include <string.h> #include <string.h>
#include "material.h" #include "material.h"
#include "r_studioint.h" #include "r_studioint.h"
#include "com_model.h" #include "com_model.h"
#include "studio.h" #include "studio.h"
extern engine_studio_api_t IEngineStudio; extern engine_studio_api_t IEngineStudio;
static int tracerCount[ 32 ]; static int tracerCount[ 32 ];
void V_PunchAxis( int axis, float punch ); void V_PunchAxis( int axis, float punch );
void VectorAngles( const float *forward, float *angles ); void VectorAngles( const float *forward, float *angles );
extern cvar_t *cl_lw; extern cvar_t *cl_lw;
extern "C" extern "C"
{ {
void EV_FireGeneric( struct event_args_s *args ); void EV_FireGeneric( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args );
void EV_SmokePuff( struct event_args_s *args ); void EV_SmokePuff( struct event_args_s *args );
} }
// play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the // play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the
// original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture. // original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture.
// returns volume of strike instrument (crowbar) to play // returns volume of strike instrument (crowbar) to play
void EV_HLDM_PlayTextureSound( pmtrace_t *ptr, const Vector &vecSrc, const Vector &vecEnd ) void EV_HLDM_PlayTextureSound( pmtrace_t *ptr, const Vector &vecSrc, const Vector &vecEnd )
{ {
// hit the world, try to play sound based on texture material type // hit the world, try to play sound based on texture material type
char *rgsz[MAX_MAT_SOUNDS]; char *rgsz[MAX_MAT_SOUNDS];
float fattn = ATTN_NORM; float fattn = ATTN_NORM;
int cnt = 0; int cnt = 0;
physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( ptr->ent ); physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( ptr->ent );
matdef_t *pMat = NULL; matdef_t *pMat = NULL;
if( pe ) if( pe )
{ {
if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP )
pMat = COM_MatDefFromSurface( gEngfuncs.pEventAPI->EV_TraceSurface( ptr->ent, (float *)&vecSrc, (float *)&vecEnd ), ptr->endpos ); pMat = COM_MatDefFromSurface( gEngfuncs.pEventAPI->EV_TraceSurface( ptr->ent, (float *)&vecSrc, (float *)&vecEnd ), ptr->endpos );
else if( pe->solid == SOLID_CUSTOM && ptr->surf ) else if( pe->solid == SOLID_CUSTOM && ptr->surf )
pMat = ptr->surf->effects; pMat = ptr->surf->effects;
if( !pMat ) return; if( !pMat ) return;
// fire effects // fire effects
for( cnt = 0; pMat->impact_parts[cnt] != NULL; cnt++ ) for( cnt = 0; pMat->impact_parts[cnt] != NULL; cnt++ )
g_pParticles.CreateEffect( pMat->impact_parts[cnt], ptr->endpos, ptr->plane.normal ); g_pParticles.CreateEffect( pMat->impact_parts[cnt], ptr->endpos, ptr->plane.normal );
// count sounds // count sounds
for( cnt = 0; pMat->impact_sounds[cnt] != NULL; cnt++ ) for( cnt = 0; pMat->impact_sounds[cnt] != NULL; cnt++ )
rgsz[cnt] = (char *)pMat->impact_sounds[cnt]; rgsz[cnt] = (char *)pMat->impact_sounds[cnt];
} }
if( !cnt ) return; if( !cnt ) return;
gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[RANDOM_LONG( 0, cnt - 1 )], 0.9, fattn, 0, 96 + RANDOM_LONG( 0, 0xf )); gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[RANDOM_LONG( 0, cnt - 1 )], 0.9, fattn, 0, 96 + RANDOM_LONG( 0, 0xf ));
} }
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, const Vector &vecSrc, const Vector &vecEnd ) void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, const Vector &vecSrc, const Vector &vecEnd )
{ {
if( pTrace->inwater ) return; if( pTrace->inwater ) return;
int iRand = RANDOM_LONG( 0, 0x7FFF ); int iRand = RANDOM_LONG( 0, 0x7FFF );
if( iRand < ( 0x7fff / 2 )) // not every bullet makes a sound. if( iRand < ( 0x7fff / 2 )) // not every bullet makes a sound.
{ {
switch( iRand % 5) switch( iRand % 5)
{ {
case 0: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; case 0: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 1: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; case 1: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 2: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; case 2: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 3: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; case 3: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 4: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; case 4: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
} }
} }
physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent );
matdef_t *pMat = NULL; matdef_t *pMat = NULL;
if( pe ) if( pe )
{ {
if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP )
{ {
pMat = COM_MatDefFromSurface( gEngfuncs.pEventAPI->EV_TraceSurface( pTrace->ent, (float *)&vecSrc, (float *)&vecEnd ), pTrace->endpos ); pMat = COM_MatDefFromSurface( gEngfuncs.pEventAPI->EV_TraceSurface( pTrace->ent, (float *)&vecSrc, (float *)&vecEnd ), pTrace->endpos );
if ( pMat ) CreateDecal( pTrace, pMat->impact_decal, RANDOM_FLOAT( 0.0f, 360.0f )); if ( pMat ) CreateDecal( pTrace, pMat->impact_decal, RANDOM_FLOAT( 0.0f, 360.0f ));
} }
else if( pe->solid == SOLID_CUSTOM && pTrace->surf ) else if( pe->solid == SOLID_CUSTOM && pTrace->surf )
{ {
pMat = pTrace->surf->effects; pMat = pTrace->surf->effects;
if ( pMat ) UTIL_StudioDecal( pMat->impact_decal, pTrace, vecSrc ); if ( pMat ) UTIL_StudioDecal( pMat->impact_decal, pTrace, vecSrc );
} }
} }
} }
/* /*
================ ================
FireBullets FireBullets
Go to the trouble of combining multiple pellets into a single damage call. Go to the trouble of combining multiple pellets into a single damage call.
================ ================
*/ */
void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY ) void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY )
{ {
int i; int i;
pmtrace_t tr; pmtrace_t tr;
int iShot; int iShot;
for ( iShot = 1; iShot <= cShots; iShot++ ) for ( iShot = 1; iShot <= cShots; iShot++ )
{ {
Vector vecDir, vecEnd; Vector vecDir, vecEnd;
float x, y, z; float x, y, z;
// We randomize for the Shotgun. // We randomize for the Shotgun.
if ( iBulletType == BULLET_BUCKSHOT ) if ( iBulletType == BULLET_BUCKSHOT )
{ {
do { do {
x = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); x = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f );
y = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); y = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f );
z = x * x + y * y; z = x * x + y * y;
} while( z > 1.0f ); } while( z > 1.0f );
for ( i = 0 ; i < 3; i++ ) for ( i = 0 ; i < 3; i++ )
{ {
vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up[i]; vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up[i];
vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; vecEnd[i] = vecSrc[i] + flDistance * vecDir[i];
} }
} }
else else
{ {
// but other guns already have their spread randomized in the synched spread. // but other guns already have their spread randomized in the synched spread.
for ( i = 0 ; i < 3; i++ ) for ( i = 0 ; i < 3; i++ )
{ {
vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up[i]; vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up[i];
vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; vecEnd[i] = vecSrc[i] + flDistance * vecDir[i];
} }
} }
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
// Store off the old count // Store off the old count
gEngfuncs.pEventAPI->EV_PushPMStates(); gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players. // Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, 0, -1, &tr ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, 0, -1, &tr );
// do damage, paint decals // do damage, paint decals
if ( tr.fraction != 1.0 && !tr.inwater ) // buz: dont smoke and particle if shoot in sky if ( tr.fraction != 1.0 && !tr.inwater ) // buz: dont smoke and particle if shoot in sky
{ {
EV_HLDM_PlayTextureSound( &tr, vecSrc, vecEnd ); EV_HLDM_PlayTextureSound( &tr, vecSrc, vecEnd );
EV_HLDM_GunshotDecalTrace( &tr, vecSrc, vecEnd ); EV_HLDM_GunshotDecalTrace( &tr, vecSrc, vecEnd );
} }
gEngfuncs.pEventAPI->EV_PopPMStates(); gEngfuncs.pEventAPI->EV_PopPMStates();
} }
} }
//====================== //======================
// WEAPON GENERIC START // WEAPON GENERIC START
//====================== //======================
void EV_FireGeneric( struct event_args_s *args ) void EV_FireGeneric( struct event_args_s *args )
{ {
int idx; int idx;
Vector origin; Vector origin;
Vector angles; Vector angles;
Vector velocity; Vector velocity;
Vector ShellVelocity; Vector ShellVelocity;
Vector ShellOrigin; Vector ShellOrigin;
Vector vecSrc, vecAiming; Vector vecSrc, vecAiming;
Vector up, right, forward; Vector up, right, forward;
float flSpread = 0.01; float flSpread = 0.01;
idx = args->entindex; idx = args->entindex;
VectorCopy( args->origin, origin ); VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles ); VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity ); VectorCopy( args->velocity, velocity );
AngleVectors( angles, forward, right, up ); AngleVectors( angles, forward, right, up );
int shell = args->bparam1; // brass shell int shell = args->bparam1; // brass shell
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 );
if( EV_IsLocal( idx )) if( EV_IsLocal( idx ))
{ {
// add muzzle flash to current weapon model // add muzzle flash to current weapon model
EV_MuzzleFlash(); EV_MuzzleFlash();
UTIL_WeaponAnimation(( args->iparam1 & 0xFFF ), 1.0f ); // FIXME: how to send framerate? UTIL_WeaponAnimation(( args->iparam1 & 0xFFF ), 1.0f ); // FIXME: how to send framerate?
V_PunchAxis( 0, RANDOM_FLOAT( ((float)args->iparam2 / 255.0f ) * -3.0f, 0.0f )); V_PunchAxis( 0, RANDOM_FLOAT( ((float)args->iparam2 / 255.0f ) * -3.0f, 0.0f ));
cl_entity_t *ent = GetViewEntity(); cl_entity_t *ent = GetViewEntity();
if( ent ) ShellOrigin = ent->attachment[1]; if( ent ) ShellOrigin = ent->attachment[1];
} }
int numShots = ((args->iparam1 >> 12) & 0xF); int numShots = ((args->iparam1 >> 12) & 0xF);
int soundType = TE_BOUNCE_SHELL; int soundType = TE_BOUNCE_SHELL;
int bulletType = BULLET_NORMAL; int bulletType = BULLET_NORMAL;
float flDist = 8192.0f; float flDist = 8192.0f;
// shotgun case // shotgun case
if( numShots > 1 ) if( numShots > 1 )
{ {
bulletType = BULLET_BUCKSHOT; bulletType = BULLET_BUCKSHOT;
soundType = TE_BOUNCE_SHOTSHELL; soundType = TE_BOUNCE_SHOTSHELL;
flDist = 2048.0f; flDist = 2048.0f;
} }
EV_EjectBrass( ShellOrigin, ShellVelocity , RANDOM_FLOAT( -angles[YAW], angles[YAW] ), shell, soundType ); EV_EjectBrass( ShellOrigin, ShellVelocity , RANDOM_FLOAT( -angles[YAW], angles[YAW] ), shell, soundType );
if( args->bparam2 ) if( args->bparam2 )
{ {
const char *fireSound = gEngfuncs.pEventAPI->EV_SoundForIndex( args->bparam2 ); const char *fireSound = gEngfuncs.pEventAPI->EV_SoundForIndex( args->bparam2 );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, fireSound, 1, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 0xf )); gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, fireSound, 1, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 0xf ));
} }
EV_GetGunPosition( args, vecSrc, origin ); EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming ); VectorCopy( forward, vecAiming );
EV_HLDM_FireBullets( idx, forward, right, up, numShots, vecSrc, vecAiming, flDist, bulletType, 2, &tracerCount[idx-1], args->fparam1, args->fparam2 ); EV_HLDM_FireBullets( idx, forward, right, up, numShots, vecSrc, vecAiming, flDist, bulletType, 2, &tracerCount[idx-1], args->fparam1, args->fparam2 );
} }
//====================== //======================
// WEAPON GENERIC END // WEAPON GENERIC END
//====================== //======================
#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch #define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch
void EV_TrainPitchAdjust( event_args_t *args ) void EV_TrainPitchAdjust( event_args_t *args )
{ {
int idx; int idx;
Vector origin; Vector origin;
unsigned short us_params; unsigned short us_params;
int noise; int noise;
float m_flVolume; float m_flVolume;
int pitch; int pitch;
int stop; int stop;
char sz[ 256 ]; char sz[ 256 ];
idx = args->entindex; idx = args->entindex;
VectorCopy( args->origin, origin ); VectorCopy( args->origin, origin );
us_params = (unsigned short)args->iparam1; us_params = (unsigned short)args->iparam1;
stop = args->bparam1; stop = args->bparam1;
m_flVolume = (float)(us_params & 0x003f)/40.0; m_flVolume = (float)(us_params & 0x003f)/40.0;
noise = (int)(((us_params) >> 12 ) & 0x0007); noise = (int)(((us_params) >> 12 ) & 0x0007);
pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) ); pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
switch ( noise ) switch ( noise )
{ {
case 1: strcpy( sz, "plats/ttrain1.wav"); break; case 1: strcpy( sz, "plats/ttrain1.wav"); break;
case 2: strcpy( sz, "plats/ttrain2.wav"); break; case 2: strcpy( sz, "plats/ttrain2.wav"); break;
case 3: strcpy( sz, "plats/ttrain3.wav"); break; case 3: strcpy( sz, "plats/ttrain3.wav"); break;
case 4: strcpy( sz, "plats/ttrain4.wav"); break; case 4: strcpy( sz, "plats/ttrain4.wav"); break;
case 5: strcpy( sz, "plats/ttrain6.wav"); break; case 5: strcpy( sz, "plats/ttrain6.wav"); break;
case 6: strcpy( sz, "plats/ttrain7.wav"); break; case 6: strcpy( sz, "plats/ttrain7.wav"); break;
default: default:
// no sound // no sound
strcpy( sz, "" ); strcpy( sz, "" );
return; return;
} }
if ( stop ) if ( stop )
{ {
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz ); gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz );
} }
else else
{ {
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch );
} }
} }
int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 ) int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 )
{ {
return 0; return 0;
} }
// buz: smokepuff event - for invoke puffs from server, when monsters firing, etc.. // buz: smokepuff event - for invoke puffs from server, when monsters firing, etc..
void EV_SmokePuff( struct event_args_s *args ) void EV_SmokePuff( struct event_args_s *args )
{ {
VectorNormalize(args->angles); // there is surface normal actually VectorNormalize(args->angles); // there is surface normal actually
g_pParticles.BulletParticles( args->origin, args->angles ); g_pParticles.BulletParticles( args->origin, args->angles );
} }
void EV_GunSmoke( const Vector &pos ) void EV_GunSmoke( const Vector &pos )
{ {
g_pParticles.GunSmoke( pos, 2 ); g_pParticles.GunSmoke( pos, 2 );
} }
void EV_ExplodeSmoke( const Vector &pos ) void EV_ExplodeSmoke( const Vector &pos )
{ {
g_pParticles.SmokeParticles( pos, 10 ); g_pParticles.SmokeParticles( pos, 10 );
} }
void EV_HLDM_WaterSplash( float x, float y, float z, float ScaleSplash1, float ScaleSplash2 ) void EV_HLDM_WaterSplash( float x, float y, float z, float ScaleSplash1, float ScaleSplash2 )
{ {
int iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash1.spr"); int iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash1.spr");
TEMPENTITY *pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15 ), TEMPENTITY *pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15 ),
Vector( 0, 0, 0 ), Vector( 0, 0, 0 ),
/*ScaleSplash1*/0.2, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL ); /*ScaleSplash1*/0.2, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL );
if(pTemp) if(pTemp)
{ {
pTemp->fadeSpeed = 90.0; pTemp->fadeSpeed = 90.0;
pTemp->entity.curstate.framerate = 70.0; pTemp->entity.curstate.framerate = 70.0;
pTemp->entity.curstate.renderamt = 155; pTemp->entity.curstate.renderamt = 155;
pTemp->entity.curstate.rendercolor.r = 255; pTemp->entity.curstate.rendercolor.r = 255;
pTemp->entity.curstate.rendercolor.g = 255; pTemp->entity.curstate.rendercolor.g = 255;
pTemp->entity.curstate.rendercolor.b = 255; pTemp->entity.curstate.rendercolor.b = 255;
} }
iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash2.spr"); iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash2.spr");
pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z ), pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z ),
Vector( 0, 0, 0 ), Vector( 0, 0, 0 ),
/*ScaleSplash2*/0.08, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL ); /*ScaleSplash2*/0.08, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL );
if(pTemp) if(pTemp)
{ {
pTemp->fadeSpeed = 60.0; pTemp->fadeSpeed = 60.0;
pTemp->entity.curstate.framerate = 60.0; pTemp->entity.curstate.framerate = 60.0;
pTemp->entity.curstate.renderamt = 150; pTemp->entity.curstate.renderamt = 150;
pTemp->entity.curstate.rendercolor.r = 255; pTemp->entity.curstate.rendercolor.r = 255;
pTemp->entity.curstate.rendercolor.g = 255; pTemp->entity.curstate.rendercolor.g = 255;
pTemp->entity.curstate.rendercolor.b = 255; pTemp->entity.curstate.rendercolor.b = 255;
pTemp->entity.angles = Vector( 90, 0, 0 ); pTemp->entity.angles = Vector( 90, 0, 0 );
} }
} }
void EV_HLDM_NewExplode( float x, float y, float z, float ScaleExplode1 ) void EV_HLDM_NewExplode( float x, float y, float z, float ScaleExplode1 )
{ {
float rnd = gEngfuncs.pfnRandomFloat( -0.03, 0.03 ); float rnd = gEngfuncs.pfnRandomFloat( -0.03, 0.03 );
int iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/dexplo.spr"); int iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/dexplo.spr");
TEMPENTITY *pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15 ), Vector( 0, 0, 0 ), TEMPENTITY *pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15 ), Vector( 0, 0, 0 ),
ScaleExplode1, iNewExplode, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT ); ScaleExplode1, iNewExplode, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT );
if( pTemp ) if( pTemp )
{ {
pTemp->fadeSpeed = 90.0; pTemp->fadeSpeed = 90.0;
pTemp->entity.curstate.framerate = 37.0; pTemp->entity.curstate.framerate = 37.0;
pTemp->entity.curstate.renderamt = 155; pTemp->entity.curstate.renderamt = 155;
pTemp->entity.curstate.rendercolor.r = 255; pTemp->entity.curstate.rendercolor.r = 255;
pTemp->entity.curstate.rendercolor.g = 255; pTemp->entity.curstate.rendercolor.g = 255;
pTemp->entity.curstate.rendercolor.b = 255; pTemp->entity.curstate.rendercolor.b = 255;
} }
iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/fexplo.spr"); iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/fexplo.spr");
pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15), Vector( 0, 0, 0 ), pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15), Vector( 0, 0, 0 ),
ScaleExplode1, iNewExplode, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT ); ScaleExplode1, iNewExplode, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT );
if( pTemp ) if( pTemp )
{ {
pTemp->fadeSpeed = 100.0; pTemp->fadeSpeed = 100.0;
pTemp->entity.curstate.framerate = 35.0; pTemp->entity.curstate.framerate = 35.0;
pTemp->entity.curstate.renderamt = 150; pTemp->entity.curstate.renderamt = 150;
pTemp->entity.curstate.rendercolor.r = 255; pTemp->entity.curstate.rendercolor.r = 255;
pTemp->entity.curstate.rendercolor.g = 255; pTemp->entity.curstate.rendercolor.g = 255;
pTemp->entity.curstate.rendercolor.b = 255; pTemp->entity.curstate.rendercolor.b = 255;
pTemp->entity.angles = Vector( 90, 0, 0 ); pTemp->entity.angles = Vector( 90, 0, 0 );
} }
iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/smokeball.spr"); iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/smokeball.spr");
pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 16), Vector( 0, 0, 0 ), pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 16), Vector( 0, 0, 0 ),
ScaleExplode1, iNewExplode, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT ); ScaleExplode1, iNewExplode, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT );
if( pTemp ) if( pTemp )
{ {
pTemp->fadeSpeed = 50.0; pTemp->fadeSpeed = 50.0;
pTemp->entity.curstate.framerate = 22.0; pTemp->entity.curstate.framerate = 22.0;
pTemp->entity.curstate.renderamt = 120; pTemp->entity.curstate.renderamt = 120;
pTemp->entity.curstate.rendercolor.r = 255; pTemp->entity.curstate.rendercolor.r = 255;
pTemp->entity.curstate.rendercolor.g = 255; pTemp->entity.curstate.rendercolor.g = 255;
pTemp->entity.curstate.rendercolor.b = 255; pTemp->entity.curstate.rendercolor.b = 255;
pTemp->entity.angles = Vector( 90, 0, 0 ); pTemp->entity.angles = Vector( 90, 0, 0 );
} }
EV_ExplodeSmoke( Vector( x, y, z + 4.0f )); EV_ExplodeSmoke( Vector( x, y, z + 4.0f ));
} }

View File

@ -1,17 +1,17 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#if !defined ( EV_HLDMH ) #if !defined ( EV_HLDMH )
#define EV_HLDMH #define EV_HLDMH
#include <bullets.h> #include <bullets.h>
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, const Vector &vecSrc, const Vector &vecEnd ); void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, const Vector &vecSrc, const Vector &vecEnd );
int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount ); int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );
void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY ); void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY );
#endif // EV_HLDMH #endif // EV_HLDMH

View File

@ -1,23 +1,23 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
void Game_HookEvents( void ); void Game_HookEvents( void );
/* /*
=================== ===================
EV_HookEvents EV_HookEvents
See if game specific code wants to hook any events. See if game specific code wants to hook any events.
=================== ===================
*/ */
void EV_HookEvents( void ) void EV_HookEvents( void )
{ {
Game_HookEvents(); Game_HookEvents();
} }

View File

@ -1,74 +1,74 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
// eventscripts.h // eventscripts.h
#if !defined ( EVENTSCRIPTSH ) #if !defined ( EVENTSCRIPTSH )
#define EVENTSCRIPTSH #define EVENTSCRIPTSH
// defaults for clientinfo messages // defaults for clientinfo messages
#define DEFAULT_VIEWHEIGHT 28 #define DEFAULT_VIEWHEIGHT 28
#define VEC_DUCK_VIEW 12 #define VEC_DUCK_VIEW 12
#define FTENT_FADEOUT 0x00000080 #define FTENT_FADEOUT 0x00000080
#define DMG_GENERIC 0 // generic damage was done #define DMG_GENERIC 0 // generic damage was done
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object #define DMG_CRUSH (1 << 0) // crushed by falling or moving object
#define DMG_BULLET (1 << 1) // shot #define DMG_BULLET (1 << 1) // shot
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed #define DMG_SLASH (1 << 2) // cut, clawed, stabbed
#define DMG_BURN (1 << 3) // heat burned #define DMG_BURN (1 << 3) // heat burned
#define DMG_FREEZE (1 << 4) // frozen #define DMG_FREEZE (1 << 4) // frozen
#define DMG_FALL (1 << 5) // fell too far #define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage #define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt #define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
#define DMG_SHOCK (1 << 8) // electric shock #define DMG_SHOCK (1 << 8) // electric shock
#define DMG_SONIC (1 << 9) // sound pulse shockwave #define DMG_SONIC (1 << 9) // sound pulse shockwave
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam #define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death #define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. #define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
// time-based damage // time-based damage
//mask off TF-specific stuff too //mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage #define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning #define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN #define DMG_FIRSTTIMEBASED DMG_DROWN
#define DMG_PARALYZE (1 << 15) // slows affected creature down #define DMG_PARALYZE (1 << 15) // slows affected creature down
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad #define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_POISON (1 << 17) // blood poisioning #define DMG_POISON (1 << 17) // blood poisioning
#define DMG_RADIATION (1 << 18) // radiation exposure #define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery #define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns #define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven #define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer #define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) #define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
//TF ADDITIONS //TF ADDITIONS
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn #define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance #define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius. #define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor #define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
#define DMG_AIMED (1 << 28) // Does Hit location damage #define DMG_AIMED (1 << 28) // Does Hit location damage
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls #define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
#define DMG_CALTROP (1<<30) #define DMG_CALTROP (1<<30)
#define DMG_HALLUC (1<<31) #define DMG_HALLUC (1<<31)
// Some of these are HL/TFC specific? // Some of these are HL/TFC specific?
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype ); void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin ); void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
void EV_GetDefaultShellInfo( struct event_args_s *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale ); void EV_GetDefaultShellInfo( struct event_args_s *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale );
qboolean EV_IsLocal( int idx ); qboolean EV_IsLocal( int idx );
qboolean EV_IsPlayer( int idx ); qboolean EV_IsPlayer( int idx );
void EV_CreateTracer( float *start, float *end ); void EV_CreateTracer( float *start, float *end );
struct cl_entity_s *GetEntity( int idx ); struct cl_entity_s *GetEntity( int idx );
struct cl_entity_s *GetViewEntity( void ); struct cl_entity_s *GetViewEntity( void );
void EV_GunSmoke( const Vector &pos ); void EV_GunSmoke( const Vector &pos );
void EV_MuzzleFlash( void ); void EV_MuzzleFlash( void );
#endif // EVENTSCRIPTSH #endif // EVENTSCRIPTSH

View File

@ -1,151 +1,151 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// flashlight.cpp // flashlight.cpp
// //
// implementation of CHudFlashlight class // implementation of CHudFlashlight class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE(m_Flash, FlashBat) DECLARE_MESSAGE(m_Flash, FlashBat)
DECLARE_MESSAGE(m_Flash, Flashlight) DECLARE_MESSAGE(m_Flash, Flashlight)
#define BAT_NAME "sprites/%d_Flashlight.spr" #define BAT_NAME "sprites/%d_Flashlight.spr"
int CHudFlashlight::Init(void) int CHudFlashlight::Init(void)
{ {
m_fFade = 0; m_fFade = 0;
m_fOn = 0; m_fOn = 0;
HOOK_MESSAGE(Flashlight); HOOK_MESSAGE(Flashlight);
HOOK_MESSAGE(FlashBat); HOOK_MESSAGE(FlashBat);
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
return 1; return 1;
}; };
void CHudFlashlight::Reset(void) void CHudFlashlight::Reset(void)
{ {
m_fFade = 0; m_fFade = 0;
m_fOn = 0; m_fOn = 0;
} }
int CHudFlashlight::VidInit(void) int CHudFlashlight::VidInit(void)
{ {
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" ); int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" ); int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" ); int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty); m_hSprite1 = gHUD.GetSprite(HUD_flash_empty);
m_hSprite2 = gHUD.GetSprite(HUD_flash_full); m_hSprite2 = gHUD.GetSprite(HUD_flash_full);
m_hBeam = gHUD.GetSprite(HUD_flash_beam); m_hBeam = gHUD.GetSprite(HUD_flash_beam);
m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty); m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty);
m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full); m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full);
m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam); m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam);
m_iWidth = m_prc2->right - m_prc2->left; m_iWidth = m_prc2->right - m_prc2->left;
return 1; return 1;
}; };
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ) int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int x = READ_BYTE(); int x = READ_BYTE();
m_iBat = x; m_iBat = x;
m_flBat = ((float)x)/100.0; m_flBat = ((float)x)/100.0;
return 1; return 1;
} }
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf ) int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_fOn = READ_BYTE(); m_fOn = READ_BYTE();
int x = READ_BYTE(); int x = READ_BYTE();
m_iBat = x; m_iBat = x;
m_flBat = ((float)x)/100.0; m_flBat = ((float)x)/100.0;
return 1; return 1;
} }
int CHudFlashlight::Draw(float flTime) int CHudFlashlight::Draw(float flTime)
{ {
return 1; // buz: no flashlight return 1; // buz: no flashlight
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ) if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
return 1; return 1;
int r, g, b, x, y, a; int r, g, b, x, y, a;
wrect_t rc; wrect_t rc;
if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT )) if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT ))
return 1; return 1;
if (m_fOn) if (m_fOn)
a = 225; a = 225;
else else
a = MIN_ALPHA; a = MIN_ALPHA;
if (m_flBat < 0.20) if (m_flBat < 0.20)
UnpackRGB(r,g,b, RGB_REDISH); UnpackRGB(r,g,b, RGB_REDISH);
else else
UnpackRGB(r,g,b, gHUD.m_iHUDColor); UnpackRGB(r,g,b, gHUD.m_iHUDColor);
ScaleColors(r, g, b, a); ScaleColors(r, g, b, a);
y = (m_prc1->bottom - m_prc2->top)/2; y = (m_prc1->bottom - m_prc2->top)/2;
x = ScreenWidth - m_iWidth - m_iWidth/2 ; x = ScreenWidth - m_iWidth - m_iWidth/2 ;
// Draw the flashlight casing // Draw the flashlight casing
SPR_Set(m_hSprite1, r, g, b ); SPR_Set(m_hSprite1, r, g, b );
SPR_DrawAdditive( 0, x, y, m_prc1); SPR_DrawAdditive( 0, x, y, m_prc1);
if ( m_fOn ) if ( m_fOn )
{ // draw the flashlight beam { // draw the flashlight beam
x = ScreenWidth - m_iWidth/2; x = ScreenWidth - m_iWidth/2;
SPR_Set( m_hBeam, r, g, b ); SPR_Set( m_hBeam, r, g, b );
SPR_DrawAdditive( 0, x, y, m_prcBeam ); SPR_DrawAdditive( 0, x, y, m_prcBeam );
} }
// draw the flashlight energy level // draw the flashlight energy level
x = ScreenWidth - m_iWidth - m_iWidth/2 ; x = ScreenWidth - m_iWidth - m_iWidth/2 ;
int iOffset = m_iWidth * (1.0 - m_flBat); int iOffset = m_iWidth * (1.0 - m_flBat);
if (iOffset < m_iWidth) if (iOffset < m_iWidth)
{ {
rc = *m_prc2; rc = *m_prc2;
rc.left += iOffset; rc.left += iOffset;
SPR_Set(m_hSprite2, r, g, b ); SPR_Set(m_hSprite2, r, g, b );
SPR_DrawAdditive( 0, x + iOffset, y, &rc); SPR_DrawAdditive( 0, x + iOffset, y, &rc);
} }
return 1; return 1;
} }

View File

@ -1,184 +1,184 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// Geiger.cpp // Geiger.cpp
// //
// implementation of CHudAmmo class // implementation of CHudAmmo class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE(m_Geiger, Geiger ) DECLARE_MESSAGE(m_Geiger, Geiger )
int CHudGeiger::Init(void) int CHudGeiger::Init(void)
{ {
HOOK_MESSAGE( Geiger ); HOOK_MESSAGE( Geiger );
m_iGeigerRange = 0; m_iGeigerRange = 0;
m_iFlags = 0; m_iFlags = 0;
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
srand( (unsigned)time( NULL ) ); srand( (unsigned)time( NULL ) );
return 1; return 1;
}; };
int CHudGeiger::VidInit(void) int CHudGeiger::VidInit(void)
{ {
return 1; return 1;
}; };
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf) int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
// update geiger data // update geiger data
m_iGeigerRange = READ_BYTE(); m_iGeigerRange = READ_BYTE();
m_iGeigerRange = m_iGeigerRange << 2; m_iGeigerRange = m_iGeigerRange << 2;
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
return 1; return 1;
} }
int CHudGeiger::Draw (float flTime) int CHudGeiger::Draw (float flTime)
{ {
int pct; int pct;
float flvol; float flvol;
int rg[3]; int rg[3];
int i; int i;
if (m_iGeigerRange < 1000 && m_iGeigerRange > 0) if (m_iGeigerRange < 1000 && m_iGeigerRange > 0)
{ {
// peicewise linear is better than continuous formula for this // peicewise linear is better than continuous formula for this
if (m_iGeigerRange > 800) if (m_iGeigerRange > 800)
{ {
pct = 0; //Con_Printf ( "range > 800\n"); pct = 0; //Con_Printf ( "range > 800\n");
} }
else if (m_iGeigerRange > 600) else if (m_iGeigerRange > 600)
{ {
pct = 2; pct = 2;
flvol = 0.4; //Con_Printf ( "range > 600\n"); flvol = 0.4; //Con_Printf ( "range > 600\n");
rg[0] = 1; rg[0] = 1;
rg[1] = 1; rg[1] = 1;
i = 2; i = 2;
} }
else if (m_iGeigerRange > 500) else if (m_iGeigerRange > 500)
{ {
pct = 4; pct = 4;
flvol = 0.5; //Con_Printf ( "range > 500\n"); flvol = 0.5; //Con_Printf ( "range > 500\n");
rg[0] = 1; rg[0] = 1;
rg[1] = 2; rg[1] = 2;
i = 2; i = 2;
} }
else if (m_iGeigerRange > 400) else if (m_iGeigerRange > 400)
{ {
pct = 8; pct = 8;
flvol = 0.6; //Con_Printf ( "range > 400\n"); flvol = 0.6; //Con_Printf ( "range > 400\n");
rg[0] = 1; rg[0] = 1;
rg[1] = 2; rg[1] = 2;
rg[2] = 3; rg[2] = 3;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 300) else if (m_iGeigerRange > 300)
{ {
pct = 8; pct = 8;
flvol = 0.7; //Con_Printf ( "range > 300\n"); flvol = 0.7; //Con_Printf ( "range > 300\n");
rg[0] = 2; rg[0] = 2;
rg[1] = 3; rg[1] = 3;
rg[2] = 4; rg[2] = 4;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 200) else if (m_iGeigerRange > 200)
{ {
pct = 28; pct = 28;
flvol = 0.78; //Con_Printf ( "range > 200\n"); flvol = 0.78; //Con_Printf ( "range > 200\n");
rg[0] = 2; rg[0] = 2;
rg[1] = 3; rg[1] = 3;
rg[2] = 4; rg[2] = 4;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 150) else if (m_iGeigerRange > 150)
{ {
pct = 40; pct = 40;
flvol = 0.80; //Con_Printf ( "range > 150\n"); flvol = 0.80; //Con_Printf ( "range > 150\n");
rg[0] = 3; rg[0] = 3;
rg[1] = 4; rg[1] = 4;
rg[2] = 5; rg[2] = 5;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 100) else if (m_iGeigerRange > 100)
{ {
pct = 60; pct = 60;
flvol = 0.85; //Con_Printf ( "range > 100\n"); flvol = 0.85; //Con_Printf ( "range > 100\n");
rg[0] = 3; rg[0] = 3;
rg[1] = 4; rg[1] = 4;
rg[2] = 5; rg[2] = 5;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 75) else if (m_iGeigerRange > 75)
{ {
pct = 80; pct = 80;
flvol = 0.9; //Con_Printf ( "range > 75\n"); flvol = 0.9; //Con_Printf ( "range > 75\n");
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
rg[0] = 4; rg[0] = 4;
rg[1] = 5; rg[1] = 5;
rg[2] = 6; rg[2] = 6;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 50) else if (m_iGeigerRange > 50)
{ {
pct = 90; pct = 90;
flvol = 0.95; //Con_Printf ( "range > 50\n"); flvol = 0.95; //Con_Printf ( "range > 50\n");
rg[0] = 5; rg[0] = 5;
rg[1] = 6; rg[1] = 6;
i = 2; i = 2;
} }
else else
{ {
pct = 95; pct = 95;
flvol = 1.0; //Con_Printf ( "range < 50\n"); flvol = 1.0; //Con_Printf ( "range < 50\n");
rg[0] = 5; rg[0] = 5;
rg[1] = 6; rg[1] = 6;
i = 2; i = 2;
} }
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5); flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
if ((rand() & 127) < pct || (rand() & 127) < pct) if ((rand() & 127) < pct || (rand() & 127) < pct)
{ {
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100); //S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
char sz[256]; char sz[256];
int j = rand() & 1; int j = rand() & 1;
if (i > 2) if (i > 2)
j += rand() & 1; j += rand() & 1;
sprintf(sz, "player/geiger%d.wav", j + 1); sprintf(sz, "player/geiger%d.wav", j + 1);
PlaySound(sz, flvol); PlaySound(sz, flvol);
} }
} }
return 1; return 1;
} }

View File

@ -1,11 +1,11 @@
// ============================ // ============================
// getfont - function, returning font pointer from text message // getfont - function, returning font pointer from text message
// written by BUzer // written by BUzer
// ============================ // ============================
#ifndef _GETFONT_H #ifndef _GETFONT_H
#define _GETFONT_H #define _GETFONT_H
Font* FontFromMessage(const char* &ptext); Font* FontFromMessage(const char* &ptext);
#endif // _GETFONT_H #endif // _GETFONT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,128 +1,128 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#define DMG_IMAGE_LIFE 2 // seconds that image is up #define DMG_IMAGE_LIFE 2 // seconds that image is up
#define DMG_IMAGE_POISON 0 #define DMG_IMAGE_POISON 0
#define DMG_IMAGE_ACID 1 #define DMG_IMAGE_ACID 1
#define DMG_IMAGE_COLD 2 #define DMG_IMAGE_COLD 2
#define DMG_IMAGE_DROWN 3 #define DMG_IMAGE_DROWN 3
#define DMG_IMAGE_BURN 4 #define DMG_IMAGE_BURN 4
#define DMG_IMAGE_NERVE 5 #define DMG_IMAGE_NERVE 5
#define DMG_IMAGE_RAD 6 #define DMG_IMAGE_RAD 6
#define DMG_IMAGE_SHOCK 7 #define DMG_IMAGE_SHOCK 7
//tf defines //tf defines
#define DMG_IMAGE_CALTROP 8 #define DMG_IMAGE_CALTROP 8
#define DMG_IMAGE_TRANQ 9 #define DMG_IMAGE_TRANQ 9
#define DMG_IMAGE_CONCUSS 10 #define DMG_IMAGE_CONCUSS 10
#define DMG_IMAGE_HALLUC 11 #define DMG_IMAGE_HALLUC 11
#define NUM_DMG_TYPES 12 #define NUM_DMG_TYPES 12
// instant damage // instant damage
#define DMG_GENERIC 0 // generic damage was done #define DMG_GENERIC 0 // generic damage was done
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object #define DMG_CRUSH (1 << 0) // crushed by falling or moving object
#define DMG_BULLET (1 << 1) // shot #define DMG_BULLET (1 << 1) // shot
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed #define DMG_SLASH (1 << 2) // cut, clawed, stabbed
#define DMG_BURN (1 << 3) // heat burned #define DMG_BURN (1 << 3) // heat burned
#define DMG_FREEZE (1 << 4) // frozen #define DMG_FREEZE (1 << 4) // frozen
#define DMG_FALL (1 << 5) // fell too far #define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage #define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt #define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
#define DMG_SHOCK (1 << 8) // electric shock #define DMG_SHOCK (1 << 8) // electric shock
#define DMG_SONIC (1 << 9) // sound pulse shockwave #define DMG_SONIC (1 << 9) // sound pulse shockwave
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam #define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death #define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. #define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
// time-based damage // time-based damage
//mask off TF-specific stuff too //mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage #define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning #define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN #define DMG_FIRSTTIMEBASED DMG_DROWN
#define DMG_PARALYZE (1 << 15) // slows affected creature down #define DMG_PARALYZE (1 << 15) // slows affected creature down
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad #define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_POISON (1 << 17) // blood poisioning #define DMG_POISON (1 << 17) // blood poisioning
#define DMG_RADIATION (1 << 18) // radiation exposure #define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery #define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns #define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven #define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer #define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) #define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
//TF ADDITIONS //TF ADDITIONS
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn #define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance #define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius. #define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor #define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
#define DMG_AIMED (1 << 28) // Does Hit location damage #define DMG_AIMED (1 << 28) // Does Hit location damage
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls #define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
#define DMG_CALTROP (1<<30) #define DMG_CALTROP (1<<30)
#define DMG_HALLUC (1<<31) #define DMG_HALLUC (1<<31)
// TF Healing Additions for TakeHealth // TF Healing Additions for TakeHealth
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE #define DMG_IGNORE_MAXHEALTH DMG_IGNITE
// TF Redefines since we never use the originals // TF Redefines since we never use the originals
#define DMG_NAIL DMG_SLASH #define DMG_NAIL DMG_SLASH
#define DMG_NOT_SELF DMG_FREEZE #define DMG_NOT_SELF DMG_FREEZE
#define DMG_TRANQ DMG_MORTAR #define DMG_TRANQ DMG_MORTAR
#define DMG_CONCUSS DMG_SONIC #define DMG_CONCUSS DMG_SONIC
typedef struct typedef struct
{ {
float fExpire; float fExpire;
float fBaseline; float fBaseline;
int x, y; int x, y;
} DAMAGE_IMAGE; } DAMAGE_IMAGE;
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudHealth: public CHudBase class CHudHealth: public CHudBase
{ {
public: public:
virtual int Init( void ); virtual int Init( void );
virtual int VidInit( void ); virtual int VidInit( void );
virtual int Draw(float fTime); virtual int Draw(float fTime);
virtual void Reset( void ); virtual void Reset( void );
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf); int MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf); int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf);
int m_iHealth; int m_iHealth;
int m_HUD_dmg_bio; int m_HUD_dmg_bio;
int m_HUD_cross; int m_HUD_cross;
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight; float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
void GetPainColor( int &r, int &g, int &b ); void GetPainColor( int &r, int &g, int &b );
float m_fFade; float m_fFade;
private: private:
HSPRITE m_hSprite; HSPRITE m_hSprite;
HSPRITE m_hDamage; HSPRITE m_hDamage;
int m_hDecoration; // buz int m_hDecoration; // buz
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES]; DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
int m_bitsDamage; int m_bitsDamage;
int DrawPain(float fTime); int DrawPain(float fTime);
int DrawDamage(float fTime); int DrawDamage(float fTime);
void CalcDamageDirection(vec3_t vecFrom); void CalcDamageDirection(vec3_t vecFrom);
void UpdateTiles(float fTime, long bits); void UpdateTiles(float fTime, long bits);
}; };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#if !defined( HUD_IFACEH ) #if !defined( HUD_IFACEH )
#define HUD_IFACEH #define HUD_IFACEH
#pragma once #pragma once
#define EXPORT _declspec( dllexport ) #define EXPORT _declspec( dllexport )
#define _DLLEXPORT __declspec( dllexport ) #define _DLLEXPORT __declspec( dllexport )
#include "../engine/cdll_int.h" #include "../engine/cdll_int.h"
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,41 +1,41 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#if !defined( HUD_SERVERSH ) #if !defined( HUD_SERVERSH )
#define HUD_SERVERSH #define HUD_SERVERSH
#pragma once #pragma once
#define NET_CALLBACK /* */ #define NET_CALLBACK /* */
// Dispatchers // Dispatchers
void NET_CALLBACK ListResponse( struct net_response_s *response ); void NET_CALLBACK ListResponse( struct net_response_s *response );
void NET_CALLBACK ServerResponse( struct net_response_s *response ); void NET_CALLBACK ServerResponse( struct net_response_s *response );
void NET_CALLBACK PingResponse( struct net_response_s *response ); void NET_CALLBACK PingResponse( struct net_response_s *response );
void NET_CALLBACK RulesResponse( struct net_response_s *response ); void NET_CALLBACK RulesResponse( struct net_response_s *response );
void NET_CALLBACK PlayersResponse( struct net_response_s *response ); void NET_CALLBACK PlayersResponse( struct net_response_s *response );
void ServersInit( void ); void ServersInit( void );
void ServersShutdown( void ); void ServersShutdown( void );
void ServersThink( double time ); void ServersThink( double time );
void ServersCancel( void ); void ServersCancel( void );
// Get list and get server info from each // Get list and get server info from each
void ServersList( void ); void ServersList( void );
// Query for IP / IPX LAN servers // Query for IP / IPX LAN servers
void BroadcastServersList( int clearpending ); void BroadcastServersList( int clearpending );
void ServerPing( int server ); void ServerPing( int server );
void ServerRules( int server ); void ServerRules( int server );
void ServerPlayers( int server ); void ServerPlayers( int server );
int ServersGetCount( void ); int ServersGetCount( void );
const char *ServersGetInfo( int server ); const char *ServersGetInfo( int server );
int ServersIsQuerying( void ); int ServersIsQuerying( void );
void SortServers( const char *fieldname ); void SortServers( const char *fieldname );
#endif // HUD_SERVERSH #endif // HUD_SERVERSH

View File

@ -1,98 +1,98 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#if !defined( HUD_SERVERS_PRIVH ) #if !defined( HUD_SERVERS_PRIVH )
#define HUD_SERVERS_PRIVH #define HUD_SERVERS_PRIVH
#pragma once #pragma once
#include "netadr.h" #include "netadr.h"
class CHudServers class CHudServers
{ {
public: public:
typedef struct request_s typedef struct request_s
{ {
struct request_s *next; struct request_s *next;
netadr_t remote_address; netadr_t remote_address;
int context; int context;
} request_t; } request_t;
typedef struct server_s typedef struct server_s
{ {
struct server_s *next; struct server_s *next;
netadr_t remote_address; netadr_t remote_address;
char *info; char *info;
int ping; int ping;
} server_t; } server_t;
CHudServers(); CHudServers();
~CHudServers(); ~CHudServers();
void Think( double time ); void Think( double time );
void QueryThink( void ); void QueryThink( void );
int isQuerying( void ); int isQuerying( void );
int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr ); int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr );
void RequestList( void ); void RequestList( void );
void RequestBroadcastList( int clearpending ); void RequestBroadcastList( int clearpending );
void ServerPing( int server ); void ServerPing( int server );
void ServerRules( int server ); void ServerRules( int server );
void ServerPlayers( int server ); void ServerPlayers( int server );
void CancelRequest( void ); void CancelRequest( void );
int CompareServers( server_t *p1, server_t *p2 ); int CompareServers( server_t *p1, server_t *p2 );
void ClearServerList( server_t **ppList ); void ClearServerList( server_t **ppList );
void ClearRequestList( request_t **ppList ); void ClearRequestList( request_t **ppList );
void AddServer( server_t **ppList, server_t *p ); void AddServer( server_t **ppList, server_t *p );
void RemoveServerFromList( request_t **ppList, request_t *item ); void RemoveServerFromList( request_t **ppList, request_t *item );
request_t *FindRequest( int context, request_t *pList ); request_t *FindRequest( int context, request_t *pList );
int ServerListSize( void ); int ServerListSize( void );
char *GetServerInfo( int server ); char *GetServerInfo( int server );
int GetServerCount( void ); int GetServerCount( void );
void SortServers( const char *fieldname ); void SortServers( const char *fieldname );
void ListResponse( struct net_response_s *response ); void ListResponse( struct net_response_s *response );
void ServerResponse( struct net_response_s *response ); void ServerResponse( struct net_response_s *response );
void PingResponse( struct net_response_s *response ); void PingResponse( struct net_response_s *response );
void RulesResponse( struct net_response_s *response ); void RulesResponse( struct net_response_s *response );
void PlayersResponse( struct net_response_s *response ); void PlayersResponse( struct net_response_s *response );
private: private:
server_t *GetServer( int server ); server_t *GetServer( int server );
// //
char m_szToken[ 1024 ]; char m_szToken[ 1024 ];
int m_nRequesting; int m_nRequesting;
int m_nDone; int m_nDone;
double m_dStarted; double m_dStarted;
request_t *m_pServerList; request_t *m_pServerList;
request_t *m_pActiveList; request_t *m_pActiveList;
server_t *m_pServers; server_t *m_pServers;
int m_nServerCount; int m_nServerCount;
int m_nActiveQueries; int m_nActiveQueries;
int m_nQuerying; int m_nQuerying;
double m_fElapsed; double m_fElapsed;
request_t *m_pPingRequest; request_t *m_pPingRequest;
request_t *m_pRulesRequest; request_t *m_pRulesRequest;
request_t *m_pPlayersRequest; request_t *m_pPlayersRequest;
}; };
#endif // HUD_SERVERS_PRIVH #endif // HUD_SERVERS_PRIVH

File diff suppressed because it is too large Load Diff

View File

@ -1,132 +1,132 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#ifndef SPECTATOR_H #ifndef SPECTATOR_H
#define SPECTATOR_H #define SPECTATOR_H
#pragma once #pragma once
#include "cl_entity.h" #include "cl_entity.h"
#define INSET_OFF 0 #define INSET_OFF 0
#define INSET_CHASE_FREE 1 #define INSET_CHASE_FREE 1
#define INSET_IN_EYE 2 #define INSET_IN_EYE 2
#define INSET_MAP_FREE 3 #define INSET_MAP_FREE 3
#define INSET_MAP_CHASE 4 #define INSET_MAP_CHASE 4
#define MAX_SPEC_HUD_MESSAGES 8 #define MAX_SPEC_HUD_MESSAGES 8
#define OVERVIEW_TILE_SIZE 128 // don't change this #define OVERVIEW_TILE_SIZE 128 // don't change this
#define OVERVIEW_MAX_LAYERS 1 #define OVERVIEW_MAX_LAYERS 1
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it ) // Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
typedef struct overviewInfo_s { typedef struct overviewInfo_s {
char map[64]; // cl.levelname or empty char map[64]; // cl.levelname or empty
vec3_t origin; // center of map vec3_t origin; // center of map
float zoom; // zoom of map images float zoom; // zoom of map images
int layers; // how may layers do we have int layers; // how may layers do we have
float layersHeights[OVERVIEW_MAX_LAYERS]; float layersHeights[OVERVIEW_MAX_LAYERS];
char layersImages[OVERVIEW_MAX_LAYERS][255]; char layersImages[OVERVIEW_MAX_LAYERS][255];
qboolean rotated; // are map images rotated (90 degrees) ? qboolean rotated; // are map images rotated (90 degrees) ?
int insetWindowX; int insetWindowX;
int insetWindowY; int insetWindowY;
int insetWindowHeight; int insetWindowHeight;
int insetWindowWidth; int insetWindowWidth;
} overviewInfo_t; } overviewInfo_t;
typedef struct overviewEntity_s { typedef struct overviewEntity_s {
HSPRITE hSprite; HSPRITE hSprite;
struct cl_entity_s * entity; struct cl_entity_s * entity;
double killTime; double killTime;
} overviewEntity_t; } overviewEntity_t;
#define MAX_OVERVIEW_ENTITIES 128 #define MAX_OVERVIEW_ENTITIES 128
class CHudSpectator : public CHudBase class CHudSpectator : public CHudBase
{ {
public: public:
void Reset(); void Reset();
int ToggleInset(bool allowOff); int ToggleInset(bool allowOff);
void CheckSettings(); void CheckSettings();
void InitHUDData( void ); void InitHUDData( void );
bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime); bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime);
void DeathMessage(int victim); void DeathMessage(int victim);
bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname ); bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname );
void CheckOverviewEntities(); void CheckOverviewEntities();
void DrawOverview(); void DrawOverview();
void DrawOverviewEntities(); void DrawOverviewEntities();
void GetMapPosition( float * returnvec ); void GetMapPosition( float * returnvec );
void DrawOverviewLayer(); void DrawOverviewLayer();
void LoadMapSprites(); void LoadMapSprites();
bool ParseOverviewFile(); bool ParseOverviewFile();
bool IsActivePlayer(cl_entity_t * ent); bool IsActivePlayer(cl_entity_t * ent);
void SetModes(int iMainMode, int iInsetMode); void SetModes(int iMainMode, int iInsetMode);
void HandleButtonsDown(int ButtonPressed); void HandleButtonsDown(int ButtonPressed);
void HandleButtonsUp(int ButtonPressed); void HandleButtonsUp(int ButtonPressed);
void FindNextPlayer( bool bReverse ); void FindNextPlayer( bool bReverse );
void DirectorMessage( int iSize, void *pbuf ); void DirectorMessage( int iSize, void *pbuf );
void SetSpectatorStartPosition(); void SetSpectatorStartPosition();
int Init(); int Init();
int VidInit(); int VidInit();
int Draw(float flTime); int Draw(float flTime);
int m_iDrawCycle; int m_iDrawCycle;
client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES]; client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES];
char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128]; char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128];
int m_lastHudMessage; int m_lastHudMessage;
overviewInfo_t m_OverviewData; overviewInfo_t m_OverviewData;
overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES]; overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES];
int m_iObserverFlags; int m_iObserverFlags;
int m_iSpectatorNumber; int m_iSpectatorNumber;
float m_mapZoom; // zoom the user currently uses float m_mapZoom; // zoom the user currently uses
vec3_t m_mapOrigin; // origin where user rotates around vec3_t m_mapOrigin; // origin where user rotates around
cvar_t * m_drawnames; cvar_t * m_drawnames;
cvar_t * m_drawcone; cvar_t * m_drawcone;
cvar_t * m_drawstatus; cvar_t * m_drawstatus;
cvar_t * m_autoDirector; cvar_t * m_autoDirector;
cvar_t * m_pip; cvar_t * m_pip;
qboolean m_chatEnabled; qboolean m_chatEnabled;
vec3_t m_cameraOrigin; // a help camera vec3_t m_cameraOrigin; // a help camera
vec3_t m_cameraAngles; // and it's angles vec3_t m_cameraAngles; // and it's angles
private: private:
vec3_t m_vPlayerPos[MAX_PLAYERS]; vec3_t m_vPlayerPos[MAX_PLAYERS];
HSPRITE m_hsprPlayerBlue; HSPRITE m_hsprPlayerBlue;
HSPRITE m_hsprPlayerRed; HSPRITE m_hsprPlayerRed;
HSPRITE m_hsprPlayer; HSPRITE m_hsprPlayer;
HSPRITE m_hsprCamera; HSPRITE m_hsprCamera;
HSPRITE m_hsprPlayerDead; HSPRITE m_hsprPlayerDead;
HSPRITE m_hsprViewcone; HSPRITE m_hsprViewcone;
HSPRITE m_hsprUnkownMap; HSPRITE m_hsprUnkownMap;
HSPRITE m_hsprBeam; HSPRITE m_hsprBeam;
HSPRITE m_hCrosshair; HSPRITE m_hCrosshair;
wrect_t m_crosshairRect; wrect_t m_crosshairRect;
struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame
float m_flNextObserverInput; float m_flNextObserverInput;
float m_zoomDelta; float m_zoomDelta;
float m_moveDelta; float m_moveDelta;
int m_lastPrimaryObject; int m_lastPrimaryObject;
int m_lastSecondaryObject; int m_lastSecondaryObject;
}; };
#endif // SPECTATOR_H #endif // SPECTATOR_H

View File

@ -1,54 +1,54 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// hud_update.cpp // hud_update.cpp
// //
#include <math.h> #include <math.h>
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <memory.h>
int CL_ButtonBits( int ); int CL_ButtonBits( int );
void CL_ResetButtonBits( int bits ); void CL_ResetButtonBits( int bits );
extern float v_idlescale; extern float v_idlescale;
float in_fov; float in_fov;
extern void HUD_SetCmdBits( int bits ); extern void HUD_SetCmdBits( int bits );
int CHud::UpdateClientData(client_data_t *cdata, float time) int CHud::UpdateClientData(client_data_t *cdata, float time)
{ {
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t)); memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t)); memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
m_iKeyBits = CL_ButtonBits( 0 ); m_iKeyBits = CL_ButtonBits( 0 );
m_iWeaponBits = cdata->iWeaponBits; m_iWeaponBits = cdata->iWeaponBits;
in_fov = cdata->fov; in_fov = cdata->fov;
Think(); Think();
cdata->fov = m_flFOV;//m_iFOV; buz cdata->fov = m_flFOV;//m_iFOV; buz
// v_idlescale = m_iConcussionEffect; // v_idlescale = m_iConcussionEffect;
CL_ResetButtonBits( m_iKeyBits ); CL_ResetButtonBits( m_iKeyBits );
// return 1 if in anything in the client_data struct has been changed, 0 otherwise // return 1 if in anything in the client_data struct has been changed, 0 otherwise
return 1; return 1;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,24 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#if !defined( IN_DEFSH ) #if !defined( IN_DEFSH )
#define IN_DEFSH #define IN_DEFSH
#pragma once #pragma once
// up / down // up / down
#define PITCH 0 #define PITCH 0
// left / right // left / right
#define YAW 1 #define YAW 1
// fall over // fall over
#define ROLL 2 #define ROLL 2
#define DLLEXPORT __declspec( dllexport ) #define DLLEXPORT __declspec( dllexport )
void V_StartPitchDrift( void ); void V_StartPitchDrift( void );
void V_StopPitchDrift( void ); void V_StopPitchDrift( void );
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#if !defined( KBUTTONH ) #if !defined( KBUTTONH )
#define KBUTTONH #define KBUTTONH
#pragma once #pragma once
typedef struct kbutton_s typedef struct kbutton_s
{ {
int down[2]; // key nums holding it down int down[2]; // key nums holding it down
int state; // low bit is down state int state; // low bit is down state
} kbutton_t; } kbutton_t;
#endif // !KBUTTONH #endif // !KBUTTONH

View File

@ -1,364 +1,364 @@
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include "parsemsg.h" #include "parsemsg.h"
#include "vgui_TeamFortressViewport.h" #include "vgui_TeamFortressViewport.h"
#include "triangleapi.h" #include "triangleapi.h"
#include "ref_params.h" #include "ref_params.h"
#include "event_api.h" #include "event_api.h"
#include "pm_defs.h" #include "pm_defs.h"
#include "pm_movevars.h" #include "pm_movevars.h"
#include "gl_local.h" #include "gl_local.h"
int CHudLensflare :: Init( void ) int CHudLensflare :: Init( void )
{ {
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
m_pCvarDraw = CVAR_REGISTER( "cl_lensflare", "1", FCVAR_ARCHIVE ); m_pCvarDraw = CVAR_REGISTER( "cl_lensflare", "1", FCVAR_ARCHIVE );
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
return 1; return 1;
} }
int CHudLensflare :: VidInit( void ) int CHudLensflare :: VidInit( void )
{ {
text[0] = SPR_Load("sprites/lens/lens1.spr"); text[0] = SPR_Load("sprites/lens/lens1.spr");
red[0] = green[0] = blue[0] = 1.0; red[0] = green[0] = blue[0] = 1.0;
scale[0] = 45; scale[0] = 45;
multi[0] = -0.45; multi[0] = -0.45;
text[1] = SPR_Load("sprites/lens/lens2.spr"); text[1] = SPR_Load("sprites/lens/lens2.spr");
red[1] = green[0] = blue[0] = 1.0; red[1] = green[0] = blue[0] = 1.0;
scale[1] = 25; scale[1] = 25;
multi[1] = 0.2; multi[1] = 0.2;
text[2] = SPR_Load("sprites/lens/glow1.spr"); text[2] = SPR_Load("sprites/lens/glow1.spr");
red[2] = 132/255; red[2] = 132/255;
green[2] = 1.0; green[2] = 1.0;
blue[2] = 153/255; blue[2] = 153/255;
scale[2] = 35; scale[2] = 35;
multi[2] = 0.3; multi[2] = 0.3;
text[3] = SPR_Load("sprites/lens/glow2.spr"); text[3] = SPR_Load("sprites/lens/glow2.spr");
red[3] = 1.0; red[3] = 1.0;
green[3] = 164/255; green[3] = 164/255;
blue[3] = 164/255; blue[3] = 164/255;
scale[3] = 40; scale[3] = 40;
multi[3] = 0.46; multi[3] = 0.46;
text[4] = SPR_Load("sprites/lens/lens3.spr"); text[4] = SPR_Load("sprites/lens/lens3.spr");
red[4] = 1.0; red[4] = 1.0;
green[4] = 164/255; green[4] = 164/255;
blue[4] = 164/255; blue[4] = 164/255;
scale[4] = 52; scale[4] = 52;
multi[4] = 0.5; multi[4] = 0.5;
text[5] = SPR_Load("sprites/lens/lens2.spr"); text[5] = SPR_Load("sprites/lens/lens2.spr");
red[5] = green[5] = blue[5] = 1.0; red[5] = green[5] = blue[5] = 1.0;
scale[5] = 31; scale[5] = 31;
multi[5] = 0.54; multi[5] = 0.54;
text[6] = SPR_Load("sprites/lens/lens2.spr"); text[6] = SPR_Load("sprites/lens/lens2.spr");
red[6] = 0.6; red[6] = 0.6;
green[6] = 1.0; green[6] = 1.0;
blue[6] = 0.6; blue[6] = 0.6;
scale[6] = 26; scale[6] = 26;
multi[6] = 0.64; multi[6] = 0.64;
text[7] = SPR_Load("sprites/lens/glow1.spr"); text[7] = SPR_Load("sprites/lens/glow1.spr");
red[7] = 0.5; red[7] = 0.5;
green[7] = 1.0; green[7] = 1.0;
blue[7] = 0.5; blue[7] = 0.5;
scale[7] = 20; scale[7] = 20;
multi[7] = 0.77; multi[7] = 0.77;
text[8] = SPR_Load("sprites/lens/lens2.spr"); text[8] = SPR_Load("sprites/lens/lens2.spr");
text[9] = SPR_Load("sprites/lens/lens1.spr"); text[9] = SPR_Load("sprites/lens/lens1.spr");
flPlayerBlend = 0.0; flPlayerBlend = 0.0;
flPlayerBlend2 = 0.0; flPlayerBlend2 = 0.0;
return 1; return 1;
} }
int CHudLensflare :: DrawFlare( const Vector &forward, const Vector &lightdir, const Vector &lightorg ) int CHudLensflare :: DrawFlare( const Vector &forward, const Vector &lightdir, const Vector &lightorg )
{ {
flPlayerBlend = max( DotProduct( forward, lightdir ) - 0.85, 0.0 ) * 6.8; flPlayerBlend = max( DotProduct( forward, lightdir ) - 0.85, 0.0 ) * 6.8;
if( flPlayerBlend > 1.0 ) flPlayerBlend = 1.0; if( flPlayerBlend > 1.0 ) flPlayerBlend = 1.0;
flPlayerBlend4 = max( DotProduct( forward, lightdir ) - 0.90, 0.0 ) * 6.6; flPlayerBlend4 = max( DotProduct( forward, lightdir ) - 0.90, 0.0 ) * 6.6;
if( flPlayerBlend4 > 1.0 ) flPlayerBlend4 = 1.0; if( flPlayerBlend4 > 1.0 ) flPlayerBlend4 = 1.0;
flPlayerBlend6 = max( DotProduct( forward, lightdir ) - 0.80, 0.0 ) * 6.7; flPlayerBlend6 = max( DotProduct( forward, lightdir ) - 0.80, 0.0 ) * 6.7;
if( flPlayerBlend6 > 1.0 ) flPlayerBlend6 = 1.0; if( flPlayerBlend6 > 1.0 ) flPlayerBlend6 = 1.0;
flPlayerBlend2 = flPlayerBlend6 * 140.0 ; flPlayerBlend2 = flPlayerBlend6 * 140.0 ;
flPlayerBlend3 = flPlayerBlend * 190.0 ; flPlayerBlend3 = flPlayerBlend * 190.0 ;
flPlayerBlend5 = flPlayerBlend4 * 222.0 ; flPlayerBlend5 = flPlayerBlend4 * 222.0 ;
Vector normal, point, screen; Vector normal, point, screen;
if( cv_renderer->value ) R_WorldToScreen( lightorg, screen ); if( cv_renderer->value ) R_WorldToScreen( lightorg, screen );
else gEngfuncs.pTriAPI->WorldToScreen( (float *)&lightorg, screen ); else gEngfuncs.pTriAPI->WorldToScreen( (float *)&lightorg, screen );
Suncoordx = XPROJECT( screen[0] ); Suncoordx = XPROJECT( screen[0] );
Suncoordy = YPROJECT( screen[1] ); Suncoordy = YPROJECT( screen[1] );
Screenmx = ScreenWidth / 2; Screenmx = ScreenWidth / 2;
Screenmy = ScreenHeight / 2; Screenmy = ScreenHeight / 2;
Sundistx = Screenmx - Suncoordx; Sundistx = Screenmx - Suncoordx;
Sundisty = Screenmy - Suncoordy; Sundisty = Screenmy - Suncoordy;
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensflare2.spr")) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensflare2.spr")) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f( 0.97f, 0.6f, 0.02f, 1.0f ); gEngfuncs.pTriAPI->Color4f( 0.97f, 0.6f, 0.02f, 1.0f );
gEngfuncs.pTriAPI->Brightness( 0.3f ); gEngfuncs.pTriAPI->Brightness( 0.3f );
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy + 190, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy + 190, 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy - 190, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy - 190, 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy - 190, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy - 190, 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy + 190, 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy + 190, 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow2.spr")) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow2.spr")) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend3/255.0); gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend3/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy + 160, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy + 160, 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy - 160, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy - 160, 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy - 160, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy - 160, 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy + 160, 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy + 160, 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow3.spr")) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow3.spr")) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend5/255.0); gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend5/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend5/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend5/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(0, 0, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(0, 0, 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(0, ScreenHeight, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(0, ScreenHeight, 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, ScreenHeight, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, ScreenHeight, 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, 0, 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, 0, 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
int i = 1; int i = 1;
Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
Lensy[i] = (Suncoordy + (Sundisty * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
Lensy[i] = (Suncoordy + (Sundisty * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
Lensy[i] = (Suncoordy + (Sundisty * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
Lensy[i] = (Suncoordy + (Sundisty * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
Lensy[i] = (Suncoordy + (Sundisty * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
Lensy[i] = (Suncoordy + (Sundisty * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
Lensx[i] = (Suncoordx + (Sundistx * multi[i])); Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
Lensy[i] = (Suncoordy + (Sundisty * multi[i])); Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
int scale1 = 32; int scale1 = 32;
int Lensx1,Lensy1 = 0; int Lensx1,Lensy1 = 0;
Lensx1 = (Suncoordx + (Sundistx * 0.88)); Lensx1 = (Suncoordx + (Sundistx * 0.88));
Lensy1 = (Suncoordy + (Sundisty * 0.88)); Lensy1 = (Suncoordy + (Sundisty * 0.88));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
i++; i++;
scale1 = 140; scale1 = 140;
Lensx1 = (Suncoordx + (Sundistx * 1.1)); Lensx1 = (Suncoordx + (Sundistx * 1.1));
Lensy1 = (Suncoordy + (Sundisty * 1.1)); Lensy1 = (Suncoordy + (Sundisty * 1.1));
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0); gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
gEngfuncs.pTriAPI->CullFace( TRI_FRONT ); gEngfuncs.pTriAPI->CullFace( TRI_FRONT );
return 1; return 1;
} }
int CHudLensflare :: Draw( float flTime ) int CHudLensflare :: Draw( float flTime )
{ {
Vector forward, sundir, suntarget; Vector forward, sundir, suntarget;
pmtrace_t ptr; pmtrace_t ptr;
if( m_pCvarDraw->value <= 0.0f ) if( m_pCvarDraw->value <= 0.0f )
return 0; return 0;
forward = g_pViewParams->forward; forward = g_pViewParams->forward;
// draw flares for dynlights // draw flares for dynlights
for( int i = 0; i < MAX_DLIGHTS; i++ ) for( int i = 0; i < MAX_DLIGHTS; i++ )
{ {
CDynLight *pl = &tr.dlights[i]; CDynLight *pl = &tr.dlights[i];
if( pl->die < flTime || !pl->radius || !FBitSet( pl->flags, DLF_LENSFLARE )) if( pl->die < flTime || !pl->radius || !FBitSet( pl->flags, DLF_LENSFLARE ))
continue; continue;
if( pl->type == LIGHT_SPOT ) if( pl->type == LIGHT_SPOT )
sundir = pl->frustum.GetPlane( FRUSTUM_FAR )->normal; sundir = pl->frustum.GetPlane( FRUSTUM_FAR )->normal;
else sundir = ( pl->origin - g_pViewParams->vieworg ).Normalize(); else sundir = ( pl->origin - g_pViewParams->vieworg ).Normalize();
suntarget = pl->origin; suntarget = pl->origin;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( g_pViewParams->vieworg, suntarget, PM_GLASS_IGNORE, -1, &ptr ); gEngfuncs.pEventAPI->EV_PlayerTrace( g_pViewParams->vieworg, suntarget, PM_GLASS_IGNORE, -1, &ptr );
if( DotProduct( forward, sundir ) >= 0.68f && !pl->frustum.CullSphere( GetVieworg(), 72.0f ) && ptr.fraction == 1.0f ) if( DotProduct( forward, sundir ) >= 0.68f && !pl->frustum.CullSphere( GetVieworg(), 72.0f ) && ptr.fraction == 1.0f )
{ {
DrawFlare( forward, sundir, suntarget ); DrawFlare( forward, sundir, suntarget );
} }
} }
if( CVAR_TO_BOOL( v_sunshafts )) if( CVAR_TO_BOOL( v_sunshafts ))
return 1; // don't mixing sunshafts and lensflares because this looks ugly return 1; // don't mixing sunshafts and lensflares because this looks ugly
if( !tr.fogEnabled ) if( !tr.fogEnabled )
{ {
Vector skyVec = tr.sky_normal; Vector skyVec = tr.sky_normal;
if( skyVec == g_vecZero ) if( skyVec == g_vecZero )
return 1; // no light_environment on a map return 1; // no light_environment on a map
sundir = -skyVec.Normalize(); sundir = -skyVec.Normalize();
suntarget = tr.cached_vieworigin + sundir * 32768.0f; suntarget = tr.cached_vieworigin + sundir * 32768.0f;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( tr.cached_vieworigin, suntarget, PM_GLASS_IGNORE, -1, &ptr ); gEngfuncs.pEventAPI->EV_PlayerTrace( tr.cached_vieworigin, suntarget, PM_GLASS_IGNORE, -1, &ptr );
if( DotProduct( forward, sundir ) >= 0.68f && R_SkyIsVisible() && gEngfuncs.PM_PointContents( ptr.endpos, null ) == CONTENTS_SKY ) if( DotProduct( forward, sundir ) >= 0.68f && R_SkyIsVisible() && gEngfuncs.PM_PointContents( ptr.endpos, null ) == CONTENTS_SKY )
{ {
DrawFlare( forward, sundir, suntarget ); DrawFlare( forward, sundir, suntarget );
} }
} }
return 1; return 1;
} }

View File

@ -1,187 +1,187 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// menu.cpp // menu.cpp
// //
// generic menu handler // generic menu handler
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "vgui_TeamFortressViewport.h" #include "vgui_TeamFortressViewport.h"
#define MAX_MENU_STRING 512 #define MAX_MENU_STRING 512
char g_szMenuString[MAX_MENU_STRING]; char g_szMenuString[MAX_MENU_STRING];
char g_szPrelocalisedMenuString[MAX_MENU_STRING]; char g_szPrelocalisedMenuString[MAX_MENU_STRING];
int KB_ConvertString( char *in, char **ppout ); int KB_ConvertString( char *in, char **ppout );
DECLARE_MESSAGE( m_Menu, ShowMenu ); DECLARE_MESSAGE( m_Menu, ShowMenu );
int CHudMenu :: Init( void ) int CHudMenu :: Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
HOOK_MESSAGE( ShowMenu ); HOOK_MESSAGE( ShowMenu );
InitHUDData(); InitHUDData();
return 1; return 1;
} }
void CHudMenu :: InitHUDData( void ) void CHudMenu :: InitHUDData( void )
{ {
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_bitsValidSlots = 0; m_bitsValidSlots = 0;
Reset(); Reset();
} }
void CHudMenu :: Reset( void ) void CHudMenu :: Reset( void )
{ {
g_szPrelocalisedMenuString[0] = 0; g_szPrelocalisedMenuString[0] = 0;
m_fWaitingForMore = FALSE; m_fWaitingForMore = FALSE;
} }
int CHudMenu :: VidInit( void ) int CHudMenu :: VidInit( void )
{ {
return 1; return 1;
} }
int CHudMenu :: Draw( float flTime ) int CHudMenu :: Draw( float flTime )
{ {
// check for if menu is set to disappear // check for if menu is set to disappear
if ( m_flShutoffTime > 0 ) if ( m_flShutoffTime > 0 )
{ {
if ( m_flShutoffTime <= gHUD.m_flTime ) if ( m_flShutoffTime <= gHUD.m_flTime )
{ // times up, shutoff { // times up, shutoff
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; return 1;
} }
} }
// don't draw the menu if the scoreboard is being shown // don't draw the menu if the scoreboard is being shown
if ( gViewPort && gViewPort->IsScoreBoardVisible() ) if ( gViewPort && gViewPort->IsScoreBoardVisible() )
return 1; return 1;
// draw the menu, along the left-hand side of the screen // draw the menu, along the left-hand side of the screen
// count the number of newlines // count the number of newlines
int nlc = 0; int nlc = 0;
for ( int i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) for ( int i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
{ {
if ( g_szMenuString[i] == '\n' ) if ( g_szMenuString[i] == '\n' )
nlc++; nlc++;
} }
// center it // center it
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
int x = 20; int x = 20;
i = 0; i = 0;
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' ) while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
{ {
gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 ); gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
y += 12; y += 12;
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' ) while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
i++; i++;
if ( g_szMenuString[i] == '\n' ) if ( g_szMenuString[i] == '\n' )
i++; i++;
} }
return 1; return 1;
} }
// selects an item from the menu // selects an item from the menu
void CHudMenu :: SelectMenuItem( int menu_item ) void CHudMenu :: SelectMenuItem( int menu_item )
{ {
// if menu_item is in a valid slot, send a menuselect command to the server // if menu_item is in a valid slot, send a menuselect command to the server
if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) ) if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) )
{ {
char szbuf[32]; char szbuf[32];
sprintf( szbuf, "menuselect %d\n", menu_item ); sprintf( szbuf, "menuselect %d\n", menu_item );
ClientCmd( szbuf ); ClientCmd( szbuf );
// remove the menu // remove the menu
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
} }
} }
// Message handler for ShowMenu message // Message handler for ShowMenu message
// takes four values: // takes four values:
// short: a bitfield of keys that are valid input // short: a bitfield of keys that are valid input
// char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen. // char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen.
// byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string // byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string
// string: menu string to display // string: menu string to display
// if this message is never received, then scores will simply be the combined totals of the players. // if this message is never received, then scores will simply be the combined totals of the players.
int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
{ {
char *temp = NULL; char *temp = NULL;
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_bitsValidSlots = READ_SHORT(); m_bitsValidSlots = READ_SHORT();
int DisplayTime = READ_CHAR(); int DisplayTime = READ_CHAR();
int NeedMore = READ_BYTE(); int NeedMore = READ_BYTE();
if ( DisplayTime > 0 ) if ( DisplayTime > 0 )
m_flShutoffTime = DisplayTime + gHUD.m_flTime; m_flShutoffTime = DisplayTime + gHUD.m_flTime;
else else
m_flShutoffTime = -1; m_flShutoffTime = -1;
if ( m_bitsValidSlots ) if ( m_bitsValidSlots )
{ {
if ( !m_fWaitingForMore ) // this is the start of a new menu if ( !m_fWaitingForMore ) // this is the start of a new menu
{ {
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING ); strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
} }
else else
{ // append to the current menu string { // append to the current menu string
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) ); strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
} }
g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not) g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not)
if ( !NeedMore ) if ( !NeedMore )
{ // we have the whole string, so we can localise it now { // we have the whole string, so we can localise it now
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ); strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
// Swap in characters // Swap in characters
if ( KB_ConvertString( g_szMenuString, &temp ) ) if ( KB_ConvertString( g_szMenuString, &temp ) )
{ {
strcpy( g_szMenuString, temp ); strcpy( g_szMenuString, temp );
free( temp ); free( temp );
} }
} }
m_fMenuDisplayed = 1; m_fMenuDisplayed = 1;
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
} }
else else
{ {
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
} }
m_fWaitingForMore = NeedMore; m_fWaitingForMore = NeedMore;
return 1; return 1;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,31 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#ifndef OVERVIEW_H #ifndef OVERVIEW_H
#define OVERVIEW_H #define OVERVIEW_H
#pragma once #pragma once
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Handles the drawing of the top-down map and all the things on it // Purpose: Handles the drawing of the top-down map and all the things on it
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class CHudOverview : public CHudBase class CHudOverview : public CHudBase
{ {
public: public:
int Init(); int Init();
int VidInit(); int VidInit();
int Draw(float flTime); int Draw(float flTime);
void InitHUDData( void ); void InitHUDData( void );
private: private:
HSPRITE m_hsprPlayer; HSPRITE m_hsprPlayer;
HSPRITE m_hsprViewcone; HSPRITE m_hsprViewcone;
}; };
#endif // OVERVIEW_H #endif // OVERVIEW_H

View File

@ -1,178 +1,178 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// parsemsg.cpp // parsemsg.cpp
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "com_model.h" #include "com_model.h"
#include "gl_local.h" #include "gl_local.h"
typedef unsigned char byte; typedef unsigned char byte;
#define true 1 #define true 1
static byte *gpBuf; static byte *gpBuf;
static int giSize; static int giSize;
static int giRead; static int giRead;
static int giBadRead; static int giBadRead;
void BEGIN_READ( void *buf, int size ) void BEGIN_READ( void *buf, int size )
{ {
giRead = 0; giRead = 0;
giBadRead = 0; giBadRead = 0;
giSize = size; giSize = size;
gpBuf = (byte*)buf; gpBuf = (byte*)buf;
} }
int READ_CHAR( void ) int READ_CHAR( void )
{ {
int c; int c;
if (giRead + 1 > giSize) if (giRead + 1 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = (signed char)gpBuf[giRead]; c = (signed char)gpBuf[giRead];
giRead++; giRead++;
return c; return c;
} }
int READ_BYTE( void ) int READ_BYTE( void )
{ {
int c; int c;
if (giRead+1 > giSize) if (giRead+1 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = (unsigned char)gpBuf[giRead]; c = (unsigned char)gpBuf[giRead];
giRead++; giRead++;
return c; return c;
} }
int READ_SHORT( void ) int READ_SHORT( void )
{ {
int c; int c;
if (giRead+2 > giSize) if (giRead+2 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) );
giRead += 2; giRead += 2;
return c; return c;
} }
int READ_WORD( void ) int READ_WORD( void )
{ {
return READ_SHORT(); return READ_SHORT();
} }
int READ_LONG( void ) int READ_LONG( void )
{ {
int c; int c;
if (giRead+4 > giSize) if (giRead+4 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24);
giRead += 4; giRead += 4;
return c; return c;
} }
float READ_FLOAT( void ) float READ_FLOAT( void )
{ {
union union
{ {
byte b[4]; byte b[4];
float f; float f;
int l; int l;
} dat; } dat;
dat.b[0] = gpBuf[giRead]; dat.b[0] = gpBuf[giRead];
dat.b[1] = gpBuf[giRead+1]; dat.b[1] = gpBuf[giRead+1];
dat.b[2] = gpBuf[giRead+2]; dat.b[2] = gpBuf[giRead+2];
dat.b[3] = gpBuf[giRead+3]; dat.b[3] = gpBuf[giRead+3];
giRead += 4; giRead += 4;
// dat.l = LittleLong (dat.l); // dat.l = LittleLong (dat.l);
return dat.f; return dat.f;
} }
char* READ_STRING( void ) char* READ_STRING( void )
{ {
static char string[2048]; static char string[2048];
int l,c; int l,c;
string[0] = 0; string[0] = 0;
l = 0; l = 0;
do do
{ {
if ( giRead+1 > giSize ) if ( giRead+1 > giSize )
break; // no more characters break; // no more characters
c = READ_CHAR(); c = READ_CHAR();
if (c == 0) break; if (c == 0) break;
string[l] = c; string[l] = c;
l++; l++;
} while (l < sizeof(string)-1); } while (l < sizeof(string)-1);
string[l] = 0; string[l] = 0;
return string; return string;
} }
float READ_COORD( void ) float READ_COORD( void )
{ {
// g-cont. we loose precision here but keep old size of coord variable! // g-cont. we loose precision here but keep old size of coord variable!
if( g_fRenderInitialized && RENDER_GET_PARM( PARM_FEATURES, 0 ) & ENGINE_WRITE_LARGE_COORD ) if( g_fRenderInitialized && RENDER_GET_PARM( PARM_FEATURES, 0 ) & ENGINE_WRITE_LARGE_COORD )
return (float)(READ_SHORT() * 1.0f); return (float)(READ_SHORT() * 1.0f);
return (float)(READ_SHORT() * (1.0f / 8.0f)); return (float)(READ_SHORT() * (1.0f / 8.0f));
} }
float READ_ANGLE( void ) float READ_ANGLE( void )
{ {
return (float)(READ_CHAR() * (360.0/256)); return (float)(READ_CHAR() * (360.0/256));
} }
float READ_HIRESANGLE( void ) float READ_HIRESANGLE( void )
{ {
return (float)(READ_SHORT() * (360.0/65536)); return (float)(READ_SHORT() * (360.0/65536));
} }
BOOL REMAIN_BYTES( void ) BOOL REMAIN_BYTES( void )
{ {
return giRead < giSize; return giRead < giSize;
} }

View File

@ -1,38 +1,38 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// parsemsg.h // parsemsg.h
// //
void BEGIN_READ( void *buf, int size ); void BEGIN_READ( void *buf, int size );
int READ_CHAR( void ); int READ_CHAR( void );
int READ_BYTE( void ); int READ_BYTE( void );
int READ_SHORT( void ); int READ_SHORT( void );
int READ_WORD( void ); int READ_WORD( void );
int READ_LONG( void ); int READ_LONG( void );
float READ_FLOAT( void ); float READ_FLOAT( void );
char* READ_STRING( void ); char* READ_STRING( void );
float READ_COORD( void ); float READ_COORD( void );
float READ_ANGLE( void ); float READ_ANGLE( void );
float READ_HIRESANGLE( void ); float READ_HIRESANGLE( void );
BOOL REMAIN_BYTES( void ); BOOL REMAIN_BYTES( void );

View File

@ -1,88 +1,88 @@
/* /*
cl_dlight.h - dynamic lighting description cl_dlight.h - dynamic lighting description
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2014 Uncle Mike Copyright (C) 2014 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef CL_DLIGHT_H #ifndef CL_DLIGHT_H
#define CL_DLIGHT_H #define CL_DLIGHT_H
#define NUM_SHADOW_SPLITS 3 // four splits #define NUM_SHADOW_SPLITS 3 // four splits
#define MAX_SHADOWMAPS (NUM_SHADOW_SPLITS + 1) #define MAX_SHADOWMAPS (NUM_SHADOW_SPLITS + 1)
// dlight flags // dlight flags
#define DLF_NOSHADOWS BIT( 0 ) #define DLF_NOSHADOWS BIT( 0 )
#define DLF_NOBUMP BIT( 1 ) #define DLF_NOBUMP BIT( 1 )
#define DLF_LENSFLARE BIT( 2 ) #define DLF_LENSFLARE BIT( 2 )
#define DLF_CULLED BIT( 3 ) // light culled by scissor #define DLF_CULLED BIT( 3 ) // light culled by scissor
#define DLF_ASPECT3X4 BIT( 4 ) #define DLF_ASPECT3X4 BIT( 4 )
#define DLF_ASPECT4X3 BIT( 5 ) #define DLF_ASPECT4X3 BIT( 5 )
#define DLF_FLIPTEXTURE BIT( 6 ) #define DLF_FLIPTEXTURE BIT( 6 )
class CDynLight class CDynLight
{ {
public: public:
Vector origin; Vector origin;
Vector angles; Vector angles;
float radius; float radius;
Vector color; // ignored for spotlights, they have a texture Vector color; // ignored for spotlights, they have a texture
float die; // stop lighting after this time float die; // stop lighting after this time
float decay; // drop this each second float decay; // drop this each second
int key; int key;
int type; // light type int type; // light type
bool update; // light needs update bool update; // light needs update
matrix4x4 viewMatrix; matrix4x4 viewMatrix;
matrix4x4 projectionMatrix; // light projection matrix matrix4x4 projectionMatrix; // light projection matrix
matrix4x4 modelviewMatrix; // light modelview matrix4x4 modelviewMatrix; // light modelview
matrix4x4 lightviewProjMatrix; // lightview projection matrix4x4 lightviewProjMatrix; // lightview projection
matrix4x4 textureMatrix[MAX_SHADOWMAPS]; // result texture matrix matrix4x4 textureMatrix[MAX_SHADOWMAPS]; // result texture matrix
matrix4x4 shadowMatrix[MAX_SHADOWMAPS]; // result texture matrix matrix4x4 shadowMatrix[MAX_SHADOWMAPS]; // result texture matrix
GLfloat gl_shadowMatrix[MAX_SHADOWMAPS][16]; // cached matrices GLfloat gl_shadowMatrix[MAX_SHADOWMAPS][16]; // cached matrices
Vector mins, maxs; // local bounds Vector mins, maxs; // local bounds
Vector absmin, absmax; // world bounds Vector absmin, absmax; // world bounds
CFrustum frustum; // normal frustum CFrustum frustum; // normal frustum
CFrustum splitFrustum[MAX_SHADOWMAPS]; CFrustum splitFrustum[MAX_SHADOWMAPS];
// scissor data // scissor data
float x, y, w, h; float x, y, w, h;
// spotlight specific: // spotlight specific:
int spotlightTexture; // spotlights only int spotlightTexture; // spotlights only
int shadowTexture[MAX_SHADOWMAPS]; // shadowmap for this light int shadowTexture[MAX_SHADOWMAPS]; // shadowmap for this light
int cinTexturenum; // not gltexturenum! int cinTexturenum; // not gltexturenum!
int lastframe; // cinematic lastframe int lastframe; // cinematic lastframe
int flags; int flags;
float fov; float fov;
bool Expired( void ) bool Expired( void )
{ {
if( die < GET_CLIENT_TIME( )) if( die < GET_CLIENT_TIME( ))
return true; return true;
if( radius <= 0.0f ) if( radius <= 0.0f )
return true; return true;
return false; return false;
} }
bool Active( void ) bool Active( void )
{ {
if( Expired( )) if( Expired( ))
return false; return false;
if( FBitSet( flags, DLF_CULLED )) if( FBitSet( flags, DLF_CULLED ))
return false; return false;
return true; return true;
} }
}; };
#endif//CL_DLIGHT_H #endif//CL_DLIGHT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,211 +1,211 @@
/* /*
r_particle.h - Laurie Cheers Aurora Particle System r_particle.h - Laurie Cheers Aurora Particle System
First implementation of 02/08/02 November235 First implementation of 02/08/02 November235
Copyright (C) 2011 Uncle Mike Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_PARTICLE_H #ifndef GL_PARTICLE_H
#define GL_PARTICLE_H #define GL_PARTICLE_H
class CParticleType; class CParticleType;
class CParticleSystem; class CParticleSystem;
#include "randomrange.h" #include "randomrange.h"
struct CParticle struct CParticle
{ {
CParticle *nextpart; CParticle *nextpart;
CParticle *m_pOverlay; // for making multi-layered particles CParticle *m_pOverlay; // for making multi-layered particles
CParticleType *pType; CParticleType *pType;
Vector origin; Vector origin;
Vector velocity; Vector velocity;
Vector accel; Vector accel;
Vector m_vecWind; Vector m_vecWind;
cl_entity_t *m_pEntity; // if not null, this particle is tied to the given entity cl_entity_t *m_pEntity; // if not null, this particle is tied to the given entity
float m_fRed; float m_fRed;
float m_fGreen; float m_fGreen;
float m_fBlue; float m_fBlue;
float m_fRedStep; float m_fRedStep;
float m_fGreenStep; float m_fGreenStep;
float m_fBlueStep; float m_fBlueStep;
float m_fAlpha; float m_fAlpha;
float m_fAlphaStep; float m_fAlphaStep;
float frame; float frame;
float m_fFrameStep; float m_fFrameStep;
float m_fAngle; float m_fAngle;
float m_fAngleStep; float m_fAngleStep;
float m_fSize; float m_fSize;
float m_fSizeStep; float m_fSizeStep;
float m_fDrag; float m_fDrag;
float age; float age;
float age_death; float age_death;
float age_spray; float age_spray;
}; };
class CParticleType class CParticleType
{ {
public: public:
CParticleType( CParticleType *pNext = NULL ); CParticleType( CParticleType *pNext = NULL );
// here is a particle system. Add a (set of) particles according to this type, and initialise their values. // here is a particle system. Add a (set of) particles according to this type, and initialise their values.
CParticle *CreateParticle( CParticleSystem *pSys ); CParticle *CreateParticle( CParticleSystem *pSys );
// initialise this particle. Does not define velocity or age. // initialise this particle. Does not define velocity or age.
void InitParticle( CParticle *pPart, CParticleSystem *pSys ); void InitParticle( CParticle *pPart, CParticleSystem *pSys );
bool m_bIsDefined; // is this CParticleType just a placeholder? bool m_bIsDefined; // is this CParticleType just a placeholder?
int m_iRenderMode; int m_iRenderMode;
int m_iDrawCond; int m_iDrawCond;
RandomRange m_Bounce; RandomRange m_Bounce;
RandomRange m_BounceFriction; RandomRange m_BounceFriction;
bool m_bBouncing; bool m_bBouncing;
RandomRange m_Life; RandomRange m_Life;
RandomRange m_StartAlpha; RandomRange m_StartAlpha;
RandomRange m_EndAlpha; RandomRange m_EndAlpha;
RandomRange m_StartRed; RandomRange m_StartRed;
RandomRange m_EndRed; RandomRange m_EndRed;
RandomRange m_StartGreen; RandomRange m_StartGreen;
RandomRange m_EndGreen; RandomRange m_EndGreen;
RandomRange m_StartBlue; RandomRange m_StartBlue;
RandomRange m_EndBlue; RandomRange m_EndBlue;
RandomRange m_StartSize; RandomRange m_StartSize;
RandomRange m_SizeDelta; RandomRange m_SizeDelta;
RandomRange m_EndSize; RandomRange m_EndSize;
RandomRange m_StartFrame; RandomRange m_StartFrame;
RandomRange m_EndFrame; RandomRange m_EndFrame;
RandomRange m_FrameRate; // incompatible with EndFrame RandomRange m_FrameRate; // incompatible with EndFrame
bool m_bEndFrame; bool m_bEndFrame;
RandomRange m_StartAngle; RandomRange m_StartAngle;
RandomRange m_AngleDelta; RandomRange m_AngleDelta;
RandomRange m_SprayRate; RandomRange m_SprayRate;
RandomRange m_SprayForce; RandomRange m_SprayForce;
RandomRange m_SprayPitch; RandomRange m_SprayPitch;
RandomRange m_SprayYaw; RandomRange m_SprayYaw;
RandomRange m_SprayRoll; RandomRange m_SprayRoll;
CParticleType *m_pSprayType; CParticleType *m_pSprayType;
RandomRange m_Gravity; RandomRange m_Gravity;
RandomRange m_WindStrength; RandomRange m_WindStrength;
RandomRange m_WindYaw; RandomRange m_WindYaw;
HSPRITE m_hSprite; HSPRITE m_hSprite;
CParticleType *m_pOverlayType; CParticleType *m_pOverlayType;
RandomRange m_Drag; RandomRange m_Drag;
CParticleType *m_pNext; CParticleType *m_pNext;
char m_szName[32]; char m_szName[32];
}; };
typedef enum typedef enum
{ {
AURORA_REMOVE = 0, AURORA_REMOVE = 0,
AURORA_INVISIBLE, AURORA_INVISIBLE,
AURORA_DRAW, AURORA_DRAW,
} AURSTATE; } AURSTATE;
class CParticleSystem class CParticleSystem
{ {
public: public:
CParticleSystem( cl_entity_t *ent, const char *szFilename, int attachment = 0, float lifetime = 0.0f ); CParticleSystem( cl_entity_t *ent, const char *szFilename, int attachment = 0, float lifetime = 0.0f );
~CParticleSystem( void ); ~CParticleSystem( void );
void AllocateParticles( int iParticles ); void AllocateParticles( int iParticles );
void CalculateDistance( void ); void CalculateDistance( void );
CParticleType *GetType( const char *szName ); CParticleType *GetType( const char *szName );
CParticleType *AddPlaceholderType( const char *szName ); CParticleType *AddPlaceholderType( const char *szName );
CParticleType *ParseType( char *&szFile ); CParticleType *ParseType( char *&szFile );
cl_entity_t *GetEntity() { return m_pEntity; } cl_entity_t *GetEntity() { return m_pEntity; }
// General functions // General functions
AURSTATE UpdateSystem( float frametime ); // If this function returns false, the manager deletes the system AURSTATE UpdateSystem( float frametime ); // If this function returns false, the manager deletes the system
void DrawSystem( void ); void DrawSystem( void );
CParticle *ActivateParticle( void ); // adds one of the free particles to the active list, and returns it for initialisation. CParticle *ActivateParticle( void ); // adds one of the free particles to the active list, and returns it for initialisation.
// MUST CHECK WHETHER THIS RESULT IS NULL! // MUST CHECK WHETHER THIS RESULT IS NULL!
// returns false if the particle has died // returns false if the particle has died
bool UpdateParticle( CParticle *part, float frametime ); bool UpdateParticle( CParticle *part, float frametime );
void DrawParticle( CParticle *part, Vector &right, Vector &up ); void DrawParticle( CParticle *part, Vector &right, Vector &up );
// Utility functions that have to be public // Utility functions that have to be public
bool ParticleIsVisible( CParticle* part ); bool ParticleIsVisible( CParticle* part );
void MarkForDeletion( void ); void MarkForDeletion( void );
static float CosLookup( int angle ) { return angle < 0 ? c_fCosTable[angle+360] : c_fCosTable[angle]; } static float CosLookup( int angle ) { return angle < 0 ? c_fCosTable[angle+360] : c_fCosTable[angle]; }
static float SinLookup( int angle ) { return angle < -90 ? c_fCosTable[angle+450] : c_fCosTable[angle+90]; } static float SinLookup( int angle ) { return angle < -90 ? c_fCosTable[angle+450] : c_fCosTable[angle+90]; }
// Pointer to next system for linked list structure // Pointer to next system for linked list structure
CParticleSystem *m_pNextSystem; CParticleSystem *m_pNextSystem;
CParticle *m_pActiveParticle; CParticle *m_pActiveParticle;
float m_fViewerDist; float m_fViewerDist;
cl_entity_t *m_pEntity; cl_entity_t *m_pEntity;
int m_iEntAttachment; int m_iEntAttachment;
int m_iKillCondition; int m_iKillCondition;
int m_iLightingModel; int m_iLightingModel;
matrix3x3 entityMatrix; matrix3x3 entityMatrix;
int m_fHasProjectionLighting; int m_fHasProjectionLighting;
float m_fLifeTime; // for auto-removed particles float m_fLifeTime; // for auto-removed particles
bool enable; bool enable;
private: private:
static float c_fCosTable[360 + 90]; static float c_fCosTable[360 + 90];
static bool c_bCosTableInit; static bool c_bCosTableInit;
// the block of allocated particles // the block of allocated particles
CParticle *m_pAllParticles; CParticle *m_pAllParticles;
// First particles in the linked list for the active particles and the dead particles // First particles in the linked list for the active particles and the dead particles
CParticle *m_pFreeParticle; CParticle *m_pFreeParticle;
CParticle *m_pMainParticle; // the "source" particle. CParticle *m_pMainParticle; // the "source" particle.
CParticleType *m_pFirstType; CParticleType *m_pFirstType;
CParticleType *m_pMainType; CParticleType *m_pMainType;
}; };
class CParticleSystemManager class CParticleSystemManager
{ {
public: public:
CParticleSystemManager( void ); CParticleSystemManager( void );
~CParticleSystemManager( void ); ~CParticleSystemManager( void );
void AddSystem( CParticleSystem* ); void AddSystem( CParticleSystem* );
CParticleSystem *FindSystem( CParticleSystem *pFirstSystem, cl_entity_t *pEntity ); CParticleSystem *FindSystem( CParticleSystem *pFirstSystem, cl_entity_t *pEntity );
void MarkSystemForDeletion( CParticleSystem *pSys ); void MarkSystemForDeletion( CParticleSystem *pSys );
void UpdateSystems( void ); void UpdateSystems( void );
void ClearSystems( void ); void ClearSystems( void );
void SortSystems( void ); void SortSystems( void );
private: private:
CParticleSystem *m_pFirstSystem; CParticleSystem *m_pFirstSystem;
}; };
extern CParticleSystemManager g_pParticleSystems; // buz extern CParticleSystemManager g_pParticleSystems; // buz
#endif//GL_PARTICLE_H #endif//GL_PARTICLE_H

File diff suppressed because it is too large Load Diff

View File

@ -1,228 +1,228 @@
/* /*
gl_cubemaps.cpp - tools for cubemaps search & handling gl_cubemaps.cpp - tools for cubemaps search & handling
Copyright (C) 2016 Uncle Mike Copyright (C) 2016 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "com_model.h" #include "com_model.h"
#include "ref_params.h" #include "ref_params.h"
#include "gl_local.h" #include "gl_local.h"
#include "gl_decals.h" #include "gl_decals.h"
#include <mathlib.h> #include <mathlib.h>
#include "gl_world.h" #include "gl_world.h"
/* /*
================= =================
CL_FindNearestCubeMap CL_FindNearestCubeMap
find the nearest cubemap for a given point find the nearest cubemap for a given point
================= =================
*/ */
void CL_FindNearestCubeMap( const Vector &pos, mcubemap_t **result ) void CL_FindNearestCubeMap( const Vector &pos, mcubemap_t **result )
{ {
if( !result ) return; if( !result ) return;
float maxDist = 99999.0f; float maxDist = 99999.0f;
*result = NULL; *result = NULL;
for( int i = 0; i < world->num_cubemaps; i++ ) for( int i = 0; i < world->num_cubemaps; i++ )
{ {
mcubemap_t *check = &world->cubemaps[i]; mcubemap_t *check = &world->cubemaps[i];
float dist = VectorDistance( check->origin, pos ); float dist = VectorDistance( check->origin, pos );
if( dist < maxDist ) if( dist < maxDist )
{ {
*result = check; *result = check;
maxDist = dist; maxDist = dist;
} }
} }
if( !*result ) if( !*result )
{ {
// this may happens if map // this may happens if map
// doesn't have any cubemaps // doesn't have any cubemaps
*result = &world->defaultCubemap; *result = &world->defaultCubemap;
} }
} }
/* /*
================= =================
CL_FindNearestCubeMapForSurface CL_FindNearestCubeMapForSurface
find the nearest cubemap on front of plane find the nearest cubemap on front of plane
================= =================
*/ */
void CL_FindNearestCubeMapForSurface( const Vector &pos, const msurface_t *surf, mcubemap_t **result ) void CL_FindNearestCubeMapForSurface( const Vector &pos, const msurface_t *surf, mcubemap_t **result )
{ {
if( !result ) return; if( !result ) return;
float maxDist = 99999.0f; float maxDist = 99999.0f;
mplane_t plane; mplane_t plane;
*result = NULL; *result = NULL;
plane = *surf->plane; plane = *surf->plane;
if( FBitSet( surf->flags, SURF_PLANEBACK )) if( FBitSet( surf->flags, SURF_PLANEBACK ))
{ {
plane.normal = -plane.normal; plane.normal = -plane.normal;
plane.dist = -plane.dist; plane.dist = -plane.dist;
} }
for( int i = 0; i < world->num_cubemaps; i++ ) for( int i = 0; i < world->num_cubemaps; i++ )
{ {
mcubemap_t *check = &world->cubemaps[i]; mcubemap_t *check = &world->cubemaps[i];
float dist = VectorDistance( check->origin, pos ); float dist = VectorDistance( check->origin, pos );
if( dist < maxDist && PlaneDiff( check->origin, &plane ) >= 0.0f ) if( dist < maxDist && PlaneDiff( check->origin, &plane ) >= 0.0f )
{ {
*result = check; *result = check;
maxDist = dist; maxDist = dist;
} }
} }
if( *result ) return; if( *result ) return;
// fallback to default method // fallback to default method
CL_FindNearestCubeMap( pos, result ); CL_FindNearestCubeMap( pos, result );
} }
/* /*
================= =================
CL_FindTwoNearestCubeMap CL_FindTwoNearestCubeMap
find the two nearest cubemaps for a given point find the two nearest cubemaps for a given point
================= =================
*/ */
void CL_FindTwoNearestCubeMap( const Vector &pos, mcubemap_t **result1, mcubemap_t **result2 ) void CL_FindTwoNearestCubeMap( const Vector &pos, mcubemap_t **result1, mcubemap_t **result2 )
{ {
if( !result1 || !result2 ) if( !result1 || !result2 )
return; return;
float maxDist1 = 99999.0f; float maxDist1 = 99999.0f;
float maxDist2 = 99999.0f; float maxDist2 = 99999.0f;
*result1 = *result2 = NULL; *result1 = *result2 = NULL;
for( int i = 0; i < world->num_cubemaps; i++ ) for( int i = 0; i < world->num_cubemaps; i++ )
{ {
mcubemap_t *check = &world->cubemaps[i]; mcubemap_t *check = &world->cubemaps[i];
float dist = VectorDistance( check->origin, pos ); float dist = VectorDistance( check->origin, pos );
if( dist < maxDist1 ) if( dist < maxDist1 )
{ {
*result1 = check; *result1 = check;
maxDist1 = dist; maxDist1 = dist;
} }
else if( dist < maxDist2 && dist > maxDist1 ) else if( dist < maxDist2 && dist > maxDist1 )
{ {
*result2 = check; *result2 = check;
maxDist2 = dist; maxDist2 = dist;
} }
} }
if( !*result1 ) if( !*result1 )
{ {
// this may happens if map // this may happens if map
// doesn't have any cubemaps // doesn't have any cubemaps
*result1 = &world->defaultCubemap; *result1 = &world->defaultCubemap;
} }
if( !*result2 ) if( !*result2 )
{ {
// this may happens if map // this may happens if map
// doesn't have any cubemaps // doesn't have any cubemaps
*result2 = *result1; *result2 = *result1;
} }
} }
/* /*
================= =================
CL_FindTwoNearestCubeMapForSurface CL_FindTwoNearestCubeMapForSurface
find the two nearest cubemaps on front of plane find the two nearest cubemaps on front of plane
================= =================
*/ */
void CL_FindTwoNearestCubeMapForSurface( const Vector &pos, const msurface_t *surf, mcubemap_t **result1, mcubemap_t **result2 ) void CL_FindTwoNearestCubeMapForSurface( const Vector &pos, const msurface_t *surf, mcubemap_t **result1, mcubemap_t **result2 )
{ {
if( !result1 || !result2 ) return; if( !result1 || !result2 ) return;
float maxDist1 = 99999.0f; float maxDist1 = 99999.0f;
float maxDist2 = 99999.0f; float maxDist2 = 99999.0f;
mplane_t plane; mplane_t plane;
*result1 = NULL; *result1 = NULL;
*result2 = NULL; *result2 = NULL;
plane = *surf->plane; plane = *surf->plane;
if( FBitSet( surf->flags, SURF_PLANEBACK )) if( FBitSet( surf->flags, SURF_PLANEBACK ))
{ {
plane.normal = -plane.normal; plane.normal = -plane.normal;
plane.dist = -plane.dist; plane.dist = -plane.dist;
} }
for( int i = 0; i < world->num_cubemaps; i++ ) for( int i = 0; i < world->num_cubemaps; i++ )
{ {
mcubemap_t *check = &world->cubemaps[i]; mcubemap_t *check = &world->cubemaps[i];
float dist = VectorDistance( check->origin, pos ); float dist = VectorDistance( check->origin, pos );
if( dist < maxDist1 && PlaneDiff( check->origin, &plane ) >= 0.0f ) if( dist < maxDist1 && PlaneDiff( check->origin, &plane ) >= 0.0f )
{ {
*result1 = check; *result1 = check;
maxDist1 = dist; maxDist1 = dist;
} }
else if( dist < maxDist2 && dist > maxDist1 ) else if( dist < maxDist2 && dist > maxDist1 )
{ {
*result2 = check; *result2 = check;
maxDist2 = dist; maxDist2 = dist;
} }
} }
if( *result1 ) if( *result1 )
{ {
if( !*result2 ) if( !*result2 )
*result2 = *result1; *result2 = *result1;
return; return;
} }
// fallback to default method // fallback to default method
CL_FindTwoNearestCubeMap( pos, result1, result2 ); CL_FindTwoNearestCubeMap( pos, result1, result2 );
} }
/* /*
================= =================
CL_BuildCubemaps_f CL_BuildCubemaps_f
force to rebuilds all the cubemaps force to rebuilds all the cubemaps
in the scene in the scene
================= =================
*/ */
void CL_BuildCubemaps_f( void ) void CL_BuildCubemaps_f( void )
{ {
mcubemap_t *m = &world->defaultCubemap; mcubemap_t *m = &world->defaultCubemap;
FREE_TEXTURE( m->texture ); FREE_TEXTURE( m->texture );
m->valid = m->texture = false; m->valid = m->texture = false;
for( int i = 0; i < world->num_cubemaps; i++ ) for( int i = 0; i < world->num_cubemaps; i++ )
{ {
mcubemap_t *m = &world->cubemaps[i]; mcubemap_t *m = &world->cubemaps[i];
FREE_TEXTURE( m->texture ); FREE_TEXTURE( m->texture );
m->valid = m->texture = false; m->valid = m->texture = false;
} }
if( FBitSet( world->features, WORLD_HAS_SKYBOX )) if( FBitSet( world->features, WORLD_HAS_SKYBOX ))
world->build_default_cubemap = true; world->build_default_cubemap = true;
world->rebuilding_cubemaps = CMREBUILD_CHECKING; world->rebuilding_cubemaps = CMREBUILD_CHECKING;
world->loading_cubemaps = true; world->loading_cubemaps = true;
} }

View File

@ -1,253 +1,253 @@
/* /*
gl_cull.cpp - render culling routines gl_cull.cpp - render culling routines
Copyright (C) 2011 Uncle Mike Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "gl_local.h" #include "gl_local.h"
#include "entity_types.h" #include "entity_types.h"
#include "mathlib.h" #include "mathlib.h"
#include "gl_world.h" #include "gl_world.h"
#include "gl_grass.h" #include "gl_grass.h"
/* /*
============= =============
R_CullModel R_CullModel
============= =============
*/ */
bool R_CullModel( cl_entity_t *e, const Vector &absmin, const Vector &absmax ) bool R_CullModel( cl_entity_t *e, const Vector &absmin, const Vector &absmax )
{ {
if( e == GET_VIEWMODEL( ) || e == gHUD.m_pHeadShieldEnt ) if( e == GET_VIEWMODEL( ) || e == gHUD.m_pHeadShieldEnt )
{ {
if( RI->params & RP_NONVIEWERREF ) if( RI->params & RP_NONVIEWERREF )
return true; return true;
return false; return false;
} }
// don't reflect this entity in mirrors // don't reflect this entity in mirrors
if( FBitSet( e->curstate.effects, EF_NOREFLECT ) && FBitSet( RI->params, RP_MIRRORVIEW )) if( FBitSet( e->curstate.effects, EF_NOREFLECT ) && FBitSet( RI->params, RP_MIRRORVIEW ))
return true; return true;
// draw only in mirrors // draw only in mirrors
if( FBitSet( e->curstate.effects, EF_REFLECTONLY ) && !FBitSet( RI->params, RP_MIRRORVIEW )) if( FBitSet( e->curstate.effects, EF_REFLECTONLY ) && !FBitSet( RI->params, RP_MIRRORVIEW ))
return true; return true;
// never draw playermodel for himself flashlight while shadowpass is active // never draw playermodel for himself flashlight while shadowpass is active
if( FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight != NULL ) if( FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight != NULL )
{ {
if( UTIL_IsLocal( e->index ) && RI->currentlight->key == FLASHLIGHT_KEY ) if( UTIL_IsLocal( e->index ) && RI->currentlight->key == FLASHLIGHT_KEY )
return true; return true;
} }
#if 0 #if 0
// don't cull local player because we draw legs instead // don't cull local player because we draw legs instead
if( RP_LOCALCLIENT( e ) && !FBitSet( RI->params, RP_THIRDPERSON ) && UTIL_IsLocal( RI->view.entity )) if( RP_LOCALCLIENT( e ) && !FBitSet( RI->params, RP_THIRDPERSON ) && UTIL_IsLocal( RI->view.entity ))
{ {
// player can view himself from the portal camera // player can view himself from the portal camera
if( !FBitSet( RI->params, RP_MIRRORVIEW|RP_SHADOWVIEW )) if( !FBitSet( RI->params, RP_MIRRORVIEW|RP_SHADOWVIEW ))
return true; return true;
} }
#endif #endif
return R_CullBox( absmin, absmax ); return R_CullBox( absmin, absmax );
} }
/* /*
================ ================
R_CullBrushModel R_CullBrushModel
Cull brush model by bbox Cull brush model by bbox
================ ================
*/ */
bool R_CullBrushModel( cl_entity_t *e ) bool R_CullBrushModel( cl_entity_t *e )
{ {
gl_state_t *glm = GL_GetCache( e->hCachedMatrix ); gl_state_t *glm = GL_GetCache( e->hCachedMatrix );
model_t *clmodel = e->model; model_t *clmodel = e->model;
Vector absmin, absmax; Vector absmin, absmax;
if( !e || !e->model ) if( !e || !e->model )
return true; return true;
// skybox entity // skybox entity
if( e->curstate.renderfx == SKYBOX_ENTITY ) if( e->curstate.renderfx == SKYBOX_ENTITY )
{ {
if( FBitSet( RI->params, RP_SHADOWVIEW )) if( FBitSet( RI->params, RP_SHADOWVIEW ))
return true; return true;
Vector trans = GetVieworg() - tr.sky_origin; Vector trans = GetVieworg() - tr.sky_origin;
if( tr.sky_speed ) if( tr.sky_speed )
{ {
trans = trans - (GetVieworg() - tr.sky_world_origin) / tr.sky_speed; trans = trans - (GetVieworg() - tr.sky_world_origin) / tr.sky_speed;
Vector skypos = tr.sky_origin + (GetVieworg() - tr.sky_world_origin) / tr.sky_speed; Vector skypos = tr.sky_origin + (GetVieworg() - tr.sky_world_origin) / tr.sky_speed;
tr.modelorg = skypos - e->origin; tr.modelorg = skypos - e->origin;
} }
else tr.modelorg = tr.sky_origin - e->origin; else tr.modelorg = tr.sky_origin - e->origin;
absmin = e->origin + trans + clmodel->mins; absmin = e->origin + trans + clmodel->mins;
absmax = e->origin + trans + clmodel->maxs; absmax = e->origin + trans + clmodel->maxs;
} }
else else
{ {
if( e->angles != g_vecZero ) if( e->angles != g_vecZero )
{ {
absmin = e->origin - clmodel->radius; absmin = e->origin - clmodel->radius;
absmax = e->origin + clmodel->radius; absmax = e->origin + clmodel->radius;
} }
else else
{ {
absmin = e->origin + clmodel->mins; absmin = e->origin + clmodel->mins;
absmax = e->origin + clmodel->maxs; absmax = e->origin + clmodel->maxs;
} }
tr.modelorg = glm->GetModelOrigin(); tr.modelorg = glm->GetModelOrigin();
} }
return R_CullModel( e, absmin, absmax ); return R_CullModel( e, absmin, absmax );
} }
static bool R_SunLightShadow( void ) static bool R_SunLightShadow( void )
{ {
if( RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL && FBitSet( RI->params, RP_SHADOWVIEW )) if( RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL && FBitSet( RI->params, RP_SHADOWVIEW ))
return true; return true;
return false; return false;
} }
/* /*
================= =================
R_AllowFacePlaneCulling R_AllowFacePlaneCulling
allow to culling backfaces allow to culling backfaces
================= =================
*/ */
static bool R_AllowFacePlaneCulling( msurface_t *surf ) static bool R_AllowFacePlaneCulling( msurface_t *surf )
{ {
if( !glState.faceCull ) if( !glState.faceCull )
return false; return false;
if( FBitSet( surf->flags, SURF_TWOSIDE )) if( FBitSet( surf->flags, SURF_TWOSIDE ))
return false; return false;
if( !FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL ) if( !FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL )
return false; return false;
// don't cull transparent surfaces because we should be draw decals on them // don't cull transparent surfaces because we should be draw decals on them
if( FBitSet( surf->flags, SURF_HAS_DECALS ) && !R_OpaqueEntity( RI->currententity )) if( FBitSet( surf->flags, SURF_HAS_DECALS ) && !R_OpaqueEntity( RI->currententity ))
return false; return false;
return true; return true;
} }
/* /*
================= =================
R_CullSurface R_CullSurface
cull invisible surfaces cull invisible surfaces
================= =================
*/ */
int R_CullSurface( msurface_t *surf, const Vector &vieworg, CFrustum *frustum, int clipFlags ) int R_CullSurface( msurface_t *surf, const Vector &vieworg, CFrustum *frustum, int clipFlags )
{ {
cl_entity_t *e = RI->currententity; cl_entity_t *e = RI->currententity;
if( !surf || !surf->texinfo || !surf->texinfo->texture ) if( !surf || !surf->texinfo || !surf->texinfo->texture )
return CULL_OTHER; return CULL_OTHER;
if( FBitSet( RI->params, RP_WATERPASS ) && R_WaterEntity( e->model )) if( FBitSet( RI->params, RP_WATERPASS ) && R_WaterEntity( e->model ))
return CULL_OTHER; // don't render water from waterplane reflection return CULL_OTHER; // don't render water from waterplane reflection
if( CVAR_TO_BOOL( r_nocull )) if( CVAR_TO_BOOL( r_nocull ))
return CULL_VISIBLE; return CULL_VISIBLE;
if( R_SunLightShadow( )) if( R_SunLightShadow( ))
return CULL_VISIBLE; return CULL_VISIBLE;
// because light or shadow passes required both sides for right self-shadowing // because light or shadow passes required both sides for right self-shadowing
if( R_AllowFacePlaneCulling( surf )) if( R_AllowFacePlaneCulling( surf ))
{ {
float dist; float dist;
// can use normal.z for world (optimisation) // can use normal.z for world (optimisation)
if( FBitSet( RI->params, RP_DRAW_OVERVIEW )) if( FBitSet( RI->params, RP_DRAW_OVERVIEW ))
{ {
Vector orthonormal; Vector orthonormal;
if( e == GET_ENTITY( 0 ) || R_StaticEntity( e )) if( e == GET_ENTITY( 0 ) || R_StaticEntity( e ))
{ {
orthonormal.z = surf->plane->normal.z; orthonormal.z = surf->plane->normal.z;
} }
else else
{ {
matrix4x4 m = matrix4x4( g_vecZero, e->angles ); matrix4x4 m = matrix4x4( g_vecZero, e->angles );
orthonormal = m.VectorRotate( surf->plane->normal ); orthonormal = m.VectorRotate( surf->plane->normal );
} }
dist = orthonormal.z; dist = orthonormal.z;
} }
else dist = PlaneDiff( vieworg, surf->plane ); else dist = PlaneDiff( vieworg, surf->plane );
if( glState.faceCull == GL_FRONT || ( RI->params & RP_MIRRORVIEW )) if( glState.faceCull == GL_FRONT || ( RI->params & RP_MIRRORVIEW ))
{ {
if( surf->flags & SURF_PLANEBACK ) if( surf->flags & SURF_PLANEBACK )
{ {
if( dist >= -BACKFACE_EPSILON ) if( dist >= -BACKFACE_EPSILON )
return CULL_BACKSIDE; // wrong side return CULL_BACKSIDE; // wrong side
} }
else else
{ {
if( dist <= BACKFACE_EPSILON ) if( dist <= BACKFACE_EPSILON )
return CULL_BACKSIDE; // wrong side return CULL_BACKSIDE; // wrong side
} }
} }
else if( glState.faceCull == GL_BACK ) else if( glState.faceCull == GL_BACK )
{ {
if( surf->flags & SURF_PLANEBACK ) if( surf->flags & SURF_PLANEBACK )
{ {
if( dist <= BACKFACE_EPSILON ) if( dist <= BACKFACE_EPSILON )
return CULL_BACKSIDE; // wrong side return CULL_BACKSIDE; // wrong side
} }
else else
{ {
if( dist >= -BACKFACE_EPSILON ) if( dist >= -BACKFACE_EPSILON )
return CULL_BACKSIDE; // wrong side return CULL_BACKSIDE; // wrong side
} }
} }
} }
if( frustum && frustum->CullBox( surf->info->mins, surf->info->maxs, clipFlags )) if( frustum && frustum->CullBox( surf->info->mins, surf->info->maxs, clipFlags ))
return CULL_FRUSTUM; return CULL_FRUSTUM;
return CULL_VISIBLE; return CULL_VISIBLE;
} }
/* /*
================ ================
R_CullNodeTopView R_CullNodeTopView
cull node by user rectangle (simple scissor) cull node by user rectangle (simple scissor)
================ ================
*/ */
bool R_CullNodeTopView( mnode_t *node ) bool R_CullNodeTopView( mnode_t *node )
{ {
Vector2D delta, size; Vector2D delta, size;
Vector center, half, mins, maxs; Vector center, half, mins, maxs;
// build the node center and half-diagonal // build the node center and half-diagonal
mins = node->minmaxs, maxs = node->minmaxs + 3; mins = node->minmaxs, maxs = node->minmaxs + 3;
center = (mins + maxs) * 0.5f; center = (mins + maxs) * 0.5f;
half = maxs - center; half = maxs - center;
// cull against the screen frustum or the appropriate area's frustum. // cull against the screen frustum or the appropriate area's frustum.
delta.x = center.x - world->orthocenter.x; delta.x = center.x - world->orthocenter.x;
delta.y = center.y - world->orthocenter.y; delta.y = center.y - world->orthocenter.y;
size.x = half.x + world->orthohalf.x; size.x = half.x + world->orthohalf.x;
size.y = half.y + world->orthohalf.y; size.y = half.y + world->orthohalf.y;
return ( fabs( delta.x ) > size.x ) || ( fabs( delta.y ) > size.y ); return ( fabs( delta.x ) > size.x ) || ( fabs( delta.y ) > size.y );
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,105 +1,105 @@
/* /*
gl_decals.h - decal project & rendering gl_decals.h - decal project & rendering
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2013 Uncle Mike Copyright (C) 2013 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_DECALS_H #ifndef GL_DECALS_H
#define GL_DECALS_H #define GL_DECALS_H
class DecalGroup; class DecalGroup;
class DecalGroupEntry class DecalGroupEntry
{ {
public: public:
char m_DecalName[64]; char m_DecalName[64];
unsigned short gl_diffuse_id; unsigned short gl_diffuse_id;
unsigned short gl_normalmap_id; unsigned short gl_normalmap_id;
unsigned short gl_heightmap_id; unsigned short gl_heightmap_id;
unsigned short gl_specular_id; // specular unsigned short gl_specular_id; // specular
int xsize, ysize; int xsize, ysize;
matdesc_t *matdesc; // pointer to settings matdesc_t *matdesc; // pointer to settings
float overlay; float overlay;
bool opaque; // solid decal doesn't use blend bool opaque; // solid decal doesn't use blend
const DecalGroup *group; // get group name const DecalGroup *group; // get group name
bool m_init; bool m_init;
void PreloadTextures( void ); void PreloadTextures( void );
}; };
class DecalGroup class DecalGroup
{ {
public: public:
DecalGroup( const char *name, int numelems, DecalGroupEntry *source ); DecalGroup( const char *name, int numelems, DecalGroupEntry *source );
~DecalGroup(); ~DecalGroup();
DecalGroupEntry *GetRandomDecal( void ); DecalGroupEntry *GetRandomDecal( void );
DecalGroup *GetNext( void ) { return pnext; } DecalGroup *GetNext( void ) { return pnext; }
const char *GetName( void ) { return m_chGroupName; } const char *GetName( void ) { return m_chGroupName; }
const char *GetName( void ) const { return m_chGroupName; } const char *GetName( void ) const { return m_chGroupName; }
static DecalGroup *FindGroup( const char *name ); static DecalGroup *FindGroup( const char *name );
DecalGroupEntry *FindEntry( const char *name ); DecalGroupEntry *FindEntry( const char *name );
DecalGroupEntry *GetEntry( int num ); DecalGroupEntry *GetEntry( int num );
static DecalGroupEntry *GetEntry( const char *name, int flags ); static DecalGroupEntry *GetEntry( const char *name, int flags );
private: private:
char m_chGroupName[16]; char m_chGroupName[16];
DecalGroupEntry *pEntryArray; DecalGroupEntry *pEntryArray;
DecalGroup *pnext; DecalGroup *pnext;
int size; int size;
}; };
typedef struct dvert_s typedef struct dvert_s
{ {
Vector vertex; // position Vector vertex; // position
Vector tangent; // tangent Vector tangent; // tangent
Vector binormal; // binormal Vector binormal; // binormal
Vector normal; // normal Vector normal; // normal
float stcoord0[4]; // ST texture coords + Decal coords float stcoord0[4]; // ST texture coords + Decal coords
float lmcoord0[4]; // LM texture coords for styles 0-1 float lmcoord0[4]; // LM texture coords for styles 0-1
float lmcoord1[4]; // LM texture coords for styles 2-3 float lmcoord1[4]; // LM texture coords for styles 2-3
byte styles[4]; // lightstyles byte styles[4]; // lightstyles
} dvert_t; } dvert_t;
// decal entry // decal entry
typedef struct brushdecal_s typedef struct brushdecal_s
{ {
// this part is goes to savelist // this part is goes to savelist
byte flags; byte flags;
short entityIndex; short entityIndex;
Vector position; Vector position;
Vector impactPlaneNormal; Vector impactPlaneNormal;
float angle; // goes into scale float angle; // goes into scale
const DecalGroupEntry *texinfo; const DecalGroupEntry *texinfo;
// verts & elems // verts & elems
dvert_t *verts; // pointer to cache array dvert_t *verts; // pointer to cache array
word *elems; // pointer to index array word *elems; // pointer to index array
byte numVerts; byte numVerts;
byte numElems; byte numElems;
// shader cache // shader cache
shader_t forwardScene; shader_t forwardScene;
shader_t deferredScene; shader_t deferredScene;
mextrasurf_t *surface; mextrasurf_t *surface;
struct brushdecal_s *pnext; // linked list for each surface struct brushdecal_s *pnext; // linked list for each surface
model_t *model; model_t *model;
} brushdecal_t; } brushdecal_t;
void DecalsInit( void ); void DecalsInit( void );
void ClearDecals( void ); void ClearDecals( void );
void DecalsShutdown( void ); void DecalsShutdown( void );
void R_RenderDecalsSolidList( drawlist_t drawlist_type ); void R_RenderDecalsSolidList( drawlist_t drawlist_type );
void R_RenderDecalsTransList( drawlist_t drawlist_type ); void R_RenderDecalsTransList( drawlist_t drawlist_type );
void R_RenderDecalsTransEntry( CTransEntry *entry, drawlist_t drawlist_type ); void R_RenderDecalsTransEntry( CTransEntry *entry, drawlist_t drawlist_type );
int SaveDecalList( decallist_t *pBaseList, int count ); int SaveDecalList( decallist_t *pBaseList, int count );
#endif//GL_DECALS_H #endif//GL_DECALS_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,63 @@
/* /*
gl_framebuffer.h - framebuffer implementation class gl_framebuffer.h - framebuffer implementation class
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2014 Uncle Mike Copyright (C) 2014 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_FRAMEBUFFER_H #ifndef GL_FRAMEBUFFER_H
#define GL_FRAMEBUFFER_H #define GL_FRAMEBUFFER_H
typedef enum typedef enum
{ {
FBO_COLOR = 0, // only color texture is used FBO_COLOR = 0, // only color texture is used
FBO_DEPTH, // only depth texture is used FBO_DEPTH, // only depth texture is used
FBO_CUBE, // only color texture as cubemap is side FBO_CUBE, // only color texture as cubemap is side
} FBO_TYPE; } FBO_TYPE;
#define FBO_MAKEPOW (1<<0) // round buffer size to nearest pow #define FBO_MAKEPOW (1<<0) // round buffer size to nearest pow
#define FBO_NOTEXTURE (1<<1) // don't create texture on initialization #define FBO_NOTEXTURE (1<<1) // don't create texture on initialization
#define FBO_FLOAT (1<<2) // use float texture #define FBO_FLOAT (1<<2) // use float texture
#define FBO_RECTANGLE (1<<3) // use rectangle texture #define FBO_RECTANGLE (1<<3) // use rectangle texture
#define FBO_LINEAR (1<<4) // use linear filtering #define FBO_LINEAR (1<<4) // use linear filtering
#define FBO_LUMINANCE (1<<5) // force to luminance texture #define FBO_LUMINANCE (1<<5) // force to luminance texture
class CFrameBuffer class CFrameBuffer
{ {
public: public:
CFrameBuffer(); CFrameBuffer();
~CFrameBuffer(); ~CFrameBuffer();
bool Init( FBO_TYPE type, GLuint width, GLuint height, GLuint flags = 0 ); bool Init( FBO_TYPE type, GLuint width, GLuint height, GLuint flags = 0 );
void Bind( GLuint texture = 0, GLuint side = 0 ); void Bind( GLuint texture = 0, GLuint side = 0 );
bool ValidateFBO( void ); bool ValidateFBO( void );
void Free( void ); void Free( void );
unsigned int GetWidth( void ) const { return m_iFrameWidth; } unsigned int GetWidth( void ) const { return m_iFrameWidth; }
unsigned int GetHeight( void ) const { return m_iFrameHeight; } unsigned int GetHeight( void ) const { return m_iFrameHeight; }
int GetTexture( void ) const { return m_iTexture; } int GetTexture( void ) const { return m_iTexture; }
bool Active( void ) const { return m_bAllowFBO; } bool Active( void ) const { return m_bAllowFBO; }
protected: protected:
static int m_iBufferNum; // single object for all instances static int m_iBufferNum; // single object for all instances
private: private:
GLuint m_iFrameWidth; GLuint m_iFrameWidth;
GLuint m_iFrameHeight; GLuint m_iFrameHeight;
GLint m_iTexture; GLint m_iTexture;
GLuint m_iFrameBuffer; GLuint m_iFrameBuffer;
GLuint m_iDepthBuffer; GLuint m_iDepthBuffer;
GLenum m_iAttachment; // attachment type GLenum m_iAttachment; // attachment type
bool m_bAllowFBO; // FBO is valid bool m_bAllowFBO; // FBO is valid
GLuint m_iFlags; // member FBO flags GLuint m_iFlags; // member FBO flags
}; };
#endif//GL_FRAMEBUFFER_H #endif//GL_FRAMEBUFFER_H

View File

@ -1,374 +1,374 @@
/* /*
gl_frustum.cpp - frustum test implementation class gl_frustum.cpp - frustum test implementation class
Copyright (C) 2014 Uncle Mike Copyright (C) 2014 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "ref_params.h" #include "ref_params.h"
#include "gl_local.h" #include "gl_local.h"
#include <mathlib.h> #include <mathlib.h>
#include <stringlib.h> #include <stringlib.h>
void CFrustum :: ClearFrustum( void ) void CFrustum :: ClearFrustum( void )
{ {
memset( planes, 0, sizeof( planes )); memset( planes, 0, sizeof( planes ));
clipFlags = 0; clipFlags = 0;
} }
void CFrustum :: EnablePlane( int side ) void CFrustum :: EnablePlane( int side )
{ {
ASSERT( side >= 0 && side < FRUSTUM_PLANES ); ASSERT( side >= 0 && side < FRUSTUM_PLANES );
// make sure what plane is ready // make sure what plane is ready
if( planes[side].normal != g_vecZero ) if( planes[side].normal != g_vecZero )
SetBits( clipFlags, BIT( side )); SetBits( clipFlags, BIT( side ));
} }
void CFrustum :: DisablePlane( int side ) void CFrustum :: DisablePlane( int side )
{ {
ASSERT( side >= 0 && side < FRUSTUM_PLANES ); ASSERT( side >= 0 && side < FRUSTUM_PLANES );
ClearBits( clipFlags, BIT( side )); ClearBits( clipFlags, BIT( side ));
} }
void CFrustum :: InitProjection( const matrix4x4 &view, float flZNear, float flZFar, float flFovX, float flFovY ) void CFrustum :: InitProjection( const matrix4x4 &view, float flZNear, float flZFar, float flFovX, float flFovY )
{ {
float xs, xc; float xs, xc;
Vector normal; Vector normal;
// horizontal fov used for left and right planes // horizontal fov used for left and right planes
SinCos( DEG2RAD( flFovX ) * 0.5f, &xs, &xc ); SinCos( DEG2RAD( flFovX ) * 0.5f, &xs, &xc );
// setup left plane // setup left plane
normal = view.GetForward() * xs + view.GetRight() * -xc; normal = view.GetForward() * xs + view.GetRight() * -xc;
SetPlane( FRUSTUM_LEFT, normal, DotProduct( view.GetOrigin(), normal )); SetPlane( FRUSTUM_LEFT, normal, DotProduct( view.GetOrigin(), normal ));
// setup right plane // setup right plane
normal = view.GetForward() * xs + view.GetRight() * xc; normal = view.GetForward() * xs + view.GetRight() * xc;
SetPlane( FRUSTUM_RIGHT, normal, DotProduct( view.GetOrigin(), normal )); SetPlane( FRUSTUM_RIGHT, normal, DotProduct( view.GetOrigin(), normal ));
// vertical fov used for top and bottom planes // vertical fov used for top and bottom planes
SinCos( DEG2RAD( flFovY ) * 0.5f, &xs, &xc ); SinCos( DEG2RAD( flFovY ) * 0.5f, &xs, &xc );
// setup bottom plane // setup bottom plane
normal = view.GetForward() * xs + view.GetUp() * -xc; normal = view.GetForward() * xs + view.GetUp() * -xc;
SetPlane( FRUSTUM_BOTTOM, normal, DotProduct( view.GetOrigin(), normal )); SetPlane( FRUSTUM_BOTTOM, normal, DotProduct( view.GetOrigin(), normal ));
// setup top plane // setup top plane
normal = view.GetForward() * xs + view.GetUp() * xc; normal = view.GetForward() * xs + view.GetUp() * xc;
SetPlane( FRUSTUM_TOP, normal, DotProduct( view.GetOrigin(), normal )); SetPlane( FRUSTUM_TOP, normal, DotProduct( view.GetOrigin(), normal ));
// setup far plane // setup far plane
SetPlane( FRUSTUM_FAR, -view.GetForward(), DotProduct( -view.GetForward(), ( view.GetOrigin() + view.GetForward() * flZFar ))); SetPlane( FRUSTUM_FAR, -view.GetForward(), DotProduct( -view.GetForward(), ( view.GetOrigin() + view.GetForward() * flZFar )));
// no need to setup backplane for general view. It's only used for portals and mirrors // no need to setup backplane for general view. It's only used for portals and mirrors
if( flZNear == 0.0f ) return; if( flZNear == 0.0f ) return;
// setup near plane // setup near plane
SetPlane( FRUSTUM_NEAR, view.GetForward(), DotProduct( view.GetForward(), ( view.GetOrigin() + view.GetForward() * flZNear ))); SetPlane( FRUSTUM_NEAR, view.GetForward(), DotProduct( view.GetForward(), ( view.GetOrigin() + view.GetForward() * flZNear )));
} }
void CFrustum :: InitOrthogonal( const matrix4x4 &view, float xLeft, float xRight, float yBottom, float yTop, float flZNear, float flZFar ) void CFrustum :: InitOrthogonal( const matrix4x4 &view, float xLeft, float xRight, float yBottom, float yTop, float flZNear, float flZFar )
{ {
// setup the near and far planes // setup the near and far planes
float orgOffset = DotProduct( view.GetOrigin(), view.GetForward() ); float orgOffset = DotProduct( view.GetOrigin(), view.GetForward() );
SetPlane( FRUSTUM_FAR, -view.GetForward(), -flZNear - orgOffset ); SetPlane( FRUSTUM_FAR, -view.GetForward(), -flZNear - orgOffset );
SetPlane( FRUSTUM_NEAR, view.GetForward(), flZFar + orgOffset ); SetPlane( FRUSTUM_NEAR, view.GetForward(), flZFar + orgOffset );
// setup left and right planes // setup left and right planes
orgOffset = DotProduct( view.GetOrigin(), view.GetRight() ); orgOffset = DotProduct( view.GetOrigin(), view.GetRight() );
SetPlane( FRUSTUM_LEFT, view.GetRight(), xLeft + orgOffset ); SetPlane( FRUSTUM_LEFT, view.GetRight(), xLeft + orgOffset );
SetPlane( FRUSTUM_RIGHT, -view.GetRight(), -xRight - orgOffset ); SetPlane( FRUSTUM_RIGHT, -view.GetRight(), -xRight - orgOffset );
// setup top and buttom planes // setup top and buttom planes
orgOffset = DotProduct( view.GetOrigin(), view.GetUp() ); orgOffset = DotProduct( view.GetOrigin(), view.GetUp() );
SetPlane( FRUSTUM_TOP, view.GetUp(), yTop + orgOffset ); SetPlane( FRUSTUM_TOP, view.GetUp(), yTop + orgOffset );
SetPlane( FRUSTUM_BOTTOM, -view.GetUp(), -yBottom - orgOffset ); SetPlane( FRUSTUM_BOTTOM, -view.GetUp(), -yBottom - orgOffset );
} }
void CFrustum :: InitBoxFrustum( const Vector &org, float radius ) void CFrustum :: InitBoxFrustum( const Vector &org, float radius )
{ {
for( int i = 0; i < 6; i++ ) for( int i = 0; i < 6; i++ )
{ {
// setup normal for each direction // setup normal for each direction
Vector normal = g_vecZero; Vector normal = g_vecZero;
normal[((i >> 1) + 1) % 3] = (i & 1) ? 1.0f : -1.0f; normal[((i >> 1) + 1) % 3] = (i & 1) ? 1.0f : -1.0f;
SetPlane( i, normal, DotProduct( org, normal ) - radius ); SetPlane( i, normal, DotProduct( org, normal ) - radius );
} }
} }
void CFrustum :: InitProjectionFromMatrix( const matrix4x4 &projection ) void CFrustum :: InitProjectionFromMatrix( const matrix4x4 &projection )
{ {
// left // left
planes[FRUSTUM_LEFT].normal[0] = projection[0][3] + projection[0][0]; planes[FRUSTUM_LEFT].normal[0] = projection[0][3] + projection[0][0];
planes[FRUSTUM_LEFT].normal[1] = projection[1][3] + projection[1][0]; planes[FRUSTUM_LEFT].normal[1] = projection[1][3] + projection[1][0];
planes[FRUSTUM_LEFT].normal[2] = projection[2][3] + projection[2][0]; planes[FRUSTUM_LEFT].normal[2] = projection[2][3] + projection[2][0];
planes[FRUSTUM_LEFT].dist = -(projection[3][3] + projection[3][0]); planes[FRUSTUM_LEFT].dist = -(projection[3][3] + projection[3][0]);
// right // right
planes[FRUSTUM_RIGHT].normal[0] = projection[0][3] - projection[0][0]; planes[FRUSTUM_RIGHT].normal[0] = projection[0][3] - projection[0][0];
planes[FRUSTUM_RIGHT].normal[1] = projection[1][3] - projection[1][0]; planes[FRUSTUM_RIGHT].normal[1] = projection[1][3] - projection[1][0];
planes[FRUSTUM_RIGHT].normal[2] = projection[2][3] - projection[2][0]; planes[FRUSTUM_RIGHT].normal[2] = projection[2][3] - projection[2][0];
planes[FRUSTUM_RIGHT].dist = -(projection[3][3] - projection[3][0]); planes[FRUSTUM_RIGHT].dist = -(projection[3][3] - projection[3][0]);
// bottom // bottom
planes[FRUSTUM_BOTTOM].normal[0] = projection[0][3] + projection[0][1]; planes[FRUSTUM_BOTTOM].normal[0] = projection[0][3] + projection[0][1];
planes[FRUSTUM_BOTTOM].normal[1] = projection[1][3] + projection[1][1]; planes[FRUSTUM_BOTTOM].normal[1] = projection[1][3] + projection[1][1];
planes[FRUSTUM_BOTTOM].normal[2] = projection[2][3] + projection[2][1]; planes[FRUSTUM_BOTTOM].normal[2] = projection[2][3] + projection[2][1];
planes[FRUSTUM_BOTTOM].dist = -(projection[3][3] + projection[3][1]); planes[FRUSTUM_BOTTOM].dist = -(projection[3][3] + projection[3][1]);
// top // top
planes[FRUSTUM_TOP].normal[0] = projection[0][3] - projection[0][1]; planes[FRUSTUM_TOP].normal[0] = projection[0][3] - projection[0][1];
planes[FRUSTUM_TOP].normal[1] = projection[1][3] - projection[1][1]; planes[FRUSTUM_TOP].normal[1] = projection[1][3] - projection[1][1];
planes[FRUSTUM_TOP].normal[2] = projection[2][3] - projection[2][1]; planes[FRUSTUM_TOP].normal[2] = projection[2][3] - projection[2][1];
planes[FRUSTUM_TOP].dist = -(projection[3][3] - projection[3][1]); planes[FRUSTUM_TOP].dist = -(projection[3][3] - projection[3][1]);
// near // near
planes[FRUSTUM_NEAR].normal[0] = projection[0][3] + projection[0][2]; planes[FRUSTUM_NEAR].normal[0] = projection[0][3] + projection[0][2];
planes[FRUSTUM_NEAR].normal[1] = projection[1][3] + projection[1][2]; planes[FRUSTUM_NEAR].normal[1] = projection[1][3] + projection[1][2];
planes[FRUSTUM_NEAR].normal[2] = projection[2][3] + projection[2][2]; planes[FRUSTUM_NEAR].normal[2] = projection[2][3] + projection[2][2];
planes[FRUSTUM_NEAR].dist = -(projection[3][3] + projection[3][2]); planes[FRUSTUM_NEAR].dist = -(projection[3][3] + projection[3][2]);
// far // far
planes[FRUSTUM_FAR].normal[0] = projection[0][3] - projection[0][2]; planes[FRUSTUM_FAR].normal[0] = projection[0][3] - projection[0][2];
planes[FRUSTUM_FAR].normal[1] = projection[1][3] - projection[1][2]; planes[FRUSTUM_FAR].normal[1] = projection[1][3] - projection[1][2];
planes[FRUSTUM_FAR].normal[2] = projection[2][3] - projection[2][2]; planes[FRUSTUM_FAR].normal[2] = projection[2][3] - projection[2][2];
planes[FRUSTUM_FAR].dist = -(projection[3][3] - projection[3][2]); planes[FRUSTUM_FAR].dist = -(projection[3][3] - projection[3][2]);
for( int i = 0; i < FRUSTUM_PLANES; i++ ) for( int i = 0; i < FRUSTUM_PLANES; i++ )
{ {
NormalizePlane( i ); NormalizePlane( i );
} }
} }
void CFrustum :: SetPlane( int side, const Vector &vecNormal, float flDist ) void CFrustum :: SetPlane( int side, const Vector &vecNormal, float flDist )
{ {
ASSERT( side >= 0 && side < FRUSTUM_PLANES ); ASSERT( side >= 0 && side < FRUSTUM_PLANES );
planes[side].type = PlaneTypeForNormal( vecNormal ); planes[side].type = PlaneTypeForNormal( vecNormal );
planes[side].signbits = SignbitsForPlane( vecNormal ); planes[side].signbits = SignbitsForPlane( vecNormal );
planes[side].normal = vecNormal; planes[side].normal = vecNormal;
planes[side].dist = flDist; planes[side].dist = flDist;
clipFlags |= BIT( side ); clipFlags |= BIT( side );
} }
void CFrustum :: NormalizePlane( int side ) void CFrustum :: NormalizePlane( int side )
{ {
ASSERT( side >= 0 && side < FRUSTUM_PLANES ); ASSERT( side >= 0 && side < FRUSTUM_PLANES );
// normalize // normalize
float length = planes[side].normal.Length(); float length = planes[side].normal.Length();
if( length ) if( length )
{ {
float ilength = (1.0f / length); float ilength = (1.0f / length);
planes[side].normal.x *= ilength; planes[side].normal.x *= ilength;
planes[side].normal.y *= ilength; planes[side].normal.y *= ilength;
planes[side].normal.z *= ilength; planes[side].normal.z *= ilength;
planes[side].dist *= ilength; planes[side].dist *= ilength;
} }
planes[side].type = PlaneTypeForNormal( planes[side].normal ); planes[side].type = PlaneTypeForNormal( planes[side].normal );
planes[side].signbits = SignbitsForPlane( planes[side].normal ); planes[side].signbits = SignbitsForPlane( planes[side].normal );
clipFlags |= BIT( side ); clipFlags |= BIT( side );
} }
void CFrustum :: ComputeFrustumCorners( Vector corners[8] ) void CFrustum :: ComputeFrustumCorners( Vector corners[8] )
{ {
memset( corners, 0, sizeof( Vector ) * 8 ); memset( corners, 0, sizeof( Vector ) * 8 );
PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_FAR], corners[0] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_FAR], corners[0] );
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_FAR], corners[1] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_FAR], corners[1] );
PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[2] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[2] );
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[3] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[3] );
if( FBitSet( clipFlags, BIT( FRUSTUM_NEAR ))) if( FBitSet( clipFlags, BIT( FRUSTUM_NEAR )))
{ {
PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_NEAR], corners[4] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_NEAR], corners[4] );
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_NEAR], corners[5] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], &planes[FRUSTUM_NEAR], corners[5] );
PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[6] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[6] );
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[7] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[7] );
} }
else else
{ {
PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], corners[4] ); PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], corners[4] );
corners[7] = corners[6] = corners[5] = corners[4]; corners[7] = corners[6] = corners[5] = corners[4];
} }
} }
void CFrustum :: ComputeFrustumBounds( Vector &mins, Vector &maxs ) void CFrustum :: ComputeFrustumBounds( Vector &mins, Vector &maxs )
{ {
Vector corners[8]; Vector corners[8];
ComputeFrustumCorners( corners ); ComputeFrustumCorners( corners );
ClearBounds( mins, maxs ); ClearBounds( mins, maxs );
for( int i = 0; i < 8; i++ ) for( int i = 0; i < 8; i++ )
AddPointToBounds( corners[i], mins, maxs ); AddPointToBounds( corners[i], mins, maxs );
} }
void CFrustum :: DrawFrustumDebug( void ) void CFrustum :: DrawFrustumDebug( void )
{ {
Vector bbox[8]; Vector bbox[8];
ComputeFrustumCorners( bbox ); ComputeFrustumCorners( bbox );
// g-cont. frustum must be yellow :-) // g-cont. frustum must be yellow :-)
pglColor4f( 1.0f, 1.0f, 0.0f, 1.0f ); pglColor4f( 1.0f, 1.0f, 0.0f, 1.0f );
GL_BindTexture( GL_TEXTURE0, tr.whiteTexture ); GL_BindTexture( GL_TEXTURE0, tr.whiteTexture );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBegin( GL_LINES ); pglBegin( GL_LINES );
for( int i = 0; i < 2; i += 1 ) for( int i = 0; i < 2; i += 1 )
{ {
pglVertex3fv( bbox[i+0] ); pglVertex3fv( bbox[i+0] );
pglVertex3fv( bbox[i+2] ); pglVertex3fv( bbox[i+2] );
pglVertex3fv( bbox[i+4] ); pglVertex3fv( bbox[i+4] );
pglVertex3fv( bbox[i+6] ); pglVertex3fv( bbox[i+6] );
pglVertex3fv( bbox[i+0] ); pglVertex3fv( bbox[i+0] );
pglVertex3fv( bbox[i+4] ); pglVertex3fv( bbox[i+4] );
pglVertex3fv( bbox[i+2] ); pglVertex3fv( bbox[i+2] );
pglVertex3fv( bbox[i+6] ); pglVertex3fv( bbox[i+6] );
pglVertex3fv( bbox[i*2+0] ); pglVertex3fv( bbox[i*2+0] );
pglVertex3fv( bbox[i*2+1] ); pglVertex3fv( bbox[i*2+1] );
pglVertex3fv( bbox[i*2+4] ); pglVertex3fv( bbox[i*2+4] );
pglVertex3fv( bbox[i*2+5] ); pglVertex3fv( bbox[i*2+5] );
} }
pglEnd(); pglEnd();
} }
bool CFrustum :: CullBox( const Vector &mins, const Vector &maxs, int userClipFlags ) bool CFrustum :: CullBox( const Vector &mins, const Vector &maxs, int userClipFlags )
{ {
int iClipFlags; int iClipFlags;
if( CVAR_TO_BOOL( r_nocull )) if( CVAR_TO_BOOL( r_nocull ))
return false; return false;
if( userClipFlags != 0 ) if( userClipFlags != 0 )
iClipFlags = userClipFlags; iClipFlags = userClipFlags;
else iClipFlags = clipFlags; else iClipFlags = clipFlags;
for( int i = 0; i < FRUSTUM_PLANES; i++ ) for( int i = 0; i < FRUSTUM_PLANES; i++ )
{ {
if( !FBitSet( iClipFlags, BIT( i ))) if( !FBitSet( iClipFlags, BIT( i )))
continue; continue;
const mplane_t *p = &planes[i]; const mplane_t *p = &planes[i];
switch( p->signbits ) switch( p->signbits )
{ {
case 0: case 0:
if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist ) if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist )
return true; return true;
break; break;
case 1: case 1:
if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist ) if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist )
return true; return true;
break; break;
case 2: case 2:
if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist ) if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist )
return true; return true;
break; break;
case 3: case 3:
if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist ) if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist )
return true; return true;
break; break;
case 4: case 4:
if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist ) if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist )
return true; return true;
break; break;
case 5: case 5:
if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist ) if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist )
return true; return true;
break; break;
case 6: case 6:
if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist ) if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist )
return true; return true;
break; break;
case 7: case 7:
if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist ) if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist )
return true; return true;
break; break;
default: default:
return false; return false;
} }
} }
return false; return false;
} }
bool CFrustum :: CullSphere( const Vector &centre, float radius, int userClipFlags ) bool CFrustum :: CullSphere( const Vector &centre, float radius, int userClipFlags )
{ {
int iClipFlags; int iClipFlags;
if( CVAR_TO_BOOL( r_nocull )) if( CVAR_TO_BOOL( r_nocull ))
return false; return false;
if( userClipFlags != 0 ) if( userClipFlags != 0 )
iClipFlags = userClipFlags; iClipFlags = userClipFlags;
else iClipFlags = clipFlags; else iClipFlags = clipFlags;
for( int i = 0; i < FRUSTUM_PLANES; i++ ) for( int i = 0; i < FRUSTUM_PLANES; i++ )
{ {
if( !FBitSet( iClipFlags, BIT( i ))) if( !FBitSet( iClipFlags, BIT( i )))
continue; continue;
const mplane_t *p = &planes[i]; const mplane_t *p = &planes[i];
if( DotProduct( centre, p->normal ) - p->dist <= -radius ) if( DotProduct( centre, p->normal ) - p->dist <= -radius )
return true; return true;
} }
return false; return false;
} }
// FIXME: could be optimize? // FIXME: could be optimize?
bool CFrustum :: CullFrustum( CFrustum *frustum, int userClipFlags ) bool CFrustum :: CullFrustum( CFrustum *frustum, int userClipFlags )
{ {
int iClipFlags; int iClipFlags;
Vector bbox[8]; Vector bbox[8];
if( CVAR_TO_BOOL( r_nocull )) if( CVAR_TO_BOOL( r_nocull ))
return false; return false;
if( userClipFlags != 0 ) if( userClipFlags != 0 )
iClipFlags = userClipFlags; iClipFlags = userClipFlags;
else iClipFlags = clipFlags; else iClipFlags = clipFlags;
frustum->ComputeFrustumCorners( bbox ); frustum->ComputeFrustumCorners( bbox );
for( int i = 0; i < FRUSTUM_PLANES; i++ ) for( int i = 0; i < FRUSTUM_PLANES; i++ )
{ {
if( !FBitSet( iClipFlags, BIT( i ))) if( !FBitSet( iClipFlags, BIT( i )))
continue; continue;
const mplane_t *p = &planes[i]; const mplane_t *p = &planes[i];
for( int j = 0; j < 8; j++ ) for( int j = 0; j < 8; j++ )
{ {
// at least one point of other frustum intersect with our frustum // at least one point of other frustum intersect with our frustum
if( DotProduct( bbox[j], p->normal ) - p->dist >= ON_EPSILON ) if( DotProduct( bbox[j], p->normal ) - p->dist >= ON_EPSILON )
return false; return false;
} }
} }
return true; return true;
} }

View File

@ -1,60 +1,60 @@
/* /*
gl_frustum.h - frustum test implementation class gl_frustum.h - frustum test implementation class
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2014 Uncle Mike Copyright (C) 2014 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_FRUSTUM_H #ifndef GL_FRUSTUM_H
#define GL_FRUSTUM_H #define GL_FRUSTUM_H
// don't change this order // don't change this order
#define FRUSTUM_LEFT 0 #define FRUSTUM_LEFT 0
#define FRUSTUM_RIGHT 1 #define FRUSTUM_RIGHT 1
#define FRUSTUM_BOTTOM 2 #define FRUSTUM_BOTTOM 2
#define FRUSTUM_TOP 3 #define FRUSTUM_TOP 3
#define FRUSTUM_FAR 4 #define FRUSTUM_FAR 4
#define FRUSTUM_NEAR 5 #define FRUSTUM_NEAR 5
#define FRUSTUM_PLANES 6 #define FRUSTUM_PLANES 6
class CFrustum class CFrustum
{ {
public: public:
void InitProjection( const matrix4x4 &view, float flZNear, float flZFar, float flFovX, float flFovY ); void InitProjection( const matrix4x4 &view, float flZNear, float flZFar, float flFovX, float flFovY );
void InitOrthogonal( const matrix4x4 &view, float xLeft, float xRight, float yBottom, float yTop, float flZNear, float flZFar ); void InitOrthogonal( const matrix4x4 &view, float xLeft, float xRight, float yBottom, float yTop, float flZNear, float flZFar );
void InitBoxFrustum( const Vector &org, float radius ); // used for pointlights void InitBoxFrustum( const Vector &org, float radius ); // used for pointlights
void InitProjectionFromMatrix( const matrix4x4 &projection ); void InitProjectionFromMatrix( const matrix4x4 &projection );
void SetPlane( int side, const mplane_t *plane ) { planes[side] = *plane; } void SetPlane( int side, const mplane_t *plane ) { planes[side] = *plane; }
void SetPlane( int side, const Vector &vecNormal, float flDist ); void SetPlane( int side, const Vector &vecNormal, float flDist );
void NormalizePlane( int side ); void NormalizePlane( int side );
const mplane_t *GetPlane( int side ) const { return &planes[side]; } const mplane_t *GetPlane( int side ) const { return &planes[side]; }
const mplane_t *GetPlanes( void ) const { return &planes[0]; } const mplane_t *GetPlanes( void ) const { return &planes[0]; }
unsigned int GetClipFlags( void ) const { return clipFlags; } unsigned int GetClipFlags( void ) const { return clipFlags; }
void ComputeFrustumBounds( Vector &mins, Vector &maxs ); void ComputeFrustumBounds( Vector &mins, Vector &maxs );
void ComputeFrustumCorners( Vector bbox[8] ); void ComputeFrustumCorners( Vector bbox[8] );
void DrawFrustumDebug( void ); void DrawFrustumDebug( void );
void ClearFrustum( void ); void ClearFrustum( void );
// cull methods // cull methods
bool CullBox( const Vector &mins, const Vector &maxs, int userClipFlags = 0 ); bool CullBox( const Vector &mins, const Vector &maxs, int userClipFlags = 0 );
bool CullSphere( const Vector &centre, float radius, int userClipFlags = 0 ); bool CullSphere( const Vector &centre, float radius, int userClipFlags = 0 );
bool CullFrustum( CFrustum *frustum, int userClipFlags = 0 ); bool CullFrustum( CFrustum *frustum, int userClipFlags = 0 );
// plane manipulating // plane manipulating
void EnablePlane( int side ); void EnablePlane( int side );
void DisablePlane( int side ); void DisablePlane( int side );
private: private:
mplane_t planes[FRUSTUM_PLANES]; mplane_t planes[FRUSTUM_PLANES];
unsigned int clipFlags; unsigned int clipFlags;
}; };
#endif//GL_FRUSTUM_H #endif//GL_FRUSTUM_H

File diff suppressed because it is too large Load Diff

View File

@ -1,116 +1,116 @@
/* /*
gl_grass.h - grass construct & rendering gl_grass.h - grass construct & rendering
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2014 Uncle Mike Copyright (C) 2014 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_GRASS_H #ifndef GL_GRASS_H
#define GL_GRASS_H #define GL_GRASS_H
#define GRASS_TEXTURES 256 // unique textures for grass (a byte limit, don't change) #define GRASS_TEXTURES 256 // unique textures for grass (a byte limit, don't change)
#define GRASS_ANIM_DIST 512.0f // if this is changed it must be changed in glsl too! #define GRASS_ANIM_DIST 512.0f // if this is changed it must be changed in glsl too!
#define MAX_GRASS_ELEMS 65536 // unsigned short limit #define MAX_GRASS_ELEMS 65536 // unsigned short limit
#define MAX_GRASS_VERTS ( MAX_GRASS_ELEMS / 2 ) // ( numelems / 1.5 ) actually #define MAX_GRASS_VERTS ( MAX_GRASS_ELEMS / 2 ) // ( numelems / 1.5 ) actually
#define MAX_GRASS_BUSHES ( MAX_GRASS_VERTS / 16 ) // one bush contain 4 poly, so we have 2048 bushes max per one surface #define MAX_GRASS_BUSHES ( MAX_GRASS_VERTS / 16 ) // one bush contain 4 poly, so we have 2048 bushes max per one surface
#define GRASS_SKY_DIST BOGUS_RANGE // in-world grass never reach this value #define GRASS_SKY_DIST BOGUS_RANGE // in-world grass never reach this value
typedef struct grassentry_s typedef struct grassentry_s
{ {
char name[16]; // name of level texture char name[16]; // name of level texture
byte texture; // number in array of grass textures byte texture; // number in array of grass textures
float density; // grass density (0 - 100) float density; // grass density (0 - 100)
float min; // min grass scale float min; // min grass scale
float max; // max grass scale float max; // max grass scale
int seed; // seed for predictable random (auto-filled) int seed; // seed for predictable random (auto-filled)
} grassentry_t; } grassentry_t;
typedef struct grasstexture_s typedef struct grasstexture_s
{ {
char name[256]; // path to grass texture char name[256]; // path to grass texture
int gl_texturenum; // gl-texture int gl_texturenum; // gl-texture
} grasstexture_t; } grasstexture_t;
typedef struct gvert_s typedef struct gvert_s
{ {
float center[4]; // used for rescale float center[4]; // used for rescale
float normal[4]; // center + vertex[2] * vertex[3]; float normal[4]; // center + vertex[2] * vertex[3];
float light[MAXLIGHTMAPS]; // packed color + unused entry float light[MAXLIGHTMAPS]; // packed color + unused entry
float delux[MAXLIGHTMAPS]; // packed lightdir + unused entry float delux[MAXLIGHTMAPS]; // packed lightdir + unused entry
byte styles[MAXLIGHTMAPS]; // styles on surface byte styles[MAXLIGHTMAPS]; // styles on surface
} gvert_t; } gvert_t;
#define FGRASS_NODRAW BIT( 0 ) // grass shader is failed to build #define FGRASS_NODRAW BIT( 0 ) // grass shader is failed to build
#define FGRASS_NODLIGHT BIT( 1 ) // grass dlight shader is failed to build #define FGRASS_NODLIGHT BIT( 1 ) // grass dlight shader is failed to build
#define FGRASS_NOSUNLIGHT BIT( 2 ) // grass dlight shader is failed to build #define FGRASS_NOSUNLIGHT BIT( 2 ) // grass dlight shader is failed to build
#define FRGASS_SKYENTITY BIT( 3 ) // it's sky grass #define FRGASS_SKYENTITY BIT( 3 ) // it's sky grass
// all the grassdata for one polygon and specified texture // all the grassdata for one polygon and specified texture
// stored into single vbo // stored into single vbo
typedef struct grass_s typedef struct grass_s
{ {
// shader cache // shader cache
shader_t forwardScene; shader_t forwardScene;
shader_t forwardLightSpot; shader_t forwardLightSpot;
shader_t forwardLightOmni; shader_t forwardLightOmni;
shader_t forwardLightProj; shader_t forwardLightProj;
shader_t deferredScene; shader_t deferredScene;
shader_t deferredLight; shader_t deferredLight;
shader_t forwardDepth; shader_t forwardDepth;
byte texture; // not a real texture just index into array byte texture; // not a real texture just index into array
byte flags; // state flags byte flags; // state flags
unsigned short numVerts; // for glDrawRangeElementsEXT unsigned short numVerts; // for glDrawRangeElementsEXT
unsigned short numElems; // for glDrawElements unsigned short numElems; // for glDrawElements
unsigned int vbo, vao, ibo; // buffer objects unsigned int vbo, vao, ibo; // buffer objects
unsigned short hCachedMatrix; // HACKHACK: get matrices unsigned short hCachedMatrix; // HACKHACK: get matrices
byte lights[MAXDYNLIGHTS];/// light numbers byte lights[MAXDYNLIGHTS];/// light numbers
unsigned int cacheSize; // debug info: uploaded cache size for this buffer unsigned int cacheSize; // debug info: uploaded cache size for this buffer
} grass_t; } grass_t;
typedef void (*pfnCreateGrassBuffer)( grass_t *pOut, gvert_t *arrayxvert ); typedef void (*pfnCreateGrassBuffer)( grass_t *pOut, gvert_t *arrayxvert );
typedef void (*pfnBindGrassBuffer)( grass_t *pOut, int attrFlags ); typedef void (*pfnBindGrassBuffer)( grass_t *pOut, int attrFlags );
enum enum
{ {
GRASSLOADER_BASE = 0, GRASSLOADER_BASE = 0,
GRASSLOADER_BASEBUMP, GRASSLOADER_BASEBUMP,
GRASSLOADER_COUNT, GRASSLOADER_COUNT,
}; };
typedef struct typedef struct
{ {
pfnCreateGrassBuffer CreateBuffer; pfnCreateGrassBuffer CreateBuffer;
pfnBindGrassBuffer BindBuffer; pfnBindGrassBuffer BindBuffer;
const char* BufferName; // debug const char* BufferName; // debug
} grass_loader_t; } grass_loader_t;
typedef struct grasshdr_s typedef struct grasshdr_s
{ {
Vector mins, maxs; // per-poly culling Vector mins, maxs; // per-poly culling
int count; // total bush count for this poly int count; // total bush count for this poly
grass_t g[1]; // variable sized grass_t g[1]; // variable sized
} grasshdr_t; } grasshdr_t;
extern void R_GrassInit( void ); extern void R_GrassInit( void );
extern void R_GrassShutdown( void ); extern void R_GrassShutdown( void );
extern void R_GrassInitForSurface( msurface_t *surf ); extern void R_GrassInitForSurface( msurface_t *surf );
extern void R_RenderGrassOnList( void ); extern void R_RenderGrassOnList( void );
extern void R_GrassSetupFrame( void ); extern void R_GrassSetupFrame( void );
extern void R_RenderShadowGrassOnList( void ); extern void R_RenderShadowGrassOnList( void );
extern void R_DrawLightForGrass( CDynLight *pl ); extern void R_DrawLightForGrass( CDynLight *pl );
extern void R_AddGrassToDrawList( msurface_t *s, drawlist_t type ); extern void R_AddGrassToDrawList( msurface_t *s, drawlist_t type );
extern void R_PrecacheGrass( msurface_t *s, mextraleaf_t *leaf ); extern void R_PrecacheGrass( msurface_t *s, mextraleaf_t *leaf );
extern void R_RemoveGrassForSurface( mextrasurf_t *es ); extern void R_RemoveGrassForSurface( mextrasurf_t *es );
extern void R_UnloadFarGrass( void ); extern void R_UnloadFarGrass( void );
#endif//GL_GRASS_H #endif//GL_GRASS_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +1,37 @@
/* /*
gl_material.h - visible material settings gl_material.h - visible material settings
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2016 Uncle Mike Copyright (C) 2016 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_MATERIAL_H #ifndef GL_MATERIAL_H
#define GL_MATERIAL_H #define GL_MATERIAL_H
typedef enum typedef enum
{ {
PHYSMODEL_BRDF = 0, // BRDF as default PHYSMODEL_BRDF = 0, // BRDF as default
PHYSMODEL_DOOM3, // obsolete lighting model like Doom3 PHYSMODEL_DOOM3, // obsolete lighting model like Doom3
PHYSMODEL_FOLIAGE, // two-side rendering, vegetation lighting model PHYSMODEL_FOLIAGE, // two-side rendering, vegetation lighting model
PHYSMODEL_GLASS, // translucent surface PHYSMODEL_GLASS, // translucent surface
PHYSMODEL_SKIN, // human skin lighting model PHYSMODEL_SKIN, // human skin lighting model
PHYSMODEL_HAIR, // anisotropic lighting model for hairs PHYSMODEL_HAIR, // anisotropic lighting model for hairs
PHYSMODEL_EYES, // eyes physical model PHYSMODEL_EYES, // eyes physical model
} physmodel_t; } physmodel_t;
typedef struct typedef struct
{ {
physmodel_t physModel; physmodel_t physModel;
struct matdef_s *effects; // material common effects (decals, particles, etc) struct matdef_s *effects; // material common effects (decals, particles, etc)
} gl_material_t; } gl_material_t;
#endif//GL_MATERIAL_H #endif//GL_MATERIAL_H

View File

@ -1,230 +1,230 @@
/* /*
gl_movie.cpp - draw screen movie surfaces gl_movie.cpp - draw screen movie surfaces
Copyright (C) 2011 Uncle Mike Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "gl_local.h" #include "gl_local.h"
#include "gl_world.h" #include "gl_world.h"
#include "mathlib.h" #include "mathlib.h"
#include "event_api.h" #include "event_api.h"
#include <stringlib.h> #include <stringlib.h>
int R_PrecacheCinematic( const char *cinname ) int R_PrecacheCinematic( const char *cinname )
{ {
int load_sound = 0; int load_sound = 0;
if( !cinname || !*cinname ) if( !cinname || !*cinname )
return -1; return -1;
if( *cinname == '*' ) if( *cinname == '*' )
{ {
if( g_iXashEngineBuildNumber >= 4256 ) if( g_iXashEngineBuildNumber >= 4256 )
load_sound = 1; load_sound = 1;
cinname++; cinname++;
} }
// not AVI file // not AVI file
if( Q_stricmp( UTIL_FileExtension( cinname ), "avi" )) if( Q_stricmp( UTIL_FileExtension( cinname ), "avi" ))
return -1; return -1;
// first check for co-existing // first check for co-existing
for( int i = 0; i < MAX_MOVIES; i++ ) for( int i = 0; i < MAX_MOVIES; i++ )
{ {
if( !Q_stricmp( tr.cinematics[i].name, cinname )) if( !Q_stricmp( tr.cinematics[i].name, cinname ))
{ {
// already existed // already existed
return i; return i;
} }
} }
// found an empty slot // found an empty slot
for( i = 0; i < MAX_MOVIES; i++ ) for( i = 0; i < MAX_MOVIES; i++ )
{ {
if( !tr.cinematics[i].name[0] ) if( !tr.cinematics[i].name[0] )
break; break;
} }
if( i == MAX_MOVIES ) if( i == MAX_MOVIES )
{ {
ALERT( at_error, "R_PrecacheCinematic: cinematic list limit exceeded\n" ); ALERT( at_error, "R_PrecacheCinematic: cinematic list limit exceeded\n" );
return -1; return -1;
} }
// register new cinematic // register new cinematic
Q_strncpy( tr.cinematics[i].name, cinname, sizeof( tr.cinematics[0].name )); Q_strncpy( tr.cinematics[i].name, cinname, sizeof( tr.cinematics[0].name ));
if( tr.cinematics[i].state ) if( tr.cinematics[i].state )
{ {
ALERT( at_warning, "Reused cin state %i with %s\n", i, tr.cinematics[i].name ); ALERT( at_warning, "Reused cin state %i with %s\n", i, tr.cinematics[i].name );
FREE_CINEMATIC( tr.cinematics[i].state ); FREE_CINEMATIC( tr.cinematics[i].state );
} }
ALERT( at_console, "Loading cinematic %s [%s]\n", cinname, load_sound ? "sound" : "muted" ); ALERT( at_console, "Loading cinematic %s [%s]\n", cinname, load_sound ? "sound" : "muted" );
tr.cinematics[i].state = OPEN_CINEMATIC( tr.cinematics[i].name, load_sound ); tr.cinematics[i].state = OPEN_CINEMATIC( tr.cinematics[i].name, load_sound );
// grab info about movie // grab info about movie
if( tr.cinematics[i].state != NULL ) if( tr.cinematics[i].state != NULL )
CIN_GET_VIDEO_INFO( tr.cinematics[i].state, &tr.cinematics[i].xres, &tr.cinematics[i].yres, &tr.cinematics[i].length ); CIN_GET_VIDEO_INFO( tr.cinematics[i].state, &tr.cinematics[i].xres, &tr.cinematics[i].yres, &tr.cinematics[i].length );
return i; return i;
} }
void R_InitCinematics( void ) void R_InitCinematics( void )
{ {
const char *name, *ext; const char *name, *ext;
// make sure what we have texture to draw cinematics // make sure what we have texture to draw cinematics
if( !FBitSet( world->features, WORLD_HAS_MOVIES )) if( !FBitSet( world->features, WORLD_HAS_MOVIES ))
return; return;
for( int i = 1; i < 1024; i++ ) for( int i = 1; i < 1024; i++ )
{ {
name = gRenderfuncs.GetFileByIndex( i ); name = gRenderfuncs.GetFileByIndex( i );
if( !name || !*name ) break; // end of files array if( !name || !*name ) break; // end of files array
ext = UTIL_FileExtension( name ); ext = UTIL_FileExtension( name );
if( Q_stricmp( ext, "avi" )) continue; // not AVI if( Q_stricmp( ext, "avi" )) continue; // not AVI
if( R_PrecacheCinematic( name ) == -1 ) if( R_PrecacheCinematic( name ) == -1 )
break; // full break; // full
} }
} }
void R_FreeCinematics( void ) void R_FreeCinematics( void )
{ {
for( int i = 0; i < MAX_MOVIES; i++ ) for( int i = 0; i < MAX_MOVIES; i++ )
{ {
if( tr.cinematics[i].state ) if( tr.cinematics[i].state )
{ {
ALERT( at_notice, "release cinematic %s\n", tr.cinematics[i].name ); ALERT( at_notice, "release cinematic %s\n", tr.cinematics[i].name );
FREE_CINEMATIC( tr.cinematics[i].state ); FREE_CINEMATIC( tr.cinematics[i].state );
} }
} }
memset( tr.cinematics, 0, sizeof( tr.cinematics )); memset( tr.cinematics, 0, sizeof( tr.cinematics ));
for( i = 0; i < MAX_MOVIE_TEXTURES; i++ ) for( i = 0; i < MAX_MOVIE_TEXTURES; i++ )
{ {
if( !tr.cinTextures[i] ) break; if( !tr.cinTextures[i] ) break;
FREE_TEXTURE( tr.cinTextures[i] ); FREE_TEXTURE( tr.cinTextures[i] );
} }
memset( tr.cinTextures, 0, sizeof( tr.cinTextures )); memset( tr.cinTextures, 0, sizeof( tr.cinTextures ));
} }
int R_AllocateCinematicTexture( unsigned int txFlags ) int R_AllocateCinematicTexture( unsigned int txFlags )
{ {
int i = tr.num_cin_used; int i = tr.num_cin_used;
if( i >= MAX_MOVIE_TEXTURES ) if( i >= MAX_MOVIE_TEXTURES )
{ {
ALERT( at_error, "R_AllocateCinematicTexture: cine textures limit exceeded!\n" ); ALERT( at_error, "R_AllocateCinematicTexture: cine textures limit exceeded!\n" );
return 0; // disable return 0; // disable
} }
tr.num_cin_used++; tr.num_cin_used++;
if( !tr.cinTextures[i] ) if( !tr.cinTextures[i] )
{ {
char txName[16]; char txName[16];
Q_snprintf( txName, sizeof( txName ), "*cinematic%i", i ); Q_snprintf( txName, sizeof( txName ), "*cinematic%i", i );
// create new cinematic texture // create new cinematic texture
// NOTE: dimension of texture is no matter because CIN_UPLOAD_FRAME will be rescale texture // NOTE: dimension of texture is no matter because CIN_UPLOAD_FRAME will be rescale texture
tr.cinTextures[i] = CREATE_TEXTURE( txName, 256, 256, NULL, txFlags ); tr.cinTextures[i] = CREATE_TEXTURE( txName, 256, 256, NULL, txFlags );
} }
return (i+1); return (i+1);
} }
void R_UpdateCinematic( const msurface_t *surf ) void R_UpdateCinematic( const msurface_t *surf )
{ {
if( !RI->currententity->curstate.body ) if( !RI->currententity->curstate.body )
return; // just disabled return; // just disabled
// draw the cinematic // draw the cinematic
mextrasurf_t *es = surf->info; mextrasurf_t *es = surf->info;
// found the corresponding cinstate // found the corresponding cinstate
const char *cinname = gRenderfuncs.GetFileByIndex( RI->currententity->curstate.sequence ); const char *cinname = gRenderfuncs.GetFileByIndex( RI->currententity->curstate.sequence );
int cinhandle = R_PrecacheCinematic( cinname ); int cinhandle = R_PrecacheCinematic( cinname );
if( cinhandle >= 0 && es->cintexturenum <= 0 ) if( cinhandle >= 0 && es->cintexturenum <= 0 )
es->cintexturenum = R_AllocateCinematicTexture( TF_NOMIPMAP ); es->cintexturenum = R_AllocateCinematicTexture( TF_NOMIPMAP );
if( cinhandle == -1 || es->cintexturenum <= 0 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false ) if( cinhandle == -1 || es->cintexturenum <= 0 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false )
{ {
// cinematic textures limit exceeded, so remove SURF_MOVIE flag // cinematic textures limit exceeded, so remove SURF_MOVIE flag
((msurface_t *)surf)->flags &= ~SURF_MOVIE; ((msurface_t *)surf)->flags &= ~SURF_MOVIE;
return; return;
} }
gl_movie_t *cin = &tr.cinematics[cinhandle]; gl_movie_t *cin = &tr.cinematics[cinhandle];
float cin_time; float cin_time;
if( FBitSet( RI->currententity->curstate.iuser1, CF_LOOPED_MOVIE )) if( FBitSet( RI->currententity->curstate.iuser1, CF_LOOPED_MOVIE ))
{ {
// advances cinematic time // advances cinematic time
cin_time = fmod( RI->currententity->curstate.fuser2, cin->length ); cin_time = fmod( RI->currententity->curstate.fuser2, cin->length );
} }
else else
{ {
cin_time = RI->currententity->curstate.fuser2; cin_time = RI->currententity->curstate.fuser2;
} }
// read the next frame // read the next frame
int cin_frame = CIN_GET_FRAME_NUMBER( cin->state, cin_time ); int cin_frame = CIN_GET_FRAME_NUMBER( cin->state, cin_time );
// upload the new frame // upload the new frame
if( cin_frame != es->checkcount ) if( cin_frame != es->checkcount )
{ {
GL_SelectTexture( GL_TEXTURE0 ); // doesn't matter. select 0-th unit just as default GL_SelectTexture( GL_TEXTURE0 ); // doesn't matter. select 0-th unit just as default
byte *raw = CIN_GET_FRAMEDATA( cin->state, cin_frame ); byte *raw = CIN_GET_FRAMEDATA( cin->state, cin_frame );
CIN_UPLOAD_FRAME( tr.cinTextures[es->cintexturenum-1], cin->xres, cin->yres, cin->xres, cin->yres, raw ); CIN_UPLOAD_FRAME( tr.cinTextures[es->cintexturenum-1], cin->xres, cin->yres, cin->xres, cin->yres, raw );
es->checkcount = cin_frame; es->checkcount = cin_frame;
} }
} }
void R_UpdateCinSound( cl_entity_t *e ) void R_UpdateCinSound( cl_entity_t *e )
{ {
if( g_iXashEngineBuildNumber < 4256 ) if( g_iXashEngineBuildNumber < 4256 )
return; // too old for this feature return; // too old for this feature
if( !e->curstate.body || !FBitSet( e->curstate.iuser1, CF_MOVIE_SOUND )) if( !e->curstate.body || !FBitSet( e->curstate.iuser1, CF_MOVIE_SOUND ))
return; // just disabled return; // just disabled
// found the corresponding cinstate // found the corresponding cinstate
const char *cinname = gRenderfuncs.GetFileByIndex( e->curstate.sequence ); const char *cinname = gRenderfuncs.GetFileByIndex( e->curstate.sequence );
int cinhandle = R_PrecacheCinematic( cinname ); int cinhandle = R_PrecacheCinematic( cinname );
if( cinhandle == -1 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false ) if( cinhandle == -1 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false )
return; return;
gl_movie_t *cin = &tr.cinematics[cinhandle]; gl_movie_t *cin = &tr.cinematics[cinhandle];
float cin_time; float cin_time;
if( FBitSet( e->curstate.iuser1, CF_LOOPED_MOVIE )) if( FBitSet( e->curstate.iuser1, CF_LOOPED_MOVIE ))
{ {
// advances cinematic time // advances cinematic time
cin_time = fmod( e->curstate.fuser2, cin->length ); cin_time = fmod( e->curstate.fuser2, cin->length );
} }
else else
{ {
cin_time = e->curstate.fuser2; cin_time = e->curstate.fuser2;
} }
// stream avi sound // stream avi sound
CIN_UPDATE_SOUND( cin->state, e->index, VOL_NORM, ATTN_IDLE, cin_time ); CIN_UPDATE_SOUND( cin->state, e->index, VOL_NORM, ATTN_IDLE, cin_time );
} }

View File

@ -1,231 +1,231 @@
/* /*
gl_occlusion.cpp - occlusion query implementation class gl_occlusion.cpp - occlusion query implementation class
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2015 Uncle Mike Copyright (C) 2015 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "gl_local.h" #include "gl_local.h"
#include <utlarray.h> #include <utlarray.h>
#include "gl_occlusion.h" #include "gl_occlusion.h"
#include "gl_world.h" #include "gl_world.h"
/* /*
=============== ===============
GL_AllocOcclusionQuery GL_AllocOcclusionQuery
=============== ===============
*/ */
void GL_AllocOcclusionQuery( msurface_t *surf ) void GL_AllocOcclusionQuery( msurface_t *surf )
{ {
if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || surf->info->query ) if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || surf->info->query )
return; return;
pglGenQueriesARB( 1, &surf->info->query ); pglGenQueriesARB( 1, &surf->info->query );
} }
/* /*
=============== ===============
GL_DeleteOcclusionQuery GL_DeleteOcclusionQuery
=============== ===============
*/ */
void GL_DeleteOcclusionQuery( msurface_t *surf ) void GL_DeleteOcclusionQuery( msurface_t *surf )
{ {
if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || !surf->info->query ) if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || !surf->info->query )
return; return;
pglDeleteQueriesARB( 1, &surf->info->query ); pglDeleteQueriesARB( 1, &surf->info->query );
} }
/* /*
=============== ===============
GL_DrawOcclusionCube GL_DrawOcclusionCube
=============== ===============
*/ */
static void GL_DrawOcclusionCube( const Vector &absmin, const Vector &absmax ) static void GL_DrawOcclusionCube( const Vector &absmin, const Vector &absmax )
{ {
vec3_t bbox[8]; vec3_t bbox[8];
int i; int i;
// compute a full bounding box // compute a full bounding box
for( i = 0; i < 8; i++ ) for( i = 0; i < 8; i++ )
{ {
bbox[i][0] = ( i & 1 ) ? absmin[0] : absmax[0]; bbox[i][0] = ( i & 1 ) ? absmin[0] : absmax[0];
bbox[i][1] = ( i & 2 ) ? absmin[1] : absmax[1]; bbox[i][1] = ( i & 2 ) ? absmin[1] : absmax[1];
bbox[i][2] = ( i & 4 ) ? absmin[2] : absmax[2]; bbox[i][2] = ( i & 4 ) ? absmin[2] : absmax[2];
} }
pglBegin( GL_QUADS ); pglBegin( GL_QUADS );
for( i = 0; i < 6; i++ ) for( i = 0; i < 6; i++ )
{ {
pglVertex3fv( bbox[g_boxpnt[i][0]] ); pglVertex3fv( bbox[g_boxpnt[i][0]] );
pglVertex3fv( bbox[g_boxpnt[i][1]] ); pglVertex3fv( bbox[g_boxpnt[i][1]] );
pglVertex3fv( bbox[g_boxpnt[i][2]] ); pglVertex3fv( bbox[g_boxpnt[i][2]] );
pglVertex3fv( bbox[g_boxpnt[i][3]] ); pglVertex3fv( bbox[g_boxpnt[i][3]] );
} }
pglEnd(); pglEnd();
} }
/* /*
=============== ===============
GL_TestSurfaceOcclusion GL_TestSurfaceOcclusion
=============== ===============
*/ */
void GL_TestSurfaceOcclusion( msurface_t *surf ) void GL_TestSurfaceOcclusion( msurface_t *surf )
{ {
mextrasurf_t *es = surf->info; mextrasurf_t *es = surf->info;
Vector absmin, absmax; Vector absmin, absmax;
word cached_matrix; word cached_matrix;
Vector normal; Vector normal;
if( !es->query || FBitSet( surf->flags, SURF_QUEUED )) if( !es->query || FBitSet( surf->flags, SURF_QUEUED ))
return; // we already have the query return; // we already have the query
if( !es->parent ) cached_matrix = WORLD_MATRIX; if( !es->parent ) cached_matrix = WORLD_MATRIX;
else cached_matrix = es->parent->hCachedMatrix; else cached_matrix = es->parent->hCachedMatrix;
gl_state_t *glm = GL_GetCache( cached_matrix ); gl_state_t *glm = GL_GetCache( cached_matrix );
if( FBitSet( surf->flags, SURF_PLANEBACK )) if( FBitSet( surf->flags, SURF_PLANEBACK ))
normal = -surf->plane->normal; normal = -surf->plane->normal;
else normal = surf->plane->normal; else normal = surf->plane->normal;
// place above surface // place above surface
absmin = es->mins + normal * 5.0f; absmin = es->mins + normal * 5.0f;
absmax = es->maxs + normal * 5.0f; absmax = es->maxs + normal * 5.0f;
ExpandBounds( absmin, absmax, 2.0f ); ExpandBounds( absmin, absmax, 2.0f );
if( cached_matrix != WORLD_MATRIX ) if( cached_matrix != WORLD_MATRIX )
TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax ); TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax );
pglBeginQueryARB( GL_SAMPLES_PASSED_ARB, es->query ); pglBeginQueryARB( GL_SAMPLES_PASSED_ARB, es->query );
GL_DrawOcclusionCube( absmin, absmax ); GL_DrawOcclusionCube( absmin, absmax );
pglEndQueryARB( GL_SAMPLES_PASSED_ARB ); pglEndQueryARB( GL_SAMPLES_PASSED_ARB );
// now we have a valid query // now we have a valid query
SetBits( surf->flags, SURF_QUEUED ); SetBits( surf->flags, SURF_QUEUED );
} }
/* /*
=============== ===============
GL_TestSurfaceOcclusion GL_TestSurfaceOcclusion
=============== ===============
*/ */
void GL_DebugSurfaceOcclusion( msurface_t *surf ) void GL_DebugSurfaceOcclusion( msurface_t *surf )
{ {
mextrasurf_t *es = surf->info; mextrasurf_t *es = surf->info;
Vector absmin, absmax; Vector absmin, absmax;
word cached_matrix; word cached_matrix;
Vector normal; Vector normal;
if( !FBitSet( surf->flags, SURF_QUEUED )) if( !FBitSet( surf->flags, SURF_QUEUED ))
return; // draw only queue return; // draw only queue
if( !es->parent ) cached_matrix = WORLD_MATRIX; if( !es->parent ) cached_matrix = WORLD_MATRIX;
else cached_matrix = es->parent->hCachedMatrix; else cached_matrix = es->parent->hCachedMatrix;
gl_state_t *glm = GL_GetCache( cached_matrix ); gl_state_t *glm = GL_GetCache( cached_matrix );
if( FBitSet( surf->flags, SURF_PLANEBACK )) if( FBitSet( surf->flags, SURF_PLANEBACK ))
normal = -surf->plane->normal; normal = -surf->plane->normal;
else normal = surf->plane->normal; else normal = surf->plane->normal;
// place above surface // place above surface
absmin = es->mins + normal * 5.0f; absmin = es->mins + normal * 5.0f;
absmax = es->maxs + normal * 5.0f; absmax = es->maxs + normal * 5.0f;
ExpandBounds( absmin, absmax, 2.0f ); ExpandBounds( absmin, absmax, 2.0f );
if( cached_matrix != WORLD_MATRIX ) if( cached_matrix != WORLD_MATRIX )
TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax ); TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax );
GL_DrawOcclusionCube( absmin, absmax ); GL_DrawOcclusionCube( absmin, absmax );
} }
/* /*
================ ================
R_RenderOcclusionList R_RenderOcclusionList
================ ================
*/ */
void R_RenderSurfOcclusionList( void ) void R_RenderSurfOcclusionList( void )
{ {
int i; int i;
if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling )) if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling ))
return; return;
if( !RI->frame.num_subview_faces ) if( !RI->frame.num_subview_faces )
return; return;
pglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); pglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
GL_DepthMask( GL_FALSE ); GL_DepthMask( GL_FALSE );
GL_AlphaTest( GL_FALSE ); GL_AlphaTest( GL_FALSE );
GL_BindShader( NULL ); GL_BindShader( NULL );
for( i = 0; i < RI->frame.num_subview_faces; i++ ) for( i = 0; i < RI->frame.num_subview_faces; i++ )
GL_TestSurfaceOcclusion( RI->frame.subview_faces[i] ); GL_TestSurfaceOcclusion( RI->frame.subview_faces[i] );
pglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); pglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
GL_DepthMask( GL_TRUE ); GL_DepthMask( GL_TRUE );
pglFlush(); pglFlush();
if( r_occlusion_culling->value < 2.0f ) if( r_occlusion_culling->value < 2.0f )
return; return;
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
GL_Blend( GL_FALSE ); GL_Blend( GL_FALSE );
for( i = 0; i < RI->frame.num_subview_faces; i++ ) for( i = 0; i < RI->frame.num_subview_faces; i++ )
GL_DebugSurfaceOcclusion( RI->frame.subview_faces[i] ); GL_DebugSurfaceOcclusion( RI->frame.subview_faces[i] );
} }
/* /*
================ ================
GL_SurfaceOccluded GL_SurfaceOccluded
================ ================
*/ */
bool GL_SurfaceOccluded( msurface_t *surf ) bool GL_SurfaceOccluded( msurface_t *surf )
{ {
mextrasurf_t *es = surf->info; mextrasurf_t *es = surf->info;
GLuint sampleCount = 0; GLuint sampleCount = 0;
GLint available = false; GLint available = false;
if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling )) if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling ))
return false; return false;
if( !es->query ) return false; if( !es->query ) return false;
if( !FBitSet( surf->flags, SURF_QUEUED )) if( !FBitSet( surf->flags, SURF_QUEUED ))
{ {
// occlusion is no more actual // occlusion is no more actual
ClearBits( surf->flags, SURF_OCCLUDED ); ClearBits( surf->flags, SURF_OCCLUDED );
return false; return false;
} }
// i hope results will be arrived on a next frame... // i hope results will be arrived on a next frame...
pglGetQueryObjectivARB( es->query, GL_QUERY_RESULT_AVAILABLE_ARB, &available ); pglGetQueryObjectivARB( es->query, GL_QUERY_RESULT_AVAILABLE_ARB, &available );
// NOTE: if we can't get actual information about query results // NOTE: if we can't get actual information about query results
// assume that object was visible and cull him with default methods: frustum, pvs etc // assume that object was visible and cull him with default methods: frustum, pvs etc
if( !available ) return false; if( !available ) return false;
pglGetQueryObjectuivARB( es->query, GL_QUERY_RESULT_ARB, &sampleCount ); pglGetQueryObjectuivARB( es->query, GL_QUERY_RESULT_ARB, &sampleCount );
ClearBits( surf->flags, SURF_QUEUED ); // we catch the results, so query is outdated ClearBits( surf->flags, SURF_QUEUED ); // we catch the results, so query is outdated
if( sampleCount == 0 ) SetBits( surf->flags, SURF_OCCLUDED ); if( sampleCount == 0 ) SetBits( surf->flags, SURF_OCCLUDED );
else ClearBits( surf->flags, SURF_OCCLUDED ); else ClearBits( surf->flags, SURF_OCCLUDED );
if( !sampleCount ) r_stats.c_occlusion_culled++; if( !sampleCount ) r_stats.c_occlusion_culled++;
return (FBitSet( surf->flags, SURF_OCCLUDED ) != 0); return (FBitSet( surf->flags, SURF_OCCLUDED ) != 0);
} }

View File

@ -1,25 +1,25 @@
/* /*
gl_occlusion.h - occlusion query implementation gl_occlusion.h - occlusion query implementation
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2015 Uncle Mike Copyright (C) 2015 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_OCCLUSION_H #ifndef GL_OCCLUSION_H
#define GL_OCCLUSION_H #define GL_OCCLUSION_H
void GL_AllocOcclusionQuery( msurface_t *surf ); void GL_AllocOcclusionQuery( msurface_t *surf );
void GL_DeleteOcclusionQuery( msurface_t *surf ); void GL_DeleteOcclusionQuery( msurface_t *surf );
bool GL_SurfaceOccluded( msurface_t *surf ); bool GL_SurfaceOccluded( msurface_t *surf );
void GL_TestSurfaceOcclusion( msurface_t *surf ); void GL_TestSurfaceOcclusion( msurface_t *surf );
#endif//GL_OCCLUSION_H #endif//GL_OCCLUSION_H

File diff suppressed because it is too large Load Diff

View File

@ -1,99 +1,99 @@
/* /*
gl_primitive.cpp - rendering primitives gl_primitive.cpp - rendering primitives
Copyright (C) 2018 Uncle Mike Copyright (C) 2018 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include <stringlib.h> #include <stringlib.h>
#include "cl_util.h" #include "cl_util.h"
#include "pm_defs.h" #include "pm_defs.h"
#include "event_api.h" #include "event_api.h"
#include "gl_local.h" #include "gl_local.h"
#include "gl_studio.h" #include "gl_studio.h"
#include "gl_world.h" #include "gl_world.h"
#include "gl_grass.h" #include "gl_grass.h"
void CSolidEntry :: SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode ) void CSolidEntry :: SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode )
{ {
m_bDrawType = DRAWTYPE_QUAD; m_bDrawType = DRAWTYPE_QUAD;
m_iStartVertex = RI->frame.primverts.Count(); m_iStartVertex = RI->frame.primverts.Count();
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
RI->frame.primverts.AddToTail( verts[i] ); RI->frame.primverts.AddToTail( verts[i] );
m_iColor = PackRGBA( color.x * 255, color.y * 255, color.z * 255, color.w * 255 ); m_iColor = PackRGBA( color.x * 255, color.y * 255, color.z * 255, color.w * 255 );
m_iRenderMode = rendermode; m_iRenderMode = rendermode;
m_hTexture = texture; m_hTexture = texture;
} }
void CSolidEntry :: SetRenderSurface( msurface_t *surface, word hProgram ) void CSolidEntry :: SetRenderSurface( msurface_t *surface, word hProgram )
{ {
m_bDrawType = DRAWTYPE_SURFACE; m_bDrawType = DRAWTYPE_SURFACE;
m_pSurf = surface; m_pSurf = surface;
m_pParentEntity = RI->currententity; m_pParentEntity = RI->currententity;
m_pRenderModel = RI->currentmodel; m_pRenderModel = RI->currentmodel;
m_hProgram = hProgram; m_hProgram = hProgram;
} }
void CSolidEntry :: SetRenderMesh( vbomesh_t *mesh, word hProgram ) void CSolidEntry :: SetRenderMesh( vbomesh_t *mesh, word hProgram )
{ {
m_bDrawType = DRAWTYPE_MESH; m_bDrawType = DRAWTYPE_MESH;
m_pMesh = mesh; m_pMesh = mesh;
m_pParentEntity = RI->currententity; m_pParentEntity = RI->currententity;
m_pRenderModel = RI->currentmodel; m_pRenderModel = RI->currentmodel;
m_hProgram = hProgram; m_hProgram = hProgram;
} }
void CTransEntry :: ComputeViewDistance( const Vector &absmin, const Vector &absmax ) void CTransEntry :: ComputeViewDistance( const Vector &absmin, const Vector &absmax )
{ {
#if 1 #if 1
m_flViewDist = CalcSqrDistanceToAABB( absmin, absmax, GetVieworg( )); m_flViewDist = CalcSqrDistanceToAABB( absmin, absmax, GetVieworg( ));
#else #else
Vector origin = (absmin + absmax) * 0.5f; Vector origin = (absmin + absmax) * 0.5f;
m_flViewDist = DotProduct( origin, GetVForward() ) - RI->view.planedist; m_flViewDist = DotProduct( origin, GetVForward() ) - RI->view.planedist;
// m_flViewDist = VectorDistance2( origin, GetVieworg( )); // m_flViewDist = VectorDistance2( origin, GetVieworg( ));
#endif #endif
} }
void CTransEntry :: ComputeScissor( const Vector &absmin, const Vector &absmax ) void CTransEntry :: ComputeScissor( const Vector &absmin, const Vector &absmax )
{ {
ComputeViewDistance( absmin, absmax ); ComputeViewDistance( absmin, absmax );
if( R_ScissorForAABB( absmin, absmax, &m_vecRect.x, &m_vecRect.y, &m_vecRect.z, &m_vecRect.w )) if( R_ScissorForAABB( absmin, absmax, &m_vecRect.x, &m_vecRect.y, &m_vecRect.z, &m_vecRect.w ))
m_bScissorReady = true; m_bScissorReady = true;
else m_bScissorReady = false; else m_bScissorReady = false;
} }
void CTransEntry :: RequestScreenColor( void ) void CTransEntry :: RequestScreenColor( void )
{ {
if( !m_bScissorReady ) return; if( !m_bScissorReady ) return;
float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y; float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y;
GL_BindTexture( GL_TEXTURE0, tr.screen_color ); GL_BindTexture( GL_TEXTURE0, tr.screen_color );
pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, m_vecRect.x, y2, m_vecRect.x, y2, m_vecRect.z, m_vecRect.w ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, m_vecRect.x, y2, m_vecRect.x, y2, m_vecRect.z, m_vecRect.w );
} }
void CTransEntry :: RequestScreenDepth( void ) void CTransEntry :: RequestScreenDepth( void )
{ {
if( !m_bScissorReady ) return; if( !m_bScissorReady ) return;
float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y; float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y;
GL_BindTexture( GL_TEXTURE0, tr.screen_depth ); GL_BindTexture( GL_TEXTURE0, tr.screen_depth );
pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, m_vecRect.x, y2, m_vecRect.x, y2, m_vecRect.z, m_vecRect.w ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, m_vecRect.x, y2, m_vecRect.x, y2, m_vecRect.z, m_vecRect.w );
} }
void CTransEntry :: RenderScissorDebug( void ) void CTransEntry :: RenderScissorDebug( void )
{ {
if( !m_bScissorReady ) return; if( !m_bScissorReady ) return;
R_DrawScissorRectangle( m_vecRect.x, m_vecRect.y, m_vecRect.z, m_vecRect.w ); R_DrawScissorRectangle( m_vecRect.x, m_vecRect.y, m_vecRect.z, m_vecRect.w );
} }

View File

@ -1,80 +1,80 @@
/* /*
gl_primitive.h - render primitives gl_primitive.h - render primitives
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2013 Uncle Mike Copyright (C) 2013 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_PRIMITIVE_H #ifndef GL_PRIMITIVE_H
#define GL_PRIMITIVE_H #define GL_PRIMITIVE_H
#define DRAWTYPE_UNKNOWN 0 #define DRAWTYPE_UNKNOWN 0
#define DRAWTYPE_SURFACE 1 #define DRAWTYPE_SURFACE 1
#define DRAWTYPE_MESH 2 #define DRAWTYPE_MESH 2
#define DRAWTYPE_QUAD 3 #define DRAWTYPE_QUAD 3
//#pragma pack(1) //#pragma pack(1)
class CSolidEntry class CSolidEntry
{ {
public: public:
void SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode ); void SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode );
void SetRenderSurface( msurface_t *surface, word hProgram ); void SetRenderSurface( msurface_t *surface, word hProgram );
void SetRenderMesh( struct vbomesh_s *mesh, word hProgram ); void SetRenderMesh( struct vbomesh_s *mesh, word hProgram );
virtual bool IsTranslucent( void ) { return false; } virtual bool IsTranslucent( void ) { return false; }
int GetType( void ) { return m_bDrawType; } int GetType( void ) { return m_bDrawType; }
byte m_bDrawType; // type of entry byte m_bDrawType; // type of entry
union union
{ {
cl_entity_t *m_pParentEntity; // pointer to parent entity cl_entity_t *m_pParentEntity; // pointer to parent entity
int m_iRenderMode; // rendermode for primitive int m_iRenderMode; // rendermode for primitive
}; };
union union
{ {
model_t *m_pRenderModel; // render model model_t *m_pRenderModel; // render model
int m_iStartVertex; // offset in global heap int m_iStartVertex; // offset in global heap
}; };
union union
{ {
unsigned short m_hProgram; // handle to glsl program (may be 0) unsigned short m_hProgram; // handle to glsl program (may be 0)
unsigned short m_hTexture; // texture for primitive unsigned short m_hTexture; // texture for primitive
}; };
union union
{ {
struct vbomesh_s *m_pMesh; // NULL or mesh struct vbomesh_s *m_pMesh; // NULL or mesh
msurface_t *m_pSurf; // NULL or surface msurface_t *m_pSurf; // NULL or surface
int m_iColor; // primitive color int m_iColor; // primitive color
}; };
}; };
class CTransEntry : public CSolidEntry class CTransEntry : public CSolidEntry
{ {
public: public:
void ComputeViewDistance( const Vector &absmin, const Vector &absmax ); void ComputeViewDistance( const Vector &absmin, const Vector &absmax );
void ComputeScissor( const Vector &absmin, const Vector &absmax ); void ComputeScissor( const Vector &absmin, const Vector &absmax );
virtual bool IsTranslucent( void ) { return true; } virtual bool IsTranslucent( void ) { return true; }
void RequestScreenColor( void ); void RequestScreenColor( void );
void RequestScreenDepth( void ); void RequestScreenDepth( void );
void RenderScissorDebug( void ); void RenderScissorDebug( void );
float m_flViewDist; float m_flViewDist;
Vector4D m_vecRect; Vector4D m_vecRect;
bool m_bScissorReady : 1; bool m_bScissorReady : 1;
}; };
//#pragma pack() //#pragma pack()
#endif//GL_PRIMITIVE_H #endif//GL_PRIMITIVE_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,144 +1,144 @@
/* /*
gl_rpart.h - quake-like particles gl_rpart.h - quake-like particles
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2013 Uncle Mike Copyright (C) 2013 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_RPART_H #ifndef GL_RPART_H
#define GL_RPART_H #define GL_RPART_H
#include "randomrange.h" #include "randomrange.h"
#define MAX_PARTICLES 8192 #define MAX_PARTICLES 8192
#define MAX_PARTINFOS 256 // various types of part-system #define MAX_PARTINFOS 256 // various types of part-system
// built-in particle-system flags // built-in particle-system flags
#define FPART_BOUNCE (1<<0) // makes a bouncy particle #define FPART_BOUNCE (1<<0) // makes a bouncy particle
#define FPART_FRICTION (1<<1) #define FPART_FRICTION (1<<1)
#define FPART_VERTEXLIGHT (1<<2) // give some ambient light for it #define FPART_VERTEXLIGHT (1<<2) // give some ambient light for it
#define FPART_STRETCH (1<<3) #define FPART_STRETCH (1<<3)
#define FPART_UNDERWATER (1<<4) #define FPART_UNDERWATER (1<<4)
#define FPART_INSTANT (1<<5) #define FPART_INSTANT (1<<5)
#define FPART_ADDITIVE (1<<6) #define FPART_ADDITIVE (1<<6)
#define FPART_NOTWATER (1<<7) // don't spawn in water #define FPART_NOTWATER (1<<7) // don't spawn in water
class CQuakePart class CQuakePart
{ {
public: public:
Vector m_vecOrigin; // position for current frame Vector m_vecOrigin; // position for current frame
Vector m_vecLastOrg; // position from previous frame Vector m_vecLastOrg; // position from previous frame
Vector m_vecVelocity; // linear velocity Vector m_vecVelocity; // linear velocity
Vector m_vecAccel; Vector m_vecAccel;
Vector m_vecColor; Vector m_vecColor;
Vector m_vecColorVelocity; Vector m_vecColorVelocity;
float m_flAlpha; float m_flAlpha;
float m_flAlphaVelocity; float m_flAlphaVelocity;
float m_flRadius; float m_flRadius;
float m_flRadiusVelocity; float m_flRadiusVelocity;
float m_flLength; float m_flLength;
float m_flLengthVelocity; float m_flLengthVelocity;
float m_flRotation; // texture ROLL angle float m_flRotation; // texture ROLL angle
float m_flBounceFactor; float m_flBounceFactor;
CQuakePart *pNext; // linked list CQuakePart *pNext; // linked list
int m_hTexture; int m_hTexture;
float m_flTime; float m_flTime;
int m_iFlags; int m_iFlags;
bool Evaluate( float gravity ); bool Evaluate( float gravity );
}; };
typedef enum typedef enum
{ {
NORMAL_IGNORE = 0, NORMAL_IGNORE = 0,
NORMAL_OFFSET, NORMAL_OFFSET,
NORMAL_DIRECTION, NORMAL_DIRECTION,
NORMAL_OFS_DIR, NORMAL_OFS_DIR,
}; };
class CQuakePartInfo class CQuakePartInfo
{ {
public: public:
char m_szName[32]; // effect name char m_szName[32]; // effect name
struct model_s *m_pSprite; // sprite struct model_s *m_pSprite; // sprite
int m_hTexture; // tga texture int m_hTexture; // tga texture
RandomRange offset[3]; RandomRange offset[3];
RandomRange velocity[3]; RandomRange velocity[3];
RandomRange accel[3]; RandomRange accel[3];
RandomRange color[3]; RandomRange color[3];
RandomRange colorVel[3]; RandomRange colorVel[3];
RandomRange alpha; RandomRange alpha;
RandomRange alphaVel; RandomRange alphaVel;
RandomRange radius; RandomRange radius;
RandomRange radiusVel; RandomRange radiusVel;
RandomRange length; RandomRange length;
RandomRange lengthVel; RandomRange lengthVel;
RandomRange rotation; RandomRange rotation;
RandomRange bounce; RandomRange bounce;
RandomRange frame; RandomRange frame;
RandomRange count; // particle count RandomRange count; // particle count
int normal; // how to use normal int normal; // how to use normal
int flags; // particle flags int flags; // particle flags
}; };
class CQuakePartSystem class CQuakePartSystem
{ {
CQuakePart *m_pActiveParticles; CQuakePart *m_pActiveParticles;
CQuakePart *m_pFreeParticles; CQuakePart *m_pFreeParticles;
CQuakePart m_pParticles[MAX_PARTICLES]; CQuakePart m_pParticles[MAX_PARTICLES];
CQuakePartInfo m_pPartInfo[MAX_PARTINFOS]; CQuakePartInfo m_pPartInfo[MAX_PARTINFOS];
int m_iNumPartInfo; int m_iNumPartInfo;
// private partsystem shaders // private partsystem shaders
int m_hDefaultParticle; int m_hDefaultParticle;
int m_hSparks; int m_hSparks;
int m_hSmoke; int m_hSmoke;
int m_hWaterSplash; int m_hWaterSplash;
cvar_t *m_pAllowParticles; cvar_t *m_pAllowParticles;
cvar_t *m_pParticleLod; cvar_t *m_pParticleLod;
public: public:
CQuakePartSystem( void ); CQuakePartSystem( void );
virtual ~CQuakePartSystem( void ); virtual ~CQuakePartSystem( void );
void Clear( void ); void Clear( void );
void Update( void ); void Update( void );
void FreeParticle( CQuakePart *pCur ); void FreeParticle( CQuakePart *pCur );
CQuakePart *AllocParticle( void ); CQuakePart *AllocParticle( void );
bool AddParticle( CQuakePart *src, int texture = 0, int flags = 0 ); bool AddParticle( CQuakePart *src, int texture = 0, int flags = 0 );
void ParsePartInfos( const char *filename ); void ParsePartInfos( const char *filename );
bool ParsePartInfo( CQuakePartInfo *info, char *&pfile ); bool ParsePartInfo( CQuakePartInfo *info, char *&pfile );
bool ParseRandomVector( char *&pfile, RandomRange out[3] ); bool ParseRandomVector( char *&pfile, RandomRange out[3] );
int ParseParticleFlags( char *pfile ); int ParseParticleFlags( char *pfile );
CQuakePartInfo *FindPartInfo( const char *name ); CQuakePartInfo *FindPartInfo( const char *name );
void CreateEffect( const char *name, const Vector &origin, const Vector &normal ); void CreateEffect( const char *name, const Vector &origin, const Vector &normal );
// example presets // example presets
void ExplosionParticles( const Vector &pos ); void ExplosionParticles( const Vector &pos );
void BulletParticles( const Vector &org, const Vector &dir ); void BulletParticles( const Vector &org, const Vector &dir );
void BubbleParticles( const Vector &org, int count, float magnitude ); void BubbleParticles( const Vector &org, int count, float magnitude );
void SparkParticles( const Vector &org, const Vector &dir ); void SparkParticles( const Vector &org, const Vector &dir );
void RicochetSparks( const Vector &org, float scale ); void RicochetSparks( const Vector &org, float scale );
void SmokeParticles( const Vector &pos, int count ); void SmokeParticles( const Vector &pos, int count );
void GunSmoke( const Vector &pos, int count ); void GunSmoke( const Vector &pos, int count );
}; };
extern CQuakePartSystem g_pParticles; extern CQuakePartSystem g_pParticles;
#endif//GL_RPART_H #endif//GL_RPART_H

View File

@ -1,99 +1,99 @@
/* /*
gl_rsurf.cpp - surface-related code gl_rsurf.cpp - surface-related code
Copyright (C) 2013 Uncle Mike Copyright (C) 2013 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "gl_local.h" #include "gl_local.h"
static int rtable[MOD_FRAMES][MOD_FRAMES]; static int rtable[MOD_FRAMES][MOD_FRAMES];
/* /*
=============== ===============
R_TextureAnimation R_TextureAnimation
Returns the proper texture for a given time and base texture Returns the proper texture for a given time and base texture
=============== ===============
*/ */
texture_t *R_TextureAnimation( msurface_t *s ) texture_t *R_TextureAnimation( msurface_t *s )
{ {
texture_t *base = s->texinfo->texture; texture_t *base = s->texinfo->texture;
int count, reletive = 0; int count, reletive = 0;
if(( RI->currententity != NULL ) && ( RI->currententity->curstate.frame != 0.0f )) if(( RI->currententity != NULL ) && ( RI->currententity->curstate.frame != 0.0f ))
{ {
if( base->alternate_anims ) if( base->alternate_anims )
base = base->alternate_anims; base = base->alternate_anims;
} }
if( !base->anim_total ) if( !base->anim_total )
return base; return base;
if( base->name[0] == '-' ) if( base->name[0] == '-' )
{ {
int tx = (int)((s->texturemins[0] + (base->width << 16)) / base->width) % MOD_FRAMES; int tx = (int)((s->texturemins[0] + (base->width << 16)) / base->width) % MOD_FRAMES;
int ty = (int)((s->texturemins[1] + (base->height << 16)) / base->height) % MOD_FRAMES; int ty = (int)((s->texturemins[1] + (base->height << 16)) / base->height) % MOD_FRAMES;
reletive = rtable[tx][ty] % base->anim_total; reletive = rtable[tx][ty] % base->anim_total;
} }
else else
{ {
reletive = (int)(tr.time * 20) % base->anim_total; reletive = (int)(tr.time * 20) % base->anim_total;
} }
count = 0; count = 0;
while( base->anim_min > reletive || base->anim_max <= reletive ) while( base->anim_min > reletive || base->anim_max <= reletive )
{ {
base = base->anim_next; base = base->anim_next;
if( !base ) if( !base )
{ {
ALERT( at_error, "R_TextureAnimation: broken loop\n" ); ALERT( at_error, "R_TextureAnimation: broken loop\n" );
return s->texinfo->texture; return s->texinfo->texture;
} }
if( ++count > MOD_FRAMES ) if( ++count > MOD_FRAMES )
{ {
ALERT( at_error, "R_TextureAnimation: infinite loop\n" ); ALERT( at_error, "R_TextureAnimation: infinite loop\n" );
return s->texinfo->texture; return s->texinfo->texture;
} }
} }
return base; return base;
} }
/* /*
============================================================= =============================================================
WORLD MODEL WORLD MODEL
============================================================= =============================================================
*/ */
void GL_InitRandomTable( void ) void GL_InitRandomTable( void )
{ {
int tu, tv; int tu, tv;
// make random predictable // make random predictable
RANDOM_SEED( 255 ); RANDOM_SEED( 255 );
for( tu = 0; tu < MOD_FRAMES; tu++ ) for( tu = 0; tu < MOD_FRAMES; tu++ )
{ {
for( tv = 0; tv < MOD_FRAMES; tv++ ) for( tv = 0; tv < MOD_FRAMES; tv++ )
{ {
rtable[tu][tv] = RANDOM_LONG( 0, 0x7FFF ); rtable[tu][tv] = RANDOM_LONG( 0, 0x7FFF );
} }
} }
RANDOM_SEED( 0 ); RANDOM_SEED( 0 );
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,262 +1,262 @@
/* /*
gl_shader.h - shader parsing and handling gl_shader.h - shader parsing and handling
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2013 Uncle Mike Copyright (C) 2013 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_SHADER_H #ifndef GL_SHADER_H
#define GL_SHADER_H #define GL_SHADER_H
#define MAX_OPTIONS_LENGTH 512 #define MAX_OPTIONS_LENGTH 512
#define MAX_GLSL_PROGRAMS 4096 #define MAX_GLSL_PROGRAMS 4096
#define SHADER_VERTEX_COMPILED BIT( 0 ) #define SHADER_VERTEX_COMPILED BIT( 0 )
#define SHADER_FRAGMENT_COMPILED BIT( 1 ) #define SHADER_FRAGMENT_COMPILED BIT( 1 )
#define SHADER_PROGRAM_LINKED BIT( 2 ) #define SHADER_PROGRAM_LINKED BIT( 2 )
#define SHADER_UBERSHADER BIT( 3 ) #define SHADER_UBERSHADER BIT( 3 )
#define SHADER_TRANSLUCENT BIT( 4 ) #define SHADER_TRANSLUCENT BIT( 4 )
#define SHADER_USE_CUBEMAPS BIT( 5 ) #define SHADER_USE_CUBEMAPS BIT( 5 )
#define SHADER_USE_SCREENCOPY BIT( 6 ) #define SHADER_USE_SCREENCOPY BIT( 6 )
#define SHADER_ADDITIVE BIT( 7 ) #define SHADER_ADDITIVE BIT( 7 )
#define SHADER_STATUS_OK ( SHADER_PROGRAM_LINKED|SHADER_VERTEX_COMPILED|SHADER_FRAGMENT_COMPILED ) #define SHADER_STATUS_OK ( SHADER_PROGRAM_LINKED|SHADER_VERTEX_COMPILED|SHADER_FRAGMENT_COMPILED )
#define CheckShader( shader ) ( shader && shader->status == SHADER_STATUS_OK ) #define CheckShader( shader ) ( shader && shader->status == SHADER_STATUS_OK )
enum enum
{ {
ATTR_INDEX_POSITION = 0, ATTR_INDEX_POSITION = 0,
ATTR_INDEX_TANGENT, ATTR_INDEX_TANGENT,
ATTR_INDEX_BINORMAL, ATTR_INDEX_BINORMAL,
ATTR_INDEX_NORMAL, ATTR_INDEX_NORMAL,
ATTR_INDEX_TEXCOORD0, // texture coord ATTR_INDEX_TEXCOORD0, // texture coord
ATTR_INDEX_TEXCOORD1, // lightmap coord (styles0-1) ATTR_INDEX_TEXCOORD1, // lightmap coord (styles0-1)
ATTR_INDEX_TEXCOORD2, // lightmap coord (styles2-3) ATTR_INDEX_TEXCOORD2, // lightmap coord (styles2-3)
ATTR_INDEX_BONE_INDEXES, // studiomodels only ATTR_INDEX_BONE_INDEXES, // studiomodels only
ATTR_INDEX_BONE_WEIGHTS, // studiomodels only ATTR_INDEX_BONE_WEIGHTS, // studiomodels only
ATTR_INDEX_LIGHT_STYLES, // brushmodels only ATTR_INDEX_LIGHT_STYLES, // brushmodels only
ATTR_INDEX_LIGHT_COLOR, // studio & grass ATTR_INDEX_LIGHT_COLOR, // studio & grass
ATTR_INDEX_LIGHT_VECS, // studio & grass ATTR_INDEX_LIGHT_VECS, // studio & grass
ATTR_INDEX_LIGHT_NUMS0, // brushmodels only ATTR_INDEX_LIGHT_NUMS0, // brushmodels only
ATTR_INDEX_LIGHT_NUMS1, // brushmodels only ATTR_INDEX_LIGHT_NUMS1, // brushmodels only
}; };
// shader->attribs // shader->attribs
#define FATTR_POSITION BIT( 0 ) #define FATTR_POSITION BIT( 0 )
#define FATTR_TANGENT BIT( 1 ) #define FATTR_TANGENT BIT( 1 )
#define FATTR_BINORMAL BIT( 2 ) #define FATTR_BINORMAL BIT( 2 )
#define FATTR_NORMAL BIT( 3 ) #define FATTR_NORMAL BIT( 3 )
#define FATTR_TEXCOORD0 BIT( 4 ) #define FATTR_TEXCOORD0 BIT( 4 )
#define FATTR_TEXCOORD1 BIT( 5 ) #define FATTR_TEXCOORD1 BIT( 5 )
#define FATTR_TEXCOORD2 BIT( 6 ) #define FATTR_TEXCOORD2 BIT( 6 )
#define FATTR_BONE_INDEXES BIT( 7 ) #define FATTR_BONE_INDEXES BIT( 7 )
#define FATTR_BONE_WEIGHTS BIT( 8 ) #define FATTR_BONE_WEIGHTS BIT( 8 )
#define FATTR_LIGHT_STYLES BIT( 9 ) #define FATTR_LIGHT_STYLES BIT( 9 )
#define FATTR_LIGHT_COLOR BIT( 10 ) #define FATTR_LIGHT_COLOR BIT( 10 )
#define FATTR_LIGHT_VECS BIT( 11 ) #define FATTR_LIGHT_VECS BIT( 11 )
#define FATTR_LIGHT_NUMS0 BIT( 12 ) #define FATTR_LIGHT_NUMS0 BIT( 12 )
#define FATTR_LIGHT_NUMS1 BIT( 13 ) #define FATTR_LIGHT_NUMS1 BIT( 13 )
// uniform->flags // uniform->flags
#define UFL_GLOBAL_PARM BIT( 0 ) #define UFL_GLOBAL_PARM BIT( 0 )
#define UFL_TEXTURE_UNIT BIT( 1 ) #define UFL_TEXTURE_UNIT BIT( 1 )
// uniform->type // uniform->type
typedef enum typedef enum
{ {
UT_COLORMAP = 0, UT_COLORMAP = 0,
UT_DEPTHMAP, UT_DEPTHMAP,
UT_NORMALMAP, UT_NORMALMAP,
UT_GLOSSMAP, UT_GLOSSMAP,
UT_DETAILMAP, UT_DETAILMAP,
UT_PROJECTMAP, // spotlight texture UT_PROJECTMAP, // spotlight texture
UT_SHADOWMAP0, UT_SHADOWMAP0,
UT_SHADOWMAP1, UT_SHADOWMAP1,
UT_SHADOWMAP2, UT_SHADOWMAP2,
UT_SHADOWMAP3, UT_SHADOWMAP3,
UT_SHADOWMAP, UT_SHADOWMAP,
UT_LIGHTMAP, UT_LIGHTMAP,
UT_DELUXEMAP, UT_DELUXEMAP,
UT_DECALMAP, UT_DECALMAP,
UT_SCREENMAP, UT_SCREENMAP,
UT_VISLIGHTMAP0, UT_VISLIGHTMAP0,
UT_VISLIGHTMAP1, UT_VISLIGHTMAP1,
UT_ENVMAP0, UT_ENVMAP0,
UT_ENVMAP1, UT_ENVMAP1,
UT_ENVMAP, UT_ENVMAP,
UT_GLOWMAP, UT_GLOWMAP,
UT_HEIGHTMAP, UT_HEIGHTMAP,
UT_LAYERMAP, UT_LAYERMAP,
UT_FRAGDATA0, UT_FRAGDATA0,
UT_FRAGDATA1, UT_FRAGDATA1,
UT_FRAGDATA2, UT_FRAGDATA2,
UT_BSPPLANESMAP, UT_BSPPLANESMAP,
UT_BSPNODESMAP, UT_BSPNODESMAP,
UT_BSPLIGHTSMAP, UT_BSPLIGHTSMAP,
UT_BSPMODELSMAP, UT_BSPMODELSMAP,
UT_FITNORMALMAP, UT_FITNORMALMAP,
UT_MODELMATRIX, UT_MODELMATRIX,
UT_REFLECTMATRIX, UT_REFLECTMATRIX,
UT_BONESARRAY, UT_BONESARRAY,
UT_BONEQUATERNION, UT_BONEQUATERNION,
UT_BONEPOSITION, UT_BONEPOSITION,
UT_SCREENSIZEINV, UT_SCREENSIZEINV,
UT_ZFAR, UT_ZFAR,
UT_LIGHTSTYLEVALUES, UT_LIGHTSTYLEVALUES,
UT_LIGHTSTYLES, UT_LIGHTSTYLES,
UT_REALTIME, UT_REALTIME,
UT_DETAILSCALE, UT_DETAILSCALE,
UT_FOGPARAMS, UT_FOGPARAMS,
UT_SHADOWPARMS, UT_SHADOWPARMS,
UT_TEXOFFSET, UT_TEXOFFSET,
UT_VIEWORIGIN, UT_VIEWORIGIN,
UT_VIEWRIGHT, UT_VIEWRIGHT,
UT_RENDERCOLOR, UT_RENDERCOLOR,
UT_RENDERALPHA, UT_RENDERALPHA,
UT_SMOOTHNESS, UT_SMOOTHNESS,
UT_SHADOWMATRIX, UT_SHADOWMATRIX,
UT_SHADOWSPLITDIST, UT_SHADOWSPLITDIST,
UT_TEXELSIZE, UT_TEXELSIZE,
UT_GAMMATABLE, UT_GAMMATABLE,
UT_LIGHTDIR, UT_LIGHTDIR,
UT_LIGHTDIFFUSE, UT_LIGHTDIFFUSE,
UT_LIGHTSHADE, UT_LIGHTSHADE,
UT_LIGHTORIGIN, UT_LIGHTORIGIN,
UT_LIGHTVIEWPROJMATRIX, UT_LIGHTVIEWPROJMATRIX,
UT_DIFFUSEFACTOR, UT_DIFFUSEFACTOR,
UT_AMBIENTFACTOR, UT_AMBIENTFACTOR,
UT_AMBIENTCUBE, UT_AMBIENTCUBE,
UT_SUNREFRACT, UT_SUNREFRACT,
UT_LERPFACTOR, UT_LERPFACTOR,
UT_REFRACTSCALE, UT_REFRACTSCALE,
UT_REFLECTSCALE, UT_REFLECTSCALE,
UT_ABERRATIONSCALE, UT_ABERRATIONSCALE,
UT_BOXMINS, UT_BOXMINS,
UT_BOXMAXS, UT_BOXMAXS,
UT_CUBEORIGIN, UT_CUBEORIGIN,
UT_CUBEMIPCOUNT, UT_CUBEMIPCOUNT,
UT_LIGHTNUMS0, UT_LIGHTNUMS0,
UT_LIGHTNUMS1, UT_LIGHTNUMS1,
UT_GRASSPARAMS, UT_GRASSPARAMS,
UT_RELIEFPARAMS, UT_RELIEFPARAMS,
UT_BLURFACTOR, UT_BLURFACTOR,
UT_SCREENWIDTH, UT_SCREENWIDTH,
UT_SCREENHEIGHT, UT_SCREENHEIGHT,
UT_FOCALDEPTH, UT_FOCALDEPTH,
UT_FOCALLENGTH, UT_FOCALLENGTH,
UT_DOFDEBUG, UT_DOFDEBUG,
UT_FSTOP, UT_FSTOP,
UT_GRAYSCALE, UT_GRAYSCALE,
UT_LIGHTGAMMA, UT_LIGHTGAMMA,
UT_LIGHTSCALE, UT_LIGHTSCALE,
UT_LIGHTTHRESHOLD, UT_LIGHTTHRESHOLD,
UT_NUMVISIBLEMODELS, UT_NUMVISIBLEMODELS,
UT_UNDEFINED, UT_UNDEFINED,
} uniformType_t; } uniformType_t;
union unicache_t union unicache_t
{ {
unicache_t( int v0 ) { iValue[0] = v0; iValue[1] = iValue[2] = iValue[3] = 0; } unicache_t( int v0 ) { iValue[0] = v0; iValue[1] = iValue[2] = iValue[3] = 0; }
unicache_t( int v0, int v1 ) { iValue[0] = v0; iValue[1] = v1; iValue[2] = iValue[3] = 0; } unicache_t( int v0, int v1 ) { iValue[0] = v0; iValue[1] = v1; iValue[2] = iValue[3] = 0; }
unicache_t( int v0, int v1, int v2 ) { iValue[0] = v0; iValue[1] = v1; iValue[2] = v2; iValue[3] = 0; } unicache_t( int v0, int v1, int v2 ) { iValue[0] = v0; iValue[1] = v1; iValue[2] = v2; iValue[3] = 0; }
unicache_t( int v0, int v1, int v2, int v3 ) { iValue[0] = v0; iValue[1] = v1; iValue[2] = v2; iValue[3] = v3; } unicache_t( int v0, int v1, int v2, int v3 ) { iValue[0] = v0; iValue[1] = v1; iValue[2] = v2; iValue[3] = v3; }
unicache_t( float v0 ) { fValue[0] = v0; fValue[1] = fValue[2] = fValue[3] = 0.0f; } unicache_t( float v0 ) { fValue[0] = v0; fValue[1] = fValue[2] = fValue[3] = 0.0f; }
unicache_t( float v0, float v1 ) { fValue[0] = v0; fValue[1] = v1; fValue[2] = fValue[3] = 0.0f; } unicache_t( float v0, float v1 ) { fValue[0] = v0; fValue[1] = v1; fValue[2] = fValue[3] = 0.0f; }
unicache_t( float v0, float v1, float v2 ) { fValue[0] = v0; fValue[1] = v1; fValue[2] = v2; fValue[3] = 0.0f; } unicache_t( float v0, float v1, float v2 ) { fValue[0] = v0; fValue[1] = v1; fValue[2] = v2; fValue[3] = 0.0f; }
unicache_t( float v0, float v1, float v2, float v3 ) { fValue[0] = v0; fValue[1] = v1; fValue[2] = v2; fValue[3] = v3; } unicache_t( float v0, float v1, float v2, float v3 ) { fValue[0] = v0; fValue[1] = v1; fValue[2] = v2; fValue[3] = v3; }
float fValue[4]; float fValue[4];
int iValue[4]; int iValue[4];
}; };
class uniform_t class uniform_t
{ {
public: public:
char name[MAX_QPATH]; char name[MAX_QPATH];
uniformType_t type; uniformType_t type;
int size; int size;
uint format; uint format;
int location; int location;
int unit; // texture unit int unit; // texture unit
int flags; // hints int flags; // hints
unicache_t cache; unicache_t cache;
// helpers // helpers
void SetValue( float v0 ) void SetValue( float v0 )
{ {
unicache_t pack( v0 ); unicache_t pack( v0 );
SetValue( &pack ); SetValue( &pack );
} }
void SetValue( float v0, float v1 ) void SetValue( float v0, float v1 )
{ {
unicache_t pack( v0, v1 ); unicache_t pack( v0, v1 );
SetValue( &pack ); SetValue( &pack );
} }
void SetValue( float v0, float v1, float v2 ) void SetValue( float v0, float v1, float v2 )
{ {
unicache_t pack( v0, v1, v2 ); unicache_t pack( v0, v1, v2 );
SetValue( &pack ); SetValue( &pack );
} }
void SetValue( float v0, float v1, float v2, float v3 ) void SetValue( float v0, float v1, float v2, float v3 )
{ {
unicache_t pack( v0, v1, v2, v3 ); unicache_t pack( v0, v1, v2, v3 );
SetValue( &pack ); SetValue( &pack );
} }
void SetValue( int v0 ) void SetValue( int v0 )
{ {
unicache_t pack( v0 ); unicache_t pack( v0 );
SetValue( &pack ); SetValue( &pack );
} }
void SetValue( int v0, int v1 ) void SetValue( int v0, int v1 )
{ {
unicache_t pack( v0, v1 ); unicache_t pack( v0, v1 );
SetValue( &pack ); SetValue( &pack );
} }
void SetValue( int v0, int v1, int v2 ) void SetValue( int v0, int v1, int v2 )
{ {
unicache_t pack( v0, v1, v2 ); unicache_t pack( v0, v1, v2 );
SetValue( &pack ); SetValue( &pack );
} }
void SetValue( int v0, int v1, int v2, GLint v3 ) void SetValue( int v0, int v1, int v2, GLint v3 )
{ {
unicache_t pack( v0, v1, v2, v3 ); unicache_t pack( v0, v1, v2, v3 );
SetValue( &pack ); SetValue( &pack );
} }
// passed any data here // passed any data here
void SetValue( const void *pdata, int count = -1 ); void SetValue( const void *pdata, int count = -1 );
int GetSizeInBytes( void ); int GetSizeInBytes( void );
}; };
typedef struct glsl_prog_s typedef struct glsl_prog_s
{ {
char name[64]; char name[64];
char options[MAX_OPTIONS_LENGTH]; // UberShader preprocess agrs char options[MAX_OPTIONS_LENGTH]; // UberShader preprocess agrs
GLhandleARB handle; GLhandleARB handle;
unsigned short status; unsigned short status;
struct glsl_prog_s *nextHash; struct glsl_prog_s *nextHash;
unsigned short attribs; unsigned short attribs;
uniform_t *uniforms; uniform_t *uniforms;
int numUniforms; int numUniforms;
} glsl_program_t; } glsl_program_t;
extern glsl_program_t glsl_programs[MAX_GLSL_PROGRAMS]; extern glsl_program_t glsl_programs[MAX_GLSL_PROGRAMS];
extern int num_glsl_programs; extern int num_glsl_programs;
#endif//GL_SHADER_H #endif//GL_SHADER_H

View File

@ -1,138 +1,138 @@
/* /*
gl_shadowmap.cpp - render shadowmaps for directional lights gl_shadowmap.cpp - render shadowmaps for directional lights
Copyright (C) 2018 Uncle Mike Copyright (C) 2018 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "gl_local.h" #include "gl_local.h"
#include <mathlib.h> #include <mathlib.h>
#include <stringlib.h> #include <stringlib.h>
#include "gl_studio.h" #include "gl_studio.h"
#include "gl_sprite.h" #include "gl_sprite.h"
#include "gl_world.h" #include "gl_world.h"
#include "gl_grass.h" #include "gl_grass.h"
#include "pm_defs.h" #include "pm_defs.h"
/* /*
============================================================================= =============================================================================
SHADOWMAP ALLOCATION SHADOWMAP ALLOCATION
============================================================================= =============================================================================
*/ */
static void SM_InitBlock( void ) static void SM_InitBlock( void )
{ {
gl_shadowmap_t *sms = &tr.shadowmap; gl_shadowmap_t *sms = &tr.shadowmap;
memset( sms->allocated, 0, sizeof( sms->allocated )); memset( sms->allocated, 0, sizeof( sms->allocated ));
sms->shadowmap.Init( FBO_DEPTH, SHADOW_SIZE, SHADOW_SIZE ); sms->shadowmap.Init( FBO_DEPTH, SHADOW_SIZE, SHADOW_SIZE );
} }
static int SM_AllocBlock( unsigned short w, unsigned short h, unsigned short *x, unsigned short *y ) static int SM_AllocBlock( unsigned short w, unsigned short h, unsigned short *x, unsigned short *y )
{ {
gl_shadowmap_t *sms = &tr.shadowmap; gl_shadowmap_t *sms = &tr.shadowmap;
unsigned short i, j, best, best2; unsigned short i, j, best, best2;
best = SHADOW_SIZE; best = SHADOW_SIZE;
for( i = 0; i < SHADOW_SIZE - w; i++ ) for( i = 0; i < SHADOW_SIZE - w; i++ )
{ {
best2 = 0; best2 = 0;
for( j = 0; j < w; j++ ) for( j = 0; j < w; j++ )
{ {
if( sms->allocated[i+j] >= best ) if( sms->allocated[i+j] >= best )
break; break;
if( sms->allocated[i+j] > best2 ) if( sms->allocated[i+j] > best2 )
best2 = sms->allocated[i+j]; best2 = sms->allocated[i+j];
} }
if( j == w ) if( j == w )
{ {
// this is a valid spot // this is a valid spot
*x = i; *x = i;
*y = best = best2; *y = best = best2;
} }
} }
// atlas is full // atlas is full
if( best + h > SHADOW_SIZE ) if( best + h > SHADOW_SIZE )
return false; return false;
for( i = 0; i < w; i++ ) for( i = 0; i < w; i++ )
sms->allocated[*x + i] = best + h; sms->allocated[*x + i] = best + h;
return true; return true;
} }
/* /*
================ ================
R_RenderShadowScene R_RenderShadowScene
fast version of R_RenderScene: no colors, no texcords etc fast version of R_RenderScene: no colors, no texcords etc
================ ================
*/ */
void R_RenderShadow( mworldlight_t *wl ) void R_RenderShadow( mworldlight_t *wl )
{ {
if( !wl->shadow_w || !wl->shadow_h ) if( !wl->shadow_w || !wl->shadow_h )
{ {
wl->shadow_w = 256; wl->shadow_w = 256;
wl->shadow_h = 256; wl->shadow_h = 256;
SM_AllocBlock( wl->shadow_w, wl->shadow_h, &wl->shadow_x, &wl->shadow_y ); SM_AllocBlock( wl->shadow_w, wl->shadow_h, &wl->shadow_x, &wl->shadow_y );
} }
} }
void R_RenderDeferredShadows( void ) void R_RenderDeferredShadows( void )
{ {
unsigned int oldFBO; unsigned int oldFBO;
mworldlight_t *wl; mworldlight_t *wl;
int i; int i;
if( R_FullBright() || !CVAR_TO_BOOL( r_shadows ) || tr.fGamePaused ) if( R_FullBright() || !CVAR_TO_BOOL( r_shadows ) || tr.fGamePaused )
return; return;
if( FBitSet( RI->params, ( RP_NOSHADOWS|RP_ENVVIEW|RP_SKYVIEW ))) if( FBitSet( RI->params, ( RP_NOSHADOWS|RP_ENVVIEW|RP_SKYVIEW )))
return; return;
// check for static lights // check for static lights
if( !HasStaticLights( )) return; if( !HasStaticLights( )) return;
R_PushRefState(); // make refinst backup R_PushRefState(); // make refinst backup
oldFBO = glState.frameBuffer; oldFBO = glState.frameBuffer;
for( i = 0, wl = world->worldlights; i < world->numworldlights; i++, wl++ ) for( i = 0, wl = world->worldlights; i < world->numworldlights; i++, wl++ )
{ {
if( wl->emittype == emit_ignored ) if( wl->emittype == emit_ignored )
continue; continue;
// single visible check // single visible check
if( !CHECKVISBIT( RI->view.vislight, i )) if( !CHECKVISBIT( RI->view.vislight, i ))
continue; continue;
switch( wl->emittype ) switch( wl->emittype )
{ {
case emit_surface: case emit_surface:
R_RenderShadow( wl ); R_RenderShadow( wl );
break; break;
} }
R_ResetRefState(); // restore ref instance R_ResetRefState(); // restore ref instance
} }
R_PopRefState(); // restore ref instance R_PopRefState(); // restore ref instance
// restore FBO state // restore FBO state
GL_BindFBO( oldFBO ); GL_BindFBO( oldFBO );
GL_BindShader( NULL ); GL_BindShader( NULL );
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,373 +1,373 @@
// //
// written by BUzer for HL: Paranoia modification // written by BUzer for HL: Paranoia modification
// //
// 2006 // 2006
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "gl_local.h" #include "gl_local.h"
#include "gl_shader.h" #include "gl_shader.h"
#define MAX_CLIP_VERTS 128 // skybox clip vertices #define MAX_CLIP_VERTS 128 // skybox clip vertices
static const int r_skyTexOrder[6] = { 0, 2, 1, 3, 4, 5 }; static const int r_skyTexOrder[6] = { 0, 2, 1, 3, 4, 5 };
static const Vector skyclip[6] = static const Vector skyclip[6] =
{ {
Vector( 1, 1, 0 ), Vector( 1, 1, 0 ),
Vector( 1, -1, 0 ), Vector( 1, -1, 0 ),
Vector( 0, -1, 1 ), Vector( 0, -1, 1 ),
Vector( 0, 1, 1 ), Vector( 0, 1, 1 ),
Vector( 1, 0, 1 ), Vector( 1, 0, 1 ),
Vector( -1, 0, 1 ) Vector( -1, 0, 1 )
}; };
// 1 = s, 2 = t, 3 = 2048 // 1 = s, 2 = t, 3 = 2048
static const int st_to_vec[6][3] = static const int st_to_vec[6][3] =
{ {
{ 3, -1, 2 }, { 3, -1, 2 },
{ -3, 1, 2 }, { -3, 1, 2 },
{ 1, 3, 2 }, { 1, 3, 2 },
{ -1, -3, 2 }, { -1, -3, 2 },
{ -2, -1, 3 }, // 0 degrees yaw, look straight up { -2, -1, 3 }, // 0 degrees yaw, look straight up
{ 2, -1, -3 } // look straight down { 2, -1, -3 } // look straight down
}; };
// s = [0]/[2], t = [1]/[2] // s = [0]/[2], t = [1]/[2]
static const int vec_to_st[6][3] = static const int vec_to_st[6][3] =
{ {
{ -2, 3, 1 }, { -2, 3, 1 },
{ 2, 3, -1 }, { 2, 3, -1 },
{ 1, 3, 2 }, { 1, 3, 2 },
{ -1, 3, -2 }, { -1, 3, -2 },
{ -2, -1, 3 }, { -2, -1, 3 },
{ -2, 1, -3 } { -2, 1, -3 }
}; };
static void DrawSkyPolygon( int nump, Vector vecs[] ) static void DrawSkyPolygon( int nump, Vector vecs[] )
{ {
int i, j, axis; int i, j, axis;
float s, t, dv; float s, t, dv;
Vector v, av; Vector v, av;
// decide which face it maps to // decide which face it maps to
v = g_vecZero; v = g_vecZero;
for( i = 0; i < nump; i++ ) for( i = 0; i < nump; i++ )
v += vecs[i]; v += vecs[i];
av[0] = fabs( v[0] ); av[0] = fabs( v[0] );
av[1] = fabs( v[1] ); av[1] = fabs( v[1] );
av[2] = fabs( v[2] ); av[2] = fabs( v[2] );
if( av[0] > av[1] && av[0] > av[2] ) if( av[0] > av[1] && av[0] > av[2] )
axis = (v[0] < 0) ? 1 : 0; axis = (v[0] < 0) ? 1 : 0;
else if( av[1] > av[2] && av[1] > av[0] ) else if( av[1] > av[2] && av[1] > av[0] )
axis = (v[1] < 0) ? 3 : 2; axis = (v[1] < 0) ? 3 : 2;
else axis = (v[2] < 0) ? 5 : 4; else axis = (v[2] < 0) ? 5 : 4;
// project new texture coords // project new texture coords
for( i = 0; i < nump; i++ ) for( i = 0; i < nump; i++ )
{ {
j = vec_to_st[axis][2]; j = vec_to_st[axis][2];
dv = (j > 0) ? (vecs[i])[j-1] : -(vecs[i])[-j-1]; dv = (j > 0) ? (vecs[i])[j-1] : -(vecs[i])[-j-1];
j = vec_to_st[axis][0]; j = vec_to_st[axis][0];
s = (j < 0) ? -vecs[i][-j-1] / dv : (vecs[i])[j-1] / dv; s = (j < 0) ? -vecs[i][-j-1] / dv : (vecs[i])[j-1] / dv;
j = vec_to_st[axis][1]; j = vec_to_st[axis][1];
t = (j < 0) ? -(vecs[i])[-j-1] / dv : (vecs[i])[j-1] / dv; t = (j < 0) ? -(vecs[i])[-j-1] / dv : (vecs[i])[j-1] / dv;
if( s < RI->view.skyMins[0][axis] ) RI->view.skyMins[0][axis] = s; if( s < RI->view.skyMins[0][axis] ) RI->view.skyMins[0][axis] = s;
if( t < RI->view.skyMins[1][axis] ) RI->view.skyMins[1][axis] = t; if( t < RI->view.skyMins[1][axis] ) RI->view.skyMins[1][axis] = t;
if( s > RI->view.skyMaxs[0][axis] ) RI->view.skyMaxs[0][axis] = s; if( s > RI->view.skyMaxs[0][axis] ) RI->view.skyMaxs[0][axis] = s;
if( t > RI->view.skyMaxs[1][axis] ) RI->view.skyMaxs[1][axis] = t; if( t > RI->view.skyMaxs[1][axis] ) RI->view.skyMaxs[1][axis] = t;
} }
} }
/* /*
============== ==============
ClipSkyPolygon ClipSkyPolygon
============== ==============
*/ */
static void ClipSkyPolygon( int nump, Vector vecs[], int stage ) static void ClipSkyPolygon( int nump, Vector vecs[], int stage )
{ {
bool front, back; bool front, back;
float dists[MAX_CLIP_VERTS + 1]; float dists[MAX_CLIP_VERTS + 1];
int sides[MAX_CLIP_VERTS + 1]; int sides[MAX_CLIP_VERTS + 1];
Vector newv[2][MAX_CLIP_VERTS + 1]; Vector newv[2][MAX_CLIP_VERTS + 1];
int newc[2]; int newc[2];
float d, e; float d, e;
int i; int i;
if( nump > MAX_CLIP_VERTS ) if( nump > MAX_CLIP_VERTS )
HOST_ERROR( "ClipSkyPolygon: MAX_CLIP_VERTS\n" ); HOST_ERROR( "ClipSkyPolygon: MAX_CLIP_VERTS\n" );
loc1: loc1:
if( stage == 6 ) if( stage == 6 )
{ {
// fully clipped, so draw it // fully clipped, so draw it
DrawSkyPolygon( nump, vecs ); DrawSkyPolygon( nump, vecs );
return; return;
} }
front = back = false; front = back = false;
const Vector &norm = skyclip[stage]; const Vector &norm = skyclip[stage];
for( i = 0; i < nump; i++ ) for( i = 0; i < nump; i++ )
{ {
d = DotProduct( vecs[i], norm ); d = DotProduct( vecs[i], norm );
if( d > ON_EPSILON ) if( d > ON_EPSILON )
{ {
front = true; front = true;
sides[i] = SIDE_FRONT; sides[i] = SIDE_FRONT;
} }
else if( d < -ON_EPSILON ) else if( d < -ON_EPSILON )
{ {
back = true; back = true;
sides[i] = SIDE_BACK; sides[i] = SIDE_BACK;
} }
else else
{ {
sides[i] = SIDE_ON; sides[i] = SIDE_ON;
} }
dists[i] = d; dists[i] = d;
} }
if( !front || !back ) if( !front || !back )
{ {
// not clipped // not clipped
stage++; stage++;
goto loc1; goto loc1;
} }
// clip it // clip it
sides[i] = sides[0]; sides[i] = sides[0];
dists[i] = dists[0]; dists[i] = dists[0];
vecs[i] = vecs[0]; vecs[i] = vecs[0];
newc[0] = newc[1] = 0; newc[0] = newc[1] = 0;
for( i = 0; i < nump; i++ ) for( i = 0; i < nump; i++ )
{ {
switch( sides[i] ) switch( sides[i] )
{ {
case SIDE_FRONT: case SIDE_FRONT:
newv[0][newc[0]] = vecs[i]; newv[0][newc[0]] = vecs[i];
newc[0]++; newc[0]++;
break; break;
case SIDE_BACK: case SIDE_BACK:
newv[1][newc[1]] = vecs[i]; newv[1][newc[1]] = vecs[i];
newc[1]++; newc[1]++;
break; break;
case SIDE_ON: case SIDE_ON:
newv[0][newc[0]] = vecs[i]; newv[0][newc[0]] = vecs[i];
newc[0]++; newc[0]++;
newv[1][newc[1]] = vecs[i]; newv[1][newc[1]] = vecs[i];
newc[1]++; newc[1]++;
break; break;
} }
if( sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) if( sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i] )
continue; continue;
d = dists[i] / ( dists[i] - dists[i+1] ); d = dists[i] / ( dists[i] - dists[i+1] );
for( int j = 0; j < 3; j++ ) for( int j = 0; j < 3; j++ )
{ {
e = (vecs[i])[j] + d * ( (vecs[i+1])[j] - (vecs[i])[j] ); e = (vecs[i])[j] + d * ( (vecs[i+1])[j] - (vecs[i])[j] );
newv[0][newc[0]][j] = e; newv[0][newc[0]][j] = e;
newv[1][newc[1]][j] = e; newv[1][newc[1]][j] = e;
} }
newc[0]++; newc[0]++;
newc[1]++; newc[1]++;
} }
// continue // continue
ClipSkyPolygon( newc[0], newv[0], stage + 1 ); ClipSkyPolygon( newc[0], newv[0], stage + 1 );
ClipSkyPolygon( newc[1], newv[1], stage + 1 ); ClipSkyPolygon( newc[1], newv[1], stage + 1 );
} }
static void MakeSkyVec( float s, float t, int axis ) static void MakeSkyVec( float s, float t, int axis )
{ {
int j, k, farclip; int j, k, farclip;
Vector v, b; Vector v, b;
farclip = RI->view.farClip; farclip = RI->view.farClip;
b[0] = s * (farclip >> 1); b[0] = s * (farclip >> 1);
b[1] = t * (farclip >> 1); b[1] = t * (farclip >> 1);
b[2] = (farclip >> 1); b[2] = (farclip >> 1);
for( j = 0; j < 3; j++ ) for( j = 0; j < 3; j++ )
{ {
k = st_to_vec[axis][j]; k = st_to_vec[axis][j];
v[j] = (k < 0) ? -b[-k-1] : b[k-1]; v[j] = (k < 0) ? -b[-k-1] : b[k-1];
v[j] += GetVieworg()[j]; v[j] += GetVieworg()[j];
} }
// avoid bilerp seam // avoid bilerp seam
s = (s + 1.0f) * 0.5f; s = (s + 1.0f) * 0.5f;
t = (t + 1.0f) * 0.5f; t = (t + 1.0f) * 0.5f;
if( s < ( 1.0f / 512.0f )) if( s < ( 1.0f / 512.0f ))
s = (1.0f / 512.0f); s = (1.0f / 512.0f);
else if( s > ( 511.0f / 512.0f )) else if( s > ( 511.0f / 512.0f ))
s = (511.0f / 512.0f); s = (511.0f / 512.0f);
if( t < ( 1.0f / 512.0f )) if( t < ( 1.0f / 512.0f ))
t = (1.0f / 512.0f); t = (1.0f / 512.0f);
else if( t > ( 511.0f / 512.0f )) else if( t > ( 511.0f / 512.0f ))
t = (511.0f / 512.0f); t = (511.0f / 512.0f);
t = 1.0f - t; t = 1.0f - t;
pglTexCoord2f( s, t ); pglTexCoord2f( s, t );
pglVertex3fv( v ); pglVertex3fv( v );
} }
/* /*
================= =================
R_AddSkyBoxSurface R_AddSkyBoxSurface
================= =================
*/ */
void R_AddSkyBoxSurface( msurface_t *fa ) void R_AddSkyBoxSurface( msurface_t *fa )
{ {
Vector verts[MAX_CLIP_VERTS]; Vector verts[MAX_CLIP_VERTS];
// calculate vertex values for sky box // calculate vertex values for sky box
for( glpoly_t *p = fa->polys; p; p = p->next ) for( glpoly_t *p = fa->polys; p; p = p->next )
{ {
if( p->numverts >= MAX_CLIP_VERTS ) if( p->numverts >= MAX_CLIP_VERTS )
HOST_ERROR( "R_AddSkyBoxSurface: numverts >= MAX_CLIP_VERTS\n" ); HOST_ERROR( "R_AddSkyBoxSurface: numverts >= MAX_CLIP_VERTS\n" );
for( int i = 0; i < p->numverts; i++ ) for( int i = 0; i < p->numverts; i++ )
{ {
verts[i][0] = p->verts[i][0] - GetVieworg().x; verts[i][0] = p->verts[i][0] - GetVieworg().x;
verts[i][1] = p->verts[i][1] - GetVieworg().y; verts[i][1] = p->verts[i][1] - GetVieworg().y;
verts[i][2] = p->verts[i][2] - GetVieworg().z; verts[i][2] = p->verts[i][2] - GetVieworg().z;
} }
ClipSkyPolygon( p->numverts, verts, 0 ); ClipSkyPolygon( p->numverts, verts, 0 );
} }
} }
static void GL_DrawSkySide( int skyside ) static void GL_DrawSkySide( int skyside )
{ {
pglBegin( GL_QUADS ); pglBegin( GL_QUADS );
MakeSkyVec( RI->view.skyMins[0][skyside], RI->view.skyMins[1][skyside], skyside ); MakeSkyVec( RI->view.skyMins[0][skyside], RI->view.skyMins[1][skyside], skyside );
MakeSkyVec( RI->view.skyMins[0][skyside], RI->view.skyMaxs[1][skyside], skyside ); MakeSkyVec( RI->view.skyMins[0][skyside], RI->view.skyMaxs[1][skyside], skyside );
MakeSkyVec( RI->view.skyMaxs[0][skyside], RI->view.skyMaxs[1][skyside], skyside ); MakeSkyVec( RI->view.skyMaxs[0][skyside], RI->view.skyMaxs[1][skyside], skyside );
MakeSkyVec( RI->view.skyMaxs[0][skyside], RI->view.skyMins[1][skyside], skyside ); MakeSkyVec( RI->view.skyMaxs[0][skyside], RI->view.skyMins[1][skyside], skyside );
pglEnd(); pglEnd();
} }
static void GL_DrawSkySide( word hProgram, int skyside ) static void GL_DrawSkySide( word hProgram, int skyside )
{ {
if( hProgram <= 0 ) if( hProgram <= 0 )
{ {
GL_BindShader( NULL ); GL_BindShader( NULL );
GL_BindTexture( GL_TEXTURE0, tr.skyboxTextures[r_skyTexOrder[skyside]] ); GL_BindTexture( GL_TEXTURE0, tr.skyboxTextures[r_skyTexOrder[skyside]] );
GL_DrawSkySide( skyside ); GL_DrawSkySide( skyside );
return; // old method return; // old method
} }
if( RI->currentshader != &glsl_programs[hProgram] ) if( RI->currentshader != &glsl_programs[hProgram] )
{ {
// force to bind new shader // force to bind new shader
GL_BindShader( &glsl_programs[hProgram] ); GL_BindShader( &glsl_programs[hProgram] );
} }
Vector sky_color = (tr.sun_light_enabled) ? tr.sun_diffuse : tr.sky_ambient * (1.0f/128.0f) * tr.diffuseFactor; Vector sky_color = (tr.sun_light_enabled) ? tr.sun_diffuse : tr.sky_ambient * (1.0f/128.0f) * tr.diffuseFactor;
Vector sky_vec = tr.sky_normal.Normalize(); Vector sky_vec = tr.sky_normal.Normalize();
glsl_program_t *shader = RI->currentshader; glsl_program_t *shader = RI->currentshader;
ColorNormalize( sky_color, sky_color ); ColorNormalize( sky_color, sky_color );
// setup specified uniforms (and texture bindings) // setup specified uniforms (and texture bindings)
for( int i = 0; i < shader->numUniforms; i++ ) for( int i = 0; i < shader->numUniforms; i++ )
{ {
uniform_t *u = &shader->uniforms[i]; uniform_t *u = &shader->uniforms[i];
switch( u->type ) switch( u->type )
{ {
case UT_COLORMAP: case UT_COLORMAP:
u->SetValue( tr.skyboxTextures[r_skyTexOrder[skyside]] ); u->SetValue( tr.skyboxTextures[r_skyTexOrder[skyside]] );
break; break;
case UT_LIGHTDIR: case UT_LIGHTDIR:
u->SetValue( sky_vec.x, sky_vec.y, sky_vec.z ); u->SetValue( sky_vec.x, sky_vec.y, sky_vec.z );
break; break;
case UT_LIGHTDIFFUSE: case UT_LIGHTDIFFUSE:
u->SetValue( sky_color.x, sky_color.y, sky_color.z ); u->SetValue( sky_color.x, sky_color.y, sky_color.z );
break; break;
case UT_VIEWORIGIN: case UT_VIEWORIGIN:
u->SetValue( GetVieworg().x, GetVieworg().y, GetVieworg().z ); u->SetValue( GetVieworg().x, GetVieworg().y, GetVieworg().z );
break; break;
case UT_FOGPARAMS: case UT_FOGPARAMS:
u->SetValue( tr.fogColor[0], tr.fogColor[1], tr.fogColor[2], tr.fogDensity * 0.5f ); u->SetValue( tr.fogColor[0], tr.fogColor[1], tr.fogColor[2], tr.fogDensity * 0.5f );
break; break;
case UT_ZFAR: case UT_ZFAR:
u->SetValue( RI->view.farClip ); u->SetValue( RI->view.farClip );
break; break;
default: default:
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name ); ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
break; break;
} }
} }
GL_DrawSkySide( skyside ); GL_DrawSkySide( skyside );
} }
/* /*
============== ==============
R_DrawSkybox R_DrawSkybox
============== ==============
*/ */
void R_DrawSkyBox( void ) void R_DrawSkyBox( void )
{ {
bool drawSun = true; bool drawSun = true;
float fogDenstity = tr.fogDensity; float fogDenstity = tr.fogDensity;
word hSkyShader = 0; word hSkyShader = 0;
int i; int i;
if( !FBitSet( RI->view.flags, RF_SKYVISIBLE )) if( !FBitSet( RI->view.flags, RF_SKYVISIBLE ))
return; return;
GL_DepthRange( 0.9f, 1.0f ); GL_DepthRange( 0.9f, 1.0f );
GL_DepthMask( GL_FALSE ); GL_DepthMask( GL_FALSE );
GL_Blend( GL_FALSE ); GL_Blend( GL_FALSE );
GL_AlphaTest( GL_FALSE ); GL_AlphaTest( GL_FALSE );
// clipplane cut the sky if drawing through mirror. Disable it // clipplane cut the sky if drawing through mirror. Disable it
GL_ClipPlane( false ); GL_ClipPlane( false );
int type = tr.sun_light_enabled ? 1 : 0; int type = tr.sun_light_enabled ? 1 : 0;
if( FBitSet( RI->params, RP_SKYVIEW ) || ( FBitSet( RI->params, RP_WATERPASS ) && CVAR_TO_BOOL( cv_specular ))) if( FBitSet( RI->params, RP_SKYVIEW ) || ( FBitSet( RI->params, RP_WATERPASS ) && CVAR_TO_BOOL( cv_specular )))
drawSun = false; drawSun = false;
// disable sky fogging while underwater // disable sky fogging while underwater
if( tr.waterlevel >= 3 || FBitSet( RI->params, RP_SKYVIEW )) if( tr.waterlevel >= 3 || FBitSet( RI->params, RP_SKYVIEW ))
fogDenstity = 0.0f; fogDenstity = 0.0f;
// make sure what light_environment is present // make sure what light_environment is present
if( tr.sky_normal != g_vecZero && drawSun ) if( tr.sky_normal != g_vecZero && drawSun )
{ {
if( FBitSet( RI->params, RP_DEFERREDSCENE )) if( FBitSet( RI->params, RP_DEFERREDSCENE ))
hSkyShader = tr.defSceneSky; hSkyShader = tr.defSceneSky;
else if( FBitSet( RI->params, RP_DEFERREDLIGHT )) else if( FBitSet( RI->params, RP_DEFERREDLIGHT ))
hSkyShader = tr.defLightSky; hSkyShader = tr.defLightSky;
else hSkyShader = tr.skyboxEnv[type]; else hSkyShader = tr.skyboxEnv[type];
} }
for( i = 0; i < 6; i++ ) for( i = 0; i < 6; i++ )
{ {
if( RI->view.skyMins[0][i] >= RI->view.skyMaxs[0][i] || RI->view.skyMins[1][i] >= RI->view.skyMaxs[1][i] ) if( RI->view.skyMins[0][i] >= RI->view.skyMaxs[0][i] || RI->view.skyMins[1][i] >= RI->view.skyMaxs[1][i] )
continue; continue;
GL_DrawSkySide( hSkyShader, i ); GL_DrawSkySide( hSkyShader, i );
} }
GL_ClipPlane( true ); GL_ClipPlane( true );
GL_DepthMask( GL_TRUE ); GL_DepthMask( GL_TRUE );
// back to normal depth range // back to normal depth range
GL_DepthRange( gldepthmin, gldepthmax ); GL_DepthRange( gldepthmin, gldepthmax );
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,112 +1,112 @@
/* /*
gl_sprite.h - sprite model rendering gl_sprite.h - sprite model rendering
Copyright (C) 2011 Uncle Mike Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_SPRITE_H #ifndef GL_SPRITE_H
#define GL_SPRITE_H #define GL_SPRITE_H
#include "sprite.h" #include "sprite.h"
#define GLOW_NUM_TRACES 5 #define GLOW_NUM_TRACES 5
#define GLOW_INTERP_SPEED 2.0f // time to fade glows #define GLOW_INTERP_SPEED 2.0f // time to fade glows
/* /*
==================== ====================
CSpriteModelRenderer CSpriteModelRenderer
==================== ====================
*/ */
class CSpriteModelRenderer class CSpriteModelRenderer
{ {
public: public:
// Construction/Destruction // Construction/Destruction
CSpriteModelRenderer( void ); CSpriteModelRenderer( void );
virtual ~CSpriteModelRenderer( void ); virtual ~CSpriteModelRenderer( void );
// Initialization // Initialization
virtual void Init( void ); virtual void Init( void );
private: private:
// Get Sprite description for frame // Get Sprite description for frame
virtual mspriteframe_t *GetSpriteFrame( int frame, float yaw ); virtual mspriteframe_t *GetSpriteFrame( int frame, float yaw );
virtual void SpriteComputeOrigin( cl_entity_t *e ); virtual void SpriteComputeOrigin( cl_entity_t *e );
virtual void SpriteComputeBBox( cl_entity_t *e, Vector bbox[8] ); virtual void SpriteComputeBBox( cl_entity_t *e, Vector bbox[8] );
virtual bool CullSpriteModel( void ); virtual bool CullSpriteModel( void );
virtual float GlowSightDistance( void ); virtual float GlowSightDistance( void );
virtual float SpriteGlowBlend( int rendermode, int renderfx, int alpha, float &scale ); virtual float SpriteGlowBlend( int rendermode, int renderfx, int alpha, float &scale );
virtual int SpriteOccluded( int &alpha, float &pscale ); virtual int SpriteOccluded( int &alpha, float &pscale );
virtual void DrawSpriteQuad( mspriteframe_t *frame, const Vector &org, const Vector &right, const Vector &up, float scale ); virtual void DrawSpriteQuad( mspriteframe_t *frame, const Vector &org, const Vector &right, const Vector &up, float scale );
virtual int SpriteHasLightmap( int texFormat ); virtual int SpriteHasLightmap( int texFormat );
inline void *Mod_Extradata( model_t *mod ) inline void *Mod_Extradata( model_t *mod )
{ {
if( mod && mod->type == mod_sprite ) if( mod && mod->type == mod_sprite )
return mod->cache.data; return mod->cache.data;
return NULL; return NULL;
} }
Vector sprite_origin; Vector sprite_origin;
Vector sprite_absmin, sprite_absmax; Vector sprite_absmin, sprite_absmax;
// Client clock // Client clock
double m_clTime; double m_clTime;
// Old Client clock // Old Client clock
double m_clOldTime; double m_clOldTime;
// Current render frame # // Current render frame #
int m_nFrameCount; int m_nFrameCount;
// Cvars that sprite model code needs to reference // Cvars that sprite model code needs to reference
cvar_t *m_pCvarLerping; // Use lerping for animation? cvar_t *m_pCvarLerping; // Use lerping for animation?
cvar_t *m_pCvarLighting; // lighting mode cvar_t *m_pCvarLighting; // lighting mode
// The entity which we are currently rendering. // The entity which we are currently rendering.
cl_entity_t *m_pCurrentEntity; cl_entity_t *m_pCurrentEntity;
// The model for the entity being rendered // The model for the entity being rendered
model_t *m_pRenderModel; model_t *m_pRenderModel;
// Current model rendermode // Current model rendermode
int m_iRenderMode; int m_iRenderMode;
// Pointer to header block for sprite model data // Pointer to header block for sprite model data
msprite_t *m_pSpriteHeader; msprite_t *m_pSpriteHeader;
// engine stuff (backend) // engine stuff (backend)
public: public:
void AddSpriteModelToDrawList( cl_entity_t *e, bool update = false ); void AddSpriteModelToDrawList( cl_entity_t *e, bool update = false );
// Draw generic spritemodel // Draw generic spritemodel
mspriteframe_t *GetSpriteFrame( const model_t *m_pSpriteModel, int frame ); mspriteframe_t *GetSpriteFrame( const model_t *m_pSpriteModel, int frame );
}; };
extern CSpriteModelRenderer g_SpriteRenderer; extern CSpriteModelRenderer g_SpriteRenderer;
inline mspriteframe_t *R_GetSpriteFrame( const model_t *m_pSpriteModel, int frame ) inline mspriteframe_t *R_GetSpriteFrame( const model_t *m_pSpriteModel, int frame )
{ {
return g_SpriteRenderer.GetSpriteFrame( m_pSpriteModel, frame ); return g_SpriteRenderer.GetSpriteFrame( m_pSpriteModel, frame );
} }
inline void R_AddSpriteToDrawList( cl_entity_t *e, bool update = false ) inline void R_AddSpriteToDrawList( cl_entity_t *e, bool update = false )
{ {
g_SpriteRenderer.AddSpriteModelToDrawList( e, update ); g_SpriteRenderer.AddSpriteModelToDrawList( e, update );
} }
#endif// GL_SPRITE_H #endif// GL_SPRITE_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +1,59 @@
/* /*
gl_studiodecal.h - studio decal rendering gl_studiodecal.h - studio decal rendering
Copyright (C) 2018 Uncle Mike Copyright (C) 2018 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_STUDIODECAL_H #ifndef GL_STUDIODECAL_H
#define GL_STUDIODECAL_H #define GL_STUDIODECAL_H
typedef enum typedef enum
{ {
DECAL_CLIP_MINUSU = 0x1, DECAL_CLIP_MINUSU = 0x1,
DECAL_CLIP_MINUSV = 0x2, DECAL_CLIP_MINUSV = 0x2,
DECAL_CLIP_PLUSU = 0x4, DECAL_CLIP_PLUSU = 0x4,
DECAL_CLIP_PLUSV = 0x8, DECAL_CLIP_PLUSV = 0x8,
}; };
typedef struct typedef struct
{ {
Vector2D m_UV; Vector2D m_UV;
word m_VertexIndex; // index into the DecalVertex_t list word m_VertexIndex; // index into the DecalVertex_t list
bool m_FrontFacing; bool m_FrontFacing;
bool m_InValidArea; bool m_InValidArea;
} DecalVertexInfo_t; } DecalVertexInfo_t;
// decal entry // decal entry
typedef struct studiodecal_s typedef struct studiodecal_s
{ {
// this part is goes to savelist // this part is goes to savelist
byte flags; byte flags;
Vector normal; Vector normal;
Vector position; Vector position;
word modelpose; // m_pModelInstance->pose_stamps[modelpose] word modelpose; // m_pModelInstance->pose_stamps[modelpose]
const DecalGroupEntry *texinfo; // pointer to decal material const DecalGroupEntry *texinfo; // pointer to decal material
// history // history
int depth; // equal for all the decal fragments (used to remove all frgaments) int depth; // equal for all the decal fragments (used to remove all frgaments)
// VBO cache // VBO cache
vbomesh_t mesh; // decal private mesh vbomesh_t mesh; // decal private mesh
// shader cache // shader cache
vbomesh_t* modelmesh; // pointer to studio mesh who owned decal vbomesh_t* modelmesh; // pointer to studio mesh who owned decal
shader_t forwardScene; shader_t forwardScene;
shader_t forwardLightSpot; shader_t forwardLightSpot;
shader_t forwardLightOmni; shader_t forwardLightOmni;
shader_t forwardLightProj; shader_t forwardLightProj;
} studiodecal_t; } studiodecal_t;
#endif//GL_STUDIODECAL_H #endif//GL_STUDIODECAL_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,352 +1,352 @@
/* /*
gl_mirror.cpp - draw reflected surfaces gl_mirror.cpp - draw reflected surfaces
Copyright (C) 2011 Uncle Mike Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "gl_local.h" #include "gl_local.h"
#include "gl_world.h" #include "gl_world.h"
#include "mathlib.h" #include "mathlib.h"
#include <stringlib.h> #include <stringlib.h>
#include "gl_occlusion.h" #include "gl_occlusion.h"
#define MIRROR_PLANE_EPSILON 0.1f #define MIRROR_PLANE_EPSILON 0.1f
/* /*
============================================================= =============================================================
MIRROR RENDERING MIRROR RENDERING
============================================================= =============================================================
*/ */
/* /*
================ ================
R_SetupMirrorView R_SetupMirrorView
Prepare view for mirroring Prepare view for mirroring
================ ================
*/ */
int R_SetupMirrorView( msurface_t *surf, ref_viewpass_t *rvp ) int R_SetupMirrorView( msurface_t *surf, ref_viewpass_t *rvp )
{ {
cl_entity_t *ent = surf->info->parent; cl_entity_t *ent = surf->info->parent;
matrix3x3 matAngles; matrix3x3 matAngles;
mplane_t plane; mplane_t plane;
gl_state_t *glm; gl_state_t *glm;
float d; float d;
// setup mirror plane // setup mirror plane
if( FBitSet( surf->flags, SURF_PLANEBACK )) if( FBitSet( surf->flags, SURF_PLANEBACK ))
SetPlane( &plane, -surf->plane->normal, -surf->plane->dist ); SetPlane( &plane, -surf->plane->normal, -surf->plane->dist );
else SetPlane( &plane, surf->plane->normal, surf->plane->dist ); else SetPlane( &plane, surf->plane->normal, surf->plane->dist );
glm = GL_GetCache( ent->hCachedMatrix ); glm = GL_GetCache( ent->hCachedMatrix );
if( ent->hCachedMatrix != WORLD_MATRIX ) if( ent->hCachedMatrix != WORLD_MATRIX )
glm->transform.TransformPositivePlane( plane, plane ); glm->transform.TransformPositivePlane( plane, plane );
// reflect view by mirror plane // reflect view by mirror plane
d = -2.0f * ( DotProduct( GetVieworg(), plane.normal ) - plane.dist ); d = -2.0f * ( DotProduct( GetVieworg(), plane.normal ) - plane.dist );
Vector origin = GetVieworg() + d * plane.normal; Vector origin = GetVieworg() + d * plane.normal;
d = -2.0f * DotProduct( GetVForward(), plane.normal ); d = -2.0f * DotProduct( GetVForward(), plane.normal );
Vector forward = ( GetVForward() + d * plane.normal ).Normalize(); Vector forward = ( GetVForward() + d * plane.normal ).Normalize();
d = -2.0f * DotProduct( GetVRight(), plane.normal ); d = -2.0f * DotProduct( GetVRight(), plane.normal );
Vector right = ( GetVRight() + d * plane.normal ).Normalize(); Vector right = ( GetVRight() + d * plane.normal ).Normalize();
d = -2.0f * DotProduct( GetVUp(), plane.normal ); d = -2.0f * DotProduct( GetVUp(), plane.normal );
Vector up = ( GetVUp() + d * plane.normal ).Normalize(); Vector up = ( GetVUp() + d * plane.normal ).Normalize();
// compute mirror angles // compute mirror angles
matAngles.SetForward( forward ); matAngles.SetForward( forward );
matAngles.SetRight( right ); matAngles.SetRight( right );
matAngles.SetUp( up ); matAngles.SetUp( up );
Vector angles = matAngles.GetAngles(); Vector angles = matAngles.GetAngles();
plane.dist += ON_EPSILON; // to prevent z-fighting with reflective water plane.dist += ON_EPSILON; // to prevent z-fighting with reflective water
rvp->flags = RP_MIRRORVIEW|RP_CLIPPLANE|RP_MERGE_PVS; rvp->flags = RP_MIRRORVIEW|RP_CLIPPLANE|RP_MERGE_PVS;
RI->view.frustum.SetPlane( FRUSTUM_NEAR, plane.normal, plane.dist ); RI->view.frustum.SetPlane( FRUSTUM_NEAR, plane.normal, plane.dist );
RI->clipPlane = plane; RI->clipPlane = plane;
rvp->viewangles[0] = anglemod( angles[0] ); rvp->viewangles[0] = anglemod( angles[0] );
rvp->viewangles[1] = anglemod( angles[1] ); rvp->viewangles[1] = anglemod( angles[1] );
rvp->viewangles[2] = anglemod( angles[2] ); rvp->viewangles[2] = anglemod( angles[2] );
rvp->vieworigin = origin; rvp->vieworigin = origin;
rvp->fov_x = RI->view.fov_x; rvp->fov_x = RI->view.fov_x;
rvp->fov_y = RI->view.fov_y; rvp->fov_y = RI->view.fov_y;
// put pvsorigin before the mirror plane to avoid get recursion with himself // put pvsorigin before the mirror plane to avoid get recursion with himself
if( ent == GET_ENTITY( 0 )) origin = surf->info->origin + (1.0f * plane.normal); if( ent == GET_ENTITY( 0 )) origin = surf->info->origin + (1.0f * plane.normal);
else origin = glm->transform.VectorTransform( surf->info->origin ) + (1.0f * plane.normal); else origin = glm->transform.VectorTransform( surf->info->origin ) + (1.0f * plane.normal);
material_t *mat = R_TextureAnimation( surf )->material; material_t *mat = R_TextureAnimation( surf )->material;
RI->view.pvspoint = origin; RI->view.pvspoint = origin;
rvp->viewport[0] = rvp->viewport[1] = 0; rvp->viewport[0] = rvp->viewport[1] = 0;
if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE )) if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE ))
{ {
rvp->viewport[2] = 192; rvp->viewport[2] = 192;
rvp->viewport[3] = 192; rvp->viewport[3] = 192;
} }
else else
{ {
rvp->viewport[2] = RI->view.port[2]; rvp->viewport[2] = RI->view.port[2];
rvp->viewport[3] = RI->view.port[3]; rvp->viewport[3] = RI->view.port[3];
} }
if( GL_Support( R_ARB_TEXTURE_NPOT_EXT )) if( GL_Support( R_ARB_TEXTURE_NPOT_EXT ))
{ {
// allow screen size // allow screen size
// rvp->viewport[2] = bound( 96, rvp->viewport[2], 1024 ); // rvp->viewport[2] = bound( 96, rvp->viewport[2], 1024 );
// rvp->viewport[3] = bound( 72, rvp->viewport[3], 768 ); // rvp->viewport[3] = bound( 72, rvp->viewport[3], 768 );
} }
else else
{ {
rvp->viewport[2] = NearestPOW( rvp->viewport[2], true ); rvp->viewport[2] = NearestPOW( rvp->viewport[2], true );
rvp->viewport[3] = NearestPOW( rvp->viewport[3], true ); rvp->viewport[3] = NearestPOW( rvp->viewport[3], true );
// rvp->viewport[2] = bound( 128, rvp->viewport[2], 1024 ); // rvp->viewport[2] = bound( 128, rvp->viewport[2], 1024 );
// rvp->viewport[3] = bound( 64, rvp->viewport[3], 512 ); // rvp->viewport[3] = bound( 64, rvp->viewport[3], 512 );
} }
if( FBitSet( mat->flags, BRUSH_LIQUID )) if( FBitSet( mat->flags, BRUSH_LIQUID ))
SetBits( rvp->flags, RP_WATERPASS ); SetBits( rvp->flags, RP_WATERPASS );
else if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE )) else if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE ))
SetBits( rvp->flags, RP_NOSHADOWS|RP_WATERPASS|RP_NOGRASS ); // don't draw grass from puddles SetBits( rvp->flags, RP_NOSHADOWS|RP_WATERPASS|RP_NOGRASS ); // don't draw grass from puddles
return TF_SCREEN; return TF_SCREEN;
} }
/* /*
================ ================
R_AllocateSubviewTexture R_AllocateSubviewTexture
Allocate the screen texture and make copy Allocate the screen texture and make copy
================ ================
*/ */
int R_AllocateSubviewTexture( int viewport[4], int texFlags ) int R_AllocateSubviewTexture( int viewport[4], int texFlags )
{ {
int i; int i;
// first, search for available mirror texture // first, search for available mirror texture
for( i = 0; i < tr.num_subview_used; i++ ) for( i = 0; i < tr.num_subview_used; i++ )
{ {
if( tr.subviewTextures[i].texframe == tr.realframecount ) if( tr.subviewTextures[i].texframe == tr.realframecount )
continue; // already used for this frame continue; // already used for this frame
if( viewport[2] != RENDER_GET_PARM( PARM_TEX_WIDTH, tr.subviewTextures[i].texturenum )) if( viewport[2] != RENDER_GET_PARM( PARM_TEX_WIDTH, tr.subviewTextures[i].texturenum ))
continue; // width mismatched continue; // width mismatched
if( viewport[3] != RENDER_GET_PARM( PARM_TEX_HEIGHT, tr.subviewTextures[i].texturenum )) if( viewport[3] != RENDER_GET_PARM( PARM_TEX_HEIGHT, tr.subviewTextures[i].texturenum ))
continue; // height mismatched continue; // height mismatched
// screens don't want textures with 'clamp' modifier // screens don't want textures with 'clamp' modifier
if( FBitSet( texFlags, TF_CLAMP ) != FBitSet( RENDER_GET_PARM( PARM_TEX_FLAGS, tr.subviewTextures[i].texturenum ), TF_CLAMP )) if( FBitSet( texFlags, TF_CLAMP ) != FBitSet( RENDER_GET_PARM( PARM_TEX_FLAGS, tr.subviewTextures[i].texturenum ), TF_CLAMP ))
continue; // mismatch texture flags continue; // mismatch texture flags
// found a valid spot // found a valid spot
tr.subviewTextures[i].texframe = tr.realframecount; // now used tr.subviewTextures[i].texframe = tr.realframecount; // now used
break; break;
} }
if( i == tr.num_subview_used ) if( i == tr.num_subview_used )
{ {
if( i == MAX_SUBVIEW_TEXTURES ) if( i == MAX_SUBVIEW_TEXTURES )
{ {
ALERT( at_error, "R_AllocSubviewTexture: texture limit exceeded (per frame)!\n" ); ALERT( at_error, "R_AllocSubviewTexture: texture limit exceeded (per frame)!\n" );
return 0; // disable return 0; // disable
} }
// create new mirror texture // create new mirror texture
tr.subviewTextures[i].texturenum = CREATE_TEXTURE( va( "*subview%i", i ), viewport[2], viewport[3], NULL, texFlags ); tr.subviewTextures[i].texturenum = CREATE_TEXTURE( va( "*subview%i", i ), viewport[2], viewport[3], NULL, texFlags );
tr.subviewTextures[i].texframe = tr.realframecount; // now used tr.subviewTextures[i].texframe = tr.realframecount; // now used
if( GL_Support( R_FRAMEBUFFER_OBJECT )) if( GL_Support( R_FRAMEBUFFER_OBJECT ))
tr.subviewTextures[i].framebuffer = R_AllocFrameBuffer( viewport ); tr.subviewTextures[i].framebuffer = R_AllocFrameBuffer( viewport );
tr.num_subview_used++; // allocate new one tr.num_subview_used++; // allocate new one
} }
if( GL_Support( R_FRAMEBUFFER_OBJECT )) if( GL_Support( R_FRAMEBUFFER_OBJECT ))
{ {
GL_BindFrameBuffer( tr.subviewTextures[i].framebuffer, tr.subviewTextures[i].texturenum ); GL_BindFrameBuffer( tr.subviewTextures[i].framebuffer, tr.subviewTextures[i].texturenum );
} }
else else
{ {
GL_BindTexture( GL_TEXTURE0, tr.subviewTextures[i].texturenum ); GL_BindTexture( GL_TEXTURE0, tr.subviewTextures[i].texturenum );
pglCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, viewport[0], viewport[1], viewport[2], viewport[3], 0 ); pglCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, viewport[0], viewport[1], viewport[2], viewport[3], 0 );
} }
return (i+1); return (i+1);
} }
bool R_CheckMirrorClone( msurface_t *surf, msurface_t *check ) bool R_CheckMirrorClone( msurface_t *surf, msurface_t *check )
{ {
if( !FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE )) if( !FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
return false; return false;
if( !FBitSet( check->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE )) if( !FBitSet( check->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
return false; return false;
if( !check->info->subtexture[glState.stack_position-1] ) if( !check->info->subtexture[glState.stack_position-1] )
return false; return false;
if( surf->info->parent != check->info->parent ) if( surf->info->parent != check->info->parent )
return false; return false;
if( FBitSet( surf->flags, SURF_PLANEBACK ) != FBitSet( check->flags, SURF_PLANEBACK )) if( FBitSet( surf->flags, SURF_PLANEBACK ) != FBitSet( check->flags, SURF_PLANEBACK ))
return false; return false;
if( surf->plane->normal != check->plane->normal ) if( surf->plane->normal != check->plane->normal )
return false; return false;
if( Q_sign( surf->plane->dist ) != Q_sign( check->plane->dist )) if( Q_sign( surf->plane->dist ) != Q_sign( check->plane->dist ))
return false; return false;
if( fabs( surf->plane->dist - check->plane->dist ) > MIRROR_PLANE_EPSILON ) if( fabs( surf->plane->dist - check->plane->dist ) > MIRROR_PLANE_EPSILON )
return false; return false;
// just reuse the handle // just reuse the handle
surf->info->subtexture[glState.stack_position-1] = check->info->subtexture[glState.stack_position-1]; surf->info->subtexture[glState.stack_position-1] = check->info->subtexture[glState.stack_position-1];
return true; return true;
} }
bool R_CanSkipPass( int end, msurface_t *surf, ref_instance_t *prevRI ) bool R_CanSkipPass( int end, msurface_t *surf, ref_instance_t *prevRI )
{ {
// IMPORTANT: limit the recursion depth // IMPORTANT: limit the recursion depth
if( surf == prevRI->reject_face ) if( surf == prevRI->reject_face )
return true; return true;
for( int i = 0; i < end; i++ ) for( int i = 0; i < end; i++ )
{ {
if( R_CheckMirrorClone( surf, prevRI->frame.subview_faces[i] )) if( R_CheckMirrorClone( surf, prevRI->frame.subview_faces[i] ))
return true; return true;
} }
// occluded by query // occluded by query
if( FBitSet( surf->flags, SURF_OCCLUDED )) if( FBitSet( surf->flags, SURF_OCCLUDED ))
{ {
// don't use me // don't use me
surf->info->subtexture[glState.stack_position-1] = 0; surf->info->subtexture[glState.stack_position-1] = 0;
return true; return true;
} }
return false; return false;
} }
/* /*
================ ================
R_CheckOutside R_CheckOutside
check if main view is outside level check if main view is outside level
================ ================
*/ */
bool R_CheckOutside( void ) bool R_CheckOutside( void )
{ {
// only main view should be tested // only main view should be tested
if( !RP_NORMALPASS( )) if( !RP_NORMALPASS( ))
return false; return false;
mleaf_t *leaf = Mod_PointInLeaf( RI->view.origin, worldmodel->nodes ); mleaf_t *leaf = Mod_PointInLeaf( RI->view.origin, worldmodel->nodes );
if( RP_OUTSIDE( leaf )) if( RP_OUTSIDE( leaf ))
return true; return true;
return false; return false;
} }
/* /*
================ ================
R_RenderSubview R_RenderSubview
Draw scene from another points Draw scene from another points
e.g. for planar reflection, e.g. for planar reflection,
remote cameras etc remote cameras etc
================ ================
*/ */
void R_RenderSubview( void ) void R_RenderSubview( void )
{ {
ref_instance_t *prevRI; ref_instance_t *prevRI;
unsigned int oldFBO; unsigned int oldFBO;
ref_viewpass_t rvp; ref_viewpass_t rvp;
// player is outside world. Don't draw subview for speedup reasons // player is outside world. Don't draw subview for speedup reasons
if( R_CheckOutside( )) if( R_CheckOutside( ))
return; return;
if( glState.stack_position > (unsigned int)r_recursion_depth->value ) if( glState.stack_position > (unsigned int)r_recursion_depth->value )
return; // too deep... return; // too deep...
if( FBitSet( RI->params, RP_DRAW_OVERVIEW )) if( FBitSet( RI->params, RP_DRAW_OVERVIEW ))
return; return;
if( !RI->frame.num_subview_faces ) if( !RI->frame.num_subview_faces )
return; // nothing to render return; // nothing to render
R_PushRefState(); // make refinst backup R_PushRefState(); // make refinst backup
prevRI = R_GetPrevInstance(); prevRI = R_GetPrevInstance();
// draw the subviews through the list // draw the subviews through the list
for( int i = 0; i < prevRI->frame.num_subview_faces; i++ ) for( int i = 0; i < prevRI->frame.num_subview_faces; i++ )
{ {
msurface_t *surf = prevRI->frame.subview_faces[i]; msurface_t *surf = prevRI->frame.subview_faces[i];
cl_entity_t *e = RI->currententity = surf->info->parent; cl_entity_t *e = RI->currententity = surf->info->parent;
mextrasurf_t *es = surf->info; mextrasurf_t *es = surf->info;
int texFlags = 0, subview = 0; int texFlags = 0, subview = 0;
RI->currentmodel = e->model; RI->currentmodel = e->model;
if( R_CanSkipPass( i, surf, prevRI )) if( R_CanSkipPass( i, surf, prevRI ))
continue; continue;
ASSERT( RI->currententity != NULL ); ASSERT( RI->currententity != NULL );
ASSERT( RI->currentmodel != NULL ); ASSERT( RI->currentmodel != NULL );
// NOTE: we can do additionaly culling here by PVS // NOTE: we can do additionaly culling here by PVS
if( !e || e->curstate.messagenum != r_currentMessageNum ) if( !e || e->curstate.messagenum != r_currentMessageNum )
continue; // bad camera, ignore continue; // bad camera, ignore
// setup view apropriate by type // setup view apropriate by type
if( FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE )) if( FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
{ {
texFlags = R_SetupMirrorView( surf, &rvp ); texFlags = R_SetupMirrorView( surf, &rvp );
r_stats.c_subview_passes++; r_stats.c_subview_passes++;
} }
else continue; // ??? else continue; // ???
oldFBO = glState.frameBuffer; oldFBO = glState.frameBuffer;
if( GL_Support( R_FRAMEBUFFER_OBJECT )) if( GL_Support( R_FRAMEBUFFER_OBJECT ))
{ {
if(( subview = R_AllocateSubviewTexture( rvp.viewport, texFlags )) == 0 ) if(( subview = R_AllocateSubviewTexture( rvp.viewport, texFlags )) == 0 )
continue; continue;
} }
// reset the subinfo // reset the subinfo
surf->info->subtexture[glState.stack_position-1] = 0; surf->info->subtexture[glState.stack_position-1] = 0;
RI->reject_face = surf; RI->reject_face = surf;
R_RenderScene( &rvp, rvp.flags ); R_RenderScene( &rvp, rvp.flags );
RI->reject_face = NULL; RI->reject_face = NULL;
if( !GL_Support( R_FRAMEBUFFER_OBJECT )) if( !GL_Support( R_FRAMEBUFFER_OBJECT ))
subview = R_AllocateSubviewTexture( rvp.viewport, texFlags ); subview = R_AllocateSubviewTexture( rvp.viewport, texFlags );
ASSERT( subview > 0 && subview < MAX_SUBVIEW_TEXTURES ); ASSERT( subview > 0 && subview < MAX_SUBVIEW_TEXTURES );
surf->info->subtexture[glState.stack_position-1] = subview; // now it's valid surf->info->subtexture[glState.stack_position-1] = subview; // now it's valid
tr.subviewTextures[subview-1].matrix = RI->view.worldProjectionMatrix; tr.subviewTextures[subview-1].matrix = RI->view.worldProjectionMatrix;
GL_BindFBO( oldFBO ); GL_BindFBO( oldFBO );
R_ResetRefState(); R_ResetRefState();
} }
R_PopRefState(); // restore ref instance R_PopRefState(); // restore ref instance
} }

View File

@ -1,183 +1,183 @@
/* /*
gl_world.h - local world data for rendering gl_world.h - local world data for rendering
this code written for Paranoia 2: Savior modification this code written for Paranoia 2: Savior modification
Copyright (C) 2016 Uncle Mike Copyright (C) 2016 Uncle Mike
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef GL_WORLD_H #ifndef GL_WORLD_H
#define GL_WORLD_H #define GL_WORLD_H
#include "cubemap.h" #include "cubemap.h"
#include "vertex_fmt.h" #include "vertex_fmt.h"
// world features // world features
#define WORLD_HAS_MOVIES BIT( 0 ) #define WORLD_HAS_MOVIES BIT( 0 )
#define WORLD_HAS_GRASS BIT( 2 ) #define WORLD_HAS_GRASS BIT( 2 )
#define WORLD_HAS_DELUXEMAP BIT( 3 ) #define WORLD_HAS_DELUXEMAP BIT( 3 )
#define WORLD_HAS_SKYBOX BIT( 4 ) #define WORLD_HAS_SKYBOX BIT( 4 )
#define WORLD_WATERALPHA BIT( 5 ) #define WORLD_WATERALPHA BIT( 5 )
#define MAX_MAP_ELEMS MAX_MAP_VERTS * 5 // should be enough #define MAX_MAP_ELEMS MAX_MAP_VERTS * 5 // should be enough
#define SHADOW_ZBUF_RES 8 // 6 * 8 * 8 * 2 * 4 = 3k bytes per light #define SHADOW_ZBUF_RES 8 // 6 * 8 * 8 * 2 * 4 = 3k bytes per light
// rebuilding cubemap states // rebuilding cubemap states
#define CMREBUILD_INACTIVE 0 #define CMREBUILD_INACTIVE 0
#define CMREBUILD_CHECKING 1 #define CMREBUILD_CHECKING 1
#define CMREBUILD_WAITING 2 #define CMREBUILD_WAITING 2
typedef struct bvert_s typedef struct bvert_s
{ {
Vector vertex; // position Vector vertex; // position
Vector tangent; // tangent Vector tangent; // tangent
Vector binormal; // binormal Vector binormal; // binormal
Vector normal; // normal Vector normal; // normal
float stcoord0[4]; // ST texture coords float stcoord0[4]; // ST texture coords
float lmcoord0[4]; // LM texture coords for styles 0-1 float lmcoord0[4]; // LM texture coords for styles 0-1
float lmcoord1[4]; // LM texture coords for styles 2-3 float lmcoord1[4]; // LM texture coords for styles 2-3
byte styles[MAXLIGHTMAPS]; // light styles byte styles[MAXLIGHTMAPS]; // light styles
byte lights0[4]; // packed light numbers byte lights0[4]; // packed light numbers
byte lights1[4]; // packed light numbers byte lights1[4]; // packed light numbers
} bvert_t; } bvert_t;
typedef struct typedef struct
{ {
dlightcube_t cube; dlightcube_t cube;
vec3_t origin; vec3_t origin;
mleaf_t *leaf; // ambient linked into this leaf mleaf_t *leaf; // ambient linked into this leaf
} mlightprobe_t; } mlightprobe_t;
typedef struct mworldlight_s typedef struct mworldlight_s
{ {
emittype_t emittype; emittype_t emittype;
int style; int style;
byte *pvs; // accumulated domain of the light byte *pvs; // accumulated domain of the light
vec3_t origin; // light abs origin vec3_t origin; // light abs origin
vec3_t intensity; // RGB vec3_t intensity; // RGB
vec3_t normal; // for surfaces and spotlights vec3_t normal; // for surfaces and spotlights
float stopdot; // for spotlights float stopdot; // for spotlights
float stopdot2; // for spotlights float stopdot2; // for spotlights
float fade; // falloff scaling for linear and inverse square falloff 1.0 = normal, 0.5 = farther, 2.0 = shorter float fade; // falloff scaling for linear and inverse square falloff 1.0 = normal, 0.5 = farther, 2.0 = shorter
float radius; // light radius float radius; // light radius
mleaf_t *leaf; // light linked into this leaf mleaf_t *leaf; // light linked into this leaf
byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square
msurface_t *surface; // surf pointer for emit_surface msurface_t *surface; // surf pointer for emit_surface
int lightnum; // important stuff! int lightnum; // important stuff!
int modelnum; // unused int modelnum; // unused
unsigned short shadow_x; // offset by X in atlas unsigned short shadow_x; // offset by X in atlas
unsigned short shadow_y; // offset by Y in atlas unsigned short shadow_y; // offset by Y in atlas
unsigned short shadow_w; // 0 is uninitialized unsigned short shadow_w; // 0 is uninitialized
unsigned short shadow_h; // 0 is uninitialized unsigned short shadow_h; // 0 is uninitialized
} mworldlight_t; } mworldlight_t;
// leaf extradata // leaf extradata
typedef struct mextraleaf_s typedef struct mextraleaf_s
{ {
// leaf specific // leaf specific
vec3_t mins, maxs; // leaf size that updated with grass bounds vec3_t mins, maxs; // leaf size that updated with grass bounds
mlightprobe_t *ambient_light; mlightprobe_t *ambient_light;
byte num_lightprobes; byte num_lightprobes;
mworldlight_t *direct_lights; mworldlight_t *direct_lights;
int num_directlights; int num_directlights;
} mextraleaf_t; } mextraleaf_t;
struct BmodelInstance_t struct BmodelInstance_t
{ {
cl_entity_t *m_pEntity; cl_entity_t *m_pEntity;
// bounds info // bounds info
Vector bbox[8]; Vector bbox[8];
Vector absmin; Vector absmin;
Vector absmax; Vector absmax;
float radius; float radius;
byte lights[MAXDYNLIGHTS]; byte lights[MAXDYNLIGHTS];
matrix4x4 m_transform; matrix4x4 m_transform;
GLfloat m_gltransform; GLfloat m_gltransform;
}; };
struct LightShadowZBufferSample_t struct LightShadowZBufferSample_t
{ {
float m_flTraceDistance; // how far we traced. 0 = invalid float m_flTraceDistance; // how far we traced. 0 = invalid
float m_flHitDistance; // where we hit float m_flHitDistance; // where we hit
}; };
typedef CCubeMap< LightShadowZBufferSample_t, SHADOW_ZBUF_RES> lightzbuffer_t; typedef CCubeMap< LightShadowZBufferSample_t, SHADOW_ZBUF_RES> lightzbuffer_t;
typedef struct typedef struct
{ {
char name[64]; // to avoid reloading on same char name[64]; // to avoid reloading on same
word features; // world features word features; // world features
int num_visible_models; // visible models int num_visible_models; // visible models
mextraleaf_t *leafs; // [worldmodel->numleafs] mextraleaf_t *leafs; // [worldmodel->numleafs]
int totalleafs; // full leaf counting int totalleafs; // full leaf counting
int numleafs; // [submodels[0].visleafs + 1] int numleafs; // [submodels[0].visleafs + 1]
material_t *materials; // [worldmodel->numtextures] material_t *materials; // [worldmodel->numtextures]
int numleaflights; int numleaflights;
mlightprobe_t *leaflights; mlightprobe_t *leaflights;
int numworldlights; int numworldlights;
mworldlight_t *worldlights; mworldlight_t *worldlights;
dvertnorm_t *surfnormals; // is not NULL here a indexed normals dvertnorm_t *surfnormals; // is not NULL here a indexed normals
dnormal_t *normals; dnormal_t *normals;
int numnormals; int numnormals;
mcubemap_t cubemaps[MAX_MAP_CUBEMAPS]; mcubemap_t cubemaps[MAX_MAP_CUBEMAPS];
mcubemap_t defaultCubemap; mcubemap_t defaultCubemap;
int num_cubemaps; int num_cubemaps;
terrain_t *terrains; terrain_t *terrains;
unsigned int num_terrains; unsigned int num_terrains;
bvert_t *vertexes; bvert_t *vertexes;
int numvertexes; int numvertexes;
dvlightlump_t *vertex_lighting; // used for env_statics dvlightlump_t *vertex_lighting; // used for env_statics
dvlightlump_t *surface_lighting; // used for env_statics dvlightlump_t *surface_lighting; // used for env_statics
byte *vislightdata; byte *vislightdata;
color24 *deluxedata; color24 *deluxedata;
byte *shadowdata; byte *shadowdata;
lightzbuffer_t *shadowzbuffers; lightzbuffer_t *shadowzbuffers;
// single buffer for all the models // single buffer for all the models
uint vertex_buffer_object; uint vertex_buffer_object;
uint vertex_array_object; uint vertex_array_object;
uint cacheSize; uint cacheSize;
unsigned short *sortedfaces; // surfaces sorted through all models unsigned short *sortedfaces; // surfaces sorted through all models
unsigned short numsortedfaces; unsigned short numsortedfaces;
// misc info // misc info
Vector2D orthocenter; // overview stuff Vector2D orthocenter; // overview stuff
Vector2D orthohalf; Vector2D orthohalf;
// cubemap builder internal state // cubemap builder internal state
bool loading_cubemaps; bool loading_cubemaps;
bool build_default_cubemap; bool build_default_cubemap;
int rebuilding_cubemaps; int rebuilding_cubemaps;
int cubemap_build_number; int cubemap_build_number;
} gl_world_t; } gl_world_t;
extern gl_world_t *world; extern gl_world_t *world;
#endif//GL_WORLD_H #endif//GL_WORLD_H

Some files were not shown because too many files have changed in this diff Show More