forked from FWGS/Paranoia2
CRLF to LF
This commit is contained in:
parent
0455f5d6e2
commit
5cc388c45e
246
bspextra.h
246
bspextra.h
|
@ -1,124 +1,124 @@
|
|||
/*
|
||||
bspfile.h - BSP format included q1, hl1 support
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef BSPEXTRAFILE_H
|
||||
#define BSPEXTRAFILE_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
EXTRA BSP INFO
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#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 MAX_MAP_CUBEMAPS 1024
|
||||
#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_WORLDLIGHTS 65535 // including a light surfaces too
|
||||
|
||||
#define LUMP_VERTNORMALS 0 // phong shaded vertex normals
|
||||
#define LUMP_LIGHTVECS 1 // deluxemap data
|
||||
#define LUMP_CUBEMAPS 2 // cubemap description
|
||||
#define LUMP_LANDSCAPES 3 // landscape and lightmap resolution info
|
||||
#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_COLLISION 6 // physics engine collision hull dump
|
||||
#define LUMP_AINODEGRAPH 7 // node graph that stored into the bsp
|
||||
#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
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id; // must be little endian XASH
|
||||
int version;
|
||||
dlump_t lumps[EXTRA_LUMPS];
|
||||
} dextrahdr_t;
|
||||
|
||||
// MODIFIED: int flags -> short flags, short landscape (total struct size not changed!)
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4]; // texmatrix [s/t][xyz offset]
|
||||
int miptex;
|
||||
short flags;
|
||||
short landscape;
|
||||
} dtexinfo_t;
|
||||
|
||||
//============================================================================
|
||||
typedef struct
|
||||
{
|
||||
float normal[3];
|
||||
} dnormal_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short origin[3]; // position of light snapped to the nearest integer
|
||||
short size; // cubemap side size
|
||||
} dcubemap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte color[6][3]; // 6 sides 1x1 (single pixel per side)
|
||||
} dsample_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dsample_t cube;
|
||||
short origin[3];
|
||||
short leafnum; // leaf that contain this sample
|
||||
} dleafambient_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char landname[16]; // name of decsription in mapname_land.txt
|
||||
word texture_step; // default is 16, pixels\luxels ratio
|
||||
word max_extent; // default is 16, subdivision step ((texture_step * max_extent) - texture_step)
|
||||
short groupid; // to determine equal landscapes from various groups
|
||||
} dlandscape_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
emit_surface,
|
||||
emit_point,
|
||||
emit_spotlight,
|
||||
emit_skylight
|
||||
} emittype_t;
|
||||
|
||||
#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.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte emittype;
|
||||
byte style;
|
||||
byte flags; // will be set in ComputeLeafAmbientLighting
|
||||
short origin[3]; // light abs origin
|
||||
float intensity[3]; // RGB
|
||||
float normal[3]; // for surfaces and spotlights
|
||||
float stopdot; // 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 radius; // light radius
|
||||
short leafnum; // light linked into this leaf
|
||||
byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square (arghrad compat)
|
||||
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
|
||||
} dworldlight_t;
|
||||
|
||||
/*
|
||||
bspfile.h - BSP format included q1, hl1 support
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef BSPEXTRAFILE_H
|
||||
#define BSPEXTRAFILE_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
EXTRA BSP INFO
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#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 MAX_MAP_CUBEMAPS 1024
|
||||
#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_WORLDLIGHTS 65535 // including a light surfaces too
|
||||
|
||||
#define LUMP_VERTNORMALS 0 // phong shaded vertex normals
|
||||
#define LUMP_LIGHTVECS 1 // deluxemap data
|
||||
#define LUMP_CUBEMAPS 2 // cubemap description
|
||||
#define LUMP_LANDSCAPES 3 // landscape and lightmap resolution info
|
||||
#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_COLLISION 6 // physics engine collision hull dump
|
||||
#define LUMP_AINODEGRAPH 7 // node graph that stored into the bsp
|
||||
#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
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id; // must be little endian XASH
|
||||
int version;
|
||||
dlump_t lumps[EXTRA_LUMPS];
|
||||
} dextrahdr_t;
|
||||
|
||||
// MODIFIED: int flags -> short flags, short landscape (total struct size not changed!)
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4]; // texmatrix [s/t][xyz offset]
|
||||
int miptex;
|
||||
short flags;
|
||||
short landscape;
|
||||
} dtexinfo_t;
|
||||
|
||||
//============================================================================
|
||||
typedef struct
|
||||
{
|
||||
float normal[3];
|
||||
} dnormal_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short origin[3]; // position of light snapped to the nearest integer
|
||||
short size; // cubemap side size
|
||||
} dcubemap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte color[6][3]; // 6 sides 1x1 (single pixel per side)
|
||||
} dsample_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dsample_t cube;
|
||||
short origin[3];
|
||||
short leafnum; // leaf that contain this sample
|
||||
} dleafambient_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char landname[16]; // name of decsription in mapname_land.txt
|
||||
word texture_step; // default is 16, pixels\luxels ratio
|
||||
word max_extent; // default is 16, subdivision step ((texture_step * max_extent) - texture_step)
|
||||
short groupid; // to determine equal landscapes from various groups
|
||||
} dlandscape_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
emit_surface,
|
||||
emit_point,
|
||||
emit_spotlight,
|
||||
emit_skylight
|
||||
} emittype_t;
|
||||
|
||||
#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.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte emittype;
|
||||
byte style;
|
||||
byte flags; // will be set in ComputeLeafAmbientLighting
|
||||
short origin[3]; // light abs origin
|
||||
float intensity[3]; // RGB
|
||||
float normal[3]; // for surfaces and spotlights
|
||||
float stopdot; // 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 radius; // light radius
|
||||
short leafnum; // light linked into this leaf
|
||||
byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square (arghrad compat)
|
||||
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
|
||||
} dworldlight_t;
|
||||
|
||||
#endif//BSPFILE_H
|
2494
cl_dll/ammo.cpp
2494
cl_dll/ammo.cpp
File diff suppressed because it is too large
Load Diff
126
cl_dll/ammo.h
126
cl_dll/ammo.h
|
@ -1,64 +1,64 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef __AMMO_H__
|
||||
#define __AMMO_H__
|
||||
|
||||
#define MAX_WEAPON_NAME 128
|
||||
|
||||
|
||||
#define WEAPON_FLAGS_SELECTONEMPTY 1
|
||||
|
||||
#define WEAPON_IS_ONTARGET 0x40
|
||||
|
||||
struct WEAPON
|
||||
{
|
||||
char szName[MAX_WEAPON_NAME];
|
||||
int iAmmoType;
|
||||
int iAmmo2Type;
|
||||
int iMax1;
|
||||
int iMax2;
|
||||
int iSlot;
|
||||
int iSlotPos;
|
||||
int iFlags;
|
||||
int iId;
|
||||
int iClip;
|
||||
|
||||
int iCount; // # of itesm in plist
|
||||
|
||||
HSPRITE hActive;
|
||||
wrect_t rcActive;
|
||||
HSPRITE hInactive;
|
||||
wrect_t rcInactive;
|
||||
HSPRITE hNoAmmo; // buz
|
||||
wrect_t rcNoAmmo; // buz
|
||||
HSPRITE hAmmo;
|
||||
wrect_t rcAmmo;
|
||||
HSPRITE hAmmo2;
|
||||
wrect_t rcAmmo2;
|
||||
HSPRITE hCrosshair;
|
||||
wrect_t rcCrosshair;
|
||||
HSPRITE hAutoaim;
|
||||
wrect_t rcAutoaim;
|
||||
HSPRITE hZoomedCrosshair;
|
||||
wrect_t rcZoomedCrosshair;
|
||||
HSPRITE hZoomedAutoaim;
|
||||
wrect_t rcZoomedAutoaim;
|
||||
};
|
||||
|
||||
typedef int AMMO;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef __AMMO_H__
|
||||
#define __AMMO_H__
|
||||
|
||||
#define MAX_WEAPON_NAME 128
|
||||
|
||||
|
||||
#define WEAPON_FLAGS_SELECTONEMPTY 1
|
||||
|
||||
#define WEAPON_IS_ONTARGET 0x40
|
||||
|
||||
struct WEAPON
|
||||
{
|
||||
char szName[MAX_WEAPON_NAME];
|
||||
int iAmmoType;
|
||||
int iAmmo2Type;
|
||||
int iMax1;
|
||||
int iMax2;
|
||||
int iSlot;
|
||||
int iSlotPos;
|
||||
int iFlags;
|
||||
int iId;
|
||||
int iClip;
|
||||
|
||||
int iCount; // # of itesm in plist
|
||||
|
||||
HSPRITE hActive;
|
||||
wrect_t rcActive;
|
||||
HSPRITE hInactive;
|
||||
wrect_t rcInactive;
|
||||
HSPRITE hNoAmmo; // buz
|
||||
wrect_t rcNoAmmo; // buz
|
||||
HSPRITE hAmmo;
|
||||
wrect_t rcAmmo;
|
||||
HSPRITE hAmmo2;
|
||||
wrect_t rcAmmo2;
|
||||
HSPRITE hCrosshair;
|
||||
wrect_t rcCrosshair;
|
||||
HSPRITE hAutoaim;
|
||||
wrect_t rcAutoaim;
|
||||
HSPRITE hZoomedCrosshair;
|
||||
wrect_t rcZoomedCrosshair;
|
||||
HSPRITE hZoomedAutoaim;
|
||||
wrect_t rcZoomedAutoaim;
|
||||
};
|
||||
|
||||
typedef int AMMO;
|
||||
|
||||
|
||||
#endif
|
|
@ -1,159 +1,159 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammo_secondary.cpp
|
||||
//
|
||||
// implementation of CHudAmmoSecondary class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
|
||||
|
||||
int CHudAmmoSecondary :: Init( void )
|
||||
{
|
||||
HOOK_MESSAGE( SecAmmoVal );
|
||||
HOOK_MESSAGE( SecAmmoIcon );
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
m_HUD_ammoicon = 0;
|
||||
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudAmmoSecondary :: Reset( void )
|
||||
{
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: Draw(float flTime)
|
||||
{
|
||||
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
|
||||
return 1;
|
||||
|
||||
// draw secondary ammo icons above normal ammo readout
|
||||
int a, x, y, r, g, b, AmmoWidth;
|
||||
UnpackRGB( r, g, b, gHUD.m_iHUDColor ); //LRC
|
||||
a = (int) max( MIN_ALPHA, m_fFade );
|
||||
if (m_fFade > 0)
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
|
||||
ScaleColors( r, g, b, a );
|
||||
|
||||
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
|
||||
x = ScreenWidth - AmmoWidth;
|
||||
|
||||
if ( m_HUD_ammoicon )
|
||||
{
|
||||
// Draw the ammo icon
|
||||
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);
|
||||
|
||||
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
|
||||
}
|
||||
else
|
||||
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
|
||||
x -= AmmoWidth;
|
||||
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
|
||||
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
|
||||
{
|
||||
if ( m_iAmmoAmounts[i] < 0 )
|
||||
continue; // negative ammo amounts imply that they shouldn't be drawn
|
||||
|
||||
// half a char gap between the ammo number and the previous pic
|
||||
x -= (AmmoWidth / 2);
|
||||
|
||||
// draw the number, right-aligned
|
||||
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
|
||||
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
|
||||
|
||||
if ( i != 0 )
|
||||
{
|
||||
// draw the divider bar
|
||||
x -= (AmmoWidth / 2);
|
||||
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Value
|
||||
// accepts one value:
|
||||
// string: sprite name
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Icon
|
||||
// Sets an ammo value
|
||||
// takes two values:
|
||||
// byte: ammo index
|
||||
// byte: ammo value
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int index = READ_BYTE();
|
||||
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
|
||||
return 1;
|
||||
|
||||
m_iAmmoAmounts[index] = READ_BYTE();
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
// check to see if there is anything left to draw
|
||||
int count = 0;
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
{
|
||||
count += max( 0, m_iAmmoAmounts[i] );
|
||||
}
|
||||
|
||||
if ( count == 0 )
|
||||
{ // the ammo fields are all empty, so turn off this hud area
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// make the icons light up
|
||||
m_fFade = 200.0f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammo_secondary.cpp
|
||||
//
|
||||
// implementation of CHudAmmoSecondary class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
|
||||
|
||||
int CHudAmmoSecondary :: Init( void )
|
||||
{
|
||||
HOOK_MESSAGE( SecAmmoVal );
|
||||
HOOK_MESSAGE( SecAmmoIcon );
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
m_HUD_ammoicon = 0;
|
||||
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudAmmoSecondary :: Reset( void )
|
||||
{
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: Draw(float flTime)
|
||||
{
|
||||
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
|
||||
return 1;
|
||||
|
||||
// draw secondary ammo icons above normal ammo readout
|
||||
int a, x, y, r, g, b, AmmoWidth;
|
||||
UnpackRGB( r, g, b, gHUD.m_iHUDColor ); //LRC
|
||||
a = (int) max( MIN_ALPHA, m_fFade );
|
||||
if (m_fFade > 0)
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
|
||||
ScaleColors( r, g, b, a );
|
||||
|
||||
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
|
||||
x = ScreenWidth - AmmoWidth;
|
||||
|
||||
if ( m_HUD_ammoicon )
|
||||
{
|
||||
// Draw the ammo icon
|
||||
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);
|
||||
|
||||
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
|
||||
}
|
||||
else
|
||||
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
|
||||
x -= AmmoWidth;
|
||||
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
|
||||
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
|
||||
{
|
||||
if ( m_iAmmoAmounts[i] < 0 )
|
||||
continue; // negative ammo amounts imply that they shouldn't be drawn
|
||||
|
||||
// half a char gap between the ammo number and the previous pic
|
||||
x -= (AmmoWidth / 2);
|
||||
|
||||
// draw the number, right-aligned
|
||||
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
|
||||
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
|
||||
|
||||
if ( i != 0 )
|
||||
{
|
||||
// draw the divider bar
|
||||
x -= (AmmoWidth / 2);
|
||||
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Value
|
||||
// accepts one value:
|
||||
// string: sprite name
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Icon
|
||||
// Sets an ammo value
|
||||
// takes two values:
|
||||
// byte: ammo index
|
||||
// byte: ammo value
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int index = READ_BYTE();
|
||||
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
|
||||
return 1;
|
||||
|
||||
m_iAmmoAmounts[index] = READ_BYTE();
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
// check to see if there is anything left to draw
|
||||
int count = 0;
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
{
|
||||
count += max( 0, m_iAmmoAmounts[i] );
|
||||
}
|
||||
|
||||
if ( count == 0 )
|
||||
{ // the ammo fields are all empty, so turn off this hud area
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// make the icons light up
|
||||
m_fFade = 200.0f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,190 +1,190 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.cpp
|
||||
//
|
||||
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ammohistory.h"
|
||||
|
||||
HistoryResource gHR;
|
||||
|
||||
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
|
||||
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
|
||||
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
|
||||
|
||||
#define MAX_ITEM_NAME 32
|
||||
int HISTORY_DRAW_TIME = 5;
|
||||
|
||||
// keep a list of items
|
||||
struct ITEM_INFO
|
||||
{
|
||||
char szName[MAX_ITEM_NAME];
|
||||
HSPRITE spr;
|
||||
wrect_t rect;
|
||||
};
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
|
||||
{
|
||||
if ( iType == HISTSLOT_AMMO && !iCount )
|
||||
return; // no amount, so don't add
|
||||
|
||||
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
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
|
||||
freeslot->type = iType;
|
||||
freeslot->iId = iId;
|
||||
freeslot->iCount = iCount;
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
|
||||
{
|
||||
if ( iType != HISTSLOT_ITEM )
|
||||
return;
|
||||
|
||||
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
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
|
||||
// I am really unhappy with all the code in this file
|
||||
|
||||
int i = gHUD.GetSpriteIndex( szName );
|
||||
if ( i == -1 )
|
||||
return; // unknown sprite name, don't add it to history
|
||||
|
||||
freeslot->iId = i;
|
||||
freeslot->type = iType;
|
||||
freeslot->iCount = iCount;
|
||||
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
|
||||
void HistoryResource :: CheckClearHistory( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
return;
|
||||
}
|
||||
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Ammo pickup history
|
||||
//
|
||||
int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
{
|
||||
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
|
||||
|
||||
if ( rgAmmoHistory[i].DisplayTime <= flTime )
|
||||
{ // pic drawing time has expired
|
||||
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
|
||||
CheckClearHistory();
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
|
||||
{
|
||||
wrect_t rcPic;
|
||||
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
// Draw the pic
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - 24;
|
||||
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
|
||||
SPR_Set( *spr, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
|
||||
}
|
||||
|
||||
// Draw the number
|
||||
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
|
||||
{
|
||||
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
|
||||
|
||||
if ( !weap )
|
||||
return 1; // we don't know about the weapon yet, so don't draw anything
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
|
||||
if ( !gWR.HasAmmo( weap ) )
|
||||
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
|
||||
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
|
||||
SPR_Set( weap->hInactive, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
if ( !rgAmmoHistory[i].iId )
|
||||
continue; // sprite not loaded
|
||||
|
||||
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
|
||||
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
|
||||
|
||||
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rect );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.cpp
|
||||
//
|
||||
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ammohistory.h"
|
||||
|
||||
HistoryResource gHR;
|
||||
|
||||
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
|
||||
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
|
||||
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
|
||||
|
||||
#define MAX_ITEM_NAME 32
|
||||
int HISTORY_DRAW_TIME = 5;
|
||||
|
||||
// keep a list of items
|
||||
struct ITEM_INFO
|
||||
{
|
||||
char szName[MAX_ITEM_NAME];
|
||||
HSPRITE spr;
|
||||
wrect_t rect;
|
||||
};
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
|
||||
{
|
||||
if ( iType == HISTSLOT_AMMO && !iCount )
|
||||
return; // no amount, so don't add
|
||||
|
||||
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
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
|
||||
freeslot->type = iType;
|
||||
freeslot->iId = iId;
|
||||
freeslot->iCount = iCount;
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
|
||||
{
|
||||
if ( iType != HISTSLOT_ITEM )
|
||||
return;
|
||||
|
||||
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
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
|
||||
// I am really unhappy with all the code in this file
|
||||
|
||||
int i = gHUD.GetSpriteIndex( szName );
|
||||
if ( i == -1 )
|
||||
return; // unknown sprite name, don't add it to history
|
||||
|
||||
freeslot->iId = i;
|
||||
freeslot->type = iType;
|
||||
freeslot->iCount = iCount;
|
||||
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
|
||||
void HistoryResource :: CheckClearHistory( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
return;
|
||||
}
|
||||
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Ammo pickup history
|
||||
//
|
||||
int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
{
|
||||
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
|
||||
|
||||
if ( rgAmmoHistory[i].DisplayTime <= flTime )
|
||||
{ // pic drawing time has expired
|
||||
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
|
||||
CheckClearHistory();
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
|
||||
{
|
||||
wrect_t rcPic;
|
||||
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
// Draw the pic
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - 24;
|
||||
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
|
||||
SPR_Set( *spr, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
|
||||
}
|
||||
|
||||
// Draw the number
|
||||
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
|
||||
{
|
||||
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
|
||||
|
||||
if ( !weap )
|
||||
return 1; // we don't know about the weapon yet, so don't draw anything
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
|
||||
if ( !gWR.HasAmmo( weap ) )
|
||||
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
|
||||
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
|
||||
SPR_Set( weap->hInactive, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
if ( !rgAmmoHistory[i].iId )
|
||||
continue; // sprite not loaded
|
||||
|
||||
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
|
||||
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
|
||||
|
||||
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rect );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,154 +1,154 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.h
|
||||
//
|
||||
|
||||
// this is the max number of items in each bucket
|
||||
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
|
||||
extern WEAPON *gpActiveSel;
|
||||
|
||||
class WeaponsResource
|
||||
{
|
||||
public: // buz: made public to access from drawing code (valves idea about WR is suxx)
|
||||
// Information about weapons & ammo
|
||||
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
|
||||
|
||||
// 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
|
||||
int riAmmo[MAX_AMMO_SLOTS]; // count of each ammo type
|
||||
|
||||
public:
|
||||
void Init( void )
|
||||
{
|
||||
memset( rgWeapons, 0, sizeof rgWeapons );
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
iOldWeaponBits = 0;
|
||||
m_iSelectedColumn = -1;
|
||||
memset( rgSlots, 0, sizeof rgSlots );
|
||||
memset( riAmmo, 0, sizeof riAmmo );
|
||||
}
|
||||
|
||||
///// WEAPON /////
|
||||
int iOldWeaponBits;
|
||||
|
||||
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
|
||||
void AddWeapon( WEAPON *wp )
|
||||
{
|
||||
rgWeapons[ wp->iId ] = *wp;
|
||||
LoadWeaponSprites( &rgWeapons[ wp->iId ] );
|
||||
}
|
||||
|
||||
void PickupWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
|
||||
if ((m_iSelectedColumn == wp->iSlot) && !gpActiveSel) // buz: menu active, but no weapons in this category
|
||||
gpActiveSel = wp;
|
||||
}
|
||||
|
||||
void DropWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
|
||||
if (wp == gpActiveSel) // buz: removed current weapon
|
||||
gpActiveSel = GetFirstPos( wp->iSlot );
|
||||
}
|
||||
|
||||
void DropAllWeapons( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
if ( rgWeapons[i].iId )
|
||||
DropWeapon( &rgWeapons[i] );
|
||||
}
|
||||
}
|
||||
|
||||
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
|
||||
|
||||
void LoadWeaponSprites( WEAPON* wp );
|
||||
void LoadAllWeaponSprites( void );
|
||||
WEAPON* GetFirstPos( int iSlot );
|
||||
WEAPON* GetLastPos( int iSlot ); // buz
|
||||
void SelectSlot( int iSlot, int fAdvance, int iDirection );
|
||||
WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
|
||||
WEAPON* GetPrevActivePos( int iSlot, int iSlotPos ); // buz
|
||||
|
||||
int HasAmmo( WEAPON *p );
|
||||
|
||||
///// AMMO /////
|
||||
AMMO GetAmmo( int iId ) { return iId; }
|
||||
|
||||
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
|
||||
|
||||
int CountAmmo( int iId );
|
||||
|
||||
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
|
||||
|
||||
int m_iSelectedColumn; // buz: -1 means menu inactive
|
||||
float m_rgColumnSizes[MAX_WEAPON_SLOTS]; // buz
|
||||
};
|
||||
|
||||
extern WeaponsResource gWR;
|
||||
|
||||
|
||||
#define MAX_HISTORY 12
|
||||
enum {
|
||||
HISTSLOT_EMPTY,
|
||||
HISTSLOT_AMMO,
|
||||
HISTSLOT_WEAP,
|
||||
HISTSLOT_ITEM,
|
||||
};
|
||||
|
||||
class HistoryResource
|
||||
{
|
||||
private:
|
||||
struct HIST_ITEM {
|
||||
int type;
|
||||
float DisplayTime; // the time at which this item should be removed from the history
|
||||
int iCount;
|
||||
int iId;
|
||||
};
|
||||
|
||||
HIST_ITEM rgAmmoHistory[MAX_HISTORY];
|
||||
|
||||
public:
|
||||
|
||||
void Init( void )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
|
||||
}
|
||||
|
||||
int iHistoryGap;
|
||||
int iCurrentHistorySlot;
|
||||
|
||||
void AddToHistory( int iType, int iId, int iCount = 0 );
|
||||
void AddToHistory( int iType, const char *szName, int iCount = 0 );
|
||||
|
||||
void CheckClearHistory( void );
|
||||
int DrawAmmoHistory( float flTime );
|
||||
};
|
||||
|
||||
extern HistoryResource gHR;
|
||||
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.h
|
||||
//
|
||||
|
||||
// this is the max number of items in each bucket
|
||||
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
|
||||
extern WEAPON *gpActiveSel;
|
||||
|
||||
class WeaponsResource
|
||||
{
|
||||
public: // buz: made public to access from drawing code (valves idea about WR is suxx)
|
||||
// Information about weapons & ammo
|
||||
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
|
||||
|
||||
// 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
|
||||
int riAmmo[MAX_AMMO_SLOTS]; // count of each ammo type
|
||||
|
||||
public:
|
||||
void Init( void )
|
||||
{
|
||||
memset( rgWeapons, 0, sizeof rgWeapons );
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
iOldWeaponBits = 0;
|
||||
m_iSelectedColumn = -1;
|
||||
memset( rgSlots, 0, sizeof rgSlots );
|
||||
memset( riAmmo, 0, sizeof riAmmo );
|
||||
}
|
||||
|
||||
///// WEAPON /////
|
||||
int iOldWeaponBits;
|
||||
|
||||
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
|
||||
void AddWeapon( WEAPON *wp )
|
||||
{
|
||||
rgWeapons[ wp->iId ] = *wp;
|
||||
LoadWeaponSprites( &rgWeapons[ wp->iId ] );
|
||||
}
|
||||
|
||||
void PickupWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
|
||||
if ((m_iSelectedColumn == wp->iSlot) && !gpActiveSel) // buz: menu active, but no weapons in this category
|
||||
gpActiveSel = wp;
|
||||
}
|
||||
|
||||
void DropWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
|
||||
if (wp == gpActiveSel) // buz: removed current weapon
|
||||
gpActiveSel = GetFirstPos( wp->iSlot );
|
||||
}
|
||||
|
||||
void DropAllWeapons( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
if ( rgWeapons[i].iId )
|
||||
DropWeapon( &rgWeapons[i] );
|
||||
}
|
||||
}
|
||||
|
||||
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
|
||||
|
||||
void LoadWeaponSprites( WEAPON* wp );
|
||||
void LoadAllWeaponSprites( void );
|
||||
WEAPON* GetFirstPos( int iSlot );
|
||||
WEAPON* GetLastPos( int iSlot ); // buz
|
||||
void SelectSlot( int iSlot, int fAdvance, int iDirection );
|
||||
WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
|
||||
WEAPON* GetPrevActivePos( int iSlot, int iSlotPos ); // buz
|
||||
|
||||
int HasAmmo( WEAPON *p );
|
||||
|
||||
///// AMMO /////
|
||||
AMMO GetAmmo( int iId ) { return iId; }
|
||||
|
||||
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
|
||||
|
||||
int CountAmmo( int iId );
|
||||
|
||||
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
|
||||
|
||||
int m_iSelectedColumn; // buz: -1 means menu inactive
|
||||
float m_rgColumnSizes[MAX_WEAPON_SLOTS]; // buz
|
||||
};
|
||||
|
||||
extern WeaponsResource gWR;
|
||||
|
||||
|
||||
#define MAX_HISTORY 12
|
||||
enum {
|
||||
HISTSLOT_EMPTY,
|
||||
HISTSLOT_AMMO,
|
||||
HISTSLOT_WEAP,
|
||||
HISTSLOT_ITEM,
|
||||
};
|
||||
|
||||
class HistoryResource
|
||||
{
|
||||
private:
|
||||
struct HIST_ITEM {
|
||||
int type;
|
||||
float DisplayTime; // the time at which this item should be removed from the history
|
||||
int iCount;
|
||||
int iId;
|
||||
};
|
||||
|
||||
HIST_ITEM rgAmmoHistory[MAX_HISTORY];
|
||||
|
||||
public:
|
||||
|
||||
void Init( void )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
|
||||
}
|
||||
|
||||
int iHistoryGap;
|
||||
int iCurrentHistorySlot;
|
||||
|
||||
void AddToHistory( int iType, int iId, int iCount = 0 );
|
||||
void AddToHistory( int iType, const char *szName, int iCount = 0 );
|
||||
|
||||
void CheckClearHistory( void );
|
||||
int DrawAmmoHistory( float flTime );
|
||||
};
|
||||
|
||||
extern HistoryResource gHR;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,145 +1,145 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// battery.cpp
|
||||
//
|
||||
// implementation of CHudBattery class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vgui_TeamFortressViewport.h" // buz
|
||||
#include "vgui_hud.h" // buz
|
||||
|
||||
DECLARE_MESSAGE(m_Battery, Battery)
|
||||
|
||||
int CHudBattery::Init(void)
|
||||
{
|
||||
m_iBat = 0;
|
||||
m_fFade = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
HOOK_MESSAGE(Battery);
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
int CHudBattery::VidInit(void)
|
||||
{
|
||||
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
|
||||
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_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
|
||||
m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
|
||||
m_iHeight = m_prc2->bottom - m_prc1->top;
|
||||
m_fFade = 0;
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_SHORT();
|
||||
|
||||
if( x != m_iBat )
|
||||
{
|
||||
m_fFade = FADE_TIME;
|
||||
m_iBat = x;
|
||||
}
|
||||
|
||||
gViewPort->m_pHud2->UpdateArmor(x); // buz
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudBattery::Draw(float flTime)
|
||||
{
|
||||
return 1; // buz: dont draw battery..
|
||||
|
||||
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
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
|
||||
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
|
||||
if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT ))
|
||||
return 1;
|
||||
|
||||
// Has health changed? Flash the health #
|
||||
if (m_fFade)
|
||||
{
|
||||
if (m_fFade > FADE_TIME)
|
||||
m_fFade = FADE_TIME;
|
||||
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
||||
if (m_fFade <= 0)
|
||||
{
|
||||
a = 128;
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
// Fade the health number back to dim
|
||||
|
||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
||||
|
||||
}
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
ScaleColors(r, g, b, a );
|
||||
|
||||
int iOffset = (m_prc1->bottom - m_prc1->top)/6;
|
||||
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
x = ScreenWidth/5;
|
||||
|
||||
// make sure we have the right sprite handles
|
||||
if ( !m_hSprite1 )
|
||||
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
|
||||
if ( !m_hSprite2 )
|
||||
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
|
||||
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
|
||||
|
||||
if (rc.bottom > rc.top)
|
||||
{
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
|
||||
}
|
||||
|
||||
x += (m_prc1->right - m_prc1->left);
|
||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// battery.cpp
|
||||
//
|
||||
// implementation of CHudBattery class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vgui_TeamFortressViewport.h" // buz
|
||||
#include "vgui_hud.h" // buz
|
||||
|
||||
DECLARE_MESSAGE(m_Battery, Battery)
|
||||
|
||||
int CHudBattery::Init(void)
|
||||
{
|
||||
m_iBat = 0;
|
||||
m_fFade = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
HOOK_MESSAGE(Battery);
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
int CHudBattery::VidInit(void)
|
||||
{
|
||||
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
|
||||
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_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
|
||||
m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
|
||||
m_iHeight = m_prc2->bottom - m_prc1->top;
|
||||
m_fFade = 0;
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_SHORT();
|
||||
|
||||
if( x != m_iBat )
|
||||
{
|
||||
m_fFade = FADE_TIME;
|
||||
m_iBat = x;
|
||||
}
|
||||
|
||||
gViewPort->m_pHud2->UpdateArmor(x); // buz
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudBattery::Draw(float flTime)
|
||||
{
|
||||
return 1; // buz: dont draw battery..
|
||||
|
||||
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
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
|
||||
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
|
||||
if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT ))
|
||||
return 1;
|
||||
|
||||
// Has health changed? Flash the health #
|
||||
if (m_fFade)
|
||||
{
|
||||
if (m_fFade > FADE_TIME)
|
||||
m_fFade = FADE_TIME;
|
||||
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
||||
if (m_fFade <= 0)
|
||||
{
|
||||
a = 128;
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
// Fade the health number back to dim
|
||||
|
||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
||||
|
||||
}
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
ScaleColors(r, g, b, a );
|
||||
|
||||
int iOffset = (m_prc1->bottom - m_prc1->top)/6;
|
||||
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
x = ScreenWidth/5;
|
||||
|
||||
// make sure we have the right sprite handles
|
||||
if ( !m_hSprite1 )
|
||||
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
|
||||
if ( !m_hSprite2 )
|
||||
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
|
||||
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
|
||||
|
||||
if (rc.bottom > rc.top)
|
||||
{
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
|
||||
}
|
||||
|
||||
x += (m_prc1->right - m_prc1->left);
|
||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// Camera.h -- defines and such for a 3rd person camera
|
||||
// NOTE: must include quakedef.h first
|
||||
|
||||
#ifndef _CAMERA_H_
|
||||
#define _CAMEA_H_
|
||||
|
||||
// pitch, yaw, dist
|
||||
extern vec3_t cam_ofs;
|
||||
// Using third person camera
|
||||
extern int cam_thirdperson;
|
||||
|
||||
void CAM_Init( void );
|
||||
void CAM_ClearStates( void );
|
||||
void CAM_StartMouseMove(void);
|
||||
void CAM_EndMouseMove(void);
|
||||
|
||||
#endif // _CAMERA_H_
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// Camera.h -- defines and such for a 3rd person camera
|
||||
// NOTE: must include quakedef.h first
|
||||
|
||||
#ifndef _CAMERA_H_
|
||||
#define _CAMEA_H_
|
||||
|
||||
// pitch, yaw, dist
|
||||
extern vec3_t cam_ofs;
|
||||
// Using third person camera
|
||||
extern int cam_thirdperson;
|
||||
|
||||
void CAM_Init( void );
|
||||
void CAM_ClearStates( void );
|
||||
void CAM_StartMouseMove(void);
|
||||
void CAM_EndMouseMove(void);
|
||||
|
||||
#endif // _CAMERA_H_
|
||||
|
|
|
@ -1,344 +1,344 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cdll_int.c
|
||||
//
|
||||
// this implementation handles the linking of the engine to the DLL
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "netadr.h"
|
||||
#include "vgui_schememanager.h"
|
||||
|
||||
#include "pm_shared.h"
|
||||
#include "pm_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "hud_servers.h"
|
||||
#include "vgui_int.h"
|
||||
|
||||
int developer_level;
|
||||
int g_iXashEngineBuildNumber;
|
||||
BOOL g_fRenderInitialized = FALSE;
|
||||
BOOL g_fRenderInterfaceValid = FALSE;
|
||||
BOOL g_fXashEngine = FALSE;
|
||||
cl_enginefunc_t gEngfuncs;
|
||||
render_api_t gRenderfuncs;
|
||||
CHud gHUD;
|
||||
TeamFortressViewport *gViewPort = NULL;
|
||||
|
||||
void InitInput( void );
|
||||
void ShutdownInput( void );
|
||||
void EV_HookEvents( void );
|
||||
void IN_Commands( void );
|
||||
|
||||
/*
|
||||
==========================
|
||||
Initialize
|
||||
|
||||
Called when the DLL is first loaded.
|
||||
==========================
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
|
||||
int DLLEXPORT HUD_VidInit( void );
|
||||
void DLLEXPORT HUD_Init( void );
|
||||
void DLLEXPORT HUD_Shutdown( void );
|
||||
int DLLEXPORT HUD_Redraw( float flTime, int intermission );
|
||||
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
|
||||
void DLLEXPORT HUD_Reset ( void );
|
||||
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
|
||||
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
|
||||
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 );
|
||||
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 );
|
||||
void DLLEXPORT HUD_Frame( double time );
|
||||
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
|
||||
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 );
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
HUD_GetHullBounds
|
||||
|
||||
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 iret = 0;
|
||||
|
||||
switch ( hullnumber )
|
||||
{
|
||||
case 0: // Normal player
|
||||
mins = Vector(-16, -16, -36);
|
||||
maxs = Vector(16, 16, 36);
|
||||
iret = 1;
|
||||
break;
|
||||
case 1: // Crouched player
|
||||
mins = Vector(-16, -16, -18 );
|
||||
maxs = Vector(16, 16, 18 );
|
||||
iret = 1;
|
||||
break;
|
||||
case 2: // Point based hull
|
||||
mins = Vector( 0, 0, 0 );
|
||||
maxs = Vector( 0, 0, 0 );
|
||||
iret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
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
|
||||
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 )
|
||||
{
|
||||
// Parse stuff from args
|
||||
int max_buffer_size = *response_buffer_size;
|
||||
|
||||
// Zero it out since we aren't going to respond.
|
||||
// If we wanted to response, we'd write data into response_buffer
|
||||
*response_buffer_size = 0;
|
||||
|
||||
// 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.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
|
||||
{
|
||||
PM_Init( ppmove );
|
||||
}
|
||||
|
||||
char DLLEXPORT HUD_PlayerMoveTexture( char *name )
|
||||
{
|
||||
return (char)0;
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
|
||||
{
|
||||
PM_Move( ppmove, server );
|
||||
}
|
||||
|
||||
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
||||
{
|
||||
gEngfuncs = *pEnginefuncs;
|
||||
|
||||
if( iVersion != CLDLL_INTERFACE_VERSION )
|
||||
return 0;
|
||||
|
||||
memcpy( &gEngfuncs, pEnginefuncs, sizeof( cl_enginefunc_t ));
|
||||
|
||||
// get developer level
|
||||
developer_level = (int)CVAR_GET_FLOAT( "developer" );
|
||||
|
||||
if( CVAR_GET_POINTER( "host_clientloaded" ) != NULL )
|
||||
g_fXashEngine = TRUE;
|
||||
|
||||
g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "build" ); // 0 for old builds or GoldSrc
|
||||
if( g_iXashEngineBuildNumber <= 0 )
|
||||
g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "buildnum" );
|
||||
|
||||
EV_HookEvents();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VidInit
|
||||
|
||||
Called when the game initializes
|
||||
and whenever the vid_mode is changed
|
||||
so the HUD can reinitialize itself.
|
||||
==========================
|
||||
*/
|
||||
int DLLEXPORT HUD_VidInit( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
|
||||
VGui_Startup();
|
||||
|
||||
if( g_fXashEngine && g_fRenderInitialized )
|
||||
R_VidInit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Init
|
||||
|
||||
Called whenever the client connects
|
||||
to a server. Reinitializes all
|
||||
the hud variables.
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_Init( void )
|
||||
{
|
||||
InitInput();
|
||||
|
||||
if( g_fXashEngine && g_fRenderInitialized )
|
||||
GL_Init();
|
||||
|
||||
gHUD.Init();
|
||||
Scheme_Init();
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_Shutdown( void )
|
||||
{
|
||||
ShutdownInput();
|
||||
|
||||
if( g_fXashEngine && g_fRenderInitialized )
|
||||
GL_Shutdown();
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Redraw
|
||||
|
||||
called every screen frame to
|
||||
redraw the HUD.
|
||||
===========================
|
||||
*/
|
||||
int DLLEXPORT HUD_Redraw( float time, int intermission )
|
||||
{
|
||||
return gHUD.Redraw( time, intermission );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_UpdateClientData
|
||||
|
||||
called every time shared client
|
||||
dll/engine data gets changed,
|
||||
and gives the cdll a chance
|
||||
to modify the data.
|
||||
|
||||
returns 1 if anything has been changed, 0 otherwise.
|
||||
==========================
|
||||
*/
|
||||
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
|
||||
{
|
||||
IN_Commands();
|
||||
|
||||
return gHUD.UpdateClientData(pcldata, flTime );
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Reset
|
||||
|
||||
Called at start and end of demos to restore to "non"HUD state.
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_Reset( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Frame
|
||||
|
||||
Called by engine every frame that client .dll is loaded
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_Frame( double time )
|
||||
{
|
||||
ServersThink( time );
|
||||
|
||||
GetClientVoiceMgr()->Frame(time);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VoiceStatus
|
||||
|
||||
Called when a player starts or stops talking.
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking )
|
||||
{
|
||||
GetClientVoiceMgr()->UpdateSpeakerStatus( entindex, bTalking );
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_DirectorEvent
|
||||
|
||||
Called when a director event message was received
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_DirectorMessage( int iSize, void *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 )
|
||||
{
|
||||
to->client.fov = 0;//g_lastFOV; buz
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_ClipMoveToEntity
|
||||
|
||||
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 )
|
||||
{
|
||||
// convert physent_t to cl_entity_t
|
||||
cl_entity_t *pTouch = gEngfuncs.GetEntityByIndex( pe->info );
|
||||
trace_t trace;
|
||||
|
||||
if( !pTouch )
|
||||
{
|
||||
// removed entity?
|
||||
tr->allsolid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// make trace default
|
||||
memset( &trace, 0, sizeof( trace ));
|
||||
trace.allsolid = true;
|
||||
trace.fraction = 1.0f;
|
||||
trace.endpos = end;
|
||||
|
||||
Physic_SweepTest( pTouch, start, mins, maxs, end, &trace );
|
||||
|
||||
// convert trace_t into pmtrace_t
|
||||
memcpy( tr, &trace, 48 );
|
||||
tr->surf = trace.surf;
|
||||
|
||||
if( trace.ent != NULL && PM_GetPlayerMove( ))
|
||||
tr->ent = pe - PM_GetPlayerMove()->physents;
|
||||
else tr->ent = -1;
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cdll_int.c
|
||||
//
|
||||
// this implementation handles the linking of the engine to the DLL
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "netadr.h"
|
||||
#include "vgui_schememanager.h"
|
||||
|
||||
#include "pm_shared.h"
|
||||
#include "pm_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "hud_servers.h"
|
||||
#include "vgui_int.h"
|
||||
|
||||
int developer_level;
|
||||
int g_iXashEngineBuildNumber;
|
||||
BOOL g_fRenderInitialized = FALSE;
|
||||
BOOL g_fRenderInterfaceValid = FALSE;
|
||||
BOOL g_fXashEngine = FALSE;
|
||||
cl_enginefunc_t gEngfuncs;
|
||||
render_api_t gRenderfuncs;
|
||||
CHud gHUD;
|
||||
TeamFortressViewport *gViewPort = NULL;
|
||||
|
||||
void InitInput( void );
|
||||
void ShutdownInput( void );
|
||||
void EV_HookEvents( void );
|
||||
void IN_Commands( void );
|
||||
|
||||
/*
|
||||
==========================
|
||||
Initialize
|
||||
|
||||
Called when the DLL is first loaded.
|
||||
==========================
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
|
||||
int DLLEXPORT HUD_VidInit( void );
|
||||
void DLLEXPORT HUD_Init( void );
|
||||
void DLLEXPORT HUD_Shutdown( void );
|
||||
int DLLEXPORT HUD_Redraw( float flTime, int intermission );
|
||||
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
|
||||
void DLLEXPORT HUD_Reset ( void );
|
||||
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
|
||||
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
|
||||
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 );
|
||||
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 );
|
||||
void DLLEXPORT HUD_Frame( double time );
|
||||
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
|
||||
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 );
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
HUD_GetHullBounds
|
||||
|
||||
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 iret = 0;
|
||||
|
||||
switch ( hullnumber )
|
||||
{
|
||||
case 0: // Normal player
|
||||
mins = Vector(-16, -16, -36);
|
||||
maxs = Vector(16, 16, 36);
|
||||
iret = 1;
|
||||
break;
|
||||
case 1: // Crouched player
|
||||
mins = Vector(-16, -16, -18 );
|
||||
maxs = Vector(16, 16, 18 );
|
||||
iret = 1;
|
||||
break;
|
||||
case 2: // Point based hull
|
||||
mins = Vector( 0, 0, 0 );
|
||||
maxs = Vector( 0, 0, 0 );
|
||||
iret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
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
|
||||
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 )
|
||||
{
|
||||
// Parse stuff from args
|
||||
int max_buffer_size = *response_buffer_size;
|
||||
|
||||
// Zero it out since we aren't going to respond.
|
||||
// If we wanted to response, we'd write data into response_buffer
|
||||
*response_buffer_size = 0;
|
||||
|
||||
// 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.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
|
||||
{
|
||||
PM_Init( ppmove );
|
||||
}
|
||||
|
||||
char DLLEXPORT HUD_PlayerMoveTexture( char *name )
|
||||
{
|
||||
return (char)0;
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
|
||||
{
|
||||
PM_Move( ppmove, server );
|
||||
}
|
||||
|
||||
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
||||
{
|
||||
gEngfuncs = *pEnginefuncs;
|
||||
|
||||
if( iVersion != CLDLL_INTERFACE_VERSION )
|
||||
return 0;
|
||||
|
||||
memcpy( &gEngfuncs, pEnginefuncs, sizeof( cl_enginefunc_t ));
|
||||
|
||||
// get developer level
|
||||
developer_level = (int)CVAR_GET_FLOAT( "developer" );
|
||||
|
||||
if( CVAR_GET_POINTER( "host_clientloaded" ) != NULL )
|
||||
g_fXashEngine = TRUE;
|
||||
|
||||
g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "build" ); // 0 for old builds or GoldSrc
|
||||
if( g_iXashEngineBuildNumber <= 0 )
|
||||
g_iXashEngineBuildNumber = (int)CVAR_GET_FLOAT( "buildnum" );
|
||||
|
||||
EV_HookEvents();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VidInit
|
||||
|
||||
Called when the game initializes
|
||||
and whenever the vid_mode is changed
|
||||
so the HUD can reinitialize itself.
|
||||
==========================
|
||||
*/
|
||||
int DLLEXPORT HUD_VidInit( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
|
||||
VGui_Startup();
|
||||
|
||||
if( g_fXashEngine && g_fRenderInitialized )
|
||||
R_VidInit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Init
|
||||
|
||||
Called whenever the client connects
|
||||
to a server. Reinitializes all
|
||||
the hud variables.
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_Init( void )
|
||||
{
|
||||
InitInput();
|
||||
|
||||
if( g_fXashEngine && g_fRenderInitialized )
|
||||
GL_Init();
|
||||
|
||||
gHUD.Init();
|
||||
Scheme_Init();
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_Shutdown( void )
|
||||
{
|
||||
ShutdownInput();
|
||||
|
||||
if( g_fXashEngine && g_fRenderInitialized )
|
||||
GL_Shutdown();
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Redraw
|
||||
|
||||
called every screen frame to
|
||||
redraw the HUD.
|
||||
===========================
|
||||
*/
|
||||
int DLLEXPORT HUD_Redraw( float time, int intermission )
|
||||
{
|
||||
return gHUD.Redraw( time, intermission );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_UpdateClientData
|
||||
|
||||
called every time shared client
|
||||
dll/engine data gets changed,
|
||||
and gives the cdll a chance
|
||||
to modify the data.
|
||||
|
||||
returns 1 if anything has been changed, 0 otherwise.
|
||||
==========================
|
||||
*/
|
||||
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
|
||||
{
|
||||
IN_Commands();
|
||||
|
||||
return gHUD.UpdateClientData(pcldata, flTime );
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Reset
|
||||
|
||||
Called at start and end of demos to restore to "non"HUD state.
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_Reset( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Frame
|
||||
|
||||
Called by engine every frame that client .dll is loaded
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_Frame( double time )
|
||||
{
|
||||
ServersThink( time );
|
||||
|
||||
GetClientVoiceMgr()->Frame(time);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VoiceStatus
|
||||
|
||||
Called when a player starts or stops talking.
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking )
|
||||
{
|
||||
GetClientVoiceMgr()->UpdateSpeakerStatus( entindex, bTalking );
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_DirectorEvent
|
||||
|
||||
Called when a director event message was received
|
||||
==========================
|
||||
*/
|
||||
void DLLEXPORT HUD_DirectorMessage( int iSize, void *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 )
|
||||
{
|
||||
to->client.fov = 0;//g_lastFOV; buz
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_ClipMoveToEntity
|
||||
|
||||
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 )
|
||||
{
|
||||
// convert physent_t to cl_entity_t
|
||||
cl_entity_t *pTouch = gEngfuncs.GetEntityByIndex( pe->info );
|
||||
trace_t trace;
|
||||
|
||||
if( !pTouch )
|
||||
{
|
||||
// removed entity?
|
||||
tr->allsolid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// make trace default
|
||||
memset( &trace, 0, sizeof( trace ));
|
||||
trace.allsolid = true;
|
||||
trace.fraction = 1.0f;
|
||||
trace.endpos = end;
|
||||
|
||||
Physic_SweepTest( pTouch, start, mins, maxs, end, &trace );
|
||||
|
||||
// convert trace_t into pmtrace_t
|
||||
memcpy( tr, &trace, 48 );
|
||||
tr->surf = trace.surf;
|
||||
|
||||
if( trace.ent != NULL && PM_GetPlayerMove( ))
|
||||
tr->ent = pe - PM_GetPlayerMove()->physents;
|
||||
else tr->ent = -1;
|
||||
}
|
|
@ -1,49 +1,49 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_dll.h
|
||||
//
|
||||
|
||||
// 4-23-98 JOHN
|
||||
|
||||
//
|
||||
// This DLL is linked by the client when they first initialize.
|
||||
// This DLL is responsible for the following tasks:
|
||||
// - Loading the HUD graphics upon initialization
|
||||
// - Drawing the HUD graphics every frame
|
||||
// - Handling the custum HUD-update packets
|
||||
//
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
#include <vector.h>
|
||||
#define EXPORT _declspec( dllexport )
|
||||
|
||||
#include "../engine/cdll_int.h"
|
||||
#include "cdll_dll.h"
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
#define CONPRINT (gEngfuncs.Con_Printf) //LRC - I can't live without printf!
|
||||
|
||||
//
|
||||
// gl_export.cpp
|
||||
//
|
||||
bool GL_Init( void );
|
||||
void GL_MapChanged( void );
|
||||
void GL_Shutdown( void );
|
||||
bool GL_Support( int r_ext );
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_dll.h
|
||||
//
|
||||
|
||||
// 4-23-98 JOHN
|
||||
|
||||
//
|
||||
// This DLL is linked by the client when they first initialize.
|
||||
// This DLL is responsible for the following tasks:
|
||||
// - Loading the HUD graphics upon initialization
|
||||
// - Drawing the HUD graphics every frame
|
||||
// - Handling the custum HUD-update packets
|
||||
//
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
#include <vector.h>
|
||||
#define EXPORT _declspec( dllexport )
|
||||
|
||||
#include "../engine/cdll_int.h"
|
||||
#include "cdll_dll.h"
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
#define CONPRINT (gEngfuncs.Con_Printf) //LRC - I can't live without printf!
|
||||
|
||||
//
|
||||
// gl_export.cpp
|
||||
//
|
||||
bool GL_Init( void );
|
||||
void GL_MapChanged( void );
|
||||
void GL_Shutdown( void );
|
||||
bool GL_Support( int r_ext );
|
||||
void R_VidInit( void );
|
638
cl_dll/cl_util.h
638
cl_dll/cl_util.h
|
@ -1,319 +1,319 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_util.h
|
||||
//
|
||||
|
||||
#include "cvardef.h"
|
||||
|
||||
#define EXPORT _declspec( dllexport )
|
||||
#define DLLEXPORT __declspec( dllexport )
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
extern int developer_level;
|
||||
extern int r_currentMessageNum;
|
||||
|
||||
extern int g_iXashEngineBuildNumber;
|
||||
extern BOOL g_fRenderInitialized;
|
||||
extern BOOL g_fRenderInterfaceValid;
|
||||
extern BOOL g_fXashEngine;
|
||||
|
||||
enum
|
||||
{
|
||||
DEV_NONE = 0,
|
||||
DEV_NORMAL,
|
||||
DEV_EXTENDED
|
||||
};
|
||||
|
||||
typedef HMODULE dllhandle_t;
|
||||
|
||||
typedef struct dllfunc_s
|
||||
{
|
||||
const char *name;
|
||||
void **func;
|
||||
} dllfunc_t;
|
||||
|
||||
// misc cvars
|
||||
extern cvar_t *r_test; // just cvar for testify new effects
|
||||
extern cvar_t *r_stencilbits;
|
||||
extern cvar_t *r_drawentities;
|
||||
extern cvar_t *gl_extensions;
|
||||
extern cvar_t *cv_dynamiclight;
|
||||
extern cvar_t *r_detailtextures;
|
||||
extern cvar_t *r_lighting_ambient;
|
||||
extern cvar_t *r_lighting_modulate;
|
||||
extern cvar_t *r_lightstyle_lerping;
|
||||
extern cvar_t *r_lighting_extended;
|
||||
extern cvar_t *r_occlusion_culling;
|
||||
extern cvar_t *r_show_lightprobes;
|
||||
extern cvar_t *r_show_cubemaps;
|
||||
extern cvar_t *r_show_viewleaf;
|
||||
extern cvar_t *cv_crosshair;
|
||||
extern cvar_t *r_shadows;
|
||||
extern cvar_t *r_fullbright;
|
||||
extern cvar_t *r_draw_beams;
|
||||
extern cvar_t *r_overview;
|
||||
extern cvar_t *r_novis;
|
||||
extern cvar_t *r_nocull;
|
||||
extern cvar_t *r_lockpvs;
|
||||
extern cvar_t *r_dof;
|
||||
extern cvar_t *r_dof_hold_time;
|
||||
extern cvar_t *r_dof_change_time;
|
||||
extern cvar_t *r_dof_focal_length;
|
||||
extern cvar_t *r_dof_fstop;
|
||||
extern cvar_t *r_dof_debug;
|
||||
extern cvar_t *r_allow_mirrors;
|
||||
extern cvar_t *cv_renderer;
|
||||
extern cvar_t *cv_brdf;
|
||||
extern cvar_t *cv_bump;
|
||||
extern cvar_t *cv_specular;
|
||||
extern cvar_t *cv_parallax;
|
||||
extern cvar_t *cv_decals;
|
||||
extern cvar_t *cv_realtime_puddles;
|
||||
extern cvar_t *cv_shadow_offset;
|
||||
extern cvar_t *cv_cubemaps;
|
||||
extern cvar_t *cv_deferred;
|
||||
extern cvar_t *cv_deferred_full;
|
||||
extern cvar_t *cv_deferred_maxlights;
|
||||
extern cvar_t *cv_deferred_tracebmodels;
|
||||
extern cvar_t *cv_cube_lod_bias;
|
||||
extern cvar_t *cv_gamma;
|
||||
extern cvar_t *cv_brightness;
|
||||
extern cvar_t *cv_water;
|
||||
extern cvar_t *cv_decalsdebug;
|
||||
extern cvar_t *cv_show_tbn;
|
||||
extern cvar_t *cv_nosort;
|
||||
extern cvar_t *r_lightmap;
|
||||
extern cvar_t *r_speeds;
|
||||
extern cvar_t *r_decals;
|
||||
extern cvar_t *r_studio_decals;
|
||||
extern cvar_t *r_hand;
|
||||
extern cvar_t *r_sunshadows;
|
||||
extern cvar_t *r_sun_allowed;
|
||||
extern cvar_t *r_shadow_split_weight;
|
||||
extern cvar_t *r_wireframe;
|
||||
extern cvar_t *r_lightstyles;
|
||||
extern cvar_t *r_polyoffset;
|
||||
extern cvar_t *r_dynamic;
|
||||
extern cvar_t *r_finish;
|
||||
extern cvar_t *r_clear;
|
||||
extern cvar_t *r_grass;
|
||||
extern cvar_t *r_grass_alpha;
|
||||
extern cvar_t *r_grass_lighting;
|
||||
extern cvar_t *r_grass_shadows;
|
||||
extern cvar_t *r_grass_fade_start;
|
||||
extern cvar_t *r_grass_fade_dist;
|
||||
extern cvar_t *r_scissor_glass_debug;
|
||||
extern cvar_t *r_scissor_light_debug;
|
||||
extern cvar_t *r_showlightmaps;
|
||||
extern cvar_t *r_recursion_depth;
|
||||
extern cvar_t *r_shadowmap_size;
|
||||
extern cvar_t *r_pssm_show_split;
|
||||
extern cvar_t *v_sunshafts;
|
||||
extern cvar_t *v_glows;
|
||||
|
||||
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
|
||||
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
|
||||
|
||||
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
|
||||
{ \
|
||||
return gHUD.##y.MsgFunc_##x(pszName, iSize, pbuf ); \
|
||||
}
|
||||
|
||||
|
||||
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
|
||||
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
|
||||
{ \
|
||||
gHUD.##y.UserCmd_##x( ); \
|
||||
}
|
||||
|
||||
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
|
||||
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
|
||||
client_sprite_t *SPR2_GetList( char *psz, int *piCount ); // new version
|
||||
|
||||
// SPR_Draw draws a the current sprite as solid
|
||||
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
|
||||
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
|
||||
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
|
||||
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
|
||||
#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.
|
||||
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
|
||||
// SPR_DisableScissor disables the clipping rect
|
||||
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
|
||||
//
|
||||
#define FillRGBA (*gEngfuncs.pfnFillRGBA)
|
||||
|
||||
|
||||
// ScreenHeight returns the height of the screen, in pixels
|
||||
#define ScreenHeight (gHUD.m_scrinfo.iHeight)
|
||||
// ScreenWidth returns the width of the screen, in pixels
|
||||
#define ScreenWidth (gHUD.m_scrinfo.iWidth)
|
||||
|
||||
// Use this to set any co-ords in 640x480 space
|
||||
#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f))
|
||||
#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f))
|
||||
|
||||
// use this to project world coordinates to screen coordinates
|
||||
#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f )
|
||||
#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f )
|
||||
|
||||
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
|
||||
#define ServerCmd (*gEngfuncs.pfnServerCmd)
|
||||
#define ClientCmd (*gEngfuncs.pfnClientCmd)
|
||||
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
|
||||
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
|
||||
|
||||
inline int ConsoleStringLen( const char *string )
|
||||
{
|
||||
int _width, _height;
|
||||
GetConsoleStringSize( string, &_width, &_height );
|
||||
return _width;
|
||||
}
|
||||
|
||||
// returns the players name of entity no.
|
||||
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
|
||||
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
|
||||
|
||||
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 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 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;}
|
||||
float Length(const float *v);
|
||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
|
||||
void VectorScale (const float *in, float scale, float *out);
|
||||
float VectorNormalize (float *v);
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
extern struct ref_params_s *g_pViewParams;
|
||||
|
||||
// disable 'possible loss of data converting float to int' warning message
|
||||
#pragma warning( disable: 4244 )
|
||||
// disable 'truncation from 'const double' to 'float' warning message
|
||||
#pragma warning( disable: 4305 )
|
||||
|
||||
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
|
||||
{\
|
||||
r = (ulRGB & 0xFF0000) >>16;\
|
||||
g = (ulRGB & 0xFF00) >> 8;\
|
||||
b = ulRGB & 0xFF;\
|
||||
}
|
||||
|
||||
inline unsigned int PackRGBA( int r, int g, int b, int a )
|
||||
{
|
||||
r = bound( 0, r, 255 );
|
||||
g = bound( 0, g, 255 );
|
||||
b = bound( 0, b, 255 );
|
||||
a = bound( 0, a, 255 );
|
||||
|
||||
return ((a)<<24|(r)<<16|(g)<<8|(b));
|
||||
}
|
||||
|
||||
inline void UnpackRGBA( int &r, int &g, int &b, int &a, unsigned int ulRGBA )
|
||||
{
|
||||
a = (ulRGBA & 0xFF000000) >> 24;
|
||||
r = (ulRGBA & 0xFF0000) >> 16;
|
||||
g = (ulRGBA & 0xFF00) >> 8;
|
||||
b = (ulRGBA & 0xFF) >> 0;
|
||||
}
|
||||
|
||||
float PackColor( const color24 &color );
|
||||
color24 UnpackColor( float pack );
|
||||
|
||||
HSPRITE LoadSprite(const char *pszName);
|
||||
|
||||
#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 CLEARVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] &= ~(1 << ((b) & 7))) : (byte)false )
|
||||
|
||||
typedef struct leaflist_s
|
||||
{
|
||||
int count;
|
||||
int maxcount;
|
||||
bool overflowed;
|
||||
short *list;
|
||||
Vector mins, maxs;
|
||||
struct mnode_s *headnode; // for overflows where each leaf can't be stored individually
|
||||
} leaflist_t;
|
||||
|
||||
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_GetCurrentVis( void );
|
||||
bool Mod_BoxVisible( const Vector &mins, const Vector &maxs, const byte *visbits );
|
||||
bool Mod_CheckEntityPVS( cl_entity_t *ent );
|
||||
bool Mod_CheckTempEntityPVS( struct tempent_s *pTemp );
|
||||
bool Mod_CheckEntityLeafPVS( const Vector &absmin, const Vector &absmax, struct mleaf_s *leaf );
|
||||
bool Mod_CheckBoxVisible( const Vector &absmin, const Vector &absmax );
|
||||
void Mod_GetFrames( int modelIndex, int &numFrames );
|
||||
struct model_s *Mod_Handle( int modelIndex );
|
||||
bool Mod_PointInSolid( const Vector &p );
|
||||
int Mod_GetType( int modelIndex );
|
||||
extern void ParseRain( void );
|
||||
extern int CL_IsDead( void );
|
||||
void SetDLightVis( struct mworldlight_s *wl, int leafnum );
|
||||
void MergeDLightVis( struct mworldlight_s *wl, int leafnum );
|
||||
|
||||
bool UTIL_IsPlayer( int idx );
|
||||
bool UTIL_IsLocal( int idx );
|
||||
void UTIL_WeaponAnimation( int iAnim, float framerate );
|
||||
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_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 );
|
||||
void R_DrawScissorRectangle( float x, float y, float w, float h );
|
||||
int WorldToScreen( const Vector &world, Vector &screen );
|
||||
void R_TransformWorldToDevice( const Vector &world, Vector &ndc );
|
||||
void R_TransformDeviceToScreen( const Vector &ndc, Vector &screen );
|
||||
float ComputePixelWidthOfSphere( const Vector& vecOrigin, float flRadius );
|
||||
|
||||
bool R_SkyIsVisible( void );
|
||||
|
||||
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 );
|
||||
|
||||
// dll managment
|
||||
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_FreeLibrary( dllhandle_t *handle );
|
||||
bool Sys_RemoveFile( const char *path );
|
||||
|
||||
void UTIL_CreateAurora( cl_entity_t *ent, const char *file, int attachment, float lifetime = 0.0f );
|
||||
void UTIL_RemoveAurora( cl_entity_t *ent );
|
||||
|
||||
extern void AngleMatrix (const float *angles, float (*matrix)[4] );
|
||||
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 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 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 float TextureToLinear( int c );
|
||||
extern int LinearToTexture( float f );
|
||||
extern void GL_GpuMemUsage_f( void );
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_util.h
|
||||
//
|
||||
|
||||
#include "cvardef.h"
|
||||
|
||||
#define EXPORT _declspec( dllexport )
|
||||
#define DLLEXPORT __declspec( dllexport )
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
extern int developer_level;
|
||||
extern int r_currentMessageNum;
|
||||
|
||||
extern int g_iXashEngineBuildNumber;
|
||||
extern BOOL g_fRenderInitialized;
|
||||
extern BOOL g_fRenderInterfaceValid;
|
||||
extern BOOL g_fXashEngine;
|
||||
|
||||
enum
|
||||
{
|
||||
DEV_NONE = 0,
|
||||
DEV_NORMAL,
|
||||
DEV_EXTENDED
|
||||
};
|
||||
|
||||
typedef HMODULE dllhandle_t;
|
||||
|
||||
typedef struct dllfunc_s
|
||||
{
|
||||
const char *name;
|
||||
void **func;
|
||||
} dllfunc_t;
|
||||
|
||||
// misc cvars
|
||||
extern cvar_t *r_test; // just cvar for testify new effects
|
||||
extern cvar_t *r_stencilbits;
|
||||
extern cvar_t *r_drawentities;
|
||||
extern cvar_t *gl_extensions;
|
||||
extern cvar_t *cv_dynamiclight;
|
||||
extern cvar_t *r_detailtextures;
|
||||
extern cvar_t *r_lighting_ambient;
|
||||
extern cvar_t *r_lighting_modulate;
|
||||
extern cvar_t *r_lightstyle_lerping;
|
||||
extern cvar_t *r_lighting_extended;
|
||||
extern cvar_t *r_occlusion_culling;
|
||||
extern cvar_t *r_show_lightprobes;
|
||||
extern cvar_t *r_show_cubemaps;
|
||||
extern cvar_t *r_show_viewleaf;
|
||||
extern cvar_t *cv_crosshair;
|
||||
extern cvar_t *r_shadows;
|
||||
extern cvar_t *r_fullbright;
|
||||
extern cvar_t *r_draw_beams;
|
||||
extern cvar_t *r_overview;
|
||||
extern cvar_t *r_novis;
|
||||
extern cvar_t *r_nocull;
|
||||
extern cvar_t *r_lockpvs;
|
||||
extern cvar_t *r_dof;
|
||||
extern cvar_t *r_dof_hold_time;
|
||||
extern cvar_t *r_dof_change_time;
|
||||
extern cvar_t *r_dof_focal_length;
|
||||
extern cvar_t *r_dof_fstop;
|
||||
extern cvar_t *r_dof_debug;
|
||||
extern cvar_t *r_allow_mirrors;
|
||||
extern cvar_t *cv_renderer;
|
||||
extern cvar_t *cv_brdf;
|
||||
extern cvar_t *cv_bump;
|
||||
extern cvar_t *cv_specular;
|
||||
extern cvar_t *cv_parallax;
|
||||
extern cvar_t *cv_decals;
|
||||
extern cvar_t *cv_realtime_puddles;
|
||||
extern cvar_t *cv_shadow_offset;
|
||||
extern cvar_t *cv_cubemaps;
|
||||
extern cvar_t *cv_deferred;
|
||||
extern cvar_t *cv_deferred_full;
|
||||
extern cvar_t *cv_deferred_maxlights;
|
||||
extern cvar_t *cv_deferred_tracebmodels;
|
||||
extern cvar_t *cv_cube_lod_bias;
|
||||
extern cvar_t *cv_gamma;
|
||||
extern cvar_t *cv_brightness;
|
||||
extern cvar_t *cv_water;
|
||||
extern cvar_t *cv_decalsdebug;
|
||||
extern cvar_t *cv_show_tbn;
|
||||
extern cvar_t *cv_nosort;
|
||||
extern cvar_t *r_lightmap;
|
||||
extern cvar_t *r_speeds;
|
||||
extern cvar_t *r_decals;
|
||||
extern cvar_t *r_studio_decals;
|
||||
extern cvar_t *r_hand;
|
||||
extern cvar_t *r_sunshadows;
|
||||
extern cvar_t *r_sun_allowed;
|
||||
extern cvar_t *r_shadow_split_weight;
|
||||
extern cvar_t *r_wireframe;
|
||||
extern cvar_t *r_lightstyles;
|
||||
extern cvar_t *r_polyoffset;
|
||||
extern cvar_t *r_dynamic;
|
||||
extern cvar_t *r_finish;
|
||||
extern cvar_t *r_clear;
|
||||
extern cvar_t *r_grass;
|
||||
extern cvar_t *r_grass_alpha;
|
||||
extern cvar_t *r_grass_lighting;
|
||||
extern cvar_t *r_grass_shadows;
|
||||
extern cvar_t *r_grass_fade_start;
|
||||
extern cvar_t *r_grass_fade_dist;
|
||||
extern cvar_t *r_scissor_glass_debug;
|
||||
extern cvar_t *r_scissor_light_debug;
|
||||
extern cvar_t *r_showlightmaps;
|
||||
extern cvar_t *r_recursion_depth;
|
||||
extern cvar_t *r_shadowmap_size;
|
||||
extern cvar_t *r_pssm_show_split;
|
||||
extern cvar_t *v_sunshafts;
|
||||
extern cvar_t *v_glows;
|
||||
|
||||
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
|
||||
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
|
||||
|
||||
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
|
||||
{ \
|
||||
return gHUD.##y.MsgFunc_##x(pszName, iSize, pbuf ); \
|
||||
}
|
||||
|
||||
|
||||
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
|
||||
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
|
||||
{ \
|
||||
gHUD.##y.UserCmd_##x( ); \
|
||||
}
|
||||
|
||||
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
|
||||
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
|
||||
client_sprite_t *SPR2_GetList( char *psz, int *piCount ); // new version
|
||||
|
||||
// SPR_Draw draws a the current sprite as solid
|
||||
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
|
||||
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
|
||||
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
|
||||
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
|
||||
#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.
|
||||
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
|
||||
// SPR_DisableScissor disables the clipping rect
|
||||
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
|
||||
//
|
||||
#define FillRGBA (*gEngfuncs.pfnFillRGBA)
|
||||
|
||||
|
||||
// ScreenHeight returns the height of the screen, in pixels
|
||||
#define ScreenHeight (gHUD.m_scrinfo.iHeight)
|
||||
// ScreenWidth returns the width of the screen, in pixels
|
||||
#define ScreenWidth (gHUD.m_scrinfo.iWidth)
|
||||
|
||||
// Use this to set any co-ords in 640x480 space
|
||||
#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f))
|
||||
#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f))
|
||||
|
||||
// use this to project world coordinates to screen coordinates
|
||||
#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f )
|
||||
#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f )
|
||||
|
||||
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
|
||||
#define ServerCmd (*gEngfuncs.pfnServerCmd)
|
||||
#define ClientCmd (*gEngfuncs.pfnClientCmd)
|
||||
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
|
||||
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
|
||||
|
||||
inline int ConsoleStringLen( const char *string )
|
||||
{
|
||||
int _width, _height;
|
||||
GetConsoleStringSize( string, &_width, &_height );
|
||||
return _width;
|
||||
}
|
||||
|
||||
// returns the players name of entity no.
|
||||
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
|
||||
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
|
||||
|
||||
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 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 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;}
|
||||
float Length(const float *v);
|
||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
|
||||
void VectorScale (const float *in, float scale, float *out);
|
||||
float VectorNormalize (float *v);
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
extern struct ref_params_s *g_pViewParams;
|
||||
|
||||
// disable 'possible loss of data converting float to int' warning message
|
||||
#pragma warning( disable: 4244 )
|
||||
// disable 'truncation from 'const double' to 'float' warning message
|
||||
#pragma warning( disable: 4305 )
|
||||
|
||||
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
|
||||
{\
|
||||
r = (ulRGB & 0xFF0000) >>16;\
|
||||
g = (ulRGB & 0xFF00) >> 8;\
|
||||
b = ulRGB & 0xFF;\
|
||||
}
|
||||
|
||||
inline unsigned int PackRGBA( int r, int g, int b, int a )
|
||||
{
|
||||
r = bound( 0, r, 255 );
|
||||
g = bound( 0, g, 255 );
|
||||
b = bound( 0, b, 255 );
|
||||
a = bound( 0, a, 255 );
|
||||
|
||||
return ((a)<<24|(r)<<16|(g)<<8|(b));
|
||||
}
|
||||
|
||||
inline void UnpackRGBA( int &r, int &g, int &b, int &a, unsigned int ulRGBA )
|
||||
{
|
||||
a = (ulRGBA & 0xFF000000) >> 24;
|
||||
r = (ulRGBA & 0xFF0000) >> 16;
|
||||
g = (ulRGBA & 0xFF00) >> 8;
|
||||
b = (ulRGBA & 0xFF) >> 0;
|
||||
}
|
||||
|
||||
float PackColor( const color24 &color );
|
||||
color24 UnpackColor( float pack );
|
||||
|
||||
HSPRITE LoadSprite(const char *pszName);
|
||||
|
||||
#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 CLEARVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] &= ~(1 << ((b) & 7))) : (byte)false )
|
||||
|
||||
typedef struct leaflist_s
|
||||
{
|
||||
int count;
|
||||
int maxcount;
|
||||
bool overflowed;
|
||||
short *list;
|
||||
Vector mins, maxs;
|
||||
struct mnode_s *headnode; // for overflows where each leaf can't be stored individually
|
||||
} leaflist_t;
|
||||
|
||||
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_GetCurrentVis( void );
|
||||
bool Mod_BoxVisible( const Vector &mins, const Vector &maxs, const byte *visbits );
|
||||
bool Mod_CheckEntityPVS( cl_entity_t *ent );
|
||||
bool Mod_CheckTempEntityPVS( struct tempent_s *pTemp );
|
||||
bool Mod_CheckEntityLeafPVS( const Vector &absmin, const Vector &absmax, struct mleaf_s *leaf );
|
||||
bool Mod_CheckBoxVisible( const Vector &absmin, const Vector &absmax );
|
||||
void Mod_GetFrames( int modelIndex, int &numFrames );
|
||||
struct model_s *Mod_Handle( int modelIndex );
|
||||
bool Mod_PointInSolid( const Vector &p );
|
||||
int Mod_GetType( int modelIndex );
|
||||
extern void ParseRain( void );
|
||||
extern int CL_IsDead( void );
|
||||
void SetDLightVis( struct mworldlight_s *wl, int leafnum );
|
||||
void MergeDLightVis( struct mworldlight_s *wl, int leafnum );
|
||||
|
||||
bool UTIL_IsPlayer( int idx );
|
||||
bool UTIL_IsLocal( int idx );
|
||||
void UTIL_WeaponAnimation( int iAnim, float framerate );
|
||||
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_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 );
|
||||
void R_DrawScissorRectangle( float x, float y, float w, float h );
|
||||
int WorldToScreen( const Vector &world, Vector &screen );
|
||||
void R_TransformWorldToDevice( const Vector &world, Vector &ndc );
|
||||
void R_TransformDeviceToScreen( const Vector &ndc, Vector &screen );
|
||||
float ComputePixelWidthOfSphere( const Vector& vecOrigin, float flRadius );
|
||||
|
||||
bool R_SkyIsVisible( void );
|
||||
|
||||
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 );
|
||||
|
||||
// dll managment
|
||||
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_FreeLibrary( dllhandle_t *handle );
|
||||
bool Sys_RemoveFile( const char *path );
|
||||
|
||||
void UTIL_CreateAurora( cl_entity_t *ent, const char *file, int attachment, float lifetime = 0.0f );
|
||||
void UTIL_RemoveAurora( cl_entity_t *ent );
|
||||
|
||||
extern void AngleMatrix (const float *angles, float (*matrix)[4] );
|
||||
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 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 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 float TextureToLinear( int c );
|
||||
extern int LinearToTexture( float f );
|
||||
extern void GL_GpuMemUsage_f( void );
|
||||
|
|
|
@ -1,108 +1,108 @@
|
|||
/************************************
|
||||
simple memory allocator
|
||||
by BUzer
|
||||
************************************/
|
||||
|
||||
template <class T>
|
||||
class MemBlock
|
||||
{
|
||||
typedef struct chunk_s {
|
||||
int next;
|
||||
T data;
|
||||
} chunk_t;
|
||||
|
||||
public:
|
||||
MemBlock(int numElements)
|
||||
{
|
||||
// ýëåìåíò 0 èñïîëüçóåòñÿ â êà÷åñòâå íà÷àëà ñïèñêà çàíÿòûõ ÿ÷ååê
|
||||
m_iArraySize = numElements + 1;
|
||||
m_pArray = new chunk_t[m_iArraySize];
|
||||
|
||||
if (!m_pArray)
|
||||
{
|
||||
m_iArraySize = 1;
|
||||
m_iFirstFree = m_iArraySize;
|
||||
return;
|
||||
}
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
~MemBlock()
|
||||
{
|
||||
delete[] m_pArray;
|
||||
m_pArray = NULL;
|
||||
}
|
||||
|
||||
void Clear( void )
|
||||
{
|
||||
if (m_iArraySize > 1)
|
||||
{
|
||||
m_pArray[0].next = 0; // åñëè îí ññûëàåòñÿ ñàì íà ñåáÿ, çíà÷èò ñïèñîê çàíÿòûõ ïóñò
|
||||
m_iFirstFree = 1;
|
||||
|
||||
for (int i = 1; i < m_iArraySize; ++i)
|
||||
m_pArray[i].next = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
T* Allocate( void )
|
||||
{
|
||||
if (m_iFirstFree != m_iArraySize)
|
||||
{
|
||||
int savedFirstFree = m_pArray[m_iFirstFree].next;
|
||||
m_pArray[m_iFirstFree].next = m_pArray[0].next; // äîáàâëÿåì ñâîáîäíóþ ÿ÷åéêó â
|
||||
m_pArray[0].next = m_iFirstFree; // ñïèñîê çàíÿòûõ
|
||||
m_iFirstFree = savedFirstFree; // èñêëþ÷àåì ÿ÷åéêó èç ñïèñêà ñâîáîäíûõ
|
||||
return &(m_pArray[m_pArray[0].next].data);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool IsClear( void )
|
||||
{
|
||||
return m_pArray[0].next ? false : true;
|
||||
}
|
||||
|
||||
bool StartPass( void )
|
||||
{
|
||||
m_iCurrent = 0; // íà÷èíàåì îáõîä ñ íóëåâîãî ýëåìåíòà
|
||||
|
||||
if (m_iArraySize > 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
T* GetCurrent( void )
|
||||
{
|
||||
int retindex = m_pArray[m_iCurrent].next;
|
||||
if (!retindex)
|
||||
return NULL;
|
||||
|
||||
return &(m_pArray[retindex].data);
|
||||
}
|
||||
|
||||
void MoveNext( void )
|
||||
{
|
||||
m_iCurrent = m_pArray[m_iCurrent].next;
|
||||
}
|
||||
|
||||
void DeleteCurrent( void )
|
||||
{
|
||||
int delindex = m_pArray[m_iCurrent].next;
|
||||
m_pArray[m_iCurrent].next = m_pArray[delindex].next; // âûáðàñûâàåì ýëåìåíò èç öåïè çàíÿòûõ
|
||||
m_pArray[delindex].next = m_iFirstFree;
|
||||
m_iFirstFree = delindex; // âêëþ÷àåì ýëåìåíò â íà÷àëî öåïè ñâîáîäíûõ
|
||||
}
|
||||
|
||||
private:
|
||||
chunk_t *m_pArray;
|
||||
int m_iArraySize;
|
||||
int m_iCurrent; // äëÿ ïðîõîæäåíèÿ ÷åðåç ìàññèâ
|
||||
|
||||
int m_iFirstFree; // íà÷àëî ñïèñêà ñâîáîäíûõ ýëåìåíòîâ
|
||||
};
|
||||
|
||||
|
||||
/************************************
|
||||
simple memory allocator
|
||||
by BUzer
|
||||
************************************/
|
||||
|
||||
template <class T>
|
||||
class MemBlock
|
||||
{
|
||||
typedef struct chunk_s {
|
||||
int next;
|
||||
T data;
|
||||
} chunk_t;
|
||||
|
||||
public:
|
||||
MemBlock(int numElements)
|
||||
{
|
||||
// ýëåìåíò 0 èñïîëüçóåòñÿ â êà÷åñòâå íà÷àëà ñïèñêà çàíÿòûõ ÿ÷ååê
|
||||
m_iArraySize = numElements + 1;
|
||||
m_pArray = new chunk_t[m_iArraySize];
|
||||
|
||||
if (!m_pArray)
|
||||
{
|
||||
m_iArraySize = 1;
|
||||
m_iFirstFree = m_iArraySize;
|
||||
return;
|
||||
}
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
~MemBlock()
|
||||
{
|
||||
delete[] m_pArray;
|
||||
m_pArray = NULL;
|
||||
}
|
||||
|
||||
void Clear( void )
|
||||
{
|
||||
if (m_iArraySize > 1)
|
||||
{
|
||||
m_pArray[0].next = 0; // åñëè îí ññûëàåòñÿ ñàì íà ñåáÿ, çíà÷èò ñïèñîê çàíÿòûõ ïóñò
|
||||
m_iFirstFree = 1;
|
||||
|
||||
for (int i = 1; i < m_iArraySize; ++i)
|
||||
m_pArray[i].next = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
T* Allocate( void )
|
||||
{
|
||||
if (m_iFirstFree != m_iArraySize)
|
||||
{
|
||||
int savedFirstFree = m_pArray[m_iFirstFree].next;
|
||||
m_pArray[m_iFirstFree].next = m_pArray[0].next; // äîáàâëÿåì ñâîáîäíóþ ÿ÷åéêó â
|
||||
m_pArray[0].next = m_iFirstFree; // ñïèñîê çàíÿòûõ
|
||||
m_iFirstFree = savedFirstFree; // èñêëþ÷àåì ÿ÷åéêó èç ñïèñêà ñâîáîäíûõ
|
||||
return &(m_pArray[m_pArray[0].next].data);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool IsClear( void )
|
||||
{
|
||||
return m_pArray[0].next ? false : true;
|
||||
}
|
||||
|
||||
bool StartPass( void )
|
||||
{
|
||||
m_iCurrent = 0; // íà÷èíàåì îáõîä ñ íóëåâîãî ýëåìåíòà
|
||||
|
||||
if (m_iArraySize > 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
T* GetCurrent( void )
|
||||
{
|
||||
int retindex = m_pArray[m_iCurrent].next;
|
||||
if (!retindex)
|
||||
return NULL;
|
||||
|
||||
return &(m_pArray[retindex].data);
|
||||
}
|
||||
|
||||
void MoveNext( void )
|
||||
{
|
||||
m_iCurrent = m_pArray[m_iCurrent].next;
|
||||
}
|
||||
|
||||
void DeleteCurrent( void )
|
||||
{
|
||||
int delindex = m_pArray[m_iCurrent].next;
|
||||
m_pArray[m_iCurrent].next = m_pArray[delindex].next; // âûáðàñûâàåì ýëåìåíò èç öåïè çàíÿòûõ
|
||||
m_pArray[delindex].next = m_iFirstFree;
|
||||
m_iFirstFree = delindex; // âêëþ÷àåì ýëåìåíò â íà÷àëî öåïè ñâîáîäíûõ
|
||||
}
|
||||
|
||||
private:
|
||||
chunk_t *m_pArray;
|
||||
int m_iArraySize;
|
||||
int m_iCurrent; // äëÿ ïðîõîæäåíèÿ ÷åðåç ìàññèâ
|
||||
|
||||
int m_iFirstFree; // íà÷àëî ñïèñêà ñâîáîäíûõ ýëåìåíòîâ
|
||||
};
|
||||
|
||||
|
||||
|
|
594
cl_dll/death.cpp
594
cl_dll/death.cpp
|
@ -1,297 +1,297 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// death notice
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
|
||||
|
||||
struct DeathNoticeItem {
|
||||
char szKiller[MAX_PLAYER_NAME_LENGTH*2];
|
||||
char szVictim[MAX_PLAYER_NAME_LENGTH*2];
|
||||
int iId; // the index number of the associated sprite
|
||||
int iSuicide;
|
||||
int iTeamKill;
|
||||
int iNonPlayerKill;
|
||||
float flDisplayTime;
|
||||
float *KillerColor;
|
||||
float *VictimColor;
|
||||
};
|
||||
|
||||
#define MAX_DEATHNOTICES 4
|
||||
static int DEATHNOTICE_DISPLAY_TIME = 6;
|
||||
|
||||
#define DEATHNOTICE_TOP 32
|
||||
|
||||
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
|
||||
|
||||
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
|
||||
float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
|
||||
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
|
||||
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
|
||||
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
|
||||
|
||||
float *GetClientColor( int clientIndex )
|
||||
{
|
||||
switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
|
||||
{
|
||||
case 1: return g_ColorBlue;
|
||||
case 2: return g_ColorRed;
|
||||
case 3: return g_ColorYellow;
|
||||
case 4: return g_ColorGreen;
|
||||
case 0: return g_ColorYellow;
|
||||
|
||||
default : return g_ColorGrey;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( DeathMsg );
|
||||
|
||||
CVAR_REGISTER( "hud_deathnotice_time", "6", 0 );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudDeathNotice :: InitHUDData( void )
|
||||
{
|
||||
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
|
||||
}
|
||||
|
||||
|
||||
int CHudDeathNotice :: VidInit( void )
|
||||
{
|
||||
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Draw( float flTime )
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
|
||||
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break; // we've gone through them all
|
||||
|
||||
if ( rgDeathNoticeList[i].flDisplayTime < flTime )
|
||||
{ // display time has expired
|
||||
// remove the current item from the list
|
||||
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
|
||||
i--; // continue on the next item; stop the counter getting incremented
|
||||
continue;
|
||||
}
|
||||
|
||||
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
|
||||
|
||||
// Only draw if the viewport will let me
|
||||
if ( gViewPort && gViewPort->AllowedToPrintText() )
|
||||
{
|
||||
// Draw the death notice
|
||||
y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!!
|
||||
|
||||
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);
|
||||
|
||||
if ( !rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
|
||||
|
||||
// Draw killers name
|
||||
if ( rgDeathNoticeList[i].KillerColor )
|
||||
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
}
|
||||
|
||||
r = 255; g = 80; b = 0;
|
||||
if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
r = 10; g = 240; b = 10; // display it in sickly green
|
||||
}
|
||||
|
||||
// Draw death weapon
|
||||
SPR_Set( gHUD.GetSprite(id), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
|
||||
|
||||
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
||||
|
||||
// Draw victims name (if it was a player that was killed)
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
|
||||
{
|
||||
if ( rgDeathNoticeList[i].VictimColor )
|
||||
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// This message handler may be better off elsewhere
|
||||
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int killer = READ_BYTE();
|
||||
int victim = READ_BYTE();
|
||||
|
||||
char killedwith[32];
|
||||
strcpy( killedwith, "d_" );
|
||||
strncat( killedwith, READ_STRING(), 32 );
|
||||
|
||||
if (gViewPort)
|
||||
gViewPort->DeathMsg( killer, victim );
|
||||
|
||||
gHUD.m_Spectator.DeathMessage(victim);
|
||||
|
||||
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break;
|
||||
}
|
||||
if ( i == MAX_DEATHNOTICES )
|
||||
{ // move the rest of the list forward to make room for this item
|
||||
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
|
||||
i = MAX_DEATHNOTICES - 1;
|
||||
}
|
||||
|
||||
if (gViewPort)
|
||||
gViewPort->GetAllPlayersInfo();
|
||||
|
||||
// Get the Killer's name
|
||||
char *killer_name = g_PlayerInfoList[ killer ].name;
|
||||
if ( !killer_name )
|
||||
{
|
||||
killer_name = "";
|
||||
rgDeathNoticeList[i].szKiller[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
|
||||
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Get the Victim's name
|
||||
char *victim_name = NULL;
|
||||
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
|
||||
if ( ((char)victim) != -1 )
|
||||
victim_name = g_PlayerInfoList[ victim ].name;
|
||||
if ( !victim_name )
|
||||
{
|
||||
victim_name = "";
|
||||
rgDeathNoticeList[i].szVictim[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
|
||||
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Is it a non-player object kill?
|
||||
if ( ((char)victim) == -1 )
|
||||
{
|
||||
rgDeathNoticeList[i].iNonPlayerKill = TRUE;
|
||||
|
||||
// Store the object's name in the Victim slot (skip the d_ bit)
|
||||
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( killer == victim || killer == 0 )
|
||||
rgDeathNoticeList[i].iSuicide = TRUE;
|
||||
|
||||
if ( !strcmp( killedwith, "d_teammate" ) )
|
||||
rgDeathNoticeList[i].iTeamKill = TRUE;
|
||||
}
|
||||
|
||||
// Find the sprite in the list
|
||||
int spr = gHUD.GetSpriteIndex( killedwith );
|
||||
|
||||
rgDeathNoticeList[i].iId = spr;
|
||||
|
||||
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
|
||||
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
|
||||
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill)
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed a " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// record the death notice in the console
|
||||
if ( rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
|
||||
if ( !strcmp( killedwith, "d_world" ) )
|
||||
{
|
||||
ConsolePrint( " died" );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( " killed self" );
|
||||
}
|
||||
}
|
||||
else if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed his teammate " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
|
||||
if ( killedwith && *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( " with " );
|
||||
ConsolePrint( killedwith+2 ); // skip over the "d_" part
|
||||
}
|
||||
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// death notice
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
|
||||
|
||||
struct DeathNoticeItem {
|
||||
char szKiller[MAX_PLAYER_NAME_LENGTH*2];
|
||||
char szVictim[MAX_PLAYER_NAME_LENGTH*2];
|
||||
int iId; // the index number of the associated sprite
|
||||
int iSuicide;
|
||||
int iTeamKill;
|
||||
int iNonPlayerKill;
|
||||
float flDisplayTime;
|
||||
float *KillerColor;
|
||||
float *VictimColor;
|
||||
};
|
||||
|
||||
#define MAX_DEATHNOTICES 4
|
||||
static int DEATHNOTICE_DISPLAY_TIME = 6;
|
||||
|
||||
#define DEATHNOTICE_TOP 32
|
||||
|
||||
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
|
||||
|
||||
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
|
||||
float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
|
||||
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
|
||||
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
|
||||
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
|
||||
|
||||
float *GetClientColor( int clientIndex )
|
||||
{
|
||||
switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
|
||||
{
|
||||
case 1: return g_ColorBlue;
|
||||
case 2: return g_ColorRed;
|
||||
case 3: return g_ColorYellow;
|
||||
case 4: return g_ColorGreen;
|
||||
case 0: return g_ColorYellow;
|
||||
|
||||
default : return g_ColorGrey;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( DeathMsg );
|
||||
|
||||
CVAR_REGISTER( "hud_deathnotice_time", "6", 0 );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudDeathNotice :: InitHUDData( void )
|
||||
{
|
||||
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
|
||||
}
|
||||
|
||||
|
||||
int CHudDeathNotice :: VidInit( void )
|
||||
{
|
||||
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Draw( float flTime )
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
|
||||
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break; // we've gone through them all
|
||||
|
||||
if ( rgDeathNoticeList[i].flDisplayTime < flTime )
|
||||
{ // display time has expired
|
||||
// remove the current item from the list
|
||||
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
|
||||
i--; // continue on the next item; stop the counter getting incremented
|
||||
continue;
|
||||
}
|
||||
|
||||
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
|
||||
|
||||
// Only draw if the viewport will let me
|
||||
if ( gViewPort && gViewPort->AllowedToPrintText() )
|
||||
{
|
||||
// Draw the death notice
|
||||
y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!!
|
||||
|
||||
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);
|
||||
|
||||
if ( !rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
|
||||
|
||||
// Draw killers name
|
||||
if ( rgDeathNoticeList[i].KillerColor )
|
||||
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
}
|
||||
|
||||
r = 255; g = 80; b = 0;
|
||||
if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
r = 10; g = 240; b = 10; // display it in sickly green
|
||||
}
|
||||
|
||||
// Draw death weapon
|
||||
SPR_Set( gHUD.GetSprite(id), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
|
||||
|
||||
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
||||
|
||||
// Draw victims name (if it was a player that was killed)
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
|
||||
{
|
||||
if ( rgDeathNoticeList[i].VictimColor )
|
||||
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// This message handler may be better off elsewhere
|
||||
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int killer = READ_BYTE();
|
||||
int victim = READ_BYTE();
|
||||
|
||||
char killedwith[32];
|
||||
strcpy( killedwith, "d_" );
|
||||
strncat( killedwith, READ_STRING(), 32 );
|
||||
|
||||
if (gViewPort)
|
||||
gViewPort->DeathMsg( killer, victim );
|
||||
|
||||
gHUD.m_Spectator.DeathMessage(victim);
|
||||
|
||||
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break;
|
||||
}
|
||||
if ( i == MAX_DEATHNOTICES )
|
||||
{ // move the rest of the list forward to make room for this item
|
||||
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
|
||||
i = MAX_DEATHNOTICES - 1;
|
||||
}
|
||||
|
||||
if (gViewPort)
|
||||
gViewPort->GetAllPlayersInfo();
|
||||
|
||||
// Get the Killer's name
|
||||
char *killer_name = g_PlayerInfoList[ killer ].name;
|
||||
if ( !killer_name )
|
||||
{
|
||||
killer_name = "";
|
||||
rgDeathNoticeList[i].szKiller[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
|
||||
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Get the Victim's name
|
||||
char *victim_name = NULL;
|
||||
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
|
||||
if ( ((char)victim) != -1 )
|
||||
victim_name = g_PlayerInfoList[ victim ].name;
|
||||
if ( !victim_name )
|
||||
{
|
||||
victim_name = "";
|
||||
rgDeathNoticeList[i].szVictim[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
|
||||
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Is it a non-player object kill?
|
||||
if ( ((char)victim) == -1 )
|
||||
{
|
||||
rgDeathNoticeList[i].iNonPlayerKill = TRUE;
|
||||
|
||||
// Store the object's name in the Victim slot (skip the d_ bit)
|
||||
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( killer == victim || killer == 0 )
|
||||
rgDeathNoticeList[i].iSuicide = TRUE;
|
||||
|
||||
if ( !strcmp( killedwith, "d_teammate" ) )
|
||||
rgDeathNoticeList[i].iTeamKill = TRUE;
|
||||
}
|
||||
|
||||
// Find the sprite in the list
|
||||
int spr = gHUD.GetSpriteIndex( killedwith );
|
||||
|
||||
rgDeathNoticeList[i].iId = spr;
|
||||
|
||||
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
|
||||
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
|
||||
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill)
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed a " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// record the death notice in the console
|
||||
if ( rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
|
||||
if ( !strcmp( killedwith, "d_world" ) )
|
||||
{
|
||||
ConsolePrint( " died" );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( " killed self" );
|
||||
}
|
||||
}
|
||||
else if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed his teammate " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
|
||||
if ( killedwith && *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( " with " );
|
||||
ConsolePrint( killedwith+2 ); // skip over the "d_" part
|
||||
}
|
||||
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
204
cl_dll/demo.cpp
204
cl_dll/demo.cpp
|
@ -1,103 +1,103 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
#include <memory.h>
|
||||
|
||||
#define DLLEXPORT __declspec( dllexport )
|
||||
|
||||
int g_demosniper = 0;
|
||||
int g_demosniperdamage = 0;
|
||||
float g_demosniperorg[3];
|
||||
float g_demosniperangles[3];
|
||||
float g_demozoom;
|
||||
|
||||
// FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap.
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_WriteBuffer
|
||||
|
||||
Write some data to the demo stream
|
||||
=====================
|
||||
*/
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
|
||||
{
|
||||
int pos = 0;
|
||||
unsigned char buf[ 32 * 1024 ];
|
||||
*( int * )&buf[pos] = type;
|
||||
pos+=sizeof( int );
|
||||
|
||||
memcpy( &buf[pos], buffer, size );
|
||||
|
||||
// Write full buffer out
|
||||
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_ReadBuffer
|
||||
|
||||
Engine wants us to parse some data from the demo stream
|
||||
=====================
|
||||
*/
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
|
||||
{
|
||||
int type;
|
||||
int i = 0;
|
||||
|
||||
type = *( int * )buffer;
|
||||
i += sizeof( int );
|
||||
switch ( type )
|
||||
{
|
||||
case TYPE_SNIPERDOT:
|
||||
g_demosniper = *(int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
if ( g_demosniper )
|
||||
{
|
||||
g_demosniperdamage = *( int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
g_demosniperangles[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
}
|
||||
break;
|
||||
case TYPE_ZOOM:
|
||||
g_demozoom = *(float * )&buffer[ i ];
|
||||
i += sizeof( float );
|
||||
break;
|
||||
default:
|
||||
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
|
||||
break;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
#include <memory.h>
|
||||
|
||||
#define DLLEXPORT __declspec( dllexport )
|
||||
|
||||
int g_demosniper = 0;
|
||||
int g_demosniperdamage = 0;
|
||||
float g_demosniperorg[3];
|
||||
float g_demosniperangles[3];
|
||||
float g_demozoom;
|
||||
|
||||
// FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap.
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_WriteBuffer
|
||||
|
||||
Write some data to the demo stream
|
||||
=====================
|
||||
*/
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
|
||||
{
|
||||
int pos = 0;
|
||||
unsigned char buf[ 32 * 1024 ];
|
||||
*( int * )&buf[pos] = type;
|
||||
pos+=sizeof( int );
|
||||
|
||||
memcpy( &buf[pos], buffer, size );
|
||||
|
||||
// Write full buffer out
|
||||
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_ReadBuffer
|
||||
|
||||
Engine wants us to parse some data from the demo stream
|
||||
=====================
|
||||
*/
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
|
||||
{
|
||||
int type;
|
||||
int i = 0;
|
||||
|
||||
type = *( int * )buffer;
|
||||
i += sizeof( int );
|
||||
switch ( type )
|
||||
{
|
||||
case TYPE_SNIPERDOT:
|
||||
g_demosniper = *(int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
if ( g_demosniper )
|
||||
{
|
||||
g_demosniperdamage = *( int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
g_demosniperangles[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
}
|
||||
break;
|
||||
case TYPE_ZOOM:
|
||||
g_demozoom = *(float * )&buffer[ i ];
|
||||
i += sizeof( float );
|
||||
break;
|
||||
default:
|
||||
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,27 +1,27 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( DEMOH )
|
||||
#define DEMOH
|
||||
#pragma once
|
||||
|
||||
// Types of demo messages we can write/parse
|
||||
enum
|
||||
{
|
||||
TYPE_SNIPERDOT = 0,
|
||||
TYPE_ZOOM
|
||||
};
|
||||
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
|
||||
|
||||
extern int g_demosniper;
|
||||
extern int g_demosniperdamage;
|
||||
extern float g_demosniperorg[3];
|
||||
extern float g_demosniperangles[3];
|
||||
extern float g_demozoom;
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( DEMOH )
|
||||
#define DEMOH
|
||||
#pragma once
|
||||
|
||||
// Types of demo messages we can write/parse
|
||||
enum
|
||||
{
|
||||
TYPE_SNIPERDOT = 0,
|
||||
TYPE_ZOOM
|
||||
};
|
||||
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
|
||||
|
||||
extern int g_demosniper;
|
||||
extern int g_demosniperdamage;
|
||||
extern float g_demosniperorg[3];
|
||||
extern float g_demosniperangles[3];
|
||||
extern float g_demozoom;
|
||||
|
||||
#endif
|
|
@ -1,173 +1,173 @@
|
|||
/*
|
||||
enginecallback.h - actual engine callbacks
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef ENGINECALLBACK_H
|
||||
#define ENGINECALLBACK_H
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
extern render_api_t gRenderfuncs;
|
||||
|
||||
#define GET_CLIENT_TIME (*gEngfuncs.GetClientTime)
|
||||
#define GET_CLIENT_OLDTIME (*gEngfuncs.GetClientOldTime)
|
||||
#define CVAR_REGISTER (*gEngfuncs.pfnRegisterVariable)
|
||||
#define CVAR_GET_FLOAT (*gEngfuncs.pfnGetCvarFloat)
|
||||
#define CVAR_GET_STRING (*gEngfuncs.pfnGetCvarString)
|
||||
#define CVAR_SET_FLOAT (*gEngfuncs.Cvar_SetValue)
|
||||
//#define CVAR_SET_STRING (*gEngfuncs.pfnCVarSetString) // not implemented
|
||||
#define CVAR_GET_POINTER (*gEngfuncs.pfnGetCvarPointer)
|
||||
#define ADD_COMMAND (*gEngfuncs.pfnAddCommand)
|
||||
#define CMD_ARGC (*gEngfuncs.Cmd_Argc)
|
||||
#define CMD_ARGV (*gEngfuncs.Cmd_Argv)
|
||||
#define Msg (*gEngfuncs.Con_Printf)
|
||||
|
||||
#define GET_LOCAL_PLAYER (*gEngfuncs.GetLocalPlayer)
|
||||
#define GET_VIEWMODEL (*gEngfuncs.GetViewModel)
|
||||
#define GET_ENTITY (*gEngfuncs.GetEntityByIndex)
|
||||
|
||||
#define POINT_CONTENTS( p ) (*gEngfuncs.PM_PointContents)( p, NULL )
|
||||
#define WATER_ENTITY (*gEngfuncs.PM_WaterEntity)
|
||||
#define RANDOM_LONG (*gEngfuncs.pfnRandomLong)
|
||||
#define RANDOM_FLOAT (*gEngfuncs.pfnRandomFloat)
|
||||
|
||||
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
|
||||
#define ServerCmd (*gEngfuncs.pfnServerCmd)
|
||||
#define ClientCmd (*gEngfuncs.pfnClientCmd)
|
||||
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
|
||||
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
|
||||
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
|
||||
|
||||
#define SPR_Load (*gEngfuncs.pfnSPR_Load)
|
||||
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
|
||||
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
|
||||
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
|
||||
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
|
||||
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive)
|
||||
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
|
||||
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
|
||||
#define FillRGBA (*gEngfuncs.pfnFillRGBA)
|
||||
#define SPR_Height (*gEngfuncs.pfnSPR_Height)
|
||||
#define SPR_Width (*gEngfuncs.pfnSPR_Width)
|
||||
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList)
|
||||
#define SPR_LoadEx (*gRenderfuncs.SPR_LoadExt)
|
||||
|
||||
#define ConsolePrint (*gEngfuncs.pfnConsolePrint)
|
||||
#define CenterPrint (*gEngfuncs.pfnCenterPrint)
|
||||
#define TextMessageGet (*gEngfuncs.pfnTextMessageGet)
|
||||
#define TextMessageDrawChar (*gEngfuncs.pfnDrawCharacter)
|
||||
#define DrawConsoleString (*gEngfuncs.pfnDrawConsoleString)
|
||||
#define GetConsoleStringSize (*gEngfuncs.pfnDrawConsoleStringLen)
|
||||
#define DrawSetTextColor (*gEngfuncs.pfnDrawSetTextColor)
|
||||
|
||||
#define LOAD_FILE( x, y ) (*gEngfuncs.COM_LoadFile)( x, 5, y )
|
||||
#define FREE_FILE (*gEngfuncs.COM_FreeFile)
|
||||
#define SAVE_FILE (*gRenderfuncs.pfnSaveFile)
|
||||
|
||||
#define Sys_DoubleTime (*gRenderfuncs.pfnTime)
|
||||
|
||||
// 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( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
|
||||
|
||||
// render api callbacks
|
||||
#define RENDER_GET_PARM (*gRenderfuncs.RenderGetParm)
|
||||
#define SET_CURRENT_ENTITY (*gRenderfuncs.R_SetCurrentEntity)
|
||||
#define SET_CURRENT_MODEL (*gRenderfuncs.R_SetCurrentModel)
|
||||
#define ENGINE_SET_PVS (*gRenderfuncs.R_FatPVS)
|
||||
#define HOST_ERROR (*gRenderfuncs.Host_Error)
|
||||
#define GET_LIGHTSTYLE (*gRenderfuncs.GetLightStyle)
|
||||
#define GET_DYNAMIC_LIGHT (*gRenderfuncs.GetDynamicLight)
|
||||
#define GET_ENTITY_LIGHT (*gRenderfuncs.GetEntityLight)
|
||||
#define TEXTURE_TO_TEXGAMMA (*gRenderfuncs.LightToTexGamma)
|
||||
#define GET_FRAMETIME (*gRenderfuncs.GetFrameTime)
|
||||
#define DRAW_SINGLE_DECAL (*gRenderfuncs.DrawSingleDecal)
|
||||
#define DECAL_SETUP_VERTS (*gRenderfuncs.R_DecalSetupVerts)
|
||||
#define GET_DETAIL_SCALE (*gRenderfuncs.GetDetailScaleForTexture)
|
||||
#define GET_EXTRA_PARAMS (*gRenderfuncs.GetExtraParmsForTexture)
|
||||
#define CREATE_TEXTURE (*gRenderfuncs.GL_CreateTexture)
|
||||
#define FIND_TEXTURE (*gRenderfuncs.GL_FindTexture)
|
||||
#define FREE_TEXTURE (*gRenderfuncs.GL_FreeTexture)
|
||||
#define CREATE_TEXTURE_ARRAY (*gRenderfuncs.GL_CreateTextureArray)
|
||||
#define STORE_EFRAGS (*gRenderfuncs.R_StoreEfrags)
|
||||
#define INIT_BEAMCHAINS (*gRenderfuncs.GetBeamChains)
|
||||
#define DRAW_PARTICLES (*gRenderfuncs.GL_DrawParticles)
|
||||
#define SET_ENGINE_WORLDVIEW_MATRIX (*gRenderfuncs.GL_SetWorldviewProjectionMatrix)
|
||||
#define GET_FOG_PARAMS (*gRenderfuncs.GetExtraParmsForTexture)
|
||||
#define GET_TEXTURE_NAME (*gRenderfuncs.GL_TextureName)
|
||||
#define GET_TEXTURE_DATA (*gRenderfuncs.GL_TextureData)
|
||||
#define COMPARE_FILE_TIME (*gRenderfuncs.COM_CompareFileTime)
|
||||
#define REMOVE_BSP_DECALS (*gRenderfuncs.R_EntityRemoveDecals)
|
||||
#define STUDIO_GET_TEXTURE (*gRenderfuncs.StudioGetTexture)
|
||||
#define GET_OVERVIEW_PARMS (*gRenderfuncs.GetOverviewParms)
|
||||
#define FS_SEARCH (*gRenderfuncs.pfnGetFilesList)
|
||||
#define ENV_SHOT (*gRenderfuncs.EnvShot)
|
||||
|
||||
#define LOAD_TEXTURE (*gRenderfuncs.GL_LoadTexture)
|
||||
#define LOAD_TEXTURE_ARRAY (*gRenderfuncs.GL_LoadTextureArray)
|
||||
|
||||
// AVIKit interface
|
||||
#define OPEN_CINEMATIC (*gRenderfuncs.AVI_LoadVideo)
|
||||
#define FREE_CINEMATIC (*gRenderfuncs.AVI_FreeVideo)
|
||||
#define CIN_IS_ACTIVE (*gRenderfuncs.AVI_IsActive)
|
||||
#define CIN_GET_VIDEO_INFO (*gRenderfuncs.AVI_GetVideoInfo)
|
||||
#define CIN_GET_FRAME_NUMBER (*gRenderfuncs.AVI_GetVideoFrameNumber)
|
||||
#define CIN_GET_FRAMEDATA (*gRenderfuncs.AVI_GetVideoFrame)
|
||||
#define CIN_UPLOAD_FRAME (*gRenderfuncs.AVI_UploadRawFrame)
|
||||
#define CIN_UPDATE_SOUND (*gRenderfuncs.AVI_StreamSound)
|
||||
|
||||
// glcommands
|
||||
#define GL_BindTexture (*gRenderfuncs.GL_Bind)
|
||||
#define GL_SelectTexture (*gRenderfuncs.GL_SelectTexture)
|
||||
#define GL_TexGen (*gRenderfuncs.GL_TexGen)
|
||||
#define GL_LoadTextureMatrix (*gRenderfuncs.GL_LoadTextureMatrix)
|
||||
#define GL_LoadIdentityTexMatrix (*gRenderfuncs.GL_TexMatrixIdentity)
|
||||
#define GL_CleanUpTextureUnits (*gRenderfuncs.GL_CleanUpTextureUnits)
|
||||
#define GL_TexCoordArrayMode (*gRenderfuncs.GL_TexCoordArrayMode)
|
||||
#define GL_TextureTarget (*gRenderfuncs.GL_TextureTarget)
|
||||
#define GL_UpdateTexSize (*gRenderfuncs.GL_UpdateTexSize)
|
||||
|
||||
#define RANDOM_SEED (*gRenderfuncs.SetRandomSeed)
|
||||
#define MUSIC_FADE_VOLUME (*gRenderfuncs.S_FadeMusicVolume)
|
||||
|
||||
#define GL_GetProcAddress (*gRenderfuncs.GL_GetProcAddress)
|
||||
|
||||
#define MODEL_HANDLE (*gRenderfuncs.pfnGetModel)
|
||||
|
||||
// built-in memory manager
|
||||
#define Mem_Alloc( x ) (*gRenderfuncs.pfnMemAlloc)( x, __FILE__, __LINE__ )
|
||||
#define Mem_Free( x ) (*gRenderfuncs.pfnMemFree)( x, __FILE__, __LINE__ )
|
||||
#define _Mem_Alloc (*gRenderfuncs.pfnMemAlloc)
|
||||
#define _Mem_Free (*gRenderfuncs.pfnMemFree)
|
||||
|
||||
#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 )))
|
||||
|
||||
extern void ALERT( ALERT_TYPE level, char *szFmt, ... );
|
||||
|
||||
inline bool FILE_EXISTS( const char *filename )
|
||||
{
|
||||
int iCompare;
|
||||
|
||||
// verify file exists
|
||||
// g-cont. idea! use COMPARE_FILE_TIME instead of COM_LoadFile
|
||||
if( COMPARE_FILE_TIME( filename, filename, &iCompare ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#define FILE_CRC32 (*gRenderfuncs.pfnFileBufferCRC32)
|
||||
#define GET_MAX_CLIENTS (*gEngfuncs.GetMaxClients)
|
||||
|
||||
/*
|
||||
enginecallback.h - actual engine callbacks
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef ENGINECALLBACK_H
|
||||
#define ENGINECALLBACK_H
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
extern render_api_t gRenderfuncs;
|
||||
|
||||
#define GET_CLIENT_TIME (*gEngfuncs.GetClientTime)
|
||||
#define GET_CLIENT_OLDTIME (*gEngfuncs.GetClientOldTime)
|
||||
#define CVAR_REGISTER (*gEngfuncs.pfnRegisterVariable)
|
||||
#define CVAR_GET_FLOAT (*gEngfuncs.pfnGetCvarFloat)
|
||||
#define CVAR_GET_STRING (*gEngfuncs.pfnGetCvarString)
|
||||
#define CVAR_SET_FLOAT (*gEngfuncs.Cvar_SetValue)
|
||||
//#define CVAR_SET_STRING (*gEngfuncs.pfnCVarSetString) // not implemented
|
||||
#define CVAR_GET_POINTER (*gEngfuncs.pfnGetCvarPointer)
|
||||
#define ADD_COMMAND (*gEngfuncs.pfnAddCommand)
|
||||
#define CMD_ARGC (*gEngfuncs.Cmd_Argc)
|
||||
#define CMD_ARGV (*gEngfuncs.Cmd_Argv)
|
||||
#define Msg (*gEngfuncs.Con_Printf)
|
||||
|
||||
#define GET_LOCAL_PLAYER (*gEngfuncs.GetLocalPlayer)
|
||||
#define GET_VIEWMODEL (*gEngfuncs.GetViewModel)
|
||||
#define GET_ENTITY (*gEngfuncs.GetEntityByIndex)
|
||||
|
||||
#define POINT_CONTENTS( p ) (*gEngfuncs.PM_PointContents)( p, NULL )
|
||||
#define WATER_ENTITY (*gEngfuncs.PM_WaterEntity)
|
||||
#define RANDOM_LONG (*gEngfuncs.pfnRandomLong)
|
||||
#define RANDOM_FLOAT (*gEngfuncs.pfnRandomFloat)
|
||||
|
||||
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
|
||||
#define ServerCmd (*gEngfuncs.pfnServerCmd)
|
||||
#define ClientCmd (*gEngfuncs.pfnClientCmd)
|
||||
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
|
||||
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
|
||||
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
|
||||
|
||||
#define SPR_Load (*gEngfuncs.pfnSPR_Load)
|
||||
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
|
||||
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
|
||||
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
|
||||
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
|
||||
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive)
|
||||
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
|
||||
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
|
||||
#define FillRGBA (*gEngfuncs.pfnFillRGBA)
|
||||
#define SPR_Height (*gEngfuncs.pfnSPR_Height)
|
||||
#define SPR_Width (*gEngfuncs.pfnSPR_Width)
|
||||
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList)
|
||||
#define SPR_LoadEx (*gRenderfuncs.SPR_LoadExt)
|
||||
|
||||
#define ConsolePrint (*gEngfuncs.pfnConsolePrint)
|
||||
#define CenterPrint (*gEngfuncs.pfnCenterPrint)
|
||||
#define TextMessageGet (*gEngfuncs.pfnTextMessageGet)
|
||||
#define TextMessageDrawChar (*gEngfuncs.pfnDrawCharacter)
|
||||
#define DrawConsoleString (*gEngfuncs.pfnDrawConsoleString)
|
||||
#define GetConsoleStringSize (*gEngfuncs.pfnDrawConsoleStringLen)
|
||||
#define DrawSetTextColor (*gEngfuncs.pfnDrawSetTextColor)
|
||||
|
||||
#define LOAD_FILE( x, y ) (*gEngfuncs.COM_LoadFile)( x, 5, y )
|
||||
#define FREE_FILE (*gEngfuncs.COM_FreeFile)
|
||||
#define SAVE_FILE (*gRenderfuncs.pfnSaveFile)
|
||||
|
||||
#define Sys_DoubleTime (*gRenderfuncs.pfnTime)
|
||||
|
||||
// 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( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
|
||||
|
||||
// render api callbacks
|
||||
#define RENDER_GET_PARM (*gRenderfuncs.RenderGetParm)
|
||||
#define SET_CURRENT_ENTITY (*gRenderfuncs.R_SetCurrentEntity)
|
||||
#define SET_CURRENT_MODEL (*gRenderfuncs.R_SetCurrentModel)
|
||||
#define ENGINE_SET_PVS (*gRenderfuncs.R_FatPVS)
|
||||
#define HOST_ERROR (*gRenderfuncs.Host_Error)
|
||||
#define GET_LIGHTSTYLE (*gRenderfuncs.GetLightStyle)
|
||||
#define GET_DYNAMIC_LIGHT (*gRenderfuncs.GetDynamicLight)
|
||||
#define GET_ENTITY_LIGHT (*gRenderfuncs.GetEntityLight)
|
||||
#define TEXTURE_TO_TEXGAMMA (*gRenderfuncs.LightToTexGamma)
|
||||
#define GET_FRAMETIME (*gRenderfuncs.GetFrameTime)
|
||||
#define DRAW_SINGLE_DECAL (*gRenderfuncs.DrawSingleDecal)
|
||||
#define DECAL_SETUP_VERTS (*gRenderfuncs.R_DecalSetupVerts)
|
||||
#define GET_DETAIL_SCALE (*gRenderfuncs.GetDetailScaleForTexture)
|
||||
#define GET_EXTRA_PARAMS (*gRenderfuncs.GetExtraParmsForTexture)
|
||||
#define CREATE_TEXTURE (*gRenderfuncs.GL_CreateTexture)
|
||||
#define FIND_TEXTURE (*gRenderfuncs.GL_FindTexture)
|
||||
#define FREE_TEXTURE (*gRenderfuncs.GL_FreeTexture)
|
||||
#define CREATE_TEXTURE_ARRAY (*gRenderfuncs.GL_CreateTextureArray)
|
||||
#define STORE_EFRAGS (*gRenderfuncs.R_StoreEfrags)
|
||||
#define INIT_BEAMCHAINS (*gRenderfuncs.GetBeamChains)
|
||||
#define DRAW_PARTICLES (*gRenderfuncs.GL_DrawParticles)
|
||||
#define SET_ENGINE_WORLDVIEW_MATRIX (*gRenderfuncs.GL_SetWorldviewProjectionMatrix)
|
||||
#define GET_FOG_PARAMS (*gRenderfuncs.GetExtraParmsForTexture)
|
||||
#define GET_TEXTURE_NAME (*gRenderfuncs.GL_TextureName)
|
||||
#define GET_TEXTURE_DATA (*gRenderfuncs.GL_TextureData)
|
||||
#define COMPARE_FILE_TIME (*gRenderfuncs.COM_CompareFileTime)
|
||||
#define REMOVE_BSP_DECALS (*gRenderfuncs.R_EntityRemoveDecals)
|
||||
#define STUDIO_GET_TEXTURE (*gRenderfuncs.StudioGetTexture)
|
||||
#define GET_OVERVIEW_PARMS (*gRenderfuncs.GetOverviewParms)
|
||||
#define FS_SEARCH (*gRenderfuncs.pfnGetFilesList)
|
||||
#define ENV_SHOT (*gRenderfuncs.EnvShot)
|
||||
|
||||
#define LOAD_TEXTURE (*gRenderfuncs.GL_LoadTexture)
|
||||
#define LOAD_TEXTURE_ARRAY (*gRenderfuncs.GL_LoadTextureArray)
|
||||
|
||||
// AVIKit interface
|
||||
#define OPEN_CINEMATIC (*gRenderfuncs.AVI_LoadVideo)
|
||||
#define FREE_CINEMATIC (*gRenderfuncs.AVI_FreeVideo)
|
||||
#define CIN_IS_ACTIVE (*gRenderfuncs.AVI_IsActive)
|
||||
#define CIN_GET_VIDEO_INFO (*gRenderfuncs.AVI_GetVideoInfo)
|
||||
#define CIN_GET_FRAME_NUMBER (*gRenderfuncs.AVI_GetVideoFrameNumber)
|
||||
#define CIN_GET_FRAMEDATA (*gRenderfuncs.AVI_GetVideoFrame)
|
||||
#define CIN_UPLOAD_FRAME (*gRenderfuncs.AVI_UploadRawFrame)
|
||||
#define CIN_UPDATE_SOUND (*gRenderfuncs.AVI_StreamSound)
|
||||
|
||||
// glcommands
|
||||
#define GL_BindTexture (*gRenderfuncs.GL_Bind)
|
||||
#define GL_SelectTexture (*gRenderfuncs.GL_SelectTexture)
|
||||
#define GL_TexGen (*gRenderfuncs.GL_TexGen)
|
||||
#define GL_LoadTextureMatrix (*gRenderfuncs.GL_LoadTextureMatrix)
|
||||
#define GL_LoadIdentityTexMatrix (*gRenderfuncs.GL_TexMatrixIdentity)
|
||||
#define GL_CleanUpTextureUnits (*gRenderfuncs.GL_CleanUpTextureUnits)
|
||||
#define GL_TexCoordArrayMode (*gRenderfuncs.GL_TexCoordArrayMode)
|
||||
#define GL_TextureTarget (*gRenderfuncs.GL_TextureTarget)
|
||||
#define GL_UpdateTexSize (*gRenderfuncs.GL_UpdateTexSize)
|
||||
|
||||
#define RANDOM_SEED (*gRenderfuncs.SetRandomSeed)
|
||||
#define MUSIC_FADE_VOLUME (*gRenderfuncs.S_FadeMusicVolume)
|
||||
|
||||
#define GL_GetProcAddress (*gRenderfuncs.GL_GetProcAddress)
|
||||
|
||||
#define MODEL_HANDLE (*gRenderfuncs.pfnGetModel)
|
||||
|
||||
// built-in memory manager
|
||||
#define Mem_Alloc( x ) (*gRenderfuncs.pfnMemAlloc)( x, __FILE__, __LINE__ )
|
||||
#define Mem_Free( x ) (*gRenderfuncs.pfnMemFree)( x, __FILE__, __LINE__ )
|
||||
#define _Mem_Alloc (*gRenderfuncs.pfnMemAlloc)
|
||||
#define _Mem_Free (*gRenderfuncs.pfnMemFree)
|
||||
|
||||
#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 )))
|
||||
|
||||
extern void ALERT( ALERT_TYPE level, char *szFmt, ... );
|
||||
|
||||
inline bool FILE_EXISTS( const char *filename )
|
||||
{
|
||||
int iCompare;
|
||||
|
||||
// verify file exists
|
||||
// g-cont. idea! use COMPARE_FILE_TIME instead of COM_LoadFile
|
||||
if( COMPARE_FILE_TIME( filename, filename, &iCompare ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#define FILE_CRC32 (*gRenderfuncs.pfnFileBufferCRC32)
|
||||
#define GET_MAX_CLIENTS (*gEngfuncs.GetMaxClients)
|
||||
|
||||
#endif//ENGINECALLBACK_H
|
1872
cl_dll/entity.cpp
1872
cl_dll/entity.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,205 +1,205 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// shared event functions
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
|
||||
#include "r_efx.h"
|
||||
|
||||
#include "eventscripts.h"
|
||||
#include "event_api.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)) )
|
||||
/*
|
||||
=================
|
||||
GetEntity
|
||||
|
||||
Return's the requested cl_entity_t
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetEntity( int idx )
|
||||
{
|
||||
return gEngfuncs.GetEntityByIndex( idx );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GetViewEntity
|
||||
|
||||
Return's the current weapon/view model
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_CreateTracer
|
||||
|
||||
Creates a tracer effect
|
||||
=================
|
||||
*/
|
||||
void EV_CreateTracer( float *start, float *end )
|
||||
{
|
||||
gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsPlayer
|
||||
|
||||
Is the entity's index in the player range?
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsPlayer( int idx )
|
||||
{
|
||||
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsLocal
|
||||
|
||||
Is the entity == the local player
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsLocal( int idx )
|
||||
{
|
||||
// check if we are in some way in first person spec mode
|
||||
if ( IS_FIRSTPERSON_SPEC )
|
||||
return (g_iUser2 == idx);
|
||||
else
|
||||
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetGunPosition
|
||||
|
||||
Figure out the height of the gun
|
||||
=================
|
||||
*/
|
||||
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
|
||||
{
|
||||
int idx;
|
||||
vec3_t view_ofs;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( idx ) )
|
||||
{
|
||||
// in spec mode use entity viewheigh, not own
|
||||
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
|
||||
{
|
||||
// Grab predicted result for local player
|
||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
VectorAdd( origin, view_ofs, pos );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_EjectBrass
|
||||
|
||||
Bullet shell casings
|
||||
=================
|
||||
*/
|
||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
|
||||
{
|
||||
Vector endpos = Vector( 0.0f, rotation, 0.0f );
|
||||
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, RANDOM_FLOAT( 1.5f, 3.0f ), model, soundtype );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetDefaultShellInfo
|
||||
|
||||
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 )
|
||||
{
|
||||
int i;
|
||||
vec3_t view_ofs;
|
||||
float fR, fU;
|
||||
|
||||
int idx;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( idx ) )
|
||||
{
|
||||
if ( EV_IsLocal( idx ) )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
// fR = gEngfuncs.pfnRandomFloat( 50, 70 );
|
||||
// fU = gEngfuncs.pfnRandomFloat( 100, 150 );
|
||||
fR = gEngfuncs.pfnRandomFloat( 80, 120 );
|
||||
fU = gEngfuncs.pfnRandomFloat( 10, 30 ); // buz
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_MuzzleFlash
|
||||
|
||||
Flag weapon/view model for muzzle flash
|
||||
=================
|
||||
*/
|
||||
void EV_MuzzleFlash( void )
|
||||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
cl_entity_t *ent = GetViewEntity();
|
||||
if ( !ent )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Or in the muzzle flash
|
||||
ent->curstate.effects |= EF_MUZZLEFLASH;
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// shared event functions
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
|
||||
#include "r_efx.h"
|
||||
|
||||
#include "eventscripts.h"
|
||||
#include "event_api.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)) )
|
||||
/*
|
||||
=================
|
||||
GetEntity
|
||||
|
||||
Return's the requested cl_entity_t
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetEntity( int idx )
|
||||
{
|
||||
return gEngfuncs.GetEntityByIndex( idx );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GetViewEntity
|
||||
|
||||
Return's the current weapon/view model
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_CreateTracer
|
||||
|
||||
Creates a tracer effect
|
||||
=================
|
||||
*/
|
||||
void EV_CreateTracer( float *start, float *end )
|
||||
{
|
||||
gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsPlayer
|
||||
|
||||
Is the entity's index in the player range?
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsPlayer( int idx )
|
||||
{
|
||||
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsLocal
|
||||
|
||||
Is the entity == the local player
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsLocal( int idx )
|
||||
{
|
||||
// check if we are in some way in first person spec mode
|
||||
if ( IS_FIRSTPERSON_SPEC )
|
||||
return (g_iUser2 == idx);
|
||||
else
|
||||
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetGunPosition
|
||||
|
||||
Figure out the height of the gun
|
||||
=================
|
||||
*/
|
||||
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
|
||||
{
|
||||
int idx;
|
||||
vec3_t view_ofs;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( idx ) )
|
||||
{
|
||||
// in spec mode use entity viewheigh, not own
|
||||
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
|
||||
{
|
||||
// Grab predicted result for local player
|
||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
VectorAdd( origin, view_ofs, pos );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_EjectBrass
|
||||
|
||||
Bullet shell casings
|
||||
=================
|
||||
*/
|
||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
|
||||
{
|
||||
Vector endpos = Vector( 0.0f, rotation, 0.0f );
|
||||
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, RANDOM_FLOAT( 1.5f, 3.0f ), model, soundtype );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetDefaultShellInfo
|
||||
|
||||
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 )
|
||||
{
|
||||
int i;
|
||||
vec3_t view_ofs;
|
||||
float fR, fU;
|
||||
|
||||
int idx;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( idx ) )
|
||||
{
|
||||
if ( EV_IsLocal( idx ) )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
// fR = gEngfuncs.pfnRandomFloat( 50, 70 );
|
||||
// fU = gEngfuncs.pfnRandomFloat( 100, 150 );
|
||||
fR = gEngfuncs.pfnRandomFloat( 80, 120 );
|
||||
fU = gEngfuncs.pfnRandomFloat( 10, 30 ); // buz
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_MuzzleFlash
|
||||
|
||||
Flag weapon/view model for muzzle flash
|
||||
=================
|
||||
*/
|
||||
void EV_MuzzleFlash( void )
|
||||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
cl_entity_t *ent = GetViewEntity();
|
||||
if ( !ent )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Or in the muzzle flash
|
||||
ent->curstate.effects |= EF_MUZZLEFLASH;
|
||||
}
|
|
@ -1,44 +1,44 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "../hud.h"
|
||||
#include "../cl_util.h"
|
||||
#include "event_api.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void EV_FireGeneric( struct event_args_s *args );
|
||||
void EV_TrainPitchAdjust( struct event_args_s *args );
|
||||
void EV_SmokePuff( struct event_args_s *args );
|
||||
}
|
||||
|
||||
/*
|
||||
======================
|
||||
Game_HookEvents
|
||||
|
||||
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
|
||||
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
|
||||
that.. i.e., a scripting system.
|
||||
|
||||
That was what we were going to do, but we ran out of time...oh well.
|
||||
======================
|
||||
*/
|
||||
void Game_HookEvents( void )
|
||||
{
|
||||
gEngfuncs.pfnHookEvent( "evTrainSound", EV_TrainPitchAdjust );
|
||||
gEngfuncs.pfnHookEvent( "evSmokePuff", EV_SmokePuff );
|
||||
gEngfuncs.pfnHookEvent( "evFireGeneric", EV_FireGeneric );
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "../hud.h"
|
||||
#include "../cl_util.h"
|
||||
#include "event_api.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void EV_FireGeneric( struct event_args_s *args );
|
||||
void EV_TrainPitchAdjust( struct event_args_s *args );
|
||||
void EV_SmokePuff( struct event_args_s *args );
|
||||
}
|
||||
|
||||
/*
|
||||
======================
|
||||
Game_HookEvents
|
||||
|
||||
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
|
||||
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
|
||||
that.. i.e., a scripting system.
|
||||
|
||||
That was what we were going to do, but we ran out of time...oh well.
|
||||
======================
|
||||
*/
|
||||
void Game_HookEvents( void )
|
||||
{
|
||||
gEngfuncs.pfnHookEvent( "evTrainSound", EV_TrainPitchAdjust );
|
||||
gEngfuncs.pfnHookEvent( "evSmokePuff", EV_SmokePuff );
|
||||
gEngfuncs.pfnHookEvent( "evFireGeneric", EV_FireGeneric );
|
||||
}
|
|
@ -1,418 +1,418 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "entity_types.h"
|
||||
#include "usercmd.h"
|
||||
#include "pm_defs.h"
|
||||
|
||||
#include "eventscripts.h"
|
||||
#include "ev_hldm.h"
|
||||
|
||||
#include "r_efx.h"
|
||||
#include "event_api.h"
|
||||
#include "event_args.h"
|
||||
#include "in_defs.h"
|
||||
#include "gl_rpart.h"
|
||||
#include <string.h>
|
||||
#include "material.h"
|
||||
#include "r_studioint.h"
|
||||
#include "com_model.h"
|
||||
#include "studio.h"
|
||||
|
||||
extern engine_studio_api_t IEngineStudio;
|
||||
|
||||
static int tracerCount[ 32 ];
|
||||
|
||||
void V_PunchAxis( int axis, float punch );
|
||||
void VectorAngles( const float *forward, float *angles );
|
||||
|
||||
extern cvar_t *cl_lw;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void EV_FireGeneric( struct event_args_s *args );
|
||||
void EV_TrainPitchAdjust( 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
|
||||
// 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
|
||||
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
|
||||
char *rgsz[MAX_MAT_SOUNDS];
|
||||
float fattn = ATTN_NORM;
|
||||
int cnt = 0;
|
||||
|
||||
physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( ptr->ent );
|
||||
|
||||
matdef_t *pMat = NULL;
|
||||
|
||||
if( pe )
|
||||
{
|
||||
if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP )
|
||||
pMat = COM_MatDefFromSurface( gEngfuncs.pEventAPI->EV_TraceSurface( ptr->ent, (float *)&vecSrc, (float *)&vecEnd ), ptr->endpos );
|
||||
else if( pe->solid == SOLID_CUSTOM && ptr->surf )
|
||||
pMat = ptr->surf->effects;
|
||||
|
||||
if( !pMat ) return;
|
||||
|
||||
// fire effects
|
||||
for( cnt = 0; pMat->impact_parts[cnt] != NULL; cnt++ )
|
||||
g_pParticles.CreateEffect( pMat->impact_parts[cnt], ptr->endpos, ptr->plane.normal );
|
||||
|
||||
// count sounds
|
||||
for( cnt = 0; pMat->impact_sounds[cnt] != NULL; cnt++ )
|
||||
rgsz[cnt] = (char *)pMat->impact_sounds[cnt];
|
||||
}
|
||||
|
||||
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 ));
|
||||
}
|
||||
|
||||
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, const Vector &vecSrc, const Vector &vecEnd )
|
||||
{
|
||||
if( pTrace->inwater ) return;
|
||||
|
||||
int iRand = RANDOM_LONG( 0, 0x7FFF );
|
||||
|
||||
if( iRand < ( 0x7fff / 2 )) // not every bullet makes a sound.
|
||||
{
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
|
||||
physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent );
|
||||
|
||||
matdef_t *pMat = NULL;
|
||||
|
||||
if( pe )
|
||||
{
|
||||
if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP )
|
||||
{
|
||||
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 ));
|
||||
}
|
||||
else if( pe->solid == SOLID_CUSTOM && pTrace->surf )
|
||||
{
|
||||
pMat = pTrace->surf->effects;
|
||||
if ( pMat ) UTIL_StudioDecal( pMat->impact_decal, pTrace, vecSrc );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
FireBullets
|
||||
|
||||
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 )
|
||||
{
|
||||
int i;
|
||||
pmtrace_t tr;
|
||||
int iShot;
|
||||
|
||||
for ( iShot = 1; iShot <= cShots; iShot++ )
|
||||
{
|
||||
Vector vecDir, vecEnd;
|
||||
|
||||
float x, y, z;
|
||||
|
||||
// We randomize for the Shotgun.
|
||||
if ( iBulletType == BULLET_BUCKSHOT )
|
||||
{
|
||||
do {
|
||||
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 );
|
||||
z = x * x + y * y;
|
||||
} while( z > 1.0f );
|
||||
|
||||
for ( i = 0 ; i < 3; i++ )
|
||||
{
|
||||
vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up[i];
|
||||
vecEnd[i] = vecSrc[i] + flDistance * vecDir[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// but other guns already have their spread randomized in the synched spread.
|
||||
for ( i = 0 ; i < 3; i++ )
|
||||
{
|
||||
vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up[i];
|
||||
vecEnd[i] = vecSrc[i] + flDistance * vecDir[i];
|
||||
}
|
||||
}
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
|
||||
|
||||
// Store off the old count
|
||||
gEngfuncs.pEventAPI->EV_PushPMStates();
|
||||
|
||||
// Now add in all of the players.
|
||||
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, 0, -1, &tr );
|
||||
|
||||
// do damage, paint decals
|
||||
if ( tr.fraction != 1.0 && !tr.inwater ) // buz: dont smoke and particle if shoot in sky
|
||||
{
|
||||
EV_HLDM_PlayTextureSound( &tr, vecSrc, vecEnd );
|
||||
EV_HLDM_GunshotDecalTrace( &tr, vecSrc, vecEnd );
|
||||
}
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PopPMStates();
|
||||
}
|
||||
}
|
||||
|
||||
//======================
|
||||
// WEAPON GENERIC START
|
||||
//======================
|
||||
void EV_FireGeneric( struct event_args_s *args )
|
||||
{
|
||||
int idx;
|
||||
Vector origin;
|
||||
Vector angles;
|
||||
Vector velocity;
|
||||
|
||||
Vector ShellVelocity;
|
||||
Vector ShellOrigin;
|
||||
Vector vecSrc, vecAiming;
|
||||
Vector up, right, forward;
|
||||
float flSpread = 0.01;
|
||||
|
||||
idx = args->entindex;
|
||||
VectorCopy( args->origin, origin );
|
||||
VectorCopy( args->angles, angles );
|
||||
VectorCopy( args->velocity, velocity );
|
||||
|
||||
AngleVectors( angles, forward, right, up );
|
||||
|
||||
int shell = args->bparam1; // brass shell
|
||||
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 );
|
||||
|
||||
if( EV_IsLocal( idx ))
|
||||
{
|
||||
// add muzzle flash to current weapon model
|
||||
EV_MuzzleFlash();
|
||||
|
||||
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 ));
|
||||
|
||||
cl_entity_t *ent = GetViewEntity();
|
||||
if( ent ) ShellOrigin = ent->attachment[1];
|
||||
}
|
||||
|
||||
int numShots = ((args->iparam1 >> 12) & 0xF);
|
||||
int soundType = TE_BOUNCE_SHELL;
|
||||
int bulletType = BULLET_NORMAL;
|
||||
float flDist = 8192.0f;
|
||||
|
||||
// shotgun case
|
||||
if( numShots > 1 )
|
||||
{
|
||||
bulletType = BULLET_BUCKSHOT;
|
||||
soundType = TE_BOUNCE_SHOTSHELL;
|
||||
flDist = 2048.0f;
|
||||
}
|
||||
|
||||
EV_EjectBrass( ShellOrigin, ShellVelocity , RANDOM_FLOAT( -angles[YAW], angles[YAW] ), shell, soundType );
|
||||
|
||||
if( 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 ));
|
||||
}
|
||||
|
||||
EV_GetGunPosition( args, vecSrc, origin );
|
||||
|
||||
VectorCopy( forward, vecAiming );
|
||||
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, numShots, vecSrc, vecAiming, flDist, bulletType, 2, &tracerCount[idx-1], args->fparam1, args->fparam2 );
|
||||
}
|
||||
//======================
|
||||
// WEAPON GENERIC END
|
||||
//======================
|
||||
#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch
|
||||
|
||||
void EV_TrainPitchAdjust( event_args_t *args )
|
||||
{
|
||||
int idx;
|
||||
Vector origin;
|
||||
|
||||
unsigned short us_params;
|
||||
int noise;
|
||||
float m_flVolume;
|
||||
int pitch;
|
||||
int stop;
|
||||
|
||||
char sz[ 256 ];
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorCopy( args->origin, origin );
|
||||
|
||||
us_params = (unsigned short)args->iparam1;
|
||||
stop = args->bparam1;
|
||||
|
||||
m_flVolume = (float)(us_params & 0x003f)/40.0;
|
||||
noise = (int)(((us_params) >> 12 ) & 0x0007);
|
||||
pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
|
||||
|
||||
switch ( noise )
|
||||
{
|
||||
case 1: strcpy( sz, "plats/ttrain1.wav"); break;
|
||||
case 2: strcpy( sz, "plats/ttrain2.wav"); break;
|
||||
case 3: strcpy( sz, "plats/ttrain3.wav"); break;
|
||||
case 4: strcpy( sz, "plats/ttrain4.wav"); break;
|
||||
case 5: strcpy( sz, "plats/ttrain6.wav"); break;
|
||||
case 6: strcpy( sz, "plats/ttrain7.wav"); break;
|
||||
default:
|
||||
// no sound
|
||||
strcpy( sz, "" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( stop )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz );
|
||||
}
|
||||
else
|
||||
{
|
||||
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 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// buz: smokepuff event - for invoke puffs from server, when monsters firing, etc..
|
||||
void EV_SmokePuff( struct event_args_s *args )
|
||||
{
|
||||
VectorNormalize(args->angles); // there is surface normal actually
|
||||
g_pParticles.BulletParticles( args->origin, args->angles );
|
||||
}
|
||||
|
||||
void EV_GunSmoke( const Vector &pos )
|
||||
{
|
||||
g_pParticles.GunSmoke( pos, 2 );
|
||||
}
|
||||
|
||||
void EV_ExplodeSmoke( const Vector &pos )
|
||||
{
|
||||
g_pParticles.SmokeParticles( pos, 10 );
|
||||
}
|
||||
|
||||
void EV_HLDM_WaterSplash( float x, float y, float z, float ScaleSplash1, float ScaleSplash2 )
|
||||
{
|
||||
int iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash1.spr");
|
||||
TEMPENTITY *pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15 ),
|
||||
Vector( 0, 0, 0 ),
|
||||
/*ScaleSplash1*/0.2, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL );
|
||||
|
||||
if(pTemp)
|
||||
{
|
||||
pTemp->fadeSpeed = 90.0;
|
||||
pTemp->entity.curstate.framerate = 70.0;
|
||||
pTemp->entity.curstate.renderamt = 155;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
}
|
||||
|
||||
iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash2.spr");
|
||||
pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z ),
|
||||
Vector( 0, 0, 0 ),
|
||||
/*ScaleSplash2*/0.08, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL );
|
||||
|
||||
if(pTemp)
|
||||
{
|
||||
pTemp->fadeSpeed = 60.0;
|
||||
pTemp->entity.curstate.framerate = 60.0;
|
||||
pTemp->entity.curstate.renderamt = 150;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
pTemp->entity.angles = Vector( 90, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void EV_HLDM_NewExplode( float x, float y, float z, float ScaleExplode1 )
|
||||
{
|
||||
float rnd = gEngfuncs.pfnRandomFloat( -0.03, 0.03 );
|
||||
int iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/dexplo.spr");
|
||||
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 );
|
||||
|
||||
if( pTemp )
|
||||
{
|
||||
pTemp->fadeSpeed = 90.0;
|
||||
pTemp->entity.curstate.framerate = 37.0;
|
||||
pTemp->entity.curstate.renderamt = 155;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
}
|
||||
|
||||
iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/fexplo.spr");
|
||||
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 );
|
||||
|
||||
if( pTemp )
|
||||
{
|
||||
pTemp->fadeSpeed = 100.0;
|
||||
pTemp->entity.curstate.framerate = 35.0;
|
||||
pTemp->entity.curstate.renderamt = 150;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
pTemp->entity.angles = Vector( 90, 0, 0 );
|
||||
}
|
||||
|
||||
iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/smokeball.spr");
|
||||
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 );
|
||||
|
||||
if( pTemp )
|
||||
{
|
||||
pTemp->fadeSpeed = 50.0;
|
||||
pTemp->entity.curstate.framerate = 22.0;
|
||||
pTemp->entity.curstate.renderamt = 120;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
pTemp->entity.angles = Vector( 90, 0, 0 );
|
||||
}
|
||||
|
||||
EV_ExplodeSmoke( Vector( x, y, z + 4.0f ));
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "entity_types.h"
|
||||
#include "usercmd.h"
|
||||
#include "pm_defs.h"
|
||||
|
||||
#include "eventscripts.h"
|
||||
#include "ev_hldm.h"
|
||||
|
||||
#include "r_efx.h"
|
||||
#include "event_api.h"
|
||||
#include "event_args.h"
|
||||
#include "in_defs.h"
|
||||
#include "gl_rpart.h"
|
||||
#include <string.h>
|
||||
#include "material.h"
|
||||
#include "r_studioint.h"
|
||||
#include "com_model.h"
|
||||
#include "studio.h"
|
||||
|
||||
extern engine_studio_api_t IEngineStudio;
|
||||
|
||||
static int tracerCount[ 32 ];
|
||||
|
||||
void V_PunchAxis( int axis, float punch );
|
||||
void VectorAngles( const float *forward, float *angles );
|
||||
|
||||
extern cvar_t *cl_lw;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void EV_FireGeneric( struct event_args_s *args );
|
||||
void EV_TrainPitchAdjust( 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
|
||||
// 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
|
||||
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
|
||||
char *rgsz[MAX_MAT_SOUNDS];
|
||||
float fattn = ATTN_NORM;
|
||||
int cnt = 0;
|
||||
|
||||
physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( ptr->ent );
|
||||
|
||||
matdef_t *pMat = NULL;
|
||||
|
||||
if( pe )
|
||||
{
|
||||
if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP )
|
||||
pMat = COM_MatDefFromSurface( gEngfuncs.pEventAPI->EV_TraceSurface( ptr->ent, (float *)&vecSrc, (float *)&vecEnd ), ptr->endpos );
|
||||
else if( pe->solid == SOLID_CUSTOM && ptr->surf )
|
||||
pMat = ptr->surf->effects;
|
||||
|
||||
if( !pMat ) return;
|
||||
|
||||
// fire effects
|
||||
for( cnt = 0; pMat->impact_parts[cnt] != NULL; cnt++ )
|
||||
g_pParticles.CreateEffect( pMat->impact_parts[cnt], ptr->endpos, ptr->plane.normal );
|
||||
|
||||
// count sounds
|
||||
for( cnt = 0; pMat->impact_sounds[cnt] != NULL; cnt++ )
|
||||
rgsz[cnt] = (char *)pMat->impact_sounds[cnt];
|
||||
}
|
||||
|
||||
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 ));
|
||||
}
|
||||
|
||||
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, const Vector &vecSrc, const Vector &vecEnd )
|
||||
{
|
||||
if( pTrace->inwater ) return;
|
||||
|
||||
int iRand = RANDOM_LONG( 0, 0x7FFF );
|
||||
|
||||
if( iRand < ( 0x7fff / 2 )) // not every bullet makes a sound.
|
||||
{
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
|
||||
physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent );
|
||||
|
||||
matdef_t *pMat = NULL;
|
||||
|
||||
if( pe )
|
||||
{
|
||||
if( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP )
|
||||
{
|
||||
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 ));
|
||||
}
|
||||
else if( pe->solid == SOLID_CUSTOM && pTrace->surf )
|
||||
{
|
||||
pMat = pTrace->surf->effects;
|
||||
if ( pMat ) UTIL_StudioDecal( pMat->impact_decal, pTrace, vecSrc );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
FireBullets
|
||||
|
||||
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 )
|
||||
{
|
||||
int i;
|
||||
pmtrace_t tr;
|
||||
int iShot;
|
||||
|
||||
for ( iShot = 1; iShot <= cShots; iShot++ )
|
||||
{
|
||||
Vector vecDir, vecEnd;
|
||||
|
||||
float x, y, z;
|
||||
|
||||
// We randomize for the Shotgun.
|
||||
if ( iBulletType == BULLET_BUCKSHOT )
|
||||
{
|
||||
do {
|
||||
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 );
|
||||
z = x * x + y * y;
|
||||
} while( z > 1.0f );
|
||||
|
||||
for ( i = 0 ; i < 3; i++ )
|
||||
{
|
||||
vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up[i];
|
||||
vecEnd[i] = vecSrc[i] + flDistance * vecDir[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// but other guns already have their spread randomized in the synched spread.
|
||||
for ( i = 0 ; i < 3; i++ )
|
||||
{
|
||||
vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up[i];
|
||||
vecEnd[i] = vecSrc[i] + flDistance * vecDir[i];
|
||||
}
|
||||
}
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
|
||||
|
||||
// Store off the old count
|
||||
gEngfuncs.pEventAPI->EV_PushPMStates();
|
||||
|
||||
// Now add in all of the players.
|
||||
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, 0, -1, &tr );
|
||||
|
||||
// do damage, paint decals
|
||||
if ( tr.fraction != 1.0 && !tr.inwater ) // buz: dont smoke and particle if shoot in sky
|
||||
{
|
||||
EV_HLDM_PlayTextureSound( &tr, vecSrc, vecEnd );
|
||||
EV_HLDM_GunshotDecalTrace( &tr, vecSrc, vecEnd );
|
||||
}
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PopPMStates();
|
||||
}
|
||||
}
|
||||
|
||||
//======================
|
||||
// WEAPON GENERIC START
|
||||
//======================
|
||||
void EV_FireGeneric( struct event_args_s *args )
|
||||
{
|
||||
int idx;
|
||||
Vector origin;
|
||||
Vector angles;
|
||||
Vector velocity;
|
||||
|
||||
Vector ShellVelocity;
|
||||
Vector ShellOrigin;
|
||||
Vector vecSrc, vecAiming;
|
||||
Vector up, right, forward;
|
||||
float flSpread = 0.01;
|
||||
|
||||
idx = args->entindex;
|
||||
VectorCopy( args->origin, origin );
|
||||
VectorCopy( args->angles, angles );
|
||||
VectorCopy( args->velocity, velocity );
|
||||
|
||||
AngleVectors( angles, forward, right, up );
|
||||
|
||||
int shell = args->bparam1; // brass shell
|
||||
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 );
|
||||
|
||||
if( EV_IsLocal( idx ))
|
||||
{
|
||||
// add muzzle flash to current weapon model
|
||||
EV_MuzzleFlash();
|
||||
|
||||
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 ));
|
||||
|
||||
cl_entity_t *ent = GetViewEntity();
|
||||
if( ent ) ShellOrigin = ent->attachment[1];
|
||||
}
|
||||
|
||||
int numShots = ((args->iparam1 >> 12) & 0xF);
|
||||
int soundType = TE_BOUNCE_SHELL;
|
||||
int bulletType = BULLET_NORMAL;
|
||||
float flDist = 8192.0f;
|
||||
|
||||
// shotgun case
|
||||
if( numShots > 1 )
|
||||
{
|
||||
bulletType = BULLET_BUCKSHOT;
|
||||
soundType = TE_BOUNCE_SHOTSHELL;
|
||||
flDist = 2048.0f;
|
||||
}
|
||||
|
||||
EV_EjectBrass( ShellOrigin, ShellVelocity , RANDOM_FLOAT( -angles[YAW], angles[YAW] ), shell, soundType );
|
||||
|
||||
if( 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 ));
|
||||
}
|
||||
|
||||
EV_GetGunPosition( args, vecSrc, origin );
|
||||
|
||||
VectorCopy( forward, vecAiming );
|
||||
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, numShots, vecSrc, vecAiming, flDist, bulletType, 2, &tracerCount[idx-1], args->fparam1, args->fparam2 );
|
||||
}
|
||||
//======================
|
||||
// WEAPON GENERIC END
|
||||
//======================
|
||||
#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch
|
||||
|
||||
void EV_TrainPitchAdjust( event_args_t *args )
|
||||
{
|
||||
int idx;
|
||||
Vector origin;
|
||||
|
||||
unsigned short us_params;
|
||||
int noise;
|
||||
float m_flVolume;
|
||||
int pitch;
|
||||
int stop;
|
||||
|
||||
char sz[ 256 ];
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorCopy( args->origin, origin );
|
||||
|
||||
us_params = (unsigned short)args->iparam1;
|
||||
stop = args->bparam1;
|
||||
|
||||
m_flVolume = (float)(us_params & 0x003f)/40.0;
|
||||
noise = (int)(((us_params) >> 12 ) & 0x0007);
|
||||
pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
|
||||
|
||||
switch ( noise )
|
||||
{
|
||||
case 1: strcpy( sz, "plats/ttrain1.wav"); break;
|
||||
case 2: strcpy( sz, "plats/ttrain2.wav"); break;
|
||||
case 3: strcpy( sz, "plats/ttrain3.wav"); break;
|
||||
case 4: strcpy( sz, "plats/ttrain4.wav"); break;
|
||||
case 5: strcpy( sz, "plats/ttrain6.wav"); break;
|
||||
case 6: strcpy( sz, "plats/ttrain7.wav"); break;
|
||||
default:
|
||||
// no sound
|
||||
strcpy( sz, "" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( stop )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz );
|
||||
}
|
||||
else
|
||||
{
|
||||
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 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// buz: smokepuff event - for invoke puffs from server, when monsters firing, etc..
|
||||
void EV_SmokePuff( struct event_args_s *args )
|
||||
{
|
||||
VectorNormalize(args->angles); // there is surface normal actually
|
||||
g_pParticles.BulletParticles( args->origin, args->angles );
|
||||
}
|
||||
|
||||
void EV_GunSmoke( const Vector &pos )
|
||||
{
|
||||
g_pParticles.GunSmoke( pos, 2 );
|
||||
}
|
||||
|
||||
void EV_ExplodeSmoke( const Vector &pos )
|
||||
{
|
||||
g_pParticles.SmokeParticles( pos, 10 );
|
||||
}
|
||||
|
||||
void EV_HLDM_WaterSplash( float x, float y, float z, float ScaleSplash1, float ScaleSplash2 )
|
||||
{
|
||||
int iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash1.spr");
|
||||
TEMPENTITY *pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z + 15 ),
|
||||
Vector( 0, 0, 0 ),
|
||||
/*ScaleSplash1*/0.2, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL );
|
||||
|
||||
if(pTemp)
|
||||
{
|
||||
pTemp->fadeSpeed = 90.0;
|
||||
pTemp->entity.curstate.framerate = 70.0;
|
||||
pTemp->entity.curstate.renderamt = 155;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
}
|
||||
|
||||
iWaterSplash = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/splash2.spr");
|
||||
pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z ),
|
||||
Vector( 0, 0, 0 ),
|
||||
/*ScaleSplash2*/0.08, iWaterSplash, kRenderTransAdd, kRenderFxNone, 1.0, 0.5, FTENT_SPRANIMATE | FTENT_FADEOUT | FTENT_COLLIDEKILL );
|
||||
|
||||
if(pTemp)
|
||||
{
|
||||
pTemp->fadeSpeed = 60.0;
|
||||
pTemp->entity.curstate.framerate = 60.0;
|
||||
pTemp->entity.curstate.renderamt = 150;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
pTemp->entity.angles = Vector( 90, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void EV_HLDM_NewExplode( float x, float y, float z, float ScaleExplode1 )
|
||||
{
|
||||
float rnd = gEngfuncs.pfnRandomFloat( -0.03, 0.03 );
|
||||
int iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/dexplo.spr");
|
||||
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 );
|
||||
|
||||
if( pTemp )
|
||||
{
|
||||
pTemp->fadeSpeed = 90.0;
|
||||
pTemp->entity.curstate.framerate = 37.0;
|
||||
pTemp->entity.curstate.renderamt = 155;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
}
|
||||
|
||||
iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/fexplo.spr");
|
||||
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 );
|
||||
|
||||
if( pTemp )
|
||||
{
|
||||
pTemp->fadeSpeed = 100.0;
|
||||
pTemp->entity.curstate.framerate = 35.0;
|
||||
pTemp->entity.curstate.renderamt = 150;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
pTemp->entity.angles = Vector( 90, 0, 0 );
|
||||
}
|
||||
|
||||
iNewExplode = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/smokeball.spr");
|
||||
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 );
|
||||
|
||||
if( pTemp )
|
||||
{
|
||||
pTemp->fadeSpeed = 50.0;
|
||||
pTemp->entity.curstate.framerate = 22.0;
|
||||
pTemp->entity.curstate.renderamt = 120;
|
||||
pTemp->entity.curstate.rendercolor.r = 255;
|
||||
pTemp->entity.curstate.rendercolor.g = 255;
|
||||
pTemp->entity.curstate.rendercolor.b = 255;
|
||||
pTemp->entity.angles = Vector( 90, 0, 0 );
|
||||
}
|
||||
|
||||
EV_ExplodeSmoke( Vector( x, y, z + 4.0f ));
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined ( EV_HLDMH )
|
||||
#define EV_HLDMH
|
||||
|
||||
#include <bullets.h>
|
||||
|
||||
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 );
|
||||
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 );
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined ( EV_HLDMH )
|
||||
#define EV_HLDMH
|
||||
|
||||
#include <bullets.h>
|
||||
|
||||
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 );
|
||||
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
|
|
@ -1,23 +1,23 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
void Game_HookEvents( void );
|
||||
|
||||
/*
|
||||
===================
|
||||
EV_HookEvents
|
||||
|
||||
See if game specific code wants to hook any events.
|
||||
===================
|
||||
*/
|
||||
void EV_HookEvents( void )
|
||||
{
|
||||
Game_HookEvents();
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
void Game_HookEvents( void );
|
||||
|
||||
/*
|
||||
===================
|
||||
EV_HookEvents
|
||||
|
||||
See if game specific code wants to hook any events.
|
||||
===================
|
||||
*/
|
||||
void EV_HookEvents( void )
|
||||
{
|
||||
Game_HookEvents();
|
||||
}
|
|
@ -1,74 +1,74 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// eventscripts.h
|
||||
#if !defined ( EVENTSCRIPTSH )
|
||||
#define EVENTSCRIPTSH
|
||||
|
||||
// defaults for clientinfo messages
|
||||
#define DEFAULT_VIEWHEIGHT 28
|
||||
#define VEC_DUCK_VIEW 12
|
||||
|
||||
#define FTENT_FADEOUT 0x00000080
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#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_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#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_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_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// Some of these are HL/TFC specific?
|
||||
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_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_IsPlayer( int idx );
|
||||
void EV_CreateTracer( float *start, float *end );
|
||||
|
||||
struct cl_entity_s *GetEntity( int idx );
|
||||
struct cl_entity_s *GetViewEntity( void );
|
||||
void EV_GunSmoke( const Vector &pos );
|
||||
void EV_MuzzleFlash( void );
|
||||
|
||||
#endif // EVENTSCRIPTSH
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// eventscripts.h
|
||||
#if !defined ( EVENTSCRIPTSH )
|
||||
#define EVENTSCRIPTSH
|
||||
|
||||
// defaults for clientinfo messages
|
||||
#define DEFAULT_VIEWHEIGHT 28
|
||||
#define VEC_DUCK_VIEW 12
|
||||
|
||||
#define FTENT_FADEOUT 0x00000080
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#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_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#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_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_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// Some of these are HL/TFC specific?
|
||||
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_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_IsPlayer( int idx );
|
||||
void EV_CreateTracer( float *start, float *end );
|
||||
|
||||
struct cl_entity_s *GetEntity( int idx );
|
||||
struct cl_entity_s *GetViewEntity( void );
|
||||
void EV_GunSmoke( const Vector &pos );
|
||||
void EV_MuzzleFlash( void );
|
||||
|
||||
#endif // EVENTSCRIPTSH
|
||||
|
|
|
@ -1,151 +1,151 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// flashlight.cpp
|
||||
//
|
||||
// implementation of CHudFlashlight class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
DECLARE_MESSAGE(m_Flash, FlashBat)
|
||||
DECLARE_MESSAGE(m_Flash, Flashlight)
|
||||
|
||||
#define BAT_NAME "sprites/%d_Flashlight.spr"
|
||||
|
||||
int CHudFlashlight::Init(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
|
||||
HOOK_MESSAGE(Flashlight);
|
||||
HOOK_MESSAGE(FlashBat);
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void CHudFlashlight::Reset(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
}
|
||||
|
||||
int CHudFlashlight::VidInit(void)
|
||||
{
|
||||
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
|
||||
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
|
||||
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
|
||||
|
||||
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty);
|
||||
m_hSprite2 = gHUD.GetSprite(HUD_flash_full);
|
||||
m_hBeam = gHUD.GetSprite(HUD_flash_beam);
|
||||
m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty);
|
||||
m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full);
|
||||
m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam);
|
||||
m_iWidth = m_prc2->right - m_prc2->left;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_fOn = READ_BYTE();
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight::Draw(float flTime)
|
||||
{
|
||||
return 1; // buz: no flashlight
|
||||
|
||||
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT ))
|
||||
return 1;
|
||||
|
||||
if (m_fOn)
|
||||
a = 225;
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
if (m_flBat < 0.20)
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
else
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
|
||||
y = (m_prc1->bottom - m_prc2->top)/2;
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
|
||||
// Draw the flashlight casing
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prc1);
|
||||
|
||||
if ( m_fOn )
|
||||
{ // draw the flashlight beam
|
||||
x = ScreenWidth - m_iWidth/2;
|
||||
|
||||
SPR_Set( m_hBeam, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prcBeam );
|
||||
}
|
||||
|
||||
// draw the flashlight energy level
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
int iOffset = m_iWidth * (1.0 - m_flBat);
|
||||
if (iOffset < m_iWidth)
|
||||
{
|
||||
rc = *m_prc2;
|
||||
rc.left += iOffset;
|
||||
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// flashlight.cpp
|
||||
//
|
||||
// implementation of CHudFlashlight class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
DECLARE_MESSAGE(m_Flash, FlashBat)
|
||||
DECLARE_MESSAGE(m_Flash, Flashlight)
|
||||
|
||||
#define BAT_NAME "sprites/%d_Flashlight.spr"
|
||||
|
||||
int CHudFlashlight::Init(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
|
||||
HOOK_MESSAGE(Flashlight);
|
||||
HOOK_MESSAGE(FlashBat);
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void CHudFlashlight::Reset(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
}
|
||||
|
||||
int CHudFlashlight::VidInit(void)
|
||||
{
|
||||
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
|
||||
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
|
||||
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
|
||||
|
||||
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty);
|
||||
m_hSprite2 = gHUD.GetSprite(HUD_flash_full);
|
||||
m_hBeam = gHUD.GetSprite(HUD_flash_beam);
|
||||
m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty);
|
||||
m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full);
|
||||
m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam);
|
||||
m_iWidth = m_prc2->right - m_prc2->left;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_fOn = READ_BYTE();
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight::Draw(float flTime)
|
||||
{
|
||||
return 1; // buz: no flashlight
|
||||
|
||||
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
if (!FBitSet( gHUD.m_iHideHUDDisplay, ITEM_SUIT ))
|
||||
return 1;
|
||||
|
||||
if (m_fOn)
|
||||
a = 225;
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
if (m_flBat < 0.20)
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
else
|
||||
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
|
||||
y = (m_prc1->bottom - m_prc2->top)/2;
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
|
||||
// Draw the flashlight casing
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prc1);
|
||||
|
||||
if ( m_fOn )
|
||||
{ // draw the flashlight beam
|
||||
x = ScreenWidth - m_iWidth/2;
|
||||
|
||||
SPR_Set( m_hBeam, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prcBeam );
|
||||
}
|
||||
|
||||
// draw the flashlight energy level
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
int iOffset = m_iWidth * (1.0 - m_flBat);
|
||||
if (iOffset < m_iWidth)
|
||||
{
|
||||
rc = *m_prc2;
|
||||
rc.left += iOffset;
|
||||
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,184 +1,184 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Geiger.cpp
|
||||
//
|
||||
// implementation of CHudAmmo class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Geiger, Geiger )
|
||||
|
||||
int CHudGeiger::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Geiger );
|
||||
|
||||
m_iGeigerRange = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
srand( (unsigned)time( NULL ) );
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
// update geiger data
|
||||
m_iGeigerRange = READ_BYTE();
|
||||
m_iGeigerRange = m_iGeigerRange << 2;
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudGeiger::Draw (float flTime)
|
||||
{
|
||||
int pct;
|
||||
float flvol;
|
||||
int rg[3];
|
||||
int i;
|
||||
|
||||
if (m_iGeigerRange < 1000 && m_iGeigerRange > 0)
|
||||
{
|
||||
// peicewise linear is better than continuous formula for this
|
||||
if (m_iGeigerRange > 800)
|
||||
{
|
||||
pct = 0; //Con_Printf ( "range > 800\n");
|
||||
}
|
||||
else if (m_iGeigerRange > 600)
|
||||
{
|
||||
pct = 2;
|
||||
flvol = 0.4; //Con_Printf ( "range > 600\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 1;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 500)
|
||||
{
|
||||
pct = 4;
|
||||
flvol = 0.5; //Con_Printf ( "range > 500\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 400)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.6; //Con_Printf ( "range > 400\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
rg[2] = 3;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 300)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.7; //Con_Printf ( "range > 300\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 200)
|
||||
{
|
||||
pct = 28;
|
||||
flvol = 0.78; //Con_Printf ( "range > 200\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 150)
|
||||
{
|
||||
pct = 40;
|
||||
flvol = 0.80; //Con_Printf ( "range > 150\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 100)
|
||||
{
|
||||
pct = 60;
|
||||
flvol = 0.85; //Con_Printf ( "range > 100\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 75)
|
||||
{
|
||||
pct = 80;
|
||||
flvol = 0.9; //Con_Printf ( "range > 75\n");
|
||||
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
|
||||
rg[0] = 4;
|
||||
rg[1] = 5;
|
||||
rg[2] = 6;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 50)
|
||||
{
|
||||
pct = 90;
|
||||
flvol = 0.95; //Con_Printf ( "range > 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pct = 95;
|
||||
flvol = 1.0; //Con_Printf ( "range < 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
|
||||
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
|
||||
|
||||
if ((rand() & 127) < pct || (rand() & 127) < pct)
|
||||
{
|
||||
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
|
||||
char sz[256];
|
||||
|
||||
int j = rand() & 1;
|
||||
if (i > 2)
|
||||
j += rand() & 1;
|
||||
|
||||
sprintf(sz, "player/geiger%d.wav", j + 1);
|
||||
PlaySound(sz, flvol);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Geiger.cpp
|
||||
//
|
||||
// implementation of CHudAmmo class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Geiger, Geiger )
|
||||
|
||||
int CHudGeiger::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Geiger );
|
||||
|
||||
m_iGeigerRange = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
srand( (unsigned)time( NULL ) );
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
// update geiger data
|
||||
m_iGeigerRange = READ_BYTE();
|
||||
m_iGeigerRange = m_iGeigerRange << 2;
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudGeiger::Draw (float flTime)
|
||||
{
|
||||
int pct;
|
||||
float flvol;
|
||||
int rg[3];
|
||||
int i;
|
||||
|
||||
if (m_iGeigerRange < 1000 && m_iGeigerRange > 0)
|
||||
{
|
||||
// peicewise linear is better than continuous formula for this
|
||||
if (m_iGeigerRange > 800)
|
||||
{
|
||||
pct = 0; //Con_Printf ( "range > 800\n");
|
||||
}
|
||||
else if (m_iGeigerRange > 600)
|
||||
{
|
||||
pct = 2;
|
||||
flvol = 0.4; //Con_Printf ( "range > 600\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 1;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 500)
|
||||
{
|
||||
pct = 4;
|
||||
flvol = 0.5; //Con_Printf ( "range > 500\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 400)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.6; //Con_Printf ( "range > 400\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
rg[2] = 3;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 300)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.7; //Con_Printf ( "range > 300\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 200)
|
||||
{
|
||||
pct = 28;
|
||||
flvol = 0.78; //Con_Printf ( "range > 200\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 150)
|
||||
{
|
||||
pct = 40;
|
||||
flvol = 0.80; //Con_Printf ( "range > 150\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 100)
|
||||
{
|
||||
pct = 60;
|
||||
flvol = 0.85; //Con_Printf ( "range > 100\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 75)
|
||||
{
|
||||
pct = 80;
|
||||
flvol = 0.9; //Con_Printf ( "range > 75\n");
|
||||
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
|
||||
rg[0] = 4;
|
||||
rg[1] = 5;
|
||||
rg[2] = 6;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 50)
|
||||
{
|
||||
pct = 90;
|
||||
flvol = 0.95; //Con_Printf ( "range > 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pct = 95;
|
||||
flvol = 1.0; //Con_Printf ( "range < 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
|
||||
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
|
||||
|
||||
if ((rand() & 127) < pct || (rand() & 127) < pct)
|
||||
{
|
||||
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
|
||||
char sz[256];
|
||||
|
||||
int j = rand() & 1;
|
||||
if (i > 2)
|
||||
j += rand() & 1;
|
||||
|
||||
sprintf(sz, "player/geiger%d.wav", j + 1);
|
||||
PlaySound(sz, flvol);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// ============================
|
||||
// getfont - function, returning font pointer from text message
|
||||
// written by BUzer
|
||||
// ============================
|
||||
|
||||
#ifndef _GETFONT_H
|
||||
#define _GETFONT_H
|
||||
|
||||
Font* FontFromMessage(const char* &ptext);
|
||||
|
||||
// ============================
|
||||
// getfont - function, returning font pointer from text message
|
||||
// written by BUzer
|
||||
// ============================
|
||||
|
||||
#ifndef _GETFONT_H
|
||||
#define _GETFONT_H
|
||||
|
||||
Font* FontFromMessage(const char* &ptext);
|
||||
|
||||
#endif // _GETFONT_H
|
1016
cl_dll/health.cpp
1016
cl_dll/health.cpp
File diff suppressed because it is too large
Load Diff
256
cl_dll/health.h
256
cl_dll/health.h
|
@ -1,128 +1,128 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#define DMG_IMAGE_LIFE 2 // seconds that image is up
|
||||
|
||||
#define DMG_IMAGE_POISON 0
|
||||
#define DMG_IMAGE_ACID 1
|
||||
#define DMG_IMAGE_COLD 2
|
||||
#define DMG_IMAGE_DROWN 3
|
||||
#define DMG_IMAGE_BURN 4
|
||||
#define DMG_IMAGE_NERVE 5
|
||||
#define DMG_IMAGE_RAD 6
|
||||
#define DMG_IMAGE_SHOCK 7
|
||||
//tf defines
|
||||
#define DMG_IMAGE_CALTROP 8
|
||||
#define DMG_IMAGE_TRANQ 9
|
||||
#define DMG_IMAGE_CONCUSS 10
|
||||
#define DMG_IMAGE_HALLUC 11
|
||||
#define NUM_DMG_TYPES 12
|
||||
// instant damage
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#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_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#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_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_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// TF Healing Additions for TakeHealth
|
||||
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE
|
||||
// TF Redefines since we never use the originals
|
||||
#define DMG_NAIL DMG_SLASH
|
||||
#define DMG_NOT_SELF DMG_FREEZE
|
||||
|
||||
|
||||
#define DMG_TRANQ DMG_MORTAR
|
||||
#define DMG_CONCUSS DMG_SONIC
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float fExpire;
|
||||
float fBaseline;
|
||||
int x, y;
|
||||
} DAMAGE_IMAGE;
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
class CHudHealth: public CHudBase
|
||||
{
|
||||
public:
|
||||
virtual int Init( void );
|
||||
virtual int VidInit( void );
|
||||
virtual int Draw(float fTime);
|
||||
virtual void Reset( void );
|
||||
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf);
|
||||
int m_iHealth;
|
||||
int m_HUD_dmg_bio;
|
||||
int m_HUD_cross;
|
||||
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
|
||||
void GetPainColor( int &r, int &g, int &b );
|
||||
float m_fFade;
|
||||
|
||||
private:
|
||||
HSPRITE m_hSprite;
|
||||
HSPRITE m_hDamage;
|
||||
int m_hDecoration; // buz
|
||||
|
||||
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
|
||||
int m_bitsDamage;
|
||||
int DrawPain(float fTime);
|
||||
int DrawDamage(float fTime);
|
||||
void CalcDamageDirection(vec3_t vecFrom);
|
||||
void UpdateTiles(float fTime, long bits);
|
||||
};
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#define DMG_IMAGE_LIFE 2 // seconds that image is up
|
||||
|
||||
#define DMG_IMAGE_POISON 0
|
||||
#define DMG_IMAGE_ACID 1
|
||||
#define DMG_IMAGE_COLD 2
|
||||
#define DMG_IMAGE_DROWN 3
|
||||
#define DMG_IMAGE_BURN 4
|
||||
#define DMG_IMAGE_NERVE 5
|
||||
#define DMG_IMAGE_RAD 6
|
||||
#define DMG_IMAGE_SHOCK 7
|
||||
//tf defines
|
||||
#define DMG_IMAGE_CALTROP 8
|
||||
#define DMG_IMAGE_TRANQ 9
|
||||
#define DMG_IMAGE_CONCUSS 10
|
||||
#define DMG_IMAGE_HALLUC 11
|
||||
#define NUM_DMG_TYPES 12
|
||||
// instant damage
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#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_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#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_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_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// TF Healing Additions for TakeHealth
|
||||
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE
|
||||
// TF Redefines since we never use the originals
|
||||
#define DMG_NAIL DMG_SLASH
|
||||
#define DMG_NOT_SELF DMG_FREEZE
|
||||
|
||||
|
||||
#define DMG_TRANQ DMG_MORTAR
|
||||
#define DMG_CONCUSS DMG_SONIC
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float fExpire;
|
||||
float fBaseline;
|
||||
int x, y;
|
||||
} DAMAGE_IMAGE;
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
class CHudHealth: public CHudBase
|
||||
{
|
||||
public:
|
||||
virtual int Init( void );
|
||||
virtual int VidInit( void );
|
||||
virtual int Draw(float fTime);
|
||||
virtual void Reset( void );
|
||||
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf);
|
||||
int m_iHealth;
|
||||
int m_HUD_dmg_bio;
|
||||
int m_HUD_cross;
|
||||
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
|
||||
void GetPainColor( int &r, int &g, int &b );
|
||||
float m_fFade;
|
||||
|
||||
private:
|
||||
HSPRITE m_hSprite;
|
||||
HSPRITE m_hDamage;
|
||||
int m_hDecoration; // buz
|
||||
|
||||
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
|
||||
int m_bitsDamage;
|
||||
int DrawPain(float fTime);
|
||||
int DrawDamage(float fTime);
|
||||
void CalcDamageDirection(vec3_t vecFrom);
|
||||
void UpdateTiles(float fTime, long bits);
|
||||
};
|
||||
|
|
1776
cl_dll/hud.cpp
1776
cl_dll/hud.cpp
File diff suppressed because it is too large
Load Diff
1664
cl_dll/hud.h
1664
cl_dll/hud.h
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +1,18 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_IFACEH )
|
||||
#define HUD_IFACEH
|
||||
#pragma once
|
||||
|
||||
#define EXPORT _declspec( dllexport )
|
||||
#define _DLLEXPORT __declspec( dllexport )
|
||||
|
||||
#include "../engine/cdll_int.h"
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_IFACEH )
|
||||
#define HUD_IFACEH
|
||||
#pragma once
|
||||
|
||||
#define EXPORT _declspec( dllexport )
|
||||
#define _DLLEXPORT __declspec( dllexport )
|
||||
|
||||
#include "../engine/cdll_int.h"
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
#endif
|
1224
cl_dll/hud_msg.cpp
1224
cl_dll/hud_msg.cpp
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
|
@ -1,41 +1,41 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERSH )
|
||||
#define HUD_SERVERSH
|
||||
#pragma once
|
||||
|
||||
#define NET_CALLBACK /* */
|
||||
|
||||
// Dispatchers
|
||||
void NET_CALLBACK ListResponse( 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 RulesResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PlayersResponse( struct net_response_s *response );
|
||||
|
||||
void ServersInit( void );
|
||||
void ServersShutdown( void );
|
||||
void ServersThink( double time );
|
||||
void ServersCancel( void );
|
||||
|
||||
// Get list and get server info from each
|
||||
void ServersList( void );
|
||||
|
||||
// Query for IP / IPX LAN servers
|
||||
void BroadcastServersList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
int ServersGetCount( void );
|
||||
const char *ServersGetInfo( int server );
|
||||
int ServersIsQuerying( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERSH )
|
||||
#define HUD_SERVERSH
|
||||
#pragma once
|
||||
|
||||
#define NET_CALLBACK /* */
|
||||
|
||||
// Dispatchers
|
||||
void NET_CALLBACK ListResponse( 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 RulesResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PlayersResponse( struct net_response_s *response );
|
||||
|
||||
void ServersInit( void );
|
||||
void ServersShutdown( void );
|
||||
void ServersThink( double time );
|
||||
void ServersCancel( void );
|
||||
|
||||
// Get list and get server info from each
|
||||
void ServersList( void );
|
||||
|
||||
// Query for IP / IPX LAN servers
|
||||
void BroadcastServersList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
int ServersGetCount( void );
|
||||
const char *ServersGetInfo( int server );
|
||||
int ServersIsQuerying( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
#endif // HUD_SERVERSH
|
|
@ -1,98 +1,98 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERS_PRIVH )
|
||||
#define HUD_SERVERS_PRIVH
|
||||
#pragma once
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
class CHudServers
|
||||
{
|
||||
public:
|
||||
typedef struct request_s
|
||||
{
|
||||
struct request_s *next;
|
||||
netadr_t remote_address;
|
||||
int context;
|
||||
} request_t;
|
||||
|
||||
typedef struct server_s
|
||||
{
|
||||
struct server_s *next;
|
||||
netadr_t remote_address;
|
||||
char *info;
|
||||
int ping;
|
||||
} server_t;
|
||||
|
||||
CHudServers();
|
||||
~CHudServers();
|
||||
|
||||
void Think( double time );
|
||||
void QueryThink( void );
|
||||
int isQuerying( void );
|
||||
|
||||
int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr );
|
||||
|
||||
void RequestList( void );
|
||||
void RequestBroadcastList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
void CancelRequest( void );
|
||||
|
||||
int CompareServers( server_t *p1, server_t *p2 );
|
||||
|
||||
void ClearServerList( server_t **ppList );
|
||||
void ClearRequestList( request_t **ppList );
|
||||
|
||||
void AddServer( server_t **ppList, server_t *p );
|
||||
|
||||
void RemoveServerFromList( request_t **ppList, request_t *item );
|
||||
|
||||
request_t *FindRequest( int context, request_t *pList );
|
||||
|
||||
int ServerListSize( void );
|
||||
char *GetServerInfo( int server );
|
||||
int GetServerCount( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
void ListResponse( struct net_response_s *response );
|
||||
void ServerResponse( struct net_response_s *response );
|
||||
void PingResponse( struct net_response_s *response );
|
||||
void RulesResponse( struct net_response_s *response );
|
||||
void PlayersResponse( struct net_response_s *response );
|
||||
private:
|
||||
|
||||
server_t *GetServer( int server );
|
||||
|
||||
//
|
||||
char m_szToken[ 1024 ];
|
||||
int m_nRequesting;
|
||||
int m_nDone;
|
||||
|
||||
double m_dStarted;
|
||||
|
||||
request_t *m_pServerList;
|
||||
request_t *m_pActiveList;
|
||||
|
||||
server_t *m_pServers;
|
||||
|
||||
int m_nServerCount;
|
||||
|
||||
int m_nActiveQueries;
|
||||
int m_nQuerying;
|
||||
double m_fElapsed;
|
||||
|
||||
request_t *m_pPingRequest;
|
||||
request_t *m_pRulesRequest;
|
||||
request_t *m_pPlayersRequest;
|
||||
};
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERS_PRIVH )
|
||||
#define HUD_SERVERS_PRIVH
|
||||
#pragma once
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
class CHudServers
|
||||
{
|
||||
public:
|
||||
typedef struct request_s
|
||||
{
|
||||
struct request_s *next;
|
||||
netadr_t remote_address;
|
||||
int context;
|
||||
} request_t;
|
||||
|
||||
typedef struct server_s
|
||||
{
|
||||
struct server_s *next;
|
||||
netadr_t remote_address;
|
||||
char *info;
|
||||
int ping;
|
||||
} server_t;
|
||||
|
||||
CHudServers();
|
||||
~CHudServers();
|
||||
|
||||
void Think( double time );
|
||||
void QueryThink( void );
|
||||
int isQuerying( void );
|
||||
|
||||
int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr );
|
||||
|
||||
void RequestList( void );
|
||||
void RequestBroadcastList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
void CancelRequest( void );
|
||||
|
||||
int CompareServers( server_t *p1, server_t *p2 );
|
||||
|
||||
void ClearServerList( server_t **ppList );
|
||||
void ClearRequestList( request_t **ppList );
|
||||
|
||||
void AddServer( server_t **ppList, server_t *p );
|
||||
|
||||
void RemoveServerFromList( request_t **ppList, request_t *item );
|
||||
|
||||
request_t *FindRequest( int context, request_t *pList );
|
||||
|
||||
int ServerListSize( void );
|
||||
char *GetServerInfo( int server );
|
||||
int GetServerCount( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
void ListResponse( struct net_response_s *response );
|
||||
void ServerResponse( struct net_response_s *response );
|
||||
void PingResponse( struct net_response_s *response );
|
||||
void RulesResponse( struct net_response_s *response );
|
||||
void PlayersResponse( struct net_response_s *response );
|
||||
private:
|
||||
|
||||
server_t *GetServer( int server );
|
||||
|
||||
//
|
||||
char m_szToken[ 1024 ];
|
||||
int m_nRequesting;
|
||||
int m_nDone;
|
||||
|
||||
double m_dStarted;
|
||||
|
||||
request_t *m_pServerList;
|
||||
request_t *m_pActiveList;
|
||||
|
||||
server_t *m_pServers;
|
||||
|
||||
int m_nServerCount;
|
||||
|
||||
int m_nActiveQueries;
|
||||
int m_nQuerying;
|
||||
double m_fElapsed;
|
||||
|
||||
request_t *m_pPingRequest;
|
||||
request_t *m_pRulesRequest;
|
||||
request_t *m_pPlayersRequest;
|
||||
};
|
||||
|
||||
#endif // HUD_SERVERS_PRIVH
|
File diff suppressed because it is too large
Load Diff
|
@ -1,132 +1,132 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef SPECTATOR_H
|
||||
#define SPECTATOR_H
|
||||
#pragma once
|
||||
|
||||
#include "cl_entity.h"
|
||||
|
||||
|
||||
|
||||
#define INSET_OFF 0
|
||||
#define INSET_CHASE_FREE 1
|
||||
#define INSET_IN_EYE 2
|
||||
#define INSET_MAP_FREE 3
|
||||
#define INSET_MAP_CHASE 4
|
||||
|
||||
#define MAX_SPEC_HUD_MESSAGES 8
|
||||
|
||||
|
||||
|
||||
#define OVERVIEW_TILE_SIZE 128 // don't change this
|
||||
#define OVERVIEW_MAX_LAYERS 1
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef struct overviewInfo_s {
|
||||
char map[64]; // cl.levelname or empty
|
||||
vec3_t origin; // center of map
|
||||
float zoom; // zoom of map images
|
||||
int layers; // how may layers do we have
|
||||
float layersHeights[OVERVIEW_MAX_LAYERS];
|
||||
char layersImages[OVERVIEW_MAX_LAYERS][255];
|
||||
qboolean rotated; // are map images rotated (90 degrees) ?
|
||||
|
||||
int insetWindowX;
|
||||
int insetWindowY;
|
||||
int insetWindowHeight;
|
||||
int insetWindowWidth;
|
||||
} overviewInfo_t;
|
||||
|
||||
typedef struct overviewEntity_s {
|
||||
|
||||
HSPRITE hSprite;
|
||||
struct cl_entity_s * entity;
|
||||
double killTime;
|
||||
} overviewEntity_t;
|
||||
|
||||
#define MAX_OVERVIEW_ENTITIES 128
|
||||
|
||||
class CHudSpectator : public CHudBase
|
||||
{
|
||||
public:
|
||||
void Reset();
|
||||
int ToggleInset(bool allowOff);
|
||||
void CheckSettings();
|
||||
void InitHUDData( void );
|
||||
bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime);
|
||||
void DeathMessage(int victim);
|
||||
bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname );
|
||||
void CheckOverviewEntities();
|
||||
void DrawOverview();
|
||||
void DrawOverviewEntities();
|
||||
void GetMapPosition( float * returnvec );
|
||||
void DrawOverviewLayer();
|
||||
void LoadMapSprites();
|
||||
bool ParseOverviewFile();
|
||||
bool IsActivePlayer(cl_entity_t * ent);
|
||||
void SetModes(int iMainMode, int iInsetMode);
|
||||
void HandleButtonsDown(int ButtonPressed);
|
||||
void HandleButtonsUp(int ButtonPressed);
|
||||
void FindNextPlayer( bool bReverse );
|
||||
void DirectorMessage( int iSize, void *pbuf );
|
||||
void SetSpectatorStartPosition();
|
||||
int Init();
|
||||
int VidInit();
|
||||
|
||||
int Draw(float flTime);
|
||||
|
||||
int m_iDrawCycle;
|
||||
client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES];
|
||||
char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128];
|
||||
int m_lastHudMessage;
|
||||
overviewInfo_t m_OverviewData;
|
||||
overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES];
|
||||
int m_iObserverFlags;
|
||||
int m_iSpectatorNumber;
|
||||
|
||||
float m_mapZoom; // zoom the user currently uses
|
||||
vec3_t m_mapOrigin; // origin where user rotates around
|
||||
cvar_t * m_drawnames;
|
||||
cvar_t * m_drawcone;
|
||||
cvar_t * m_drawstatus;
|
||||
cvar_t * m_autoDirector;
|
||||
cvar_t * m_pip;
|
||||
|
||||
|
||||
qboolean m_chatEnabled;
|
||||
|
||||
vec3_t m_cameraOrigin; // a help camera
|
||||
vec3_t m_cameraAngles; // and it's angles
|
||||
|
||||
|
||||
private:
|
||||
vec3_t m_vPlayerPos[MAX_PLAYERS];
|
||||
HSPRITE m_hsprPlayerBlue;
|
||||
HSPRITE m_hsprPlayerRed;
|
||||
HSPRITE m_hsprPlayer;
|
||||
HSPRITE m_hsprCamera;
|
||||
HSPRITE m_hsprPlayerDead;
|
||||
HSPRITE m_hsprViewcone;
|
||||
HSPRITE m_hsprUnkownMap;
|
||||
HSPRITE m_hsprBeam;
|
||||
HSPRITE m_hCrosshair;
|
||||
|
||||
wrect_t m_crosshairRect;
|
||||
|
||||
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_zoomDelta;
|
||||
float m_moveDelta;
|
||||
int m_lastPrimaryObject;
|
||||
int m_lastSecondaryObject;
|
||||
};
|
||||
|
||||
#endif // SPECTATOR_H
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef SPECTATOR_H
|
||||
#define SPECTATOR_H
|
||||
#pragma once
|
||||
|
||||
#include "cl_entity.h"
|
||||
|
||||
|
||||
|
||||
#define INSET_OFF 0
|
||||
#define INSET_CHASE_FREE 1
|
||||
#define INSET_IN_EYE 2
|
||||
#define INSET_MAP_FREE 3
|
||||
#define INSET_MAP_CHASE 4
|
||||
|
||||
#define MAX_SPEC_HUD_MESSAGES 8
|
||||
|
||||
|
||||
|
||||
#define OVERVIEW_TILE_SIZE 128 // don't change this
|
||||
#define OVERVIEW_MAX_LAYERS 1
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef struct overviewInfo_s {
|
||||
char map[64]; // cl.levelname or empty
|
||||
vec3_t origin; // center of map
|
||||
float zoom; // zoom of map images
|
||||
int layers; // how may layers do we have
|
||||
float layersHeights[OVERVIEW_MAX_LAYERS];
|
||||
char layersImages[OVERVIEW_MAX_LAYERS][255];
|
||||
qboolean rotated; // are map images rotated (90 degrees) ?
|
||||
|
||||
int insetWindowX;
|
||||
int insetWindowY;
|
||||
int insetWindowHeight;
|
||||
int insetWindowWidth;
|
||||
} overviewInfo_t;
|
||||
|
||||
typedef struct overviewEntity_s {
|
||||
|
||||
HSPRITE hSprite;
|
||||
struct cl_entity_s * entity;
|
||||
double killTime;
|
||||
} overviewEntity_t;
|
||||
|
||||
#define MAX_OVERVIEW_ENTITIES 128
|
||||
|
||||
class CHudSpectator : public CHudBase
|
||||
{
|
||||
public:
|
||||
void Reset();
|
||||
int ToggleInset(bool allowOff);
|
||||
void CheckSettings();
|
||||
void InitHUDData( void );
|
||||
bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime);
|
||||
void DeathMessage(int victim);
|
||||
bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname );
|
||||
void CheckOverviewEntities();
|
||||
void DrawOverview();
|
||||
void DrawOverviewEntities();
|
||||
void GetMapPosition( float * returnvec );
|
||||
void DrawOverviewLayer();
|
||||
void LoadMapSprites();
|
||||
bool ParseOverviewFile();
|
||||
bool IsActivePlayer(cl_entity_t * ent);
|
||||
void SetModes(int iMainMode, int iInsetMode);
|
||||
void HandleButtonsDown(int ButtonPressed);
|
||||
void HandleButtonsUp(int ButtonPressed);
|
||||
void FindNextPlayer( bool bReverse );
|
||||
void DirectorMessage( int iSize, void *pbuf );
|
||||
void SetSpectatorStartPosition();
|
||||
int Init();
|
||||
int VidInit();
|
||||
|
||||
int Draw(float flTime);
|
||||
|
||||
int m_iDrawCycle;
|
||||
client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES];
|
||||
char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128];
|
||||
int m_lastHudMessage;
|
||||
overviewInfo_t m_OverviewData;
|
||||
overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES];
|
||||
int m_iObserverFlags;
|
||||
int m_iSpectatorNumber;
|
||||
|
||||
float m_mapZoom; // zoom the user currently uses
|
||||
vec3_t m_mapOrigin; // origin where user rotates around
|
||||
cvar_t * m_drawnames;
|
||||
cvar_t * m_drawcone;
|
||||
cvar_t * m_drawstatus;
|
||||
cvar_t * m_autoDirector;
|
||||
cvar_t * m_pip;
|
||||
|
||||
|
||||
qboolean m_chatEnabled;
|
||||
|
||||
vec3_t m_cameraOrigin; // a help camera
|
||||
vec3_t m_cameraAngles; // and it's angles
|
||||
|
||||
|
||||
private:
|
||||
vec3_t m_vPlayerPos[MAX_PLAYERS];
|
||||
HSPRITE m_hsprPlayerBlue;
|
||||
HSPRITE m_hsprPlayerRed;
|
||||
HSPRITE m_hsprPlayer;
|
||||
HSPRITE m_hsprCamera;
|
||||
HSPRITE m_hsprPlayerDead;
|
||||
HSPRITE m_hsprViewcone;
|
||||
HSPRITE m_hsprUnkownMap;
|
||||
HSPRITE m_hsprBeam;
|
||||
HSPRITE m_hCrosshair;
|
||||
|
||||
wrect_t m_crosshairRect;
|
||||
|
||||
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_zoomDelta;
|
||||
float m_moveDelta;
|
||||
int m_lastPrimaryObject;
|
||||
int m_lastSecondaryObject;
|
||||
};
|
||||
|
||||
#endif // SPECTATOR_H
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_update.cpp
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
int CL_ButtonBits( int );
|
||||
void CL_ResetButtonBits( int bits );
|
||||
|
||||
extern float v_idlescale;
|
||||
float in_fov;
|
||||
extern void HUD_SetCmdBits( int bits );
|
||||
|
||||
int CHud::UpdateClientData(client_data_t *cdata, float time)
|
||||
{
|
||||
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
|
||||
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
|
||||
|
||||
m_iKeyBits = CL_ButtonBits( 0 );
|
||||
m_iWeaponBits = cdata->iWeaponBits;
|
||||
|
||||
in_fov = cdata->fov;
|
||||
|
||||
Think();
|
||||
|
||||
cdata->fov = m_flFOV;//m_iFOV; buz
|
||||
|
||||
// v_idlescale = m_iConcussionEffect;
|
||||
|
||||
CL_ResetButtonBits( m_iKeyBits );
|
||||
|
||||
// return 1 if in anything in the client_data struct has been changed, 0 otherwise
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_update.cpp
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
int CL_ButtonBits( int );
|
||||
void CL_ResetButtonBits( int bits );
|
||||
|
||||
extern float v_idlescale;
|
||||
float in_fov;
|
||||
extern void HUD_SetCmdBits( int bits );
|
||||
|
||||
int CHud::UpdateClientData(client_data_t *cdata, float time)
|
||||
{
|
||||
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
|
||||
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
|
||||
|
||||
m_iKeyBits = CL_ButtonBits( 0 );
|
||||
m_iWeaponBits = cdata->iWeaponBits;
|
||||
|
||||
in_fov = cdata->fov;
|
||||
|
||||
Think();
|
||||
|
||||
cdata->fov = m_flFOV;//m_iFOV; buz
|
||||
|
||||
// v_idlescale = m_iConcussionEffect;
|
||||
|
||||
CL_ResetButtonBits( m_iKeyBits );
|
||||
|
||||
// return 1 if in anything in the client_data struct has been changed, 0 otherwise
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
1240
cl_dll/in_camera.cpp
1240
cl_dll/in_camera.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,24 +1,24 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( IN_DEFSH )
|
||||
#define IN_DEFSH
|
||||
#pragma once
|
||||
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
// left / right
|
||||
#define YAW 1
|
||||
// fall over
|
||||
#define ROLL 2
|
||||
|
||||
#define DLLEXPORT __declspec( dllexport )
|
||||
|
||||
void V_StartPitchDrift( void );
|
||||
void V_StopPitchDrift( void );
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( IN_DEFSH )
|
||||
#define IN_DEFSH
|
||||
#pragma once
|
||||
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
// left / right
|
||||
#define YAW 1
|
||||
// fall over
|
||||
#define ROLL 2
|
||||
|
||||
#define DLLEXPORT __declspec( dllexport )
|
||||
|
||||
void V_StartPitchDrift( void );
|
||||
void V_StopPitchDrift( void );
|
||||
|
||||
#endif
|
2100
cl_dll/input.cpp
2100
cl_dll/input.cpp
File diff suppressed because it is too large
Load Diff
1924
cl_dll/inputw32.cpp
1924
cl_dll/inputw32.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +1,18 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( KBUTTONH )
|
||||
#define KBUTTONH
|
||||
#pragma once
|
||||
|
||||
typedef struct kbutton_s
|
||||
{
|
||||
int down[2]; // key nums holding it down
|
||||
int state; // low bit is down state
|
||||
} kbutton_t;
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( KBUTTONH )
|
||||
#define KBUTTONH
|
||||
#pragma once
|
||||
|
||||
typedef struct kbutton_s
|
||||
{
|
||||
int down[2]; // key nums holding it down
|
||||
int state; // low bit is down state
|
||||
} kbutton_t;
|
||||
|
||||
#endif // !KBUTTONH
|
|
@ -1,364 +1,364 @@
|
|||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "triangleapi.h"
|
||||
#include "ref_params.h"
|
||||
#include "event_api.h"
|
||||
#include "pm_defs.h"
|
||||
#include "pm_movevars.h"
|
||||
#include "gl_local.h"
|
||||
|
||||
int CHudLensflare :: Init( void )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
m_pCvarDraw = CVAR_REGISTER( "cl_lensflare", "1", FCVAR_ARCHIVE );
|
||||
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudLensflare :: VidInit( void )
|
||||
{
|
||||
text[0] = SPR_Load("sprites/lens/lens1.spr");
|
||||
red[0] = green[0] = blue[0] = 1.0;
|
||||
scale[0] = 45;
|
||||
multi[0] = -0.45;
|
||||
|
||||
text[1] = SPR_Load("sprites/lens/lens2.spr");
|
||||
red[1] = green[0] = blue[0] = 1.0;
|
||||
scale[1] = 25;
|
||||
multi[1] = 0.2;
|
||||
|
||||
text[2] = SPR_Load("sprites/lens/glow1.spr");
|
||||
red[2] = 132/255;
|
||||
green[2] = 1.0;
|
||||
blue[2] = 153/255;
|
||||
scale[2] = 35;
|
||||
multi[2] = 0.3;
|
||||
|
||||
text[3] = SPR_Load("sprites/lens/glow2.spr");
|
||||
red[3] = 1.0;
|
||||
green[3] = 164/255;
|
||||
blue[3] = 164/255;
|
||||
scale[3] = 40;
|
||||
multi[3] = 0.46;
|
||||
|
||||
text[4] = SPR_Load("sprites/lens/lens3.spr");
|
||||
red[4] = 1.0;
|
||||
green[4] = 164/255;
|
||||
blue[4] = 164/255;
|
||||
scale[4] = 52;
|
||||
multi[4] = 0.5;
|
||||
|
||||
text[5] = SPR_Load("sprites/lens/lens2.spr");
|
||||
red[5] = green[5] = blue[5] = 1.0;
|
||||
scale[5] = 31;
|
||||
multi[5] = 0.54;
|
||||
|
||||
text[6] = SPR_Load("sprites/lens/lens2.spr");
|
||||
red[6] = 0.6;
|
||||
green[6] = 1.0;
|
||||
blue[6] = 0.6;
|
||||
scale[6] = 26;
|
||||
multi[6] = 0.64;
|
||||
|
||||
text[7] = SPR_Load("sprites/lens/glow1.spr");
|
||||
red[7] = 0.5;
|
||||
green[7] = 1.0;
|
||||
blue[7] = 0.5;
|
||||
scale[7] = 20;
|
||||
multi[7] = 0.77;
|
||||
|
||||
text[8] = SPR_Load("sprites/lens/lens2.spr");
|
||||
|
||||
text[9] = SPR_Load("sprites/lens/lens1.spr");
|
||||
|
||||
flPlayerBlend = 0.0;
|
||||
flPlayerBlend2 = 0.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudLensflare :: DrawFlare( const Vector &forward, const Vector &lightdir, const Vector &lightorg )
|
||||
{
|
||||
flPlayerBlend = max( DotProduct( forward, lightdir ) - 0.85, 0.0 ) * 6.8;
|
||||
if( flPlayerBlend > 1.0 ) flPlayerBlend = 1.0;
|
||||
|
||||
flPlayerBlend4 = max( DotProduct( forward, lightdir ) - 0.90, 0.0 ) * 6.6;
|
||||
if( flPlayerBlend4 > 1.0 ) flPlayerBlend4 = 1.0;
|
||||
|
||||
flPlayerBlend6 = max( DotProduct( forward, lightdir ) - 0.80, 0.0 ) * 6.7;
|
||||
if( flPlayerBlend6 > 1.0 ) flPlayerBlend6 = 1.0;
|
||||
|
||||
flPlayerBlend2 = flPlayerBlend6 * 140.0 ;
|
||||
flPlayerBlend3 = flPlayerBlend * 190.0 ;
|
||||
flPlayerBlend5 = flPlayerBlend4 * 222.0 ;
|
||||
|
||||
Vector normal, point, screen;
|
||||
|
||||
if( cv_renderer->value ) R_WorldToScreen( lightorg, screen );
|
||||
else gEngfuncs.pTriAPI->WorldToScreen( (float *)&lightorg, screen );
|
||||
|
||||
Suncoordx = XPROJECT( screen[0] );
|
||||
Suncoordy = YPROJECT( screen[1] );
|
||||
|
||||
Screenmx = ScreenWidth / 2;
|
||||
Screenmy = ScreenHeight / 2;
|
||||
|
||||
Sundistx = Screenmx - Suncoordx;
|
||||
Sundisty = Screenmy - Suncoordy;
|
||||
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensflare2.spr")) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f( 0.97f, 0.6f, 0.02f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Brightness( 0.3f );
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy + 190, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow2.spr")) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend3/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy + 160, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow3.spr")) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend5/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend5/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, 0, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
int i = 1;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
int scale1 = 32;
|
||||
int Lensx1,Lensy1 = 0;
|
||||
Lensx1 = (Suncoordx + (Sundistx * 0.88));
|
||||
Lensy1 = (Suncoordy + (Sundisty * 0.88));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
scale1 = 140;
|
||||
Lensx1 = (Suncoordx + (Sundistx * 1.1));
|
||||
Lensy1 = (Suncoordy + (Sundisty * 1.1));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_FRONT );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudLensflare :: Draw( float flTime )
|
||||
{
|
||||
Vector forward, sundir, suntarget;
|
||||
pmtrace_t ptr;
|
||||
|
||||
if( m_pCvarDraw->value <= 0.0f )
|
||||
return 0;
|
||||
|
||||
forward = g_pViewParams->forward;
|
||||
|
||||
// draw flares for dynlights
|
||||
for( int i = 0; i < MAX_DLIGHTS; i++ )
|
||||
{
|
||||
CDynLight *pl = &tr.dlights[i];
|
||||
|
||||
if( pl->die < flTime || !pl->radius || !FBitSet( pl->flags, DLF_LENSFLARE ))
|
||||
continue;
|
||||
|
||||
if( pl->type == LIGHT_SPOT )
|
||||
sundir = pl->frustum.GetPlane( FRUSTUM_FAR )->normal;
|
||||
else sundir = ( pl->origin - g_pViewParams->vieworg ).Normalize();
|
||||
|
||||
suntarget = pl->origin;
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
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 )
|
||||
{
|
||||
DrawFlare( forward, sundir, suntarget );
|
||||
}
|
||||
}
|
||||
|
||||
if( CVAR_TO_BOOL( v_sunshafts ))
|
||||
return 1; // don't mixing sunshafts and lensflares because this looks ugly
|
||||
|
||||
if( !tr.fogEnabled )
|
||||
{
|
||||
Vector skyVec = tr.sky_normal;
|
||||
|
||||
if( skyVec == g_vecZero )
|
||||
return 1; // no light_environment on a map
|
||||
|
||||
sundir = -skyVec.Normalize();
|
||||
suntarget = tr.cached_vieworigin + sundir * 32768.0f;
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
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 )
|
||||
{
|
||||
DrawFlare( forward, sundir, suntarget );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "triangleapi.h"
|
||||
#include "ref_params.h"
|
||||
#include "event_api.h"
|
||||
#include "pm_defs.h"
|
||||
#include "pm_movevars.h"
|
||||
#include "gl_local.h"
|
||||
|
||||
int CHudLensflare :: Init( void )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
m_pCvarDraw = CVAR_REGISTER( "cl_lensflare", "1", FCVAR_ARCHIVE );
|
||||
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudLensflare :: VidInit( void )
|
||||
{
|
||||
text[0] = SPR_Load("sprites/lens/lens1.spr");
|
||||
red[0] = green[0] = blue[0] = 1.0;
|
||||
scale[0] = 45;
|
||||
multi[0] = -0.45;
|
||||
|
||||
text[1] = SPR_Load("sprites/lens/lens2.spr");
|
||||
red[1] = green[0] = blue[0] = 1.0;
|
||||
scale[1] = 25;
|
||||
multi[1] = 0.2;
|
||||
|
||||
text[2] = SPR_Load("sprites/lens/glow1.spr");
|
||||
red[2] = 132/255;
|
||||
green[2] = 1.0;
|
||||
blue[2] = 153/255;
|
||||
scale[2] = 35;
|
||||
multi[2] = 0.3;
|
||||
|
||||
text[3] = SPR_Load("sprites/lens/glow2.spr");
|
||||
red[3] = 1.0;
|
||||
green[3] = 164/255;
|
||||
blue[3] = 164/255;
|
||||
scale[3] = 40;
|
||||
multi[3] = 0.46;
|
||||
|
||||
text[4] = SPR_Load("sprites/lens/lens3.spr");
|
||||
red[4] = 1.0;
|
||||
green[4] = 164/255;
|
||||
blue[4] = 164/255;
|
||||
scale[4] = 52;
|
||||
multi[4] = 0.5;
|
||||
|
||||
text[5] = SPR_Load("sprites/lens/lens2.spr");
|
||||
red[5] = green[5] = blue[5] = 1.0;
|
||||
scale[5] = 31;
|
||||
multi[5] = 0.54;
|
||||
|
||||
text[6] = SPR_Load("sprites/lens/lens2.spr");
|
||||
red[6] = 0.6;
|
||||
green[6] = 1.0;
|
||||
blue[6] = 0.6;
|
||||
scale[6] = 26;
|
||||
multi[6] = 0.64;
|
||||
|
||||
text[7] = SPR_Load("sprites/lens/glow1.spr");
|
||||
red[7] = 0.5;
|
||||
green[7] = 1.0;
|
||||
blue[7] = 0.5;
|
||||
scale[7] = 20;
|
||||
multi[7] = 0.77;
|
||||
|
||||
text[8] = SPR_Load("sprites/lens/lens2.spr");
|
||||
|
||||
text[9] = SPR_Load("sprites/lens/lens1.spr");
|
||||
|
||||
flPlayerBlend = 0.0;
|
||||
flPlayerBlend2 = 0.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudLensflare :: DrawFlare( const Vector &forward, const Vector &lightdir, const Vector &lightorg )
|
||||
{
|
||||
flPlayerBlend = max( DotProduct( forward, lightdir ) - 0.85, 0.0 ) * 6.8;
|
||||
if( flPlayerBlend > 1.0 ) flPlayerBlend = 1.0;
|
||||
|
||||
flPlayerBlend4 = max( DotProduct( forward, lightdir ) - 0.90, 0.0 ) * 6.6;
|
||||
if( flPlayerBlend4 > 1.0 ) flPlayerBlend4 = 1.0;
|
||||
|
||||
flPlayerBlend6 = max( DotProduct( forward, lightdir ) - 0.80, 0.0 ) * 6.7;
|
||||
if( flPlayerBlend6 > 1.0 ) flPlayerBlend6 = 1.0;
|
||||
|
||||
flPlayerBlend2 = flPlayerBlend6 * 140.0 ;
|
||||
flPlayerBlend3 = flPlayerBlend * 190.0 ;
|
||||
flPlayerBlend5 = flPlayerBlend4 * 222.0 ;
|
||||
|
||||
Vector normal, point, screen;
|
||||
|
||||
if( cv_renderer->value ) R_WorldToScreen( lightorg, screen );
|
||||
else gEngfuncs.pTriAPI->WorldToScreen( (float *)&lightorg, screen );
|
||||
|
||||
Suncoordx = XPROJECT( screen[0] );
|
||||
Suncoordy = YPROJECT( screen[1] );
|
||||
|
||||
Screenmx = ScreenWidth / 2;
|
||||
Screenmy = ScreenHeight / 2;
|
||||
|
||||
Sundistx = Screenmx - Suncoordx;
|
||||
Sundisty = Screenmy - Suncoordy;
|
||||
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensflare2.spr")) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f( 0.97f, 0.6f, 0.02f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Brightness( 0.3f );
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy + 190, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow2.spr")) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend3/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy + 160, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow3.spr")) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend5/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend5/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, 0, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
int i = 1;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
|
||||
Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 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->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
int scale1 = 32;
|
||||
int Lensx1,Lensy1 = 0;
|
||||
Lensx1 = (Suncoordx + (Sundistx * 0.88));
|
||||
Lensy1 = (Suncoordy + (Sundisty * 0.88));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
i++;
|
||||
scale1 = 140;
|
||||
Lensx1 = (Suncoordx + (Sundistx * 1.1));
|
||||
Lensy1 = (Suncoordy + (Sundisty * 1.1));
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0);
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
|
||||
gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
|
||||
gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
|
||||
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, 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, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
|
||||
gEngfuncs.pTriAPI->End(); //end our list of vertexes
|
||||
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
|
||||
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_FRONT );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudLensflare :: Draw( float flTime )
|
||||
{
|
||||
Vector forward, sundir, suntarget;
|
||||
pmtrace_t ptr;
|
||||
|
||||
if( m_pCvarDraw->value <= 0.0f )
|
||||
return 0;
|
||||
|
||||
forward = g_pViewParams->forward;
|
||||
|
||||
// draw flares for dynlights
|
||||
for( int i = 0; i < MAX_DLIGHTS; i++ )
|
||||
{
|
||||
CDynLight *pl = &tr.dlights[i];
|
||||
|
||||
if( pl->die < flTime || !pl->radius || !FBitSet( pl->flags, DLF_LENSFLARE ))
|
||||
continue;
|
||||
|
||||
if( pl->type == LIGHT_SPOT )
|
||||
sundir = pl->frustum.GetPlane( FRUSTUM_FAR )->normal;
|
||||
else sundir = ( pl->origin - g_pViewParams->vieworg ).Normalize();
|
||||
|
||||
suntarget = pl->origin;
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
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 )
|
||||
{
|
||||
DrawFlare( forward, sundir, suntarget );
|
||||
}
|
||||
}
|
||||
|
||||
if( CVAR_TO_BOOL( v_sunshafts ))
|
||||
return 1; // don't mixing sunshafts and lensflares because this looks ugly
|
||||
|
||||
if( !tr.fogEnabled )
|
||||
{
|
||||
Vector skyVec = tr.sky_normal;
|
||||
|
||||
if( skyVec == g_vecZero )
|
||||
return 1; // no light_environment on a map
|
||||
|
||||
sundir = -skyVec.Normalize();
|
||||
suntarget = tr.cached_vieworigin + sundir * 32768.0f;
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
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 )
|
||||
{
|
||||
DrawFlare( forward, sundir, suntarget );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
374
cl_dll/menu.cpp
374
cl_dll/menu.cpp
|
@ -1,187 +1,187 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// menu.cpp
|
||||
//
|
||||
// generic menu handler
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
#define MAX_MENU_STRING 512
|
||||
char g_szMenuString[MAX_MENU_STRING];
|
||||
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
|
||||
|
||||
int KB_ConvertString( char *in, char **ppout );
|
||||
|
||||
DECLARE_MESSAGE( m_Menu, ShowMenu );
|
||||
|
||||
int CHudMenu :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( ShowMenu );
|
||||
|
||||
InitHUDData();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudMenu :: InitHUDData( void )
|
||||
{
|
||||
m_fMenuDisplayed = 0;
|
||||
m_bitsValidSlots = 0;
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CHudMenu :: Reset( void )
|
||||
{
|
||||
g_szPrelocalisedMenuString[0] = 0;
|
||||
m_fWaitingForMore = FALSE;
|
||||
}
|
||||
|
||||
int CHudMenu :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudMenu :: Draw( float flTime )
|
||||
{
|
||||
// check for if menu is set to disappear
|
||||
if ( m_flShutoffTime > 0 )
|
||||
{
|
||||
if ( m_flShutoffTime <= gHUD.m_flTime )
|
||||
{ // times up, shutoff
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// don't draw the menu if the scoreboard is being shown
|
||||
if ( gViewPort && gViewPort->IsScoreBoardVisible() )
|
||||
return 1;
|
||||
|
||||
// draw the menu, along the left-hand side of the screen
|
||||
|
||||
// count the number of newlines
|
||||
int nlc = 0;
|
||||
for ( int i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
|
||||
{
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
nlc++;
|
||||
}
|
||||
|
||||
// center it
|
||||
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
|
||||
int x = 20;
|
||||
|
||||
i = 0;
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
|
||||
{
|
||||
gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
|
||||
y += 12;
|
||||
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
|
||||
i++;
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
i++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// selects an item from the menu
|
||||
void CHudMenu :: SelectMenuItem( int menu_item )
|
||||
{
|
||||
// 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))) )
|
||||
{
|
||||
char szbuf[32];
|
||||
sprintf( szbuf, "menuselect %d\n", menu_item );
|
||||
ClientCmd( szbuf );
|
||||
|
||||
// remove the menu
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Message handler for ShowMenu message
|
||||
// takes four values:
|
||||
// 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.
|
||||
// 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
|
||||
// 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 )
|
||||
{
|
||||
char *temp = NULL;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
m_bitsValidSlots = READ_SHORT();
|
||||
int DisplayTime = READ_CHAR();
|
||||
int NeedMore = READ_BYTE();
|
||||
|
||||
if ( DisplayTime > 0 )
|
||||
m_flShutoffTime = DisplayTime + gHUD.m_flTime;
|
||||
else
|
||||
m_flShutoffTime = -1;
|
||||
|
||||
if ( m_bitsValidSlots )
|
||||
{
|
||||
if ( !m_fWaitingForMore ) // this is the start of a new menu
|
||||
{
|
||||
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
|
||||
}
|
||||
else
|
||||
{ // append to the current menu string
|
||||
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)
|
||||
|
||||
if ( !NeedMore )
|
||||
{ // we have the whole string, so we can localise it now
|
||||
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
|
||||
|
||||
// Swap in characters
|
||||
if ( KB_ConvertString( g_szMenuString, &temp ) )
|
||||
{
|
||||
strcpy( g_szMenuString, temp );
|
||||
free( temp );
|
||||
}
|
||||
}
|
||||
|
||||
m_fMenuDisplayed = 1;
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
m_fWaitingForMore = NeedMore;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// menu.cpp
|
||||
//
|
||||
// generic menu handler
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
#define MAX_MENU_STRING 512
|
||||
char g_szMenuString[MAX_MENU_STRING];
|
||||
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
|
||||
|
||||
int KB_ConvertString( char *in, char **ppout );
|
||||
|
||||
DECLARE_MESSAGE( m_Menu, ShowMenu );
|
||||
|
||||
int CHudMenu :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( ShowMenu );
|
||||
|
||||
InitHUDData();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudMenu :: InitHUDData( void )
|
||||
{
|
||||
m_fMenuDisplayed = 0;
|
||||
m_bitsValidSlots = 0;
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CHudMenu :: Reset( void )
|
||||
{
|
||||
g_szPrelocalisedMenuString[0] = 0;
|
||||
m_fWaitingForMore = FALSE;
|
||||
}
|
||||
|
||||
int CHudMenu :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudMenu :: Draw( float flTime )
|
||||
{
|
||||
// check for if menu is set to disappear
|
||||
if ( m_flShutoffTime > 0 )
|
||||
{
|
||||
if ( m_flShutoffTime <= gHUD.m_flTime )
|
||||
{ // times up, shutoff
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// don't draw the menu if the scoreboard is being shown
|
||||
if ( gViewPort && gViewPort->IsScoreBoardVisible() )
|
||||
return 1;
|
||||
|
||||
// draw the menu, along the left-hand side of the screen
|
||||
|
||||
// count the number of newlines
|
||||
int nlc = 0;
|
||||
for ( int i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
|
||||
{
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
nlc++;
|
||||
}
|
||||
|
||||
// center it
|
||||
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
|
||||
int x = 20;
|
||||
|
||||
i = 0;
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
|
||||
{
|
||||
gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
|
||||
y += 12;
|
||||
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
|
||||
i++;
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
i++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// selects an item from the menu
|
||||
void CHudMenu :: SelectMenuItem( int menu_item )
|
||||
{
|
||||
// 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))) )
|
||||
{
|
||||
char szbuf[32];
|
||||
sprintf( szbuf, "menuselect %d\n", menu_item );
|
||||
ClientCmd( szbuf );
|
||||
|
||||
// remove the menu
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Message handler for ShowMenu message
|
||||
// takes four values:
|
||||
// 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.
|
||||
// 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
|
||||
// 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 )
|
||||
{
|
||||
char *temp = NULL;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
m_bitsValidSlots = READ_SHORT();
|
||||
int DisplayTime = READ_CHAR();
|
||||
int NeedMore = READ_BYTE();
|
||||
|
||||
if ( DisplayTime > 0 )
|
||||
m_flShutoffTime = DisplayTime + gHUD.m_flTime;
|
||||
else
|
||||
m_flShutoffTime = -1;
|
||||
|
||||
if ( m_bitsValidSlots )
|
||||
{
|
||||
if ( !m_fWaitingForMore ) // this is the start of a new menu
|
||||
{
|
||||
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
|
||||
}
|
||||
else
|
||||
{ // append to the current menu string
|
||||
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)
|
||||
|
||||
if ( !NeedMore )
|
||||
{ // we have the whole string, so we can localise it now
|
||||
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
|
||||
|
||||
// Swap in characters
|
||||
if ( KB_ConvertString( g_szMenuString, &temp ) )
|
||||
{
|
||||
strcpy( g_szMenuString, temp );
|
||||
free( temp );
|
||||
}
|
||||
}
|
||||
|
||||
m_fMenuDisplayed = 1;
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
m_fWaitingForMore = NeedMore;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
1078
cl_dll/message.cpp
1078
cl_dll/message.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,31 +1,31 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef OVERVIEW_H
|
||||
#define OVERVIEW_H
|
||||
#pragma once
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles the drawing of the top-down map and all the things on it
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudOverview : public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init();
|
||||
int VidInit();
|
||||
|
||||
int Draw(float flTime);
|
||||
void InitHUDData( void );
|
||||
|
||||
private:
|
||||
HSPRITE m_hsprPlayer;
|
||||
HSPRITE m_hsprViewcone;
|
||||
};
|
||||
|
||||
|
||||
#endif // OVERVIEW_H
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef OVERVIEW_H
|
||||
#define OVERVIEW_H
|
||||
#pragma once
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles the drawing of the top-down map and all the things on it
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudOverview : public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init();
|
||||
int VidInit();
|
||||
|
||||
int Draw(float flTime);
|
||||
void InitHUDData( void );
|
||||
|
||||
private:
|
||||
HSPRITE m_hsprPlayer;
|
||||
HSPRITE m_hsprViewcone;
|
||||
};
|
||||
|
||||
|
||||
#endif // OVERVIEW_H
|
||||
|
|
|
@ -1,178 +1,178 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.cpp
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "com_model.h"
|
||||
#include "gl_local.h"
|
||||
|
||||
typedef unsigned char byte;
|
||||
#define true 1
|
||||
|
||||
static byte *gpBuf;
|
||||
static int giSize;
|
||||
static int giRead;
|
||||
static int giBadRead;
|
||||
|
||||
void BEGIN_READ( void *buf, int size )
|
||||
{
|
||||
giRead = 0;
|
||||
giBadRead = 0;
|
||||
giSize = size;
|
||||
gpBuf = (byte*)buf;
|
||||
}
|
||||
|
||||
|
||||
int READ_CHAR( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead + 1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (signed char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_BYTE( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (unsigned char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_SHORT( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+2 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) );
|
||||
|
||||
giRead += 2;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_WORD( void )
|
||||
{
|
||||
return READ_SHORT();
|
||||
}
|
||||
|
||||
|
||||
int READ_LONG( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+4 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24);
|
||||
|
||||
giRead += 4;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
float READ_FLOAT( void )
|
||||
{
|
||||
union
|
||||
{
|
||||
byte b[4];
|
||||
float f;
|
||||
int l;
|
||||
} dat;
|
||||
|
||||
dat.b[0] = gpBuf[giRead];
|
||||
dat.b[1] = gpBuf[giRead+1];
|
||||
dat.b[2] = gpBuf[giRead+2];
|
||||
dat.b[3] = gpBuf[giRead+3];
|
||||
giRead += 4;
|
||||
|
||||
// dat.l = LittleLong (dat.l);
|
||||
|
||||
return dat.f;
|
||||
}
|
||||
|
||||
char* READ_STRING( void )
|
||||
{
|
||||
static char string[2048];
|
||||
int l,c;
|
||||
|
||||
string[0] = 0;
|
||||
|
||||
l = 0;
|
||||
do
|
||||
{
|
||||
if ( giRead+1 > giSize )
|
||||
break; // no more characters
|
||||
|
||||
c = READ_CHAR();
|
||||
if (c == 0) break;
|
||||
string[l] = c;
|
||||
l++;
|
||||
} while (l < sizeof(string)-1);
|
||||
|
||||
string[l] = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
float READ_COORD( void )
|
||||
{
|
||||
// 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 )
|
||||
return (float)(READ_SHORT() * 1.0f);
|
||||
return (float)(READ_SHORT() * (1.0f / 8.0f));
|
||||
}
|
||||
|
||||
float READ_ANGLE( void )
|
||||
{
|
||||
return (float)(READ_CHAR() * (360.0/256));
|
||||
}
|
||||
|
||||
float READ_HIRESANGLE( void )
|
||||
{
|
||||
return (float)(READ_SHORT() * (360.0/65536));
|
||||
}
|
||||
|
||||
BOOL REMAIN_BYTES( void )
|
||||
{
|
||||
return giRead < giSize;
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.cpp
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "com_model.h"
|
||||
#include "gl_local.h"
|
||||
|
||||
typedef unsigned char byte;
|
||||
#define true 1
|
||||
|
||||
static byte *gpBuf;
|
||||
static int giSize;
|
||||
static int giRead;
|
||||
static int giBadRead;
|
||||
|
||||
void BEGIN_READ( void *buf, int size )
|
||||
{
|
||||
giRead = 0;
|
||||
giBadRead = 0;
|
||||
giSize = size;
|
||||
gpBuf = (byte*)buf;
|
||||
}
|
||||
|
||||
|
||||
int READ_CHAR( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead + 1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (signed char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_BYTE( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (unsigned char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_SHORT( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+2 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) );
|
||||
|
||||
giRead += 2;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_WORD( void )
|
||||
{
|
||||
return READ_SHORT();
|
||||
}
|
||||
|
||||
|
||||
int READ_LONG( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+4 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24);
|
||||
|
||||
giRead += 4;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
float READ_FLOAT( void )
|
||||
{
|
||||
union
|
||||
{
|
||||
byte b[4];
|
||||
float f;
|
||||
int l;
|
||||
} dat;
|
||||
|
||||
dat.b[0] = gpBuf[giRead];
|
||||
dat.b[1] = gpBuf[giRead+1];
|
||||
dat.b[2] = gpBuf[giRead+2];
|
||||
dat.b[3] = gpBuf[giRead+3];
|
||||
giRead += 4;
|
||||
|
||||
// dat.l = LittleLong (dat.l);
|
||||
|
||||
return dat.f;
|
||||
}
|
||||
|
||||
char* READ_STRING( void )
|
||||
{
|
||||
static char string[2048];
|
||||
int l,c;
|
||||
|
||||
string[0] = 0;
|
||||
|
||||
l = 0;
|
||||
do
|
||||
{
|
||||
if ( giRead+1 > giSize )
|
||||
break; // no more characters
|
||||
|
||||
c = READ_CHAR();
|
||||
if (c == 0) break;
|
||||
string[l] = c;
|
||||
l++;
|
||||
} while (l < sizeof(string)-1);
|
||||
|
||||
string[l] = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
float READ_COORD( void )
|
||||
{
|
||||
// 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 )
|
||||
return (float)(READ_SHORT() * 1.0f);
|
||||
return (float)(READ_SHORT() * (1.0f / 8.0f));
|
||||
}
|
||||
|
||||
float READ_ANGLE( void )
|
||||
{
|
||||
return (float)(READ_CHAR() * (360.0/256));
|
||||
}
|
||||
|
||||
float READ_HIRESANGLE( void )
|
||||
{
|
||||
return (float)(READ_SHORT() * (360.0/65536));
|
||||
}
|
||||
|
||||
BOOL REMAIN_BYTES( void )
|
||||
{
|
||||
return giRead < giSize;
|
||||
}
|
|
@ -1,38 +1,38 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.h
|
||||
//
|
||||
|
||||
void BEGIN_READ( void *buf, int size );
|
||||
int READ_CHAR( void );
|
||||
int READ_BYTE( void );
|
||||
int READ_SHORT( void );
|
||||
int READ_WORD( void );
|
||||
int READ_LONG( void );
|
||||
float READ_FLOAT( void );
|
||||
char* READ_STRING( void );
|
||||
float READ_COORD( void );
|
||||
float READ_ANGLE( void );
|
||||
float READ_HIRESANGLE( void );
|
||||
BOOL REMAIN_BYTES( void );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.h
|
||||
//
|
||||
|
||||
void BEGIN_READ( void *buf, int size );
|
||||
int READ_CHAR( void );
|
||||
int READ_BYTE( void );
|
||||
int READ_SHORT( void );
|
||||
int READ_WORD( void );
|
||||
int READ_LONG( void );
|
||||
float READ_FLOAT( void );
|
||||
char* READ_STRING( void );
|
||||
float READ_COORD( void );
|
||||
float READ_ANGLE( void );
|
||||
float READ_HIRESANGLE( void );
|
||||
BOOL REMAIN_BYTES( void );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
/*
|
||||
cl_dlight.h - dynamic lighting description
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef CL_DLIGHT_H
|
||||
#define CL_DLIGHT_H
|
||||
|
||||
#define NUM_SHADOW_SPLITS 3 // four splits
|
||||
#define MAX_SHADOWMAPS (NUM_SHADOW_SPLITS + 1)
|
||||
|
||||
// dlight flags
|
||||
#define DLF_NOSHADOWS BIT( 0 )
|
||||
#define DLF_NOBUMP BIT( 1 )
|
||||
#define DLF_LENSFLARE BIT( 2 )
|
||||
#define DLF_CULLED BIT( 3 ) // light culled by scissor
|
||||
#define DLF_ASPECT3X4 BIT( 4 )
|
||||
#define DLF_ASPECT4X3 BIT( 5 )
|
||||
#define DLF_FLIPTEXTURE BIT( 6 )
|
||||
|
||||
class CDynLight
|
||||
{
|
||||
public:
|
||||
Vector origin;
|
||||
Vector angles;
|
||||
float radius;
|
||||
Vector color; // ignored for spotlights, they have a texture
|
||||
float die; // stop lighting after this time
|
||||
float decay; // drop this each second
|
||||
int key;
|
||||
int type; // light type
|
||||
bool update; // light needs update
|
||||
|
||||
matrix4x4 viewMatrix;
|
||||
matrix4x4 projectionMatrix; // light projection matrix
|
||||
matrix4x4 modelviewMatrix; // light modelview
|
||||
matrix4x4 lightviewProjMatrix; // lightview projection
|
||||
matrix4x4 textureMatrix[MAX_SHADOWMAPS]; // result texture matrix
|
||||
matrix4x4 shadowMatrix[MAX_SHADOWMAPS]; // result texture matrix
|
||||
GLfloat gl_shadowMatrix[MAX_SHADOWMAPS][16]; // cached matrices
|
||||
|
||||
Vector mins, maxs; // local bounds
|
||||
Vector absmin, absmax; // world bounds
|
||||
CFrustum frustum; // normal frustum
|
||||
CFrustum splitFrustum[MAX_SHADOWMAPS];
|
||||
|
||||
// scissor data
|
||||
float x, y, w, h;
|
||||
|
||||
// spotlight specific:
|
||||
int spotlightTexture; // spotlights only
|
||||
int shadowTexture[MAX_SHADOWMAPS]; // shadowmap for this light
|
||||
int cinTexturenum; // not gltexturenum!
|
||||
int lastframe; // cinematic lastframe
|
||||
int flags;
|
||||
float fov;
|
||||
|
||||
bool Expired( void )
|
||||
{
|
||||
if( die < GET_CLIENT_TIME( ))
|
||||
return true;
|
||||
if( radius <= 0.0f )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Active( void )
|
||||
{
|
||||
if( Expired( ))
|
||||
return false;
|
||||
if( FBitSet( flags, DLF_CULLED ))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
cl_dlight.h - dynamic lighting description
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef CL_DLIGHT_H
|
||||
#define CL_DLIGHT_H
|
||||
|
||||
#define NUM_SHADOW_SPLITS 3 // four splits
|
||||
#define MAX_SHADOWMAPS (NUM_SHADOW_SPLITS + 1)
|
||||
|
||||
// dlight flags
|
||||
#define DLF_NOSHADOWS BIT( 0 )
|
||||
#define DLF_NOBUMP BIT( 1 )
|
||||
#define DLF_LENSFLARE BIT( 2 )
|
||||
#define DLF_CULLED BIT( 3 ) // light culled by scissor
|
||||
#define DLF_ASPECT3X4 BIT( 4 )
|
||||
#define DLF_ASPECT4X3 BIT( 5 )
|
||||
#define DLF_FLIPTEXTURE BIT( 6 )
|
||||
|
||||
class CDynLight
|
||||
{
|
||||
public:
|
||||
Vector origin;
|
||||
Vector angles;
|
||||
float radius;
|
||||
Vector color; // ignored for spotlights, they have a texture
|
||||
float die; // stop lighting after this time
|
||||
float decay; // drop this each second
|
||||
int key;
|
||||
int type; // light type
|
||||
bool update; // light needs update
|
||||
|
||||
matrix4x4 viewMatrix;
|
||||
matrix4x4 projectionMatrix; // light projection matrix
|
||||
matrix4x4 modelviewMatrix; // light modelview
|
||||
matrix4x4 lightviewProjMatrix; // lightview projection
|
||||
matrix4x4 textureMatrix[MAX_SHADOWMAPS]; // result texture matrix
|
||||
matrix4x4 shadowMatrix[MAX_SHADOWMAPS]; // result texture matrix
|
||||
GLfloat gl_shadowMatrix[MAX_SHADOWMAPS][16]; // cached matrices
|
||||
|
||||
Vector mins, maxs; // local bounds
|
||||
Vector absmin, absmax; // world bounds
|
||||
CFrustum frustum; // normal frustum
|
||||
CFrustum splitFrustum[MAX_SHADOWMAPS];
|
||||
|
||||
// scissor data
|
||||
float x, y, w, h;
|
||||
|
||||
// spotlight specific:
|
||||
int spotlightTexture; // spotlights only
|
||||
int shadowTexture[MAX_SHADOWMAPS]; // shadowmap for this light
|
||||
int cinTexturenum; // not gltexturenum!
|
||||
int lastframe; // cinematic lastframe
|
||||
int flags;
|
||||
float fov;
|
||||
|
||||
bool Expired( void )
|
||||
{
|
||||
if( die < GET_CLIENT_TIME( ))
|
||||
return true;
|
||||
if( radius <= 0.0f )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Active( void )
|
||||
{
|
||||
if( Expired( ))
|
||||
return false;
|
||||
if( FBitSet( flags, DLF_CULLED ))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif//CL_DLIGHT_H
|
File diff suppressed because it is too large
Load Diff
|
@ -1,211 +1,211 @@
|
|||
/*
|
||||
r_particle.h - Laurie Cheers Aurora Particle System
|
||||
First implementation of 02/08/02 November235
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_PARTICLE_H
|
||||
#define GL_PARTICLE_H
|
||||
|
||||
class CParticleType;
|
||||
class CParticleSystem;
|
||||
|
||||
#include "randomrange.h"
|
||||
|
||||
struct CParticle
|
||||
{
|
||||
CParticle *nextpart;
|
||||
CParticle *m_pOverlay; // for making multi-layered particles
|
||||
CParticleType *pType;
|
||||
|
||||
Vector origin;
|
||||
Vector velocity;
|
||||
Vector accel;
|
||||
Vector m_vecWind;
|
||||
|
||||
cl_entity_t *m_pEntity; // if not null, this particle is tied to the given entity
|
||||
|
||||
float m_fRed;
|
||||
float m_fGreen;
|
||||
float m_fBlue;
|
||||
float m_fRedStep;
|
||||
float m_fGreenStep;
|
||||
float m_fBlueStep;
|
||||
|
||||
float m_fAlpha;
|
||||
float m_fAlphaStep;
|
||||
|
||||
float frame;
|
||||
float m_fFrameStep;
|
||||
|
||||
float m_fAngle;
|
||||
float m_fAngleStep;
|
||||
|
||||
float m_fSize;
|
||||
float m_fSizeStep;
|
||||
|
||||
float m_fDrag;
|
||||
|
||||
float age;
|
||||
float age_death;
|
||||
float age_spray;
|
||||
};
|
||||
|
||||
class CParticleType
|
||||
{
|
||||
public:
|
||||
CParticleType( CParticleType *pNext = NULL );
|
||||
|
||||
// here is a particle system. Add a (set of) particles according to this type, and initialise their values.
|
||||
CParticle *CreateParticle( CParticleSystem *pSys );
|
||||
|
||||
// initialise this particle. Does not define velocity or age.
|
||||
void InitParticle( CParticle *pPart, CParticleSystem *pSys );
|
||||
|
||||
bool m_bIsDefined; // is this CParticleType just a placeholder?
|
||||
|
||||
int m_iRenderMode;
|
||||
int m_iDrawCond;
|
||||
RandomRange m_Bounce;
|
||||
RandomRange m_BounceFriction;
|
||||
bool m_bBouncing;
|
||||
|
||||
RandomRange m_Life;
|
||||
|
||||
RandomRange m_StartAlpha;
|
||||
RandomRange m_EndAlpha;
|
||||
RandomRange m_StartRed;
|
||||
RandomRange m_EndRed;
|
||||
RandomRange m_StartGreen;
|
||||
RandomRange m_EndGreen;
|
||||
RandomRange m_StartBlue;
|
||||
RandomRange m_EndBlue;
|
||||
|
||||
RandomRange m_StartSize;
|
||||
RandomRange m_SizeDelta;
|
||||
RandomRange m_EndSize;
|
||||
|
||||
RandomRange m_StartFrame;
|
||||
RandomRange m_EndFrame;
|
||||
RandomRange m_FrameRate; // incompatible with EndFrame
|
||||
bool m_bEndFrame;
|
||||
|
||||
RandomRange m_StartAngle;
|
||||
RandomRange m_AngleDelta;
|
||||
|
||||
RandomRange m_SprayRate;
|
||||
RandomRange m_SprayForce;
|
||||
RandomRange m_SprayPitch;
|
||||
RandomRange m_SprayYaw;
|
||||
RandomRange m_SprayRoll;
|
||||
|
||||
CParticleType *m_pSprayType;
|
||||
|
||||
RandomRange m_Gravity;
|
||||
RandomRange m_WindStrength;
|
||||
RandomRange m_WindYaw;
|
||||
|
||||
HSPRITE m_hSprite;
|
||||
CParticleType *m_pOverlayType;
|
||||
|
||||
RandomRange m_Drag;
|
||||
|
||||
CParticleType *m_pNext;
|
||||
char m_szName[32];
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AURORA_REMOVE = 0,
|
||||
AURORA_INVISIBLE,
|
||||
AURORA_DRAW,
|
||||
} AURSTATE;
|
||||
|
||||
class CParticleSystem
|
||||
{
|
||||
public:
|
||||
CParticleSystem( cl_entity_t *ent, const char *szFilename, int attachment = 0, float lifetime = 0.0f );
|
||||
~CParticleSystem( void );
|
||||
|
||||
void AllocateParticles( int iParticles );
|
||||
void CalculateDistance( void );
|
||||
CParticleType *GetType( const char *szName );
|
||||
CParticleType *AddPlaceholderType( const char *szName );
|
||||
CParticleType *ParseType( char *&szFile );
|
||||
|
||||
cl_entity_t *GetEntity() { return m_pEntity; }
|
||||
|
||||
// General functions
|
||||
AURSTATE UpdateSystem( float frametime ); // If this function returns false, the manager deletes the system
|
||||
void DrawSystem( void );
|
||||
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!
|
||||
// returns false if the particle has died
|
||||
bool UpdateParticle( CParticle *part, float frametime );
|
||||
void DrawParticle( CParticle *part, Vector &right, Vector &up );
|
||||
|
||||
// Utility functions that have to be public
|
||||
bool ParticleIsVisible( CParticle* part );
|
||||
|
||||
void MarkForDeletion( void );
|
||||
|
||||
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]; }
|
||||
|
||||
// Pointer to next system for linked list structure
|
||||
CParticleSystem *m_pNextSystem;
|
||||
|
||||
CParticle *m_pActiveParticle;
|
||||
float m_fViewerDist;
|
||||
cl_entity_t *m_pEntity;
|
||||
int m_iEntAttachment;
|
||||
int m_iKillCondition;
|
||||
int m_iLightingModel;
|
||||
matrix3x3 entityMatrix;
|
||||
int m_fHasProjectionLighting;
|
||||
float m_fLifeTime; // for auto-removed particles
|
||||
bool enable;
|
||||
|
||||
private:
|
||||
static float c_fCosTable[360 + 90];
|
||||
static bool c_bCosTableInit;
|
||||
|
||||
// the block of allocated particles
|
||||
CParticle *m_pAllParticles;
|
||||
|
||||
// First particles in the linked list for the active particles and the dead particles
|
||||
CParticle *m_pFreeParticle;
|
||||
CParticle *m_pMainParticle; // the "source" particle.
|
||||
|
||||
CParticleType *m_pFirstType;
|
||||
CParticleType *m_pMainType;
|
||||
};
|
||||
|
||||
class CParticleSystemManager
|
||||
{
|
||||
public:
|
||||
CParticleSystemManager( void );
|
||||
~CParticleSystemManager( void );
|
||||
void AddSystem( CParticleSystem* );
|
||||
CParticleSystem *FindSystem( CParticleSystem *pFirstSystem, cl_entity_t *pEntity );
|
||||
void MarkSystemForDeletion( CParticleSystem *pSys );
|
||||
void UpdateSystems( void );
|
||||
void ClearSystems( void );
|
||||
void SortSystems( void );
|
||||
private:
|
||||
CParticleSystem *m_pFirstSystem;
|
||||
};
|
||||
|
||||
extern CParticleSystemManager g_pParticleSystems; // buz
|
||||
|
||||
/*
|
||||
r_particle.h - Laurie Cheers Aurora Particle System
|
||||
First implementation of 02/08/02 November235
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_PARTICLE_H
|
||||
#define GL_PARTICLE_H
|
||||
|
||||
class CParticleType;
|
||||
class CParticleSystem;
|
||||
|
||||
#include "randomrange.h"
|
||||
|
||||
struct CParticle
|
||||
{
|
||||
CParticle *nextpart;
|
||||
CParticle *m_pOverlay; // for making multi-layered particles
|
||||
CParticleType *pType;
|
||||
|
||||
Vector origin;
|
||||
Vector velocity;
|
||||
Vector accel;
|
||||
Vector m_vecWind;
|
||||
|
||||
cl_entity_t *m_pEntity; // if not null, this particle is tied to the given entity
|
||||
|
||||
float m_fRed;
|
||||
float m_fGreen;
|
||||
float m_fBlue;
|
||||
float m_fRedStep;
|
||||
float m_fGreenStep;
|
||||
float m_fBlueStep;
|
||||
|
||||
float m_fAlpha;
|
||||
float m_fAlphaStep;
|
||||
|
||||
float frame;
|
||||
float m_fFrameStep;
|
||||
|
||||
float m_fAngle;
|
||||
float m_fAngleStep;
|
||||
|
||||
float m_fSize;
|
||||
float m_fSizeStep;
|
||||
|
||||
float m_fDrag;
|
||||
|
||||
float age;
|
||||
float age_death;
|
||||
float age_spray;
|
||||
};
|
||||
|
||||
class CParticleType
|
||||
{
|
||||
public:
|
||||
CParticleType( CParticleType *pNext = NULL );
|
||||
|
||||
// here is a particle system. Add a (set of) particles according to this type, and initialise their values.
|
||||
CParticle *CreateParticle( CParticleSystem *pSys );
|
||||
|
||||
// initialise this particle. Does not define velocity or age.
|
||||
void InitParticle( CParticle *pPart, CParticleSystem *pSys );
|
||||
|
||||
bool m_bIsDefined; // is this CParticleType just a placeholder?
|
||||
|
||||
int m_iRenderMode;
|
||||
int m_iDrawCond;
|
||||
RandomRange m_Bounce;
|
||||
RandomRange m_BounceFriction;
|
||||
bool m_bBouncing;
|
||||
|
||||
RandomRange m_Life;
|
||||
|
||||
RandomRange m_StartAlpha;
|
||||
RandomRange m_EndAlpha;
|
||||
RandomRange m_StartRed;
|
||||
RandomRange m_EndRed;
|
||||
RandomRange m_StartGreen;
|
||||
RandomRange m_EndGreen;
|
||||
RandomRange m_StartBlue;
|
||||
RandomRange m_EndBlue;
|
||||
|
||||
RandomRange m_StartSize;
|
||||
RandomRange m_SizeDelta;
|
||||
RandomRange m_EndSize;
|
||||
|
||||
RandomRange m_StartFrame;
|
||||
RandomRange m_EndFrame;
|
||||
RandomRange m_FrameRate; // incompatible with EndFrame
|
||||
bool m_bEndFrame;
|
||||
|
||||
RandomRange m_StartAngle;
|
||||
RandomRange m_AngleDelta;
|
||||
|
||||
RandomRange m_SprayRate;
|
||||
RandomRange m_SprayForce;
|
||||
RandomRange m_SprayPitch;
|
||||
RandomRange m_SprayYaw;
|
||||
RandomRange m_SprayRoll;
|
||||
|
||||
CParticleType *m_pSprayType;
|
||||
|
||||
RandomRange m_Gravity;
|
||||
RandomRange m_WindStrength;
|
||||
RandomRange m_WindYaw;
|
||||
|
||||
HSPRITE m_hSprite;
|
||||
CParticleType *m_pOverlayType;
|
||||
|
||||
RandomRange m_Drag;
|
||||
|
||||
CParticleType *m_pNext;
|
||||
char m_szName[32];
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AURORA_REMOVE = 0,
|
||||
AURORA_INVISIBLE,
|
||||
AURORA_DRAW,
|
||||
} AURSTATE;
|
||||
|
||||
class CParticleSystem
|
||||
{
|
||||
public:
|
||||
CParticleSystem( cl_entity_t *ent, const char *szFilename, int attachment = 0, float lifetime = 0.0f );
|
||||
~CParticleSystem( void );
|
||||
|
||||
void AllocateParticles( int iParticles );
|
||||
void CalculateDistance( void );
|
||||
CParticleType *GetType( const char *szName );
|
||||
CParticleType *AddPlaceholderType( const char *szName );
|
||||
CParticleType *ParseType( char *&szFile );
|
||||
|
||||
cl_entity_t *GetEntity() { return m_pEntity; }
|
||||
|
||||
// General functions
|
||||
AURSTATE UpdateSystem( float frametime ); // If this function returns false, the manager deletes the system
|
||||
void DrawSystem( void );
|
||||
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!
|
||||
// returns false if the particle has died
|
||||
bool UpdateParticle( CParticle *part, float frametime );
|
||||
void DrawParticle( CParticle *part, Vector &right, Vector &up );
|
||||
|
||||
// Utility functions that have to be public
|
||||
bool ParticleIsVisible( CParticle* part );
|
||||
|
||||
void MarkForDeletion( void );
|
||||
|
||||
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]; }
|
||||
|
||||
// Pointer to next system for linked list structure
|
||||
CParticleSystem *m_pNextSystem;
|
||||
|
||||
CParticle *m_pActiveParticle;
|
||||
float m_fViewerDist;
|
||||
cl_entity_t *m_pEntity;
|
||||
int m_iEntAttachment;
|
||||
int m_iKillCondition;
|
||||
int m_iLightingModel;
|
||||
matrix3x3 entityMatrix;
|
||||
int m_fHasProjectionLighting;
|
||||
float m_fLifeTime; // for auto-removed particles
|
||||
bool enable;
|
||||
|
||||
private:
|
||||
static float c_fCosTable[360 + 90];
|
||||
static bool c_bCosTableInit;
|
||||
|
||||
// the block of allocated particles
|
||||
CParticle *m_pAllParticles;
|
||||
|
||||
// First particles in the linked list for the active particles and the dead particles
|
||||
CParticle *m_pFreeParticle;
|
||||
CParticle *m_pMainParticle; // the "source" particle.
|
||||
|
||||
CParticleType *m_pFirstType;
|
||||
CParticleType *m_pMainType;
|
||||
};
|
||||
|
||||
class CParticleSystemManager
|
||||
{
|
||||
public:
|
||||
CParticleSystemManager( void );
|
||||
~CParticleSystemManager( void );
|
||||
void AddSystem( CParticleSystem* );
|
||||
CParticleSystem *FindSystem( CParticleSystem *pFirstSystem, cl_entity_t *pEntity );
|
||||
void MarkSystemForDeletion( CParticleSystem *pSys );
|
||||
void UpdateSystems( void );
|
||||
void ClearSystems( void );
|
||||
void SortSystems( void );
|
||||
private:
|
||||
CParticleSystem *m_pFirstSystem;
|
||||
};
|
||||
|
||||
extern CParticleSystemManager g_pParticleSystems; // buz
|
||||
|
||||
#endif//GL_PARTICLE_H
|
File diff suppressed because it is too large
Load Diff
|
@ -1,228 +1,228 @@
|
|||
/*
|
||||
gl_cubemaps.cpp - tools for cubemaps search & handling
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "com_model.h"
|
||||
#include "ref_params.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_decals.h"
|
||||
#include <mathlib.h>
|
||||
#include "gl_world.h"
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindNearestCubeMap
|
||||
|
||||
find the nearest cubemap for a given point
|
||||
=================
|
||||
*/
|
||||
void CL_FindNearestCubeMap( const Vector &pos, mcubemap_t **result )
|
||||
{
|
||||
if( !result ) return;
|
||||
|
||||
float maxDist = 99999.0f;
|
||||
*result = NULL;
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist )
|
||||
{
|
||||
*result = check;
|
||||
maxDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( !*result )
|
||||
{
|
||||
// this may happens if map
|
||||
// doesn't have any cubemaps
|
||||
*result = &world->defaultCubemap;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindNearestCubeMapForSurface
|
||||
|
||||
find the nearest cubemap on front of plane
|
||||
=================
|
||||
*/
|
||||
void CL_FindNearestCubeMapForSurface( const Vector &pos, const msurface_t *surf, mcubemap_t **result )
|
||||
{
|
||||
if( !result ) return;
|
||||
|
||||
float maxDist = 99999.0f;
|
||||
mplane_t plane;
|
||||
*result = NULL;
|
||||
|
||||
plane = *surf->plane;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
{
|
||||
plane.normal = -plane.normal;
|
||||
plane.dist = -plane.dist;
|
||||
}
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist && PlaneDiff( check->origin, &plane ) >= 0.0f )
|
||||
{
|
||||
*result = check;
|
||||
maxDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( *result ) return;
|
||||
|
||||
// fallback to default method
|
||||
CL_FindNearestCubeMap( pos, result );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindTwoNearestCubeMap
|
||||
|
||||
find the two nearest cubemaps for a given point
|
||||
=================
|
||||
*/
|
||||
void CL_FindTwoNearestCubeMap( const Vector &pos, mcubemap_t **result1, mcubemap_t **result2 )
|
||||
{
|
||||
if( !result1 || !result2 )
|
||||
return;
|
||||
|
||||
float maxDist1 = 99999.0f;
|
||||
float maxDist2 = 99999.0f;
|
||||
*result1 = *result2 = NULL;
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist1 )
|
||||
{
|
||||
*result1 = check;
|
||||
maxDist1 = dist;
|
||||
}
|
||||
else if( dist < maxDist2 && dist > maxDist1 )
|
||||
{
|
||||
*result2 = check;
|
||||
maxDist2 = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( !*result1 )
|
||||
{
|
||||
// this may happens if map
|
||||
// doesn't have any cubemaps
|
||||
*result1 = &world->defaultCubemap;
|
||||
}
|
||||
|
||||
if( !*result2 )
|
||||
{
|
||||
// this may happens if map
|
||||
// doesn't have any cubemaps
|
||||
*result2 = *result1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindTwoNearestCubeMapForSurface
|
||||
|
||||
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 )
|
||||
{
|
||||
if( !result1 || !result2 ) return;
|
||||
|
||||
float maxDist1 = 99999.0f;
|
||||
float maxDist2 = 99999.0f;
|
||||
mplane_t plane;
|
||||
*result1 = NULL;
|
||||
*result2 = NULL;
|
||||
|
||||
plane = *surf->plane;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
{
|
||||
plane.normal = -plane.normal;
|
||||
plane.dist = -plane.dist;
|
||||
}
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist1 && PlaneDiff( check->origin, &plane ) >= 0.0f )
|
||||
{
|
||||
*result1 = check;
|
||||
maxDist1 = dist;
|
||||
}
|
||||
else if( dist < maxDist2 && dist > maxDist1 )
|
||||
{
|
||||
*result2 = check;
|
||||
maxDist2 = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( *result1 )
|
||||
{
|
||||
if( !*result2 )
|
||||
*result2 = *result1;
|
||||
return;
|
||||
}
|
||||
|
||||
// fallback to default method
|
||||
CL_FindTwoNearestCubeMap( pos, result1, result2 );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_BuildCubemaps_f
|
||||
|
||||
force to rebuilds all the cubemaps
|
||||
in the scene
|
||||
=================
|
||||
*/
|
||||
void CL_BuildCubemaps_f( void )
|
||||
{
|
||||
mcubemap_t *m = &world->defaultCubemap;
|
||||
FREE_TEXTURE( m->texture );
|
||||
m->valid = m->texture = false;
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *m = &world->cubemaps[i];
|
||||
FREE_TEXTURE( m->texture );
|
||||
m->valid = m->texture = false;
|
||||
}
|
||||
|
||||
if( FBitSet( world->features, WORLD_HAS_SKYBOX ))
|
||||
world->build_default_cubemap = true;
|
||||
|
||||
world->rebuilding_cubemaps = CMREBUILD_CHECKING;
|
||||
world->loading_cubemaps = true;
|
||||
/*
|
||||
gl_cubemaps.cpp - tools for cubemaps search & handling
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "com_model.h"
|
||||
#include "ref_params.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_decals.h"
|
||||
#include <mathlib.h>
|
||||
#include "gl_world.h"
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindNearestCubeMap
|
||||
|
||||
find the nearest cubemap for a given point
|
||||
=================
|
||||
*/
|
||||
void CL_FindNearestCubeMap( const Vector &pos, mcubemap_t **result )
|
||||
{
|
||||
if( !result ) return;
|
||||
|
||||
float maxDist = 99999.0f;
|
||||
*result = NULL;
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist )
|
||||
{
|
||||
*result = check;
|
||||
maxDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( !*result )
|
||||
{
|
||||
// this may happens if map
|
||||
// doesn't have any cubemaps
|
||||
*result = &world->defaultCubemap;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindNearestCubeMapForSurface
|
||||
|
||||
find the nearest cubemap on front of plane
|
||||
=================
|
||||
*/
|
||||
void CL_FindNearestCubeMapForSurface( const Vector &pos, const msurface_t *surf, mcubemap_t **result )
|
||||
{
|
||||
if( !result ) return;
|
||||
|
||||
float maxDist = 99999.0f;
|
||||
mplane_t plane;
|
||||
*result = NULL;
|
||||
|
||||
plane = *surf->plane;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
{
|
||||
plane.normal = -plane.normal;
|
||||
plane.dist = -plane.dist;
|
||||
}
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist && PlaneDiff( check->origin, &plane ) >= 0.0f )
|
||||
{
|
||||
*result = check;
|
||||
maxDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( *result ) return;
|
||||
|
||||
// fallback to default method
|
||||
CL_FindNearestCubeMap( pos, result );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindTwoNearestCubeMap
|
||||
|
||||
find the two nearest cubemaps for a given point
|
||||
=================
|
||||
*/
|
||||
void CL_FindTwoNearestCubeMap( const Vector &pos, mcubemap_t **result1, mcubemap_t **result2 )
|
||||
{
|
||||
if( !result1 || !result2 )
|
||||
return;
|
||||
|
||||
float maxDist1 = 99999.0f;
|
||||
float maxDist2 = 99999.0f;
|
||||
*result1 = *result2 = NULL;
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist1 )
|
||||
{
|
||||
*result1 = check;
|
||||
maxDist1 = dist;
|
||||
}
|
||||
else if( dist < maxDist2 && dist > maxDist1 )
|
||||
{
|
||||
*result2 = check;
|
||||
maxDist2 = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( !*result1 )
|
||||
{
|
||||
// this may happens if map
|
||||
// doesn't have any cubemaps
|
||||
*result1 = &world->defaultCubemap;
|
||||
}
|
||||
|
||||
if( !*result2 )
|
||||
{
|
||||
// this may happens if map
|
||||
// doesn't have any cubemaps
|
||||
*result2 = *result1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_FindTwoNearestCubeMapForSurface
|
||||
|
||||
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 )
|
||||
{
|
||||
if( !result1 || !result2 ) return;
|
||||
|
||||
float maxDist1 = 99999.0f;
|
||||
float maxDist2 = 99999.0f;
|
||||
mplane_t plane;
|
||||
*result1 = NULL;
|
||||
*result2 = NULL;
|
||||
|
||||
plane = *surf->plane;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
{
|
||||
plane.normal = -plane.normal;
|
||||
plane.dist = -plane.dist;
|
||||
}
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *check = &world->cubemaps[i];
|
||||
float dist = VectorDistance( check->origin, pos );
|
||||
|
||||
if( dist < maxDist1 && PlaneDiff( check->origin, &plane ) >= 0.0f )
|
||||
{
|
||||
*result1 = check;
|
||||
maxDist1 = dist;
|
||||
}
|
||||
else if( dist < maxDist2 && dist > maxDist1 )
|
||||
{
|
||||
*result2 = check;
|
||||
maxDist2 = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if( *result1 )
|
||||
{
|
||||
if( !*result2 )
|
||||
*result2 = *result1;
|
||||
return;
|
||||
}
|
||||
|
||||
// fallback to default method
|
||||
CL_FindTwoNearestCubeMap( pos, result1, result2 );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_BuildCubemaps_f
|
||||
|
||||
force to rebuilds all the cubemaps
|
||||
in the scene
|
||||
=================
|
||||
*/
|
||||
void CL_BuildCubemaps_f( void )
|
||||
{
|
||||
mcubemap_t *m = &world->defaultCubemap;
|
||||
FREE_TEXTURE( m->texture );
|
||||
m->valid = m->texture = false;
|
||||
|
||||
for( int i = 0; i < world->num_cubemaps; i++ )
|
||||
{
|
||||
mcubemap_t *m = &world->cubemaps[i];
|
||||
FREE_TEXTURE( m->texture );
|
||||
m->valid = m->texture = false;
|
||||
}
|
||||
|
||||
if( FBitSet( world->features, WORLD_HAS_SKYBOX ))
|
||||
world->build_default_cubemap = true;
|
||||
|
||||
world->rebuilding_cubemaps = CMREBUILD_CHECKING;
|
||||
world->loading_cubemaps = true;
|
||||
}
|
|
@ -1,253 +1,253 @@
|
|||
/*
|
||||
gl_cull.cpp - render culling routines
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "entity_types.h"
|
||||
#include "mathlib.h"
|
||||
#include "gl_world.h"
|
||||
#include "gl_grass.h"
|
||||
|
||||
/*
|
||||
=============
|
||||
R_CullModel
|
||||
=============
|
||||
*/
|
||||
bool R_CullModel( cl_entity_t *e, const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
if( e == GET_VIEWMODEL( ) || e == gHUD.m_pHeadShieldEnt )
|
||||
{
|
||||
if( RI->params & RP_NONVIEWERREF )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// don't reflect this entity in mirrors
|
||||
if( FBitSet( e->curstate.effects, EF_NOREFLECT ) && FBitSet( RI->params, RP_MIRRORVIEW ))
|
||||
return true;
|
||||
|
||||
// draw only in mirrors
|
||||
if( FBitSet( e->curstate.effects, EF_REFLECTONLY ) && !FBitSet( RI->params, RP_MIRRORVIEW ))
|
||||
return true;
|
||||
|
||||
// never draw playermodel for himself flashlight while shadowpass is active
|
||||
if( FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight != NULL )
|
||||
{
|
||||
if( UTIL_IsLocal( e->index ) && RI->currentlight->key == FLASHLIGHT_KEY )
|
||||
return true;
|
||||
}
|
||||
#if 0
|
||||
// don't cull local player because we draw legs instead
|
||||
if( RP_LOCALCLIENT( e ) && !FBitSet( RI->params, RP_THIRDPERSON ) && UTIL_IsLocal( RI->view.entity ))
|
||||
{
|
||||
// player can view himself from the portal camera
|
||||
if( !FBitSet( RI->params, RP_MIRRORVIEW|RP_SHADOWVIEW ))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return R_CullBox( absmin, absmax );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_CullBrushModel
|
||||
|
||||
Cull brush model by bbox
|
||||
================
|
||||
*/
|
||||
bool R_CullBrushModel( cl_entity_t *e )
|
||||
{
|
||||
gl_state_t *glm = GL_GetCache( e->hCachedMatrix );
|
||||
model_t *clmodel = e->model;
|
||||
Vector absmin, absmax;
|
||||
|
||||
if( !e || !e->model )
|
||||
return true;
|
||||
|
||||
// skybox entity
|
||||
if( e->curstate.renderfx == SKYBOX_ENTITY )
|
||||
{
|
||||
if( FBitSet( RI->params, RP_SHADOWVIEW ))
|
||||
return true;
|
||||
|
||||
Vector trans = GetVieworg() - tr.sky_origin;
|
||||
|
||||
if( 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;
|
||||
tr.modelorg = skypos - e->origin;
|
||||
}
|
||||
else tr.modelorg = tr.sky_origin - e->origin;
|
||||
|
||||
absmin = e->origin + trans + clmodel->mins;
|
||||
absmax = e->origin + trans + clmodel->maxs;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( e->angles != g_vecZero )
|
||||
{
|
||||
absmin = e->origin - clmodel->radius;
|
||||
absmax = e->origin + clmodel->radius;
|
||||
}
|
||||
else
|
||||
{
|
||||
absmin = e->origin + clmodel->mins;
|
||||
absmax = e->origin + clmodel->maxs;
|
||||
}
|
||||
tr.modelorg = glm->GetModelOrigin();
|
||||
}
|
||||
|
||||
return R_CullModel( e, absmin, absmax );
|
||||
}
|
||||
|
||||
static bool R_SunLightShadow( void )
|
||||
{
|
||||
if( RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL && FBitSet( RI->params, RP_SHADOWVIEW ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_AllowFacePlaneCulling
|
||||
|
||||
allow to culling backfaces
|
||||
=================
|
||||
*/
|
||||
static bool R_AllowFacePlaneCulling( msurface_t *surf )
|
||||
{
|
||||
if( !glState.faceCull )
|
||||
return false;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_TWOSIDE ))
|
||||
return false;
|
||||
|
||||
if( !FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL )
|
||||
return false;
|
||||
|
||||
// don't cull transparent surfaces because we should be draw decals on them
|
||||
if( FBitSet( surf->flags, SURF_HAS_DECALS ) && !R_OpaqueEntity( RI->currententity ))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_CullSurface
|
||||
|
||||
cull invisible surfaces
|
||||
=================
|
||||
*/
|
||||
int R_CullSurface( msurface_t *surf, const Vector &vieworg, CFrustum *frustum, int clipFlags )
|
||||
{
|
||||
cl_entity_t *e = RI->currententity;
|
||||
|
||||
if( !surf || !surf->texinfo || !surf->texinfo->texture )
|
||||
return CULL_OTHER;
|
||||
|
||||
if( FBitSet( RI->params, RP_WATERPASS ) && R_WaterEntity( e->model ))
|
||||
return CULL_OTHER; // don't render water from waterplane reflection
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return CULL_VISIBLE;
|
||||
|
||||
if( R_SunLightShadow( ))
|
||||
return CULL_VISIBLE;
|
||||
|
||||
// because light or shadow passes required both sides for right self-shadowing
|
||||
if( R_AllowFacePlaneCulling( surf ))
|
||||
{
|
||||
float dist;
|
||||
|
||||
// can use normal.z for world (optimisation)
|
||||
if( FBitSet( RI->params, RP_DRAW_OVERVIEW ))
|
||||
{
|
||||
Vector orthonormal;
|
||||
|
||||
if( e == GET_ENTITY( 0 ) || R_StaticEntity( e ))
|
||||
{
|
||||
orthonormal.z = surf->plane->normal.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix4x4 m = matrix4x4( g_vecZero, e->angles );
|
||||
orthonormal = m.VectorRotate( surf->plane->normal );
|
||||
}
|
||||
|
||||
dist = orthonormal.z;
|
||||
}
|
||||
else dist = PlaneDiff( vieworg, surf->plane );
|
||||
|
||||
if( glState.faceCull == GL_FRONT || ( RI->params & RP_MIRRORVIEW ))
|
||||
{
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
{
|
||||
if( dist >= -BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist <= BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
}
|
||||
else if( glState.faceCull == GL_BACK )
|
||||
{
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
{
|
||||
if( dist <= BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist >= -BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( frustum && frustum->CullBox( surf->info->mins, surf->info->maxs, clipFlags ))
|
||||
return CULL_FRUSTUM;
|
||||
return CULL_VISIBLE;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_CullNodeTopView
|
||||
|
||||
cull node by user rectangle (simple scissor)
|
||||
================
|
||||
*/
|
||||
bool R_CullNodeTopView( mnode_t *node )
|
||||
{
|
||||
Vector2D delta, size;
|
||||
Vector center, half, mins, maxs;
|
||||
|
||||
// build the node center and half-diagonal
|
||||
mins = node->minmaxs, maxs = node->minmaxs + 3;
|
||||
center = (mins + maxs) * 0.5f;
|
||||
half = maxs - center;
|
||||
|
||||
// cull against the screen frustum or the appropriate area's frustum.
|
||||
delta.x = center.x - world->orthocenter.x;
|
||||
delta.y = center.y - world->orthocenter.y;
|
||||
size.x = half.x + world->orthohalf.x;
|
||||
size.y = half.y + world->orthohalf.y;
|
||||
|
||||
return ( fabs( delta.x ) > size.x ) || ( fabs( delta.y ) > size.y );
|
||||
}
|
||||
/*
|
||||
gl_cull.cpp - render culling routines
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "entity_types.h"
|
||||
#include "mathlib.h"
|
||||
#include "gl_world.h"
|
||||
#include "gl_grass.h"
|
||||
|
||||
/*
|
||||
=============
|
||||
R_CullModel
|
||||
=============
|
||||
*/
|
||||
bool R_CullModel( cl_entity_t *e, const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
if( e == GET_VIEWMODEL( ) || e == gHUD.m_pHeadShieldEnt )
|
||||
{
|
||||
if( RI->params & RP_NONVIEWERREF )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// don't reflect this entity in mirrors
|
||||
if( FBitSet( e->curstate.effects, EF_NOREFLECT ) && FBitSet( RI->params, RP_MIRRORVIEW ))
|
||||
return true;
|
||||
|
||||
// draw only in mirrors
|
||||
if( FBitSet( e->curstate.effects, EF_REFLECTONLY ) && !FBitSet( RI->params, RP_MIRRORVIEW ))
|
||||
return true;
|
||||
|
||||
// never draw playermodel for himself flashlight while shadowpass is active
|
||||
if( FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight != NULL )
|
||||
{
|
||||
if( UTIL_IsLocal( e->index ) && RI->currentlight->key == FLASHLIGHT_KEY )
|
||||
return true;
|
||||
}
|
||||
#if 0
|
||||
// don't cull local player because we draw legs instead
|
||||
if( RP_LOCALCLIENT( e ) && !FBitSet( RI->params, RP_THIRDPERSON ) && UTIL_IsLocal( RI->view.entity ))
|
||||
{
|
||||
// player can view himself from the portal camera
|
||||
if( !FBitSet( RI->params, RP_MIRRORVIEW|RP_SHADOWVIEW ))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return R_CullBox( absmin, absmax );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_CullBrushModel
|
||||
|
||||
Cull brush model by bbox
|
||||
================
|
||||
*/
|
||||
bool R_CullBrushModel( cl_entity_t *e )
|
||||
{
|
||||
gl_state_t *glm = GL_GetCache( e->hCachedMatrix );
|
||||
model_t *clmodel = e->model;
|
||||
Vector absmin, absmax;
|
||||
|
||||
if( !e || !e->model )
|
||||
return true;
|
||||
|
||||
// skybox entity
|
||||
if( e->curstate.renderfx == SKYBOX_ENTITY )
|
||||
{
|
||||
if( FBitSet( RI->params, RP_SHADOWVIEW ))
|
||||
return true;
|
||||
|
||||
Vector trans = GetVieworg() - tr.sky_origin;
|
||||
|
||||
if( 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;
|
||||
tr.modelorg = skypos - e->origin;
|
||||
}
|
||||
else tr.modelorg = tr.sky_origin - e->origin;
|
||||
|
||||
absmin = e->origin + trans + clmodel->mins;
|
||||
absmax = e->origin + trans + clmodel->maxs;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( e->angles != g_vecZero )
|
||||
{
|
||||
absmin = e->origin - clmodel->radius;
|
||||
absmax = e->origin + clmodel->radius;
|
||||
}
|
||||
else
|
||||
{
|
||||
absmin = e->origin + clmodel->mins;
|
||||
absmax = e->origin + clmodel->maxs;
|
||||
}
|
||||
tr.modelorg = glm->GetModelOrigin();
|
||||
}
|
||||
|
||||
return R_CullModel( e, absmin, absmax );
|
||||
}
|
||||
|
||||
static bool R_SunLightShadow( void )
|
||||
{
|
||||
if( RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL && FBitSet( RI->params, RP_SHADOWVIEW ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_AllowFacePlaneCulling
|
||||
|
||||
allow to culling backfaces
|
||||
=================
|
||||
*/
|
||||
static bool R_AllowFacePlaneCulling( msurface_t *surf )
|
||||
{
|
||||
if( !glState.faceCull )
|
||||
return false;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_TWOSIDE ))
|
||||
return false;
|
||||
|
||||
if( !FBitSet( RI->params, RP_SHADOWVIEW ) && RI->currentlight && RI->currentlight->type == LIGHT_DIRECTIONAL )
|
||||
return false;
|
||||
|
||||
// don't cull transparent surfaces because we should be draw decals on them
|
||||
if( FBitSet( surf->flags, SURF_HAS_DECALS ) && !R_OpaqueEntity( RI->currententity ))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_CullSurface
|
||||
|
||||
cull invisible surfaces
|
||||
=================
|
||||
*/
|
||||
int R_CullSurface( msurface_t *surf, const Vector &vieworg, CFrustum *frustum, int clipFlags )
|
||||
{
|
||||
cl_entity_t *e = RI->currententity;
|
||||
|
||||
if( !surf || !surf->texinfo || !surf->texinfo->texture )
|
||||
return CULL_OTHER;
|
||||
|
||||
if( FBitSet( RI->params, RP_WATERPASS ) && R_WaterEntity( e->model ))
|
||||
return CULL_OTHER; // don't render water from waterplane reflection
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return CULL_VISIBLE;
|
||||
|
||||
if( R_SunLightShadow( ))
|
||||
return CULL_VISIBLE;
|
||||
|
||||
// because light or shadow passes required both sides for right self-shadowing
|
||||
if( R_AllowFacePlaneCulling( surf ))
|
||||
{
|
||||
float dist;
|
||||
|
||||
// can use normal.z for world (optimisation)
|
||||
if( FBitSet( RI->params, RP_DRAW_OVERVIEW ))
|
||||
{
|
||||
Vector orthonormal;
|
||||
|
||||
if( e == GET_ENTITY( 0 ) || R_StaticEntity( e ))
|
||||
{
|
||||
orthonormal.z = surf->plane->normal.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix4x4 m = matrix4x4( g_vecZero, e->angles );
|
||||
orthonormal = m.VectorRotate( surf->plane->normal );
|
||||
}
|
||||
|
||||
dist = orthonormal.z;
|
||||
}
|
||||
else dist = PlaneDiff( vieworg, surf->plane );
|
||||
|
||||
if( glState.faceCull == GL_FRONT || ( RI->params & RP_MIRRORVIEW ))
|
||||
{
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
{
|
||||
if( dist >= -BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist <= BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
}
|
||||
else if( glState.faceCull == GL_BACK )
|
||||
{
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
{
|
||||
if( dist <= BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist >= -BACKFACE_EPSILON )
|
||||
return CULL_BACKSIDE; // wrong side
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( frustum && frustum->CullBox( surf->info->mins, surf->info->maxs, clipFlags ))
|
||||
return CULL_FRUSTUM;
|
||||
return CULL_VISIBLE;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_CullNodeTopView
|
||||
|
||||
cull node by user rectangle (simple scissor)
|
||||
================
|
||||
*/
|
||||
bool R_CullNodeTopView( mnode_t *node )
|
||||
{
|
||||
Vector2D delta, size;
|
||||
Vector center, half, mins, maxs;
|
||||
|
||||
// build the node center and half-diagonal
|
||||
mins = node->minmaxs, maxs = node->minmaxs + 3;
|
||||
center = (mins + maxs) * 0.5f;
|
||||
half = maxs - center;
|
||||
|
||||
// cull against the screen frustum or the appropriate area's frustum.
|
||||
delta.x = center.x - world->orthocenter.x;
|
||||
delta.y = center.y - world->orthocenter.y;
|
||||
size.x = half.x + world->orthohalf.x;
|
||||
size.y = half.y + world->orthohalf.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
|
@ -1,105 +1,105 @@
|
|||
/*
|
||||
gl_decals.h - decal project & rendering
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_DECALS_H
|
||||
#define GL_DECALS_H
|
||||
|
||||
class DecalGroup;
|
||||
class DecalGroupEntry
|
||||
{
|
||||
public:
|
||||
char m_DecalName[64];
|
||||
unsigned short gl_diffuse_id;
|
||||
unsigned short gl_normalmap_id;
|
||||
unsigned short gl_heightmap_id;
|
||||
unsigned short gl_specular_id; // specular
|
||||
int xsize, ysize;
|
||||
matdesc_t *matdesc; // pointer to settings
|
||||
float overlay;
|
||||
bool opaque; // solid decal doesn't use blend
|
||||
const DecalGroup *group; // get group name
|
||||
bool m_init;
|
||||
|
||||
void PreloadTextures( void );
|
||||
};
|
||||
|
||||
class DecalGroup
|
||||
{
|
||||
public:
|
||||
DecalGroup( const char *name, int numelems, DecalGroupEntry *source );
|
||||
~DecalGroup();
|
||||
|
||||
DecalGroupEntry *GetRandomDecal( void );
|
||||
DecalGroup *GetNext( void ) { return pnext; }
|
||||
const char *GetName( void ) { return m_chGroupName; }
|
||||
const char *GetName( void ) const { return m_chGroupName; }
|
||||
static DecalGroup *FindGroup( const char *name );
|
||||
DecalGroupEntry *FindEntry( const char *name );
|
||||
DecalGroupEntry *GetEntry( int num );
|
||||
static DecalGroupEntry *GetEntry( const char *name, int flags );
|
||||
private:
|
||||
char m_chGroupName[16];
|
||||
DecalGroupEntry *pEntryArray;
|
||||
DecalGroup *pnext;
|
||||
int size;
|
||||
};
|
||||
|
||||
typedef struct dvert_s
|
||||
{
|
||||
Vector vertex; // position
|
||||
Vector tangent; // tangent
|
||||
Vector binormal; // binormal
|
||||
Vector normal; // normal
|
||||
float stcoord0[4]; // ST texture coords + Decal coords
|
||||
float lmcoord0[4]; // LM texture coords for styles 0-1
|
||||
float lmcoord1[4]; // LM texture coords for styles 2-3
|
||||
byte styles[4]; // lightstyles
|
||||
} dvert_t;
|
||||
|
||||
// decal entry
|
||||
typedef struct brushdecal_s
|
||||
{
|
||||
// this part is goes to savelist
|
||||
byte flags;
|
||||
short entityIndex;
|
||||
Vector position;
|
||||
Vector impactPlaneNormal;
|
||||
float angle; // goes into scale
|
||||
const DecalGroupEntry *texinfo;
|
||||
|
||||
// verts & elems
|
||||
dvert_t *verts; // pointer to cache array
|
||||
word *elems; // pointer to index array
|
||||
byte numVerts;
|
||||
byte numElems;
|
||||
|
||||
// shader cache
|
||||
shader_t forwardScene;
|
||||
shader_t deferredScene;
|
||||
mextrasurf_t *surface;
|
||||
struct brushdecal_s *pnext; // linked list for each surface
|
||||
model_t *model;
|
||||
} brushdecal_t;
|
||||
|
||||
void DecalsInit( void );
|
||||
void ClearDecals( void );
|
||||
void DecalsShutdown( void );
|
||||
void R_RenderDecalsSolidList( drawlist_t drawlist_type );
|
||||
void R_RenderDecalsTransList( drawlist_t drawlist_type );
|
||||
void R_RenderDecalsTransEntry( CTransEntry *entry, drawlist_t drawlist_type );
|
||||
int SaveDecalList( decallist_t *pBaseList, int count );
|
||||
|
||||
/*
|
||||
gl_decals.h - decal project & rendering
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_DECALS_H
|
||||
#define GL_DECALS_H
|
||||
|
||||
class DecalGroup;
|
||||
class DecalGroupEntry
|
||||
{
|
||||
public:
|
||||
char m_DecalName[64];
|
||||
unsigned short gl_diffuse_id;
|
||||
unsigned short gl_normalmap_id;
|
||||
unsigned short gl_heightmap_id;
|
||||
unsigned short gl_specular_id; // specular
|
||||
int xsize, ysize;
|
||||
matdesc_t *matdesc; // pointer to settings
|
||||
float overlay;
|
||||
bool opaque; // solid decal doesn't use blend
|
||||
const DecalGroup *group; // get group name
|
||||
bool m_init;
|
||||
|
||||
void PreloadTextures( void );
|
||||
};
|
||||
|
||||
class DecalGroup
|
||||
{
|
||||
public:
|
||||
DecalGroup( const char *name, int numelems, DecalGroupEntry *source );
|
||||
~DecalGroup();
|
||||
|
||||
DecalGroupEntry *GetRandomDecal( void );
|
||||
DecalGroup *GetNext( void ) { return pnext; }
|
||||
const char *GetName( void ) { return m_chGroupName; }
|
||||
const char *GetName( void ) const { return m_chGroupName; }
|
||||
static DecalGroup *FindGroup( const char *name );
|
||||
DecalGroupEntry *FindEntry( const char *name );
|
||||
DecalGroupEntry *GetEntry( int num );
|
||||
static DecalGroupEntry *GetEntry( const char *name, int flags );
|
||||
private:
|
||||
char m_chGroupName[16];
|
||||
DecalGroupEntry *pEntryArray;
|
||||
DecalGroup *pnext;
|
||||
int size;
|
||||
};
|
||||
|
||||
typedef struct dvert_s
|
||||
{
|
||||
Vector vertex; // position
|
||||
Vector tangent; // tangent
|
||||
Vector binormal; // binormal
|
||||
Vector normal; // normal
|
||||
float stcoord0[4]; // ST texture coords + Decal coords
|
||||
float lmcoord0[4]; // LM texture coords for styles 0-1
|
||||
float lmcoord1[4]; // LM texture coords for styles 2-3
|
||||
byte styles[4]; // lightstyles
|
||||
} dvert_t;
|
||||
|
||||
// decal entry
|
||||
typedef struct brushdecal_s
|
||||
{
|
||||
// this part is goes to savelist
|
||||
byte flags;
|
||||
short entityIndex;
|
||||
Vector position;
|
||||
Vector impactPlaneNormal;
|
||||
float angle; // goes into scale
|
||||
const DecalGroupEntry *texinfo;
|
||||
|
||||
// verts & elems
|
||||
dvert_t *verts; // pointer to cache array
|
||||
word *elems; // pointer to index array
|
||||
byte numVerts;
|
||||
byte numElems;
|
||||
|
||||
// shader cache
|
||||
shader_t forwardScene;
|
||||
shader_t deferredScene;
|
||||
mextrasurf_t *surface;
|
||||
struct brushdecal_s *pnext; // linked list for each surface
|
||||
model_t *model;
|
||||
} brushdecal_t;
|
||||
|
||||
void DecalsInit( void );
|
||||
void ClearDecals( void );
|
||||
void DecalsShutdown( void );
|
||||
void R_RenderDecalsSolidList( drawlist_t drawlist_type );
|
||||
void R_RenderDecalsTransList( drawlist_t drawlist_type );
|
||||
void R_RenderDecalsTransEntry( CTransEntry *entry, drawlist_t drawlist_type );
|
||||
int SaveDecalList( decallist_t *pBaseList, int count );
|
||||
|
||||
#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
|
@ -1,63 +1,63 @@
|
|||
/*
|
||||
gl_framebuffer.h - framebuffer implementation class
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_FRAMEBUFFER_H
|
||||
#define GL_FRAMEBUFFER_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FBO_COLOR = 0, // only color texture is used
|
||||
FBO_DEPTH, // only depth texture is used
|
||||
FBO_CUBE, // only color texture as cubemap is side
|
||||
} FBO_TYPE;
|
||||
|
||||
#define FBO_MAKEPOW (1<<0) // round buffer size to nearest pow
|
||||
#define FBO_NOTEXTURE (1<<1) // don't create texture on initialization
|
||||
#define FBO_FLOAT (1<<2) // use float texture
|
||||
#define FBO_RECTANGLE (1<<3) // use rectangle texture
|
||||
#define FBO_LINEAR (1<<4) // use linear filtering
|
||||
#define FBO_LUMINANCE (1<<5) // force to luminance texture
|
||||
|
||||
class CFrameBuffer
|
||||
{
|
||||
public:
|
||||
CFrameBuffer();
|
||||
~CFrameBuffer();
|
||||
|
||||
bool Init( FBO_TYPE type, GLuint width, GLuint height, GLuint flags = 0 );
|
||||
void Bind( GLuint texture = 0, GLuint side = 0 );
|
||||
bool ValidateFBO( void );
|
||||
void Free( void );
|
||||
|
||||
unsigned int GetWidth( void ) const { return m_iFrameWidth; }
|
||||
unsigned int GetHeight( void ) const { return m_iFrameHeight; }
|
||||
int GetTexture( void ) const { return m_iTexture; }
|
||||
bool Active( void ) const { return m_bAllowFBO; }
|
||||
protected:
|
||||
static int m_iBufferNum; // single object for all instances
|
||||
private:
|
||||
GLuint m_iFrameWidth;
|
||||
GLuint m_iFrameHeight;
|
||||
GLint m_iTexture;
|
||||
|
||||
GLuint m_iFrameBuffer;
|
||||
GLuint m_iDepthBuffer;
|
||||
GLenum m_iAttachment; // attachment type
|
||||
bool m_bAllowFBO; // FBO is valid
|
||||
GLuint m_iFlags; // member FBO flags
|
||||
};
|
||||
|
||||
/*
|
||||
gl_framebuffer.h - framebuffer implementation class
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_FRAMEBUFFER_H
|
||||
#define GL_FRAMEBUFFER_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FBO_COLOR = 0, // only color texture is used
|
||||
FBO_DEPTH, // only depth texture is used
|
||||
FBO_CUBE, // only color texture as cubemap is side
|
||||
} FBO_TYPE;
|
||||
|
||||
#define FBO_MAKEPOW (1<<0) // round buffer size to nearest pow
|
||||
#define FBO_NOTEXTURE (1<<1) // don't create texture on initialization
|
||||
#define FBO_FLOAT (1<<2) // use float texture
|
||||
#define FBO_RECTANGLE (1<<3) // use rectangle texture
|
||||
#define FBO_LINEAR (1<<4) // use linear filtering
|
||||
#define FBO_LUMINANCE (1<<5) // force to luminance texture
|
||||
|
||||
class CFrameBuffer
|
||||
{
|
||||
public:
|
||||
CFrameBuffer();
|
||||
~CFrameBuffer();
|
||||
|
||||
bool Init( FBO_TYPE type, GLuint width, GLuint height, GLuint flags = 0 );
|
||||
void Bind( GLuint texture = 0, GLuint side = 0 );
|
||||
bool ValidateFBO( void );
|
||||
void Free( void );
|
||||
|
||||
unsigned int GetWidth( void ) const { return m_iFrameWidth; }
|
||||
unsigned int GetHeight( void ) const { return m_iFrameHeight; }
|
||||
int GetTexture( void ) const { return m_iTexture; }
|
||||
bool Active( void ) const { return m_bAllowFBO; }
|
||||
protected:
|
||||
static int m_iBufferNum; // single object for all instances
|
||||
private:
|
||||
GLuint m_iFrameWidth;
|
||||
GLuint m_iFrameHeight;
|
||||
GLint m_iTexture;
|
||||
|
||||
GLuint m_iFrameBuffer;
|
||||
GLuint m_iDepthBuffer;
|
||||
GLenum m_iAttachment; // attachment type
|
||||
bool m_bAllowFBO; // FBO is valid
|
||||
GLuint m_iFlags; // member FBO flags
|
||||
};
|
||||
|
||||
#endif//GL_FRAMEBUFFER_H
|
|
@ -1,374 +1,374 @@
|
|||
/*
|
||||
gl_frustum.cpp - frustum test implementation class
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "ref_params.h"
|
||||
#include "gl_local.h"
|
||||
#include <mathlib.h>
|
||||
#include <stringlib.h>
|
||||
|
||||
void CFrustum :: ClearFrustum( void )
|
||||
{
|
||||
memset( planes, 0, sizeof( planes ));
|
||||
clipFlags = 0;
|
||||
}
|
||||
|
||||
void CFrustum :: EnablePlane( int side )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
|
||||
// make sure what plane is ready
|
||||
if( planes[side].normal != g_vecZero )
|
||||
SetBits( clipFlags, BIT( side ));
|
||||
}
|
||||
|
||||
void CFrustum :: DisablePlane( int side )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
ClearBits( clipFlags, BIT( side ));
|
||||
}
|
||||
|
||||
void CFrustum :: InitProjection( const matrix4x4 &view, float flZNear, float flZFar, float flFovX, float flFovY )
|
||||
{
|
||||
float xs, xc;
|
||||
Vector normal;
|
||||
|
||||
// horizontal fov used for left and right planes
|
||||
SinCos( DEG2RAD( flFovX ) * 0.5f, &xs, &xc );
|
||||
|
||||
// setup left plane
|
||||
normal = view.GetForward() * xs + view.GetRight() * -xc;
|
||||
SetPlane( FRUSTUM_LEFT, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// setup right plane
|
||||
normal = view.GetForward() * xs + view.GetRight() * xc;
|
||||
SetPlane( FRUSTUM_RIGHT, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// vertical fov used for top and bottom planes
|
||||
SinCos( DEG2RAD( flFovY ) * 0.5f, &xs, &xc );
|
||||
|
||||
// setup bottom plane
|
||||
normal = view.GetForward() * xs + view.GetUp() * -xc;
|
||||
SetPlane( FRUSTUM_BOTTOM, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// setup top plane
|
||||
normal = view.GetForward() * xs + view.GetUp() * xc;
|
||||
SetPlane( FRUSTUM_TOP, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// setup far plane
|
||||
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
|
||||
if( flZNear == 0.0f ) return;
|
||||
|
||||
// setup near plane
|
||||
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 )
|
||||
{
|
||||
// setup the near and far planes
|
||||
float orgOffset = DotProduct( view.GetOrigin(), view.GetForward() );
|
||||
|
||||
SetPlane( FRUSTUM_FAR, -view.GetForward(), -flZNear - orgOffset );
|
||||
SetPlane( FRUSTUM_NEAR, view.GetForward(), flZFar + orgOffset );
|
||||
|
||||
// setup left and right planes
|
||||
orgOffset = DotProduct( view.GetOrigin(), view.GetRight() );
|
||||
|
||||
SetPlane( FRUSTUM_LEFT, view.GetRight(), xLeft + orgOffset );
|
||||
SetPlane( FRUSTUM_RIGHT, -view.GetRight(), -xRight - orgOffset );
|
||||
|
||||
// setup top and buttom planes
|
||||
orgOffset = DotProduct( view.GetOrigin(), view.GetUp() );
|
||||
|
||||
SetPlane( FRUSTUM_TOP, view.GetUp(), yTop + orgOffset );
|
||||
SetPlane( FRUSTUM_BOTTOM, -view.GetUp(), -yBottom - orgOffset );
|
||||
}
|
||||
|
||||
void CFrustum :: InitBoxFrustum( const Vector &org, float radius )
|
||||
{
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
// setup normal for each direction
|
||||
Vector normal = g_vecZero;
|
||||
normal[((i >> 1) + 1) % 3] = (i & 1) ? 1.0f : -1.0f;
|
||||
SetPlane( i, normal, DotProduct( org, normal ) - radius );
|
||||
}
|
||||
}
|
||||
|
||||
void CFrustum :: InitProjectionFromMatrix( const matrix4x4 &projection )
|
||||
{
|
||||
// left
|
||||
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[2] = projection[2][3] + projection[2][0];
|
||||
planes[FRUSTUM_LEFT].dist = -(projection[3][3] + projection[3][0]);
|
||||
|
||||
// right
|
||||
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[2] = projection[2][3] - projection[2][0];
|
||||
planes[FRUSTUM_RIGHT].dist = -(projection[3][3] - projection[3][0]);
|
||||
|
||||
// bottom
|
||||
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[2] = projection[2][3] + projection[2][1];
|
||||
planes[FRUSTUM_BOTTOM].dist = -(projection[3][3] + projection[3][1]);
|
||||
|
||||
// top
|
||||
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[2] = projection[2][3] - projection[2][1];
|
||||
planes[FRUSTUM_TOP].dist = -(projection[3][3] - projection[3][1]);
|
||||
|
||||
// near
|
||||
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[2] = projection[2][3] + projection[2][2];
|
||||
planes[FRUSTUM_NEAR].dist = -(projection[3][3] + projection[3][2]);
|
||||
|
||||
// far
|
||||
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[2] = projection[2][3] - projection[2][2];
|
||||
planes[FRUSTUM_FAR].dist = -(projection[3][3] - projection[3][2]);
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
NormalizePlane( i );
|
||||
}
|
||||
}
|
||||
|
||||
void CFrustum :: SetPlane( int side, const Vector &vecNormal, float flDist )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
|
||||
planes[side].type = PlaneTypeForNormal( vecNormal );
|
||||
planes[side].signbits = SignbitsForPlane( vecNormal );
|
||||
planes[side].normal = vecNormal;
|
||||
planes[side].dist = flDist;
|
||||
|
||||
clipFlags |= BIT( side );
|
||||
}
|
||||
|
||||
void CFrustum :: NormalizePlane( int side )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
|
||||
// normalize
|
||||
float length = planes[side].normal.Length();
|
||||
|
||||
if( length )
|
||||
{
|
||||
float ilength = (1.0f / length);
|
||||
planes[side].normal.x *= ilength;
|
||||
planes[side].normal.y *= ilength;
|
||||
planes[side].normal.z *= ilength;
|
||||
planes[side].dist *= ilength;
|
||||
}
|
||||
|
||||
planes[side].type = PlaneTypeForNormal( planes[side].normal );
|
||||
planes[side].signbits = SignbitsForPlane( planes[side].normal );
|
||||
|
||||
clipFlags |= BIT( side );
|
||||
}
|
||||
|
||||
void CFrustum :: ComputeFrustumCorners( Vector corners[8] )
|
||||
{
|
||||
memset( corners, 0, sizeof( Vector ) * 8 );
|
||||
|
||||
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_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[2] );
|
||||
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[3] );
|
||||
|
||||
if( FBitSet( clipFlags, BIT( FRUSTUM_NEAR )))
|
||||
{
|
||||
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_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[6] );
|
||||
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[7] );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], corners[4] );
|
||||
corners[7] = corners[6] = corners[5] = corners[4];
|
||||
}
|
||||
}
|
||||
|
||||
void CFrustum :: ComputeFrustumBounds( Vector &mins, Vector &maxs )
|
||||
{
|
||||
Vector corners[8];
|
||||
|
||||
ComputeFrustumCorners( corners );
|
||||
|
||||
ClearBounds( mins, maxs );
|
||||
|
||||
for( int i = 0; i < 8; i++ )
|
||||
AddPointToBounds( corners[i], mins, maxs );
|
||||
}
|
||||
|
||||
void CFrustum :: DrawFrustumDebug( void )
|
||||
{
|
||||
Vector bbox[8];
|
||||
|
||||
ComputeFrustumCorners( bbox );
|
||||
|
||||
// g-cont. frustum must be yellow :-)
|
||||
pglColor4f( 1.0f, 1.0f, 0.0f, 1.0f );
|
||||
GL_BindTexture( GL_TEXTURE0, tr.whiteTexture );
|
||||
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
pglBegin( GL_LINES );
|
||||
|
||||
for( int i = 0; i < 2; i += 1 )
|
||||
{
|
||||
pglVertex3fv( bbox[i+0] );
|
||||
pglVertex3fv( bbox[i+2] );
|
||||
pglVertex3fv( bbox[i+4] );
|
||||
pglVertex3fv( bbox[i+6] );
|
||||
pglVertex3fv( bbox[i+0] );
|
||||
pglVertex3fv( bbox[i+4] );
|
||||
pglVertex3fv( bbox[i+2] );
|
||||
pglVertex3fv( bbox[i+6] );
|
||||
pglVertex3fv( bbox[i*2+0] );
|
||||
pglVertex3fv( bbox[i*2+1] );
|
||||
pglVertex3fv( bbox[i*2+4] );
|
||||
pglVertex3fv( bbox[i*2+5] );
|
||||
}
|
||||
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
bool CFrustum :: CullBox( const Vector &mins, const Vector &maxs, int userClipFlags )
|
||||
{
|
||||
int iClipFlags;
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return false;
|
||||
|
||||
if( userClipFlags != 0 )
|
||||
iClipFlags = userClipFlags;
|
||||
else iClipFlags = clipFlags;
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
if( !FBitSet( iClipFlags, BIT( i )))
|
||||
continue;
|
||||
|
||||
const mplane_t *p = &planes[i];
|
||||
|
||||
switch( p->signbits )
|
||||
{
|
||||
case 0:
|
||||
if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 1:
|
||||
if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 2:
|
||||
if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 3:
|
||||
if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 4:
|
||||
if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 5:
|
||||
if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 6:
|
||||
if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 7:
|
||||
if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFrustum :: CullSphere( const Vector ¢re, float radius, int userClipFlags )
|
||||
{
|
||||
int iClipFlags;
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return false;
|
||||
|
||||
if( userClipFlags != 0 )
|
||||
iClipFlags = userClipFlags;
|
||||
else iClipFlags = clipFlags;
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
if( !FBitSet( iClipFlags, BIT( i )))
|
||||
continue;
|
||||
|
||||
const mplane_t *p = &planes[i];
|
||||
|
||||
if( DotProduct( centre, p->normal ) - p->dist <= -radius )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: could be optimize?
|
||||
bool CFrustum :: CullFrustum( CFrustum *frustum, int userClipFlags )
|
||||
{
|
||||
int iClipFlags;
|
||||
Vector bbox[8];
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return false;
|
||||
|
||||
if( userClipFlags != 0 )
|
||||
iClipFlags = userClipFlags;
|
||||
else iClipFlags = clipFlags;
|
||||
|
||||
frustum->ComputeFrustumCorners( bbox );
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
if( !FBitSet( iClipFlags, BIT( i )))
|
||||
continue;
|
||||
|
||||
const mplane_t *p = &planes[i];
|
||||
|
||||
for( int j = 0; j < 8; j++ )
|
||||
{
|
||||
// at least one point of other frustum intersect with our frustum
|
||||
if( DotProduct( bbox[j], p->normal ) - p->dist >= ON_EPSILON )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
/*
|
||||
gl_frustum.cpp - frustum test implementation class
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "ref_params.h"
|
||||
#include "gl_local.h"
|
||||
#include <mathlib.h>
|
||||
#include <stringlib.h>
|
||||
|
||||
void CFrustum :: ClearFrustum( void )
|
||||
{
|
||||
memset( planes, 0, sizeof( planes ));
|
||||
clipFlags = 0;
|
||||
}
|
||||
|
||||
void CFrustum :: EnablePlane( int side )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
|
||||
// make sure what plane is ready
|
||||
if( planes[side].normal != g_vecZero )
|
||||
SetBits( clipFlags, BIT( side ));
|
||||
}
|
||||
|
||||
void CFrustum :: DisablePlane( int side )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
ClearBits( clipFlags, BIT( side ));
|
||||
}
|
||||
|
||||
void CFrustum :: InitProjection( const matrix4x4 &view, float flZNear, float flZFar, float flFovX, float flFovY )
|
||||
{
|
||||
float xs, xc;
|
||||
Vector normal;
|
||||
|
||||
// horizontal fov used for left and right planes
|
||||
SinCos( DEG2RAD( flFovX ) * 0.5f, &xs, &xc );
|
||||
|
||||
// setup left plane
|
||||
normal = view.GetForward() * xs + view.GetRight() * -xc;
|
||||
SetPlane( FRUSTUM_LEFT, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// setup right plane
|
||||
normal = view.GetForward() * xs + view.GetRight() * xc;
|
||||
SetPlane( FRUSTUM_RIGHT, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// vertical fov used for top and bottom planes
|
||||
SinCos( DEG2RAD( flFovY ) * 0.5f, &xs, &xc );
|
||||
|
||||
// setup bottom plane
|
||||
normal = view.GetForward() * xs + view.GetUp() * -xc;
|
||||
SetPlane( FRUSTUM_BOTTOM, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// setup top plane
|
||||
normal = view.GetForward() * xs + view.GetUp() * xc;
|
||||
SetPlane( FRUSTUM_TOP, normal, DotProduct( view.GetOrigin(), normal ));
|
||||
|
||||
// setup far plane
|
||||
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
|
||||
if( flZNear == 0.0f ) return;
|
||||
|
||||
// setup near plane
|
||||
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 )
|
||||
{
|
||||
// setup the near and far planes
|
||||
float orgOffset = DotProduct( view.GetOrigin(), view.GetForward() );
|
||||
|
||||
SetPlane( FRUSTUM_FAR, -view.GetForward(), -flZNear - orgOffset );
|
||||
SetPlane( FRUSTUM_NEAR, view.GetForward(), flZFar + orgOffset );
|
||||
|
||||
// setup left and right planes
|
||||
orgOffset = DotProduct( view.GetOrigin(), view.GetRight() );
|
||||
|
||||
SetPlane( FRUSTUM_LEFT, view.GetRight(), xLeft + orgOffset );
|
||||
SetPlane( FRUSTUM_RIGHT, -view.GetRight(), -xRight - orgOffset );
|
||||
|
||||
// setup top and buttom planes
|
||||
orgOffset = DotProduct( view.GetOrigin(), view.GetUp() );
|
||||
|
||||
SetPlane( FRUSTUM_TOP, view.GetUp(), yTop + orgOffset );
|
||||
SetPlane( FRUSTUM_BOTTOM, -view.GetUp(), -yBottom - orgOffset );
|
||||
}
|
||||
|
||||
void CFrustum :: InitBoxFrustum( const Vector &org, float radius )
|
||||
{
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
// setup normal for each direction
|
||||
Vector normal = g_vecZero;
|
||||
normal[((i >> 1) + 1) % 3] = (i & 1) ? 1.0f : -1.0f;
|
||||
SetPlane( i, normal, DotProduct( org, normal ) - radius );
|
||||
}
|
||||
}
|
||||
|
||||
void CFrustum :: InitProjectionFromMatrix( const matrix4x4 &projection )
|
||||
{
|
||||
// left
|
||||
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[2] = projection[2][3] + projection[2][0];
|
||||
planes[FRUSTUM_LEFT].dist = -(projection[3][3] + projection[3][0]);
|
||||
|
||||
// right
|
||||
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[2] = projection[2][3] - projection[2][0];
|
||||
planes[FRUSTUM_RIGHT].dist = -(projection[3][3] - projection[3][0]);
|
||||
|
||||
// bottom
|
||||
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[2] = projection[2][3] + projection[2][1];
|
||||
planes[FRUSTUM_BOTTOM].dist = -(projection[3][3] + projection[3][1]);
|
||||
|
||||
// top
|
||||
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[2] = projection[2][3] - projection[2][1];
|
||||
planes[FRUSTUM_TOP].dist = -(projection[3][3] - projection[3][1]);
|
||||
|
||||
// near
|
||||
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[2] = projection[2][3] + projection[2][2];
|
||||
planes[FRUSTUM_NEAR].dist = -(projection[3][3] + projection[3][2]);
|
||||
|
||||
// far
|
||||
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[2] = projection[2][3] - projection[2][2];
|
||||
planes[FRUSTUM_FAR].dist = -(projection[3][3] - projection[3][2]);
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
NormalizePlane( i );
|
||||
}
|
||||
}
|
||||
|
||||
void CFrustum :: SetPlane( int side, const Vector &vecNormal, float flDist )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
|
||||
planes[side].type = PlaneTypeForNormal( vecNormal );
|
||||
planes[side].signbits = SignbitsForPlane( vecNormal );
|
||||
planes[side].normal = vecNormal;
|
||||
planes[side].dist = flDist;
|
||||
|
||||
clipFlags |= BIT( side );
|
||||
}
|
||||
|
||||
void CFrustum :: NormalizePlane( int side )
|
||||
{
|
||||
ASSERT( side >= 0 && side < FRUSTUM_PLANES );
|
||||
|
||||
// normalize
|
||||
float length = planes[side].normal.Length();
|
||||
|
||||
if( length )
|
||||
{
|
||||
float ilength = (1.0f / length);
|
||||
planes[side].normal.x *= ilength;
|
||||
planes[side].normal.y *= ilength;
|
||||
planes[side].normal.z *= ilength;
|
||||
planes[side].dist *= ilength;
|
||||
}
|
||||
|
||||
planes[side].type = PlaneTypeForNormal( planes[side].normal );
|
||||
planes[side].signbits = SignbitsForPlane( planes[side].normal );
|
||||
|
||||
clipFlags |= BIT( side );
|
||||
}
|
||||
|
||||
void CFrustum :: ComputeFrustumCorners( Vector corners[8] )
|
||||
{
|
||||
memset( corners, 0, sizeof( Vector ) * 8 );
|
||||
|
||||
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_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[2] );
|
||||
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_FAR], corners[3] );
|
||||
|
||||
if( FBitSet( clipFlags, BIT( FRUSTUM_NEAR )))
|
||||
{
|
||||
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_LEFT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[6] );
|
||||
PlanesGetIntersectionPoint( &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_BOTTOM], &planes[FRUSTUM_NEAR], corners[7] );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlanesGetIntersectionPoint( &planes[FRUSTUM_LEFT], &planes[FRUSTUM_RIGHT], &planes[FRUSTUM_TOP], corners[4] );
|
||||
corners[7] = corners[6] = corners[5] = corners[4];
|
||||
}
|
||||
}
|
||||
|
||||
void CFrustum :: ComputeFrustumBounds( Vector &mins, Vector &maxs )
|
||||
{
|
||||
Vector corners[8];
|
||||
|
||||
ComputeFrustumCorners( corners );
|
||||
|
||||
ClearBounds( mins, maxs );
|
||||
|
||||
for( int i = 0; i < 8; i++ )
|
||||
AddPointToBounds( corners[i], mins, maxs );
|
||||
}
|
||||
|
||||
void CFrustum :: DrawFrustumDebug( void )
|
||||
{
|
||||
Vector bbox[8];
|
||||
|
||||
ComputeFrustumCorners( bbox );
|
||||
|
||||
// g-cont. frustum must be yellow :-)
|
||||
pglColor4f( 1.0f, 1.0f, 0.0f, 1.0f );
|
||||
GL_BindTexture( GL_TEXTURE0, tr.whiteTexture );
|
||||
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
pglBegin( GL_LINES );
|
||||
|
||||
for( int i = 0; i < 2; i += 1 )
|
||||
{
|
||||
pglVertex3fv( bbox[i+0] );
|
||||
pglVertex3fv( bbox[i+2] );
|
||||
pglVertex3fv( bbox[i+4] );
|
||||
pglVertex3fv( bbox[i+6] );
|
||||
pglVertex3fv( bbox[i+0] );
|
||||
pglVertex3fv( bbox[i+4] );
|
||||
pglVertex3fv( bbox[i+2] );
|
||||
pglVertex3fv( bbox[i+6] );
|
||||
pglVertex3fv( bbox[i*2+0] );
|
||||
pglVertex3fv( bbox[i*2+1] );
|
||||
pglVertex3fv( bbox[i*2+4] );
|
||||
pglVertex3fv( bbox[i*2+5] );
|
||||
}
|
||||
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
bool CFrustum :: CullBox( const Vector &mins, const Vector &maxs, int userClipFlags )
|
||||
{
|
||||
int iClipFlags;
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return false;
|
||||
|
||||
if( userClipFlags != 0 )
|
||||
iClipFlags = userClipFlags;
|
||||
else iClipFlags = clipFlags;
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
if( !FBitSet( iClipFlags, BIT( i )))
|
||||
continue;
|
||||
|
||||
const mplane_t *p = &planes[i];
|
||||
|
||||
switch( p->signbits )
|
||||
{
|
||||
case 0:
|
||||
if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 1:
|
||||
if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 2:
|
||||
if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 3:
|
||||
if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * maxs.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 4:
|
||||
if( p->normal.x * maxs.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 5:
|
||||
if( p->normal.x * mins.x + p->normal.y * maxs.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 6:
|
||||
if( p->normal.x * maxs.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
case 7:
|
||||
if( p->normal.x * mins.x + p->normal.y * mins.y + p->normal.z * mins.z < p->dist )
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFrustum :: CullSphere( const Vector ¢re, float radius, int userClipFlags )
|
||||
{
|
||||
int iClipFlags;
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return false;
|
||||
|
||||
if( userClipFlags != 0 )
|
||||
iClipFlags = userClipFlags;
|
||||
else iClipFlags = clipFlags;
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
if( !FBitSet( iClipFlags, BIT( i )))
|
||||
continue;
|
||||
|
||||
const mplane_t *p = &planes[i];
|
||||
|
||||
if( DotProduct( centre, p->normal ) - p->dist <= -radius )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: could be optimize?
|
||||
bool CFrustum :: CullFrustum( CFrustum *frustum, int userClipFlags )
|
||||
{
|
||||
int iClipFlags;
|
||||
Vector bbox[8];
|
||||
|
||||
if( CVAR_TO_BOOL( r_nocull ))
|
||||
return false;
|
||||
|
||||
if( userClipFlags != 0 )
|
||||
iClipFlags = userClipFlags;
|
||||
else iClipFlags = clipFlags;
|
||||
|
||||
frustum->ComputeFrustumCorners( bbox );
|
||||
|
||||
for( int i = 0; i < FRUSTUM_PLANES; i++ )
|
||||
{
|
||||
if( !FBitSet( iClipFlags, BIT( i )))
|
||||
continue;
|
||||
|
||||
const mplane_t *p = &planes[i];
|
||||
|
||||
for( int j = 0; j < 8; j++ )
|
||||
{
|
||||
// at least one point of other frustum intersect with our frustum
|
||||
if( DotProduct( bbox[j], p->normal ) - p->dist >= ON_EPSILON )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,60 +1,60 @@
|
|||
/*
|
||||
gl_frustum.h - frustum test implementation class
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_FRUSTUM_H
|
||||
#define GL_FRUSTUM_H
|
||||
|
||||
// don't change this order
|
||||
#define FRUSTUM_LEFT 0
|
||||
#define FRUSTUM_RIGHT 1
|
||||
#define FRUSTUM_BOTTOM 2
|
||||
#define FRUSTUM_TOP 3
|
||||
#define FRUSTUM_FAR 4
|
||||
#define FRUSTUM_NEAR 5
|
||||
#define FRUSTUM_PLANES 6
|
||||
|
||||
class CFrustum
|
||||
{
|
||||
public:
|
||||
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 InitBoxFrustum( const Vector &org, float radius ); // used for pointlights
|
||||
void InitProjectionFromMatrix( const matrix4x4 &projection );
|
||||
void SetPlane( int side, const mplane_t *plane ) { planes[side] = *plane; }
|
||||
void SetPlane( int side, const Vector &vecNormal, float flDist );
|
||||
void NormalizePlane( int side );
|
||||
const mplane_t *GetPlane( int side ) const { return &planes[side]; }
|
||||
const mplane_t *GetPlanes( void ) const { return &planes[0]; }
|
||||
unsigned int GetClipFlags( void ) const { return clipFlags; }
|
||||
void ComputeFrustumBounds( Vector &mins, Vector &maxs );
|
||||
void ComputeFrustumCorners( Vector bbox[8] );
|
||||
void DrawFrustumDebug( void );
|
||||
void ClearFrustum( void );
|
||||
|
||||
// cull methods
|
||||
bool CullBox( const Vector &mins, const Vector &maxs, int userClipFlags = 0 );
|
||||
bool CullSphere( const Vector ¢re, float radius, int userClipFlags = 0 );
|
||||
bool CullFrustum( CFrustum *frustum, int userClipFlags = 0 );
|
||||
|
||||
// plane manipulating
|
||||
void EnablePlane( int side );
|
||||
void DisablePlane( int side );
|
||||
private:
|
||||
mplane_t planes[FRUSTUM_PLANES];
|
||||
unsigned int clipFlags;
|
||||
};
|
||||
|
||||
/*
|
||||
gl_frustum.h - frustum test implementation class
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_FRUSTUM_H
|
||||
#define GL_FRUSTUM_H
|
||||
|
||||
// don't change this order
|
||||
#define FRUSTUM_LEFT 0
|
||||
#define FRUSTUM_RIGHT 1
|
||||
#define FRUSTUM_BOTTOM 2
|
||||
#define FRUSTUM_TOP 3
|
||||
#define FRUSTUM_FAR 4
|
||||
#define FRUSTUM_NEAR 5
|
||||
#define FRUSTUM_PLANES 6
|
||||
|
||||
class CFrustum
|
||||
{
|
||||
public:
|
||||
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 InitBoxFrustum( const Vector &org, float radius ); // used for pointlights
|
||||
void InitProjectionFromMatrix( const matrix4x4 &projection );
|
||||
void SetPlane( int side, const mplane_t *plane ) { planes[side] = *plane; }
|
||||
void SetPlane( int side, const Vector &vecNormal, float flDist );
|
||||
void NormalizePlane( int side );
|
||||
const mplane_t *GetPlane( int side ) const { return &planes[side]; }
|
||||
const mplane_t *GetPlanes( void ) const { return &planes[0]; }
|
||||
unsigned int GetClipFlags( void ) const { return clipFlags; }
|
||||
void ComputeFrustumBounds( Vector &mins, Vector &maxs );
|
||||
void ComputeFrustumCorners( Vector bbox[8] );
|
||||
void DrawFrustumDebug( void );
|
||||
void ClearFrustum( void );
|
||||
|
||||
// cull methods
|
||||
bool CullBox( const Vector &mins, const Vector &maxs, int userClipFlags = 0 );
|
||||
bool CullSphere( const Vector ¢re, float radius, int userClipFlags = 0 );
|
||||
bool CullFrustum( CFrustum *frustum, int userClipFlags = 0 );
|
||||
|
||||
// plane manipulating
|
||||
void EnablePlane( int side );
|
||||
void DisablePlane( int side );
|
||||
private:
|
||||
mplane_t planes[FRUSTUM_PLANES];
|
||||
unsigned int clipFlags;
|
||||
};
|
||||
|
||||
#endif//GL_FRUSTUM_H
|
File diff suppressed because it is too large
Load Diff
|
@ -1,116 +1,116 @@
|
|||
/*
|
||||
gl_grass.h - grass construct & rendering
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_GRASS_H
|
||||
#define GL_GRASS_H
|
||||
|
||||
#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 MAX_GRASS_ELEMS 65536 // unsigned short limit
|
||||
#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 GRASS_SKY_DIST BOGUS_RANGE // in-world grass never reach this value
|
||||
|
||||
typedef struct grassentry_s
|
||||
{
|
||||
char name[16]; // name of level texture
|
||||
byte texture; // number in array of grass textures
|
||||
float density; // grass density (0 - 100)
|
||||
float min; // min grass scale
|
||||
float max; // max grass scale
|
||||
int seed; // seed for predictable random (auto-filled)
|
||||
} grassentry_t;
|
||||
|
||||
typedef struct grasstexture_s
|
||||
{
|
||||
char name[256]; // path to grass texture
|
||||
int gl_texturenum; // gl-texture
|
||||
} grasstexture_t;
|
||||
|
||||
typedef struct gvert_s
|
||||
{
|
||||
float center[4]; // used for rescale
|
||||
float normal[4]; // center + vertex[2] * vertex[3];
|
||||
float light[MAXLIGHTMAPS]; // packed color + unused entry
|
||||
float delux[MAXLIGHTMAPS]; // packed lightdir + unused entry
|
||||
byte styles[MAXLIGHTMAPS]; // styles on surface
|
||||
} gvert_t;
|
||||
|
||||
#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_NOSUNLIGHT BIT( 2 ) // grass dlight shader is failed to build
|
||||
#define FRGASS_SKYENTITY BIT( 3 ) // it's sky grass
|
||||
|
||||
// all the grassdata for one polygon and specified texture
|
||||
// stored into single vbo
|
||||
typedef struct grass_s
|
||||
{
|
||||
// shader cache
|
||||
shader_t forwardScene;
|
||||
shader_t forwardLightSpot;
|
||||
shader_t forwardLightOmni;
|
||||
shader_t forwardLightProj;
|
||||
shader_t deferredScene;
|
||||
shader_t deferredLight;
|
||||
shader_t forwardDepth;
|
||||
|
||||
byte texture; // not a real texture just index into array
|
||||
byte flags; // state flags
|
||||
unsigned short numVerts; // for glDrawRangeElementsEXT
|
||||
unsigned short numElems; // for glDrawElements
|
||||
unsigned int vbo, vao, ibo; // buffer objects
|
||||
unsigned short hCachedMatrix; // HACKHACK: get matrices
|
||||
byte lights[MAXDYNLIGHTS];/// light numbers
|
||||
unsigned int cacheSize; // debug info: uploaded cache size for this buffer
|
||||
} grass_t;
|
||||
|
||||
typedef void (*pfnCreateGrassBuffer)( grass_t *pOut, gvert_t *arrayxvert );
|
||||
typedef void (*pfnBindGrassBuffer)( grass_t *pOut, int attrFlags );
|
||||
|
||||
enum
|
||||
{
|
||||
GRASSLOADER_BASE = 0,
|
||||
GRASSLOADER_BASEBUMP,
|
||||
GRASSLOADER_COUNT,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pfnCreateGrassBuffer CreateBuffer;
|
||||
pfnBindGrassBuffer BindBuffer;
|
||||
const char* BufferName; // debug
|
||||
} grass_loader_t;
|
||||
|
||||
typedef struct grasshdr_s
|
||||
{
|
||||
Vector mins, maxs; // per-poly culling
|
||||
int count; // total bush count for this poly
|
||||
grass_t g[1]; // variable sized
|
||||
} grasshdr_t;
|
||||
|
||||
extern void R_GrassInit( void );
|
||||
extern void R_GrassShutdown( void );
|
||||
extern void R_GrassInitForSurface( msurface_t *surf );
|
||||
extern void R_RenderGrassOnList( void );
|
||||
extern void R_GrassSetupFrame( void );
|
||||
extern void R_RenderShadowGrassOnList( void );
|
||||
extern void R_DrawLightForGrass( CDynLight *pl );
|
||||
extern void R_AddGrassToDrawList( msurface_t *s, drawlist_t type );
|
||||
extern void R_PrecacheGrass( msurface_t *s, mextraleaf_t *leaf );
|
||||
extern void R_RemoveGrassForSurface( mextrasurf_t *es );
|
||||
extern void R_UnloadFarGrass( void );
|
||||
|
||||
/*
|
||||
gl_grass.h - grass construct & rendering
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2014 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_GRASS_H
|
||||
#define GL_GRASS_H
|
||||
|
||||
#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 MAX_GRASS_ELEMS 65536 // unsigned short limit
|
||||
#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 GRASS_SKY_DIST BOGUS_RANGE // in-world grass never reach this value
|
||||
|
||||
typedef struct grassentry_s
|
||||
{
|
||||
char name[16]; // name of level texture
|
||||
byte texture; // number in array of grass textures
|
||||
float density; // grass density (0 - 100)
|
||||
float min; // min grass scale
|
||||
float max; // max grass scale
|
||||
int seed; // seed for predictable random (auto-filled)
|
||||
} grassentry_t;
|
||||
|
||||
typedef struct grasstexture_s
|
||||
{
|
||||
char name[256]; // path to grass texture
|
||||
int gl_texturenum; // gl-texture
|
||||
} grasstexture_t;
|
||||
|
||||
typedef struct gvert_s
|
||||
{
|
||||
float center[4]; // used for rescale
|
||||
float normal[4]; // center + vertex[2] * vertex[3];
|
||||
float light[MAXLIGHTMAPS]; // packed color + unused entry
|
||||
float delux[MAXLIGHTMAPS]; // packed lightdir + unused entry
|
||||
byte styles[MAXLIGHTMAPS]; // styles on surface
|
||||
} gvert_t;
|
||||
|
||||
#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_NOSUNLIGHT BIT( 2 ) // grass dlight shader is failed to build
|
||||
#define FRGASS_SKYENTITY BIT( 3 ) // it's sky grass
|
||||
|
||||
// all the grassdata for one polygon and specified texture
|
||||
// stored into single vbo
|
||||
typedef struct grass_s
|
||||
{
|
||||
// shader cache
|
||||
shader_t forwardScene;
|
||||
shader_t forwardLightSpot;
|
||||
shader_t forwardLightOmni;
|
||||
shader_t forwardLightProj;
|
||||
shader_t deferredScene;
|
||||
shader_t deferredLight;
|
||||
shader_t forwardDepth;
|
||||
|
||||
byte texture; // not a real texture just index into array
|
||||
byte flags; // state flags
|
||||
unsigned short numVerts; // for glDrawRangeElementsEXT
|
||||
unsigned short numElems; // for glDrawElements
|
||||
unsigned int vbo, vao, ibo; // buffer objects
|
||||
unsigned short hCachedMatrix; // HACKHACK: get matrices
|
||||
byte lights[MAXDYNLIGHTS];/// light numbers
|
||||
unsigned int cacheSize; // debug info: uploaded cache size for this buffer
|
||||
} grass_t;
|
||||
|
||||
typedef void (*pfnCreateGrassBuffer)( grass_t *pOut, gvert_t *arrayxvert );
|
||||
typedef void (*pfnBindGrassBuffer)( grass_t *pOut, int attrFlags );
|
||||
|
||||
enum
|
||||
{
|
||||
GRASSLOADER_BASE = 0,
|
||||
GRASSLOADER_BASEBUMP,
|
||||
GRASSLOADER_COUNT,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pfnCreateGrassBuffer CreateBuffer;
|
||||
pfnBindGrassBuffer BindBuffer;
|
||||
const char* BufferName; // debug
|
||||
} grass_loader_t;
|
||||
|
||||
typedef struct grasshdr_s
|
||||
{
|
||||
Vector mins, maxs; // per-poly culling
|
||||
int count; // total bush count for this poly
|
||||
grass_t g[1]; // variable sized
|
||||
} grasshdr_t;
|
||||
|
||||
extern void R_GrassInit( void );
|
||||
extern void R_GrassShutdown( void );
|
||||
extern void R_GrassInitForSurface( msurface_t *surf );
|
||||
extern void R_RenderGrassOnList( void );
|
||||
extern void R_GrassSetupFrame( void );
|
||||
extern void R_RenderShadowGrassOnList( void );
|
||||
extern void R_DrawLightForGrass( CDynLight *pl );
|
||||
extern void R_AddGrassToDrawList( msurface_t *s, drawlist_t type );
|
||||
extern void R_PrecacheGrass( msurface_t *s, mextraleaf_t *leaf );
|
||||
extern void R_RemoveGrassForSurface( mextrasurf_t *es );
|
||||
extern void R_UnloadFarGrass( void );
|
||||
|
||||
#endif//GL_GRASS_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,37 +1,37 @@
|
|||
/*
|
||||
gl_material.h - visible material settings
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_MATERIAL_H
|
||||
#define GL_MATERIAL_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PHYSMODEL_BRDF = 0, // BRDF as default
|
||||
PHYSMODEL_DOOM3, // obsolete lighting model like Doom3
|
||||
PHYSMODEL_FOLIAGE, // two-side rendering, vegetation lighting model
|
||||
PHYSMODEL_GLASS, // translucent surface
|
||||
PHYSMODEL_SKIN, // human skin lighting model
|
||||
PHYSMODEL_HAIR, // anisotropic lighting model for hairs
|
||||
PHYSMODEL_EYES, // eyes physical model
|
||||
} physmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
physmodel_t physModel;
|
||||
struct matdef_s *effects; // material common effects (decals, particles, etc)
|
||||
} gl_material_t;
|
||||
|
||||
/*
|
||||
gl_material.h - visible material settings
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_MATERIAL_H
|
||||
#define GL_MATERIAL_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PHYSMODEL_BRDF = 0, // BRDF as default
|
||||
PHYSMODEL_DOOM3, // obsolete lighting model like Doom3
|
||||
PHYSMODEL_FOLIAGE, // two-side rendering, vegetation lighting model
|
||||
PHYSMODEL_GLASS, // translucent surface
|
||||
PHYSMODEL_SKIN, // human skin lighting model
|
||||
PHYSMODEL_HAIR, // anisotropic lighting model for hairs
|
||||
PHYSMODEL_EYES, // eyes physical model
|
||||
} physmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
physmodel_t physModel;
|
||||
struct matdef_s *effects; // material common effects (decals, particles, etc)
|
||||
} gl_material_t;
|
||||
|
||||
#endif//GL_MATERIAL_H
|
|
@ -1,230 +1,230 @@
|
|||
/*
|
||||
gl_movie.cpp - draw screen movie surfaces
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_world.h"
|
||||
#include "mathlib.h"
|
||||
#include "event_api.h"
|
||||
#include <stringlib.h>
|
||||
|
||||
int R_PrecacheCinematic( const char *cinname )
|
||||
{
|
||||
int load_sound = 0;
|
||||
|
||||
if( !cinname || !*cinname )
|
||||
return -1;
|
||||
|
||||
if( *cinname == '*' )
|
||||
{
|
||||
if( g_iXashEngineBuildNumber >= 4256 )
|
||||
load_sound = 1;
|
||||
cinname++;
|
||||
}
|
||||
|
||||
// not AVI file
|
||||
if( Q_stricmp( UTIL_FileExtension( cinname ), "avi" ))
|
||||
return -1;
|
||||
|
||||
// first check for co-existing
|
||||
for( int i = 0; i < MAX_MOVIES; i++ )
|
||||
{
|
||||
if( !Q_stricmp( tr.cinematics[i].name, cinname ))
|
||||
{
|
||||
// already existed
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// found an empty slot
|
||||
for( i = 0; i < MAX_MOVIES; i++ )
|
||||
{
|
||||
if( !tr.cinematics[i].name[0] )
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == MAX_MOVIES )
|
||||
{
|
||||
ALERT( at_error, "R_PrecacheCinematic: cinematic list limit exceeded\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// register new cinematic
|
||||
Q_strncpy( tr.cinematics[i].name, cinname, sizeof( tr.cinematics[0].name ));
|
||||
if( tr.cinematics[i].state )
|
||||
{
|
||||
ALERT( at_warning, "Reused cin state %i with %s\n", i, tr.cinematics[i].name );
|
||||
FREE_CINEMATIC( tr.cinematics[i].state );
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
// grab info about movie
|
||||
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 );
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void R_InitCinematics( void )
|
||||
{
|
||||
const char *name, *ext;
|
||||
|
||||
// make sure what we have texture to draw cinematics
|
||||
if( !FBitSet( world->features, WORLD_HAS_MOVIES ))
|
||||
return;
|
||||
|
||||
for( int i = 1; i < 1024; i++ )
|
||||
{
|
||||
name = gRenderfuncs.GetFileByIndex( i );
|
||||
|
||||
if( !name || !*name ) break; // end of files array
|
||||
|
||||
ext = UTIL_FileExtension( name );
|
||||
if( Q_stricmp( ext, "avi" )) continue; // not AVI
|
||||
|
||||
if( R_PrecacheCinematic( name ) == -1 )
|
||||
break; // full
|
||||
}
|
||||
}
|
||||
|
||||
void R_FreeCinematics( void )
|
||||
{
|
||||
for( int i = 0; i < MAX_MOVIES; i++ )
|
||||
{
|
||||
if( tr.cinematics[i].state )
|
||||
{
|
||||
ALERT( at_notice, "release cinematic %s\n", tr.cinematics[i].name );
|
||||
FREE_CINEMATIC( tr.cinematics[i].state );
|
||||
}
|
||||
}
|
||||
|
||||
memset( tr.cinematics, 0, sizeof( tr.cinematics ));
|
||||
|
||||
for( i = 0; i < MAX_MOVIE_TEXTURES; i++ )
|
||||
{
|
||||
if( !tr.cinTextures[i] ) break;
|
||||
FREE_TEXTURE( tr.cinTextures[i] );
|
||||
}
|
||||
|
||||
memset( tr.cinTextures, 0, sizeof( tr.cinTextures ));
|
||||
}
|
||||
|
||||
int R_AllocateCinematicTexture( unsigned int txFlags )
|
||||
{
|
||||
int i = tr.num_cin_used;
|
||||
|
||||
if( i >= MAX_MOVIE_TEXTURES )
|
||||
{
|
||||
ALERT( at_error, "R_AllocateCinematicTexture: cine textures limit exceeded!\n" );
|
||||
return 0; // disable
|
||||
}
|
||||
tr.num_cin_used++;
|
||||
|
||||
if( !tr.cinTextures[i] )
|
||||
{
|
||||
char txName[16];
|
||||
|
||||
Q_snprintf( txName, sizeof( txName ), "*cinematic%i", i );
|
||||
|
||||
// create new cinematic 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 );
|
||||
}
|
||||
|
||||
return (i+1);
|
||||
}
|
||||
|
||||
void R_UpdateCinematic( const msurface_t *surf )
|
||||
{
|
||||
if( !RI->currententity->curstate.body )
|
||||
return; // just disabled
|
||||
|
||||
// draw the cinematic
|
||||
mextrasurf_t *es = surf->info;
|
||||
|
||||
// found the corresponding cinstate
|
||||
const char *cinname = gRenderfuncs.GetFileByIndex( RI->currententity->curstate.sequence );
|
||||
int cinhandle = R_PrecacheCinematic( cinname );
|
||||
|
||||
if( cinhandle >= 0 && es->cintexturenum <= 0 )
|
||||
es->cintexturenum = R_AllocateCinematicTexture( TF_NOMIPMAP );
|
||||
|
||||
if( cinhandle == -1 || es->cintexturenum <= 0 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false )
|
||||
{
|
||||
// cinematic textures limit exceeded, so remove SURF_MOVIE flag
|
||||
((msurface_t *)surf)->flags &= ~SURF_MOVIE;
|
||||
return;
|
||||
}
|
||||
|
||||
gl_movie_t *cin = &tr.cinematics[cinhandle];
|
||||
float cin_time;
|
||||
|
||||
if( FBitSet( RI->currententity->curstate.iuser1, CF_LOOPED_MOVIE ))
|
||||
{
|
||||
// advances cinematic time
|
||||
cin_time = fmod( RI->currententity->curstate.fuser2, cin->length );
|
||||
}
|
||||
else
|
||||
{
|
||||
cin_time = RI->currententity->curstate.fuser2;
|
||||
}
|
||||
|
||||
// read the next frame
|
||||
int cin_frame = CIN_GET_FRAME_NUMBER( cin->state, cin_time );
|
||||
|
||||
// upload the new frame
|
||||
if( cin_frame != es->checkcount )
|
||||
{
|
||||
GL_SelectTexture( GL_TEXTURE0 ); // doesn't matter. select 0-th unit just as default
|
||||
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 );
|
||||
es->checkcount = cin_frame;
|
||||
}
|
||||
}
|
||||
|
||||
void R_UpdateCinSound( cl_entity_t *e )
|
||||
{
|
||||
if( g_iXashEngineBuildNumber < 4256 )
|
||||
return; // too old for this feature
|
||||
|
||||
if( !e->curstate.body || !FBitSet( e->curstate.iuser1, CF_MOVIE_SOUND ))
|
||||
return; // just disabled
|
||||
|
||||
// found the corresponding cinstate
|
||||
const char *cinname = gRenderfuncs.GetFileByIndex( e->curstate.sequence );
|
||||
int cinhandle = R_PrecacheCinematic( cinname );
|
||||
|
||||
if( cinhandle == -1 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false )
|
||||
return;
|
||||
|
||||
gl_movie_t *cin = &tr.cinematics[cinhandle];
|
||||
float cin_time;
|
||||
|
||||
if( FBitSet( e->curstate.iuser1, CF_LOOPED_MOVIE ))
|
||||
{
|
||||
// advances cinematic time
|
||||
cin_time = fmod( e->curstate.fuser2, cin->length );
|
||||
}
|
||||
else
|
||||
{
|
||||
cin_time = e->curstate.fuser2;
|
||||
}
|
||||
|
||||
// stream avi sound
|
||||
CIN_UPDATE_SOUND( cin->state, e->index, VOL_NORM, ATTN_IDLE, cin_time );
|
||||
/*
|
||||
gl_movie.cpp - draw screen movie surfaces
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_world.h"
|
||||
#include "mathlib.h"
|
||||
#include "event_api.h"
|
||||
#include <stringlib.h>
|
||||
|
||||
int R_PrecacheCinematic( const char *cinname )
|
||||
{
|
||||
int load_sound = 0;
|
||||
|
||||
if( !cinname || !*cinname )
|
||||
return -1;
|
||||
|
||||
if( *cinname == '*' )
|
||||
{
|
||||
if( g_iXashEngineBuildNumber >= 4256 )
|
||||
load_sound = 1;
|
||||
cinname++;
|
||||
}
|
||||
|
||||
// not AVI file
|
||||
if( Q_stricmp( UTIL_FileExtension( cinname ), "avi" ))
|
||||
return -1;
|
||||
|
||||
// first check for co-existing
|
||||
for( int i = 0; i < MAX_MOVIES; i++ )
|
||||
{
|
||||
if( !Q_stricmp( tr.cinematics[i].name, cinname ))
|
||||
{
|
||||
// already existed
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// found an empty slot
|
||||
for( i = 0; i < MAX_MOVIES; i++ )
|
||||
{
|
||||
if( !tr.cinematics[i].name[0] )
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == MAX_MOVIES )
|
||||
{
|
||||
ALERT( at_error, "R_PrecacheCinematic: cinematic list limit exceeded\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// register new cinematic
|
||||
Q_strncpy( tr.cinematics[i].name, cinname, sizeof( tr.cinematics[0].name ));
|
||||
if( tr.cinematics[i].state )
|
||||
{
|
||||
ALERT( at_warning, "Reused cin state %i with %s\n", i, tr.cinematics[i].name );
|
||||
FREE_CINEMATIC( tr.cinematics[i].state );
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
// grab info about movie
|
||||
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 );
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void R_InitCinematics( void )
|
||||
{
|
||||
const char *name, *ext;
|
||||
|
||||
// make sure what we have texture to draw cinematics
|
||||
if( !FBitSet( world->features, WORLD_HAS_MOVIES ))
|
||||
return;
|
||||
|
||||
for( int i = 1; i < 1024; i++ )
|
||||
{
|
||||
name = gRenderfuncs.GetFileByIndex( i );
|
||||
|
||||
if( !name || !*name ) break; // end of files array
|
||||
|
||||
ext = UTIL_FileExtension( name );
|
||||
if( Q_stricmp( ext, "avi" )) continue; // not AVI
|
||||
|
||||
if( R_PrecacheCinematic( name ) == -1 )
|
||||
break; // full
|
||||
}
|
||||
}
|
||||
|
||||
void R_FreeCinematics( void )
|
||||
{
|
||||
for( int i = 0; i < MAX_MOVIES; i++ )
|
||||
{
|
||||
if( tr.cinematics[i].state )
|
||||
{
|
||||
ALERT( at_notice, "release cinematic %s\n", tr.cinematics[i].name );
|
||||
FREE_CINEMATIC( tr.cinematics[i].state );
|
||||
}
|
||||
}
|
||||
|
||||
memset( tr.cinematics, 0, sizeof( tr.cinematics ));
|
||||
|
||||
for( i = 0; i < MAX_MOVIE_TEXTURES; i++ )
|
||||
{
|
||||
if( !tr.cinTextures[i] ) break;
|
||||
FREE_TEXTURE( tr.cinTextures[i] );
|
||||
}
|
||||
|
||||
memset( tr.cinTextures, 0, sizeof( tr.cinTextures ));
|
||||
}
|
||||
|
||||
int R_AllocateCinematicTexture( unsigned int txFlags )
|
||||
{
|
||||
int i = tr.num_cin_used;
|
||||
|
||||
if( i >= MAX_MOVIE_TEXTURES )
|
||||
{
|
||||
ALERT( at_error, "R_AllocateCinematicTexture: cine textures limit exceeded!\n" );
|
||||
return 0; // disable
|
||||
}
|
||||
tr.num_cin_used++;
|
||||
|
||||
if( !tr.cinTextures[i] )
|
||||
{
|
||||
char txName[16];
|
||||
|
||||
Q_snprintf( txName, sizeof( txName ), "*cinematic%i", i );
|
||||
|
||||
// create new cinematic 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 );
|
||||
}
|
||||
|
||||
return (i+1);
|
||||
}
|
||||
|
||||
void R_UpdateCinematic( const msurface_t *surf )
|
||||
{
|
||||
if( !RI->currententity->curstate.body )
|
||||
return; // just disabled
|
||||
|
||||
// draw the cinematic
|
||||
mextrasurf_t *es = surf->info;
|
||||
|
||||
// found the corresponding cinstate
|
||||
const char *cinname = gRenderfuncs.GetFileByIndex( RI->currententity->curstate.sequence );
|
||||
int cinhandle = R_PrecacheCinematic( cinname );
|
||||
|
||||
if( cinhandle >= 0 && es->cintexturenum <= 0 )
|
||||
es->cintexturenum = R_AllocateCinematicTexture( TF_NOMIPMAP );
|
||||
|
||||
if( cinhandle == -1 || es->cintexturenum <= 0 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false )
|
||||
{
|
||||
// cinematic textures limit exceeded, so remove SURF_MOVIE flag
|
||||
((msurface_t *)surf)->flags &= ~SURF_MOVIE;
|
||||
return;
|
||||
}
|
||||
|
||||
gl_movie_t *cin = &tr.cinematics[cinhandle];
|
||||
float cin_time;
|
||||
|
||||
if( FBitSet( RI->currententity->curstate.iuser1, CF_LOOPED_MOVIE ))
|
||||
{
|
||||
// advances cinematic time
|
||||
cin_time = fmod( RI->currententity->curstate.fuser2, cin->length );
|
||||
}
|
||||
else
|
||||
{
|
||||
cin_time = RI->currententity->curstate.fuser2;
|
||||
}
|
||||
|
||||
// read the next frame
|
||||
int cin_frame = CIN_GET_FRAME_NUMBER( cin->state, cin_time );
|
||||
|
||||
// upload the new frame
|
||||
if( cin_frame != es->checkcount )
|
||||
{
|
||||
GL_SelectTexture( GL_TEXTURE0 ); // doesn't matter. select 0-th unit just as default
|
||||
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 );
|
||||
es->checkcount = cin_frame;
|
||||
}
|
||||
}
|
||||
|
||||
void R_UpdateCinSound( cl_entity_t *e )
|
||||
{
|
||||
if( g_iXashEngineBuildNumber < 4256 )
|
||||
return; // too old for this feature
|
||||
|
||||
if( !e->curstate.body || !FBitSet( e->curstate.iuser1, CF_MOVIE_SOUND ))
|
||||
return; // just disabled
|
||||
|
||||
// found the corresponding cinstate
|
||||
const char *cinname = gRenderfuncs.GetFileByIndex( e->curstate.sequence );
|
||||
int cinhandle = R_PrecacheCinematic( cinname );
|
||||
|
||||
if( cinhandle == -1 || CIN_IS_ACTIVE( tr.cinematics[cinhandle].state ) == false )
|
||||
return;
|
||||
|
||||
gl_movie_t *cin = &tr.cinematics[cinhandle];
|
||||
float cin_time;
|
||||
|
||||
if( FBitSet( e->curstate.iuser1, CF_LOOPED_MOVIE ))
|
||||
{
|
||||
// advances cinematic time
|
||||
cin_time = fmod( e->curstate.fuser2, cin->length );
|
||||
}
|
||||
else
|
||||
{
|
||||
cin_time = e->curstate.fuser2;
|
||||
}
|
||||
|
||||
// stream avi sound
|
||||
CIN_UPDATE_SOUND( cin->state, e->index, VOL_NORM, ATTN_IDLE, cin_time );
|
||||
}
|
|
@ -1,231 +1,231 @@
|
|||
/*
|
||||
gl_occlusion.cpp - occlusion query implementation class
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2015 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "gl_local.h"
|
||||
#include <utlarray.h>
|
||||
#include "gl_occlusion.h"
|
||||
#include "gl_world.h"
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_AllocOcclusionQuery
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_AllocOcclusionQuery( msurface_t *surf )
|
||||
{
|
||||
if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || surf->info->query )
|
||||
return;
|
||||
|
||||
pglGenQueriesARB( 1, &surf->info->query );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_DeleteOcclusionQuery
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_DeleteOcclusionQuery( msurface_t *surf )
|
||||
{
|
||||
if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || !surf->info->query )
|
||||
return;
|
||||
|
||||
pglDeleteQueriesARB( 1, &surf->info->query );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_DrawOcclusionCube
|
||||
|
||||
===============
|
||||
*/
|
||||
static void GL_DrawOcclusionCube( const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
vec3_t bbox[8];
|
||||
int i;
|
||||
|
||||
// compute a full bounding box
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
bbox[i][0] = ( i & 1 ) ? absmin[0] : absmax[0];
|
||||
bbox[i][1] = ( i & 2 ) ? absmin[1] : absmax[1];
|
||||
bbox[i][2] = ( i & 4 ) ? absmin[2] : absmax[2];
|
||||
}
|
||||
|
||||
pglBegin( GL_QUADS );
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
pglVertex3fv( bbox[g_boxpnt[i][0]] );
|
||||
pglVertex3fv( bbox[g_boxpnt[i][1]] );
|
||||
pglVertex3fv( bbox[g_boxpnt[i][2]] );
|
||||
pglVertex3fv( bbox[g_boxpnt[i][3]] );
|
||||
}
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_TestSurfaceOcclusion
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_TestSurfaceOcclusion( msurface_t *surf )
|
||||
{
|
||||
mextrasurf_t *es = surf->info;
|
||||
Vector absmin, absmax;
|
||||
word cached_matrix;
|
||||
Vector normal;
|
||||
|
||||
if( !es->query || FBitSet( surf->flags, SURF_QUEUED ))
|
||||
return; // we already have the query
|
||||
|
||||
if( !es->parent ) cached_matrix = WORLD_MATRIX;
|
||||
else cached_matrix = es->parent->hCachedMatrix;
|
||||
gl_state_t *glm = GL_GetCache( cached_matrix );
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
normal = -surf->plane->normal;
|
||||
else normal = surf->plane->normal;
|
||||
|
||||
// place above surface
|
||||
absmin = es->mins + normal * 5.0f;
|
||||
absmax = es->maxs + normal * 5.0f;
|
||||
ExpandBounds( absmin, absmax, 2.0f );
|
||||
|
||||
if( cached_matrix != WORLD_MATRIX )
|
||||
TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax );
|
||||
pglBeginQueryARB( GL_SAMPLES_PASSED_ARB, es->query );
|
||||
GL_DrawOcclusionCube( absmin, absmax );
|
||||
pglEndQueryARB( GL_SAMPLES_PASSED_ARB );
|
||||
|
||||
// now we have a valid query
|
||||
SetBits( surf->flags, SURF_QUEUED );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_TestSurfaceOcclusion
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_DebugSurfaceOcclusion( msurface_t *surf )
|
||||
{
|
||||
mextrasurf_t *es = surf->info;
|
||||
Vector absmin, absmax;
|
||||
word cached_matrix;
|
||||
Vector normal;
|
||||
|
||||
if( !FBitSet( surf->flags, SURF_QUEUED ))
|
||||
return; // draw only queue
|
||||
|
||||
if( !es->parent ) cached_matrix = WORLD_MATRIX;
|
||||
else cached_matrix = es->parent->hCachedMatrix;
|
||||
gl_state_t *glm = GL_GetCache( cached_matrix );
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
normal = -surf->plane->normal;
|
||||
else normal = surf->plane->normal;
|
||||
|
||||
// place above surface
|
||||
absmin = es->mins + normal * 5.0f;
|
||||
absmax = es->maxs + normal * 5.0f;
|
||||
ExpandBounds( absmin, absmax, 2.0f );
|
||||
|
||||
if( cached_matrix != WORLD_MATRIX )
|
||||
TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax );
|
||||
GL_DrawOcclusionCube( absmin, absmax );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_RenderOcclusionList
|
||||
================
|
||||
*/
|
||||
void R_RenderSurfOcclusionList( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling ))
|
||||
return;
|
||||
|
||||
if( !RI->frame.num_subview_faces )
|
||||
return;
|
||||
|
||||
pglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
|
||||
GL_DepthMask( GL_FALSE );
|
||||
GL_AlphaTest( GL_FALSE );
|
||||
GL_BindShader( NULL );
|
||||
|
||||
for( i = 0; i < RI->frame.num_subview_faces; i++ )
|
||||
GL_TestSurfaceOcclusion( RI->frame.subview_faces[i] );
|
||||
|
||||
pglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
||||
GL_DepthMask( GL_TRUE );
|
||||
pglFlush();
|
||||
|
||||
if( r_occlusion_culling->value < 2.0f )
|
||||
return;
|
||||
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
GL_Blend( GL_FALSE );
|
||||
|
||||
for( i = 0; i < RI->frame.num_subview_faces; i++ )
|
||||
GL_DebugSurfaceOcclusion( RI->frame.subview_faces[i] );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
GL_SurfaceOccluded
|
||||
================
|
||||
*/
|
||||
bool GL_SurfaceOccluded( msurface_t *surf )
|
||||
{
|
||||
mextrasurf_t *es = surf->info;
|
||||
GLuint sampleCount = 0;
|
||||
GLint available = false;
|
||||
|
||||
if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling ))
|
||||
return false;
|
||||
|
||||
if( !es->query ) return false;
|
||||
|
||||
if( !FBitSet( surf->flags, SURF_QUEUED ))
|
||||
{
|
||||
// occlusion is no more actual
|
||||
ClearBits( surf->flags, SURF_OCCLUDED );
|
||||
return false;
|
||||
}
|
||||
|
||||
// i hope results will be arrived on a next frame...
|
||||
pglGetQueryObjectivARB( es->query, GL_QUERY_RESULT_AVAILABLE_ARB, &available );
|
||||
|
||||
// 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
|
||||
if( !available ) return false;
|
||||
|
||||
pglGetQueryObjectuivARB( es->query, GL_QUERY_RESULT_ARB, &sampleCount );
|
||||
ClearBits( surf->flags, SURF_QUEUED ); // we catch the results, so query is outdated
|
||||
if( sampleCount == 0 ) SetBits( surf->flags, SURF_OCCLUDED );
|
||||
else ClearBits( surf->flags, SURF_OCCLUDED );
|
||||
if( !sampleCount ) r_stats.c_occlusion_culled++;
|
||||
|
||||
return (FBitSet( surf->flags, SURF_OCCLUDED ) != 0);
|
||||
/*
|
||||
gl_occlusion.cpp - occlusion query implementation class
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2015 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "gl_local.h"
|
||||
#include <utlarray.h>
|
||||
#include "gl_occlusion.h"
|
||||
#include "gl_world.h"
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_AllocOcclusionQuery
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_AllocOcclusionQuery( msurface_t *surf )
|
||||
{
|
||||
if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || surf->info->query )
|
||||
return;
|
||||
|
||||
pglGenQueriesARB( 1, &surf->info->query );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_DeleteOcclusionQuery
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_DeleteOcclusionQuery( msurface_t *surf )
|
||||
{
|
||||
if( !GL_Support( R_OCCLUSION_QUERIES_EXT ) || !surf->info->query )
|
||||
return;
|
||||
|
||||
pglDeleteQueriesARB( 1, &surf->info->query );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_DrawOcclusionCube
|
||||
|
||||
===============
|
||||
*/
|
||||
static void GL_DrawOcclusionCube( const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
vec3_t bbox[8];
|
||||
int i;
|
||||
|
||||
// compute a full bounding box
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
bbox[i][0] = ( i & 1 ) ? absmin[0] : absmax[0];
|
||||
bbox[i][1] = ( i & 2 ) ? absmin[1] : absmax[1];
|
||||
bbox[i][2] = ( i & 4 ) ? absmin[2] : absmax[2];
|
||||
}
|
||||
|
||||
pglBegin( GL_QUADS );
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
pglVertex3fv( bbox[g_boxpnt[i][0]] );
|
||||
pglVertex3fv( bbox[g_boxpnt[i][1]] );
|
||||
pglVertex3fv( bbox[g_boxpnt[i][2]] );
|
||||
pglVertex3fv( bbox[g_boxpnt[i][3]] );
|
||||
}
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_TestSurfaceOcclusion
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_TestSurfaceOcclusion( msurface_t *surf )
|
||||
{
|
||||
mextrasurf_t *es = surf->info;
|
||||
Vector absmin, absmax;
|
||||
word cached_matrix;
|
||||
Vector normal;
|
||||
|
||||
if( !es->query || FBitSet( surf->flags, SURF_QUEUED ))
|
||||
return; // we already have the query
|
||||
|
||||
if( !es->parent ) cached_matrix = WORLD_MATRIX;
|
||||
else cached_matrix = es->parent->hCachedMatrix;
|
||||
gl_state_t *glm = GL_GetCache( cached_matrix );
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
normal = -surf->plane->normal;
|
||||
else normal = surf->plane->normal;
|
||||
|
||||
// place above surface
|
||||
absmin = es->mins + normal * 5.0f;
|
||||
absmax = es->maxs + normal * 5.0f;
|
||||
ExpandBounds( absmin, absmax, 2.0f );
|
||||
|
||||
if( cached_matrix != WORLD_MATRIX )
|
||||
TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax );
|
||||
pglBeginQueryARB( GL_SAMPLES_PASSED_ARB, es->query );
|
||||
GL_DrawOcclusionCube( absmin, absmax );
|
||||
pglEndQueryARB( GL_SAMPLES_PASSED_ARB );
|
||||
|
||||
// now we have a valid query
|
||||
SetBits( surf->flags, SURF_QUEUED );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_TestSurfaceOcclusion
|
||||
|
||||
===============
|
||||
*/
|
||||
void GL_DebugSurfaceOcclusion( msurface_t *surf )
|
||||
{
|
||||
mextrasurf_t *es = surf->info;
|
||||
Vector absmin, absmax;
|
||||
word cached_matrix;
|
||||
Vector normal;
|
||||
|
||||
if( !FBitSet( surf->flags, SURF_QUEUED ))
|
||||
return; // draw only queue
|
||||
|
||||
if( !es->parent ) cached_matrix = WORLD_MATRIX;
|
||||
else cached_matrix = es->parent->hCachedMatrix;
|
||||
gl_state_t *glm = GL_GetCache( cached_matrix );
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
normal = -surf->plane->normal;
|
||||
else normal = surf->plane->normal;
|
||||
|
||||
// place above surface
|
||||
absmin = es->mins + normal * 5.0f;
|
||||
absmax = es->maxs + normal * 5.0f;
|
||||
ExpandBounds( absmin, absmax, 2.0f );
|
||||
|
||||
if( cached_matrix != WORLD_MATRIX )
|
||||
TransformAABB( glm->transform, es->mins, es->maxs, absmin, absmax );
|
||||
GL_DrawOcclusionCube( absmin, absmax );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_RenderOcclusionList
|
||||
================
|
||||
*/
|
||||
void R_RenderSurfOcclusionList( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling ))
|
||||
return;
|
||||
|
||||
if( !RI->frame.num_subview_faces )
|
||||
return;
|
||||
|
||||
pglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
|
||||
GL_DepthMask( GL_FALSE );
|
||||
GL_AlphaTest( GL_FALSE );
|
||||
GL_BindShader( NULL );
|
||||
|
||||
for( i = 0; i < RI->frame.num_subview_faces; i++ )
|
||||
GL_TestSurfaceOcclusion( RI->frame.subview_faces[i] );
|
||||
|
||||
pglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
||||
GL_DepthMask( GL_TRUE );
|
||||
pglFlush();
|
||||
|
||||
if( r_occlusion_culling->value < 2.0f )
|
||||
return;
|
||||
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
GL_Blend( GL_FALSE );
|
||||
|
||||
for( i = 0; i < RI->frame.num_subview_faces; i++ )
|
||||
GL_DebugSurfaceOcclusion( RI->frame.subview_faces[i] );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
GL_SurfaceOccluded
|
||||
================
|
||||
*/
|
||||
bool GL_SurfaceOccluded( msurface_t *surf )
|
||||
{
|
||||
mextrasurf_t *es = surf->info;
|
||||
GLuint sampleCount = 0;
|
||||
GLint available = false;
|
||||
|
||||
if( !RP_NORMALPASS() || !CVAR_TO_BOOL( r_occlusion_culling ))
|
||||
return false;
|
||||
|
||||
if( !es->query ) return false;
|
||||
|
||||
if( !FBitSet( surf->flags, SURF_QUEUED ))
|
||||
{
|
||||
// occlusion is no more actual
|
||||
ClearBits( surf->flags, SURF_OCCLUDED );
|
||||
return false;
|
||||
}
|
||||
|
||||
// i hope results will be arrived on a next frame...
|
||||
pglGetQueryObjectivARB( es->query, GL_QUERY_RESULT_AVAILABLE_ARB, &available );
|
||||
|
||||
// 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
|
||||
if( !available ) return false;
|
||||
|
||||
pglGetQueryObjectuivARB( es->query, GL_QUERY_RESULT_ARB, &sampleCount );
|
||||
ClearBits( surf->flags, SURF_QUEUED ); // we catch the results, so query is outdated
|
||||
if( sampleCount == 0 ) SetBits( surf->flags, SURF_OCCLUDED );
|
||||
else ClearBits( surf->flags, SURF_OCCLUDED );
|
||||
if( !sampleCount ) r_stats.c_occlusion_culled++;
|
||||
|
||||
return (FBitSet( surf->flags, SURF_OCCLUDED ) != 0);
|
||||
}
|
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
gl_occlusion.h - occlusion query implementation
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2015 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_OCCLUSION_H
|
||||
#define GL_OCCLUSION_H
|
||||
|
||||
void GL_AllocOcclusionQuery( msurface_t *surf );
|
||||
void GL_DeleteOcclusionQuery( msurface_t *surf );
|
||||
bool GL_SurfaceOccluded( msurface_t *surf );
|
||||
void GL_TestSurfaceOcclusion( msurface_t *surf );
|
||||
|
||||
/*
|
||||
gl_occlusion.h - occlusion query implementation
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2015 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_OCCLUSION_H
|
||||
#define GL_OCCLUSION_H
|
||||
|
||||
void GL_AllocOcclusionQuery( msurface_t *surf );
|
||||
void GL_DeleteOcclusionQuery( msurface_t *surf );
|
||||
bool GL_SurfaceOccluded( msurface_t *surf );
|
||||
void GL_TestSurfaceOcclusion( msurface_t *surf );
|
||||
|
||||
#endif//GL_OCCLUSION_H
|
File diff suppressed because it is too large
Load Diff
|
@ -1,99 +1,99 @@
|
|||
/*
|
||||
gl_primitive.cpp - rendering primitives
|
||||
Copyright (C) 2018 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include <stringlib.h>
|
||||
#include "cl_util.h"
|
||||
#include "pm_defs.h"
|
||||
#include "event_api.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_studio.h"
|
||||
#include "gl_world.h"
|
||||
#include "gl_grass.h"
|
||||
|
||||
void CSolidEntry :: SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode )
|
||||
{
|
||||
m_bDrawType = DRAWTYPE_QUAD;
|
||||
m_iStartVertex = RI->frame.primverts.Count();
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
RI->frame.primverts.AddToTail( verts[i] );
|
||||
m_iColor = PackRGBA( color.x * 255, color.y * 255, color.z * 255, color.w * 255 );
|
||||
m_iRenderMode = rendermode;
|
||||
m_hTexture = texture;
|
||||
}
|
||||
|
||||
void CSolidEntry :: SetRenderSurface( msurface_t *surface, word hProgram )
|
||||
{
|
||||
m_bDrawType = DRAWTYPE_SURFACE;
|
||||
m_pSurf = surface;
|
||||
m_pParentEntity = RI->currententity;
|
||||
m_pRenderModel = RI->currentmodel;
|
||||
m_hProgram = hProgram;
|
||||
}
|
||||
|
||||
void CSolidEntry :: SetRenderMesh( vbomesh_t *mesh, word hProgram )
|
||||
{
|
||||
m_bDrawType = DRAWTYPE_MESH;
|
||||
m_pMesh = mesh;
|
||||
m_pParentEntity = RI->currententity;
|
||||
m_pRenderModel = RI->currentmodel;
|
||||
m_hProgram = hProgram;
|
||||
}
|
||||
|
||||
void CTransEntry :: ComputeViewDistance( const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
#if 1
|
||||
m_flViewDist = CalcSqrDistanceToAABB( absmin, absmax, GetVieworg( ));
|
||||
#else
|
||||
Vector origin = (absmin + absmax) * 0.5f;
|
||||
m_flViewDist = DotProduct( origin, GetVForward() ) - RI->view.planedist;
|
||||
// m_flViewDist = VectorDistance2( origin, GetVieworg( ));
|
||||
#endif
|
||||
}
|
||||
|
||||
void CTransEntry :: ComputeScissor( const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
ComputeViewDistance( absmin, absmax );
|
||||
|
||||
if( R_ScissorForAABB( absmin, absmax, &m_vecRect.x, &m_vecRect.y, &m_vecRect.z, &m_vecRect.w ))
|
||||
m_bScissorReady = true;
|
||||
else m_bScissorReady = false;
|
||||
}
|
||||
|
||||
void CTransEntry :: RequestScreenColor( void )
|
||||
{
|
||||
if( !m_bScissorReady ) return;
|
||||
|
||||
float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y;
|
||||
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 );
|
||||
}
|
||||
|
||||
void CTransEntry :: RequestScreenDepth( void )
|
||||
{
|
||||
if( !m_bScissorReady ) return;
|
||||
|
||||
float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y;
|
||||
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 );
|
||||
}
|
||||
|
||||
void CTransEntry :: RenderScissorDebug( void )
|
||||
{
|
||||
if( !m_bScissorReady ) return;
|
||||
|
||||
R_DrawScissorRectangle( m_vecRect.x, m_vecRect.y, m_vecRect.z, m_vecRect.w );
|
||||
/*
|
||||
gl_primitive.cpp - rendering primitives
|
||||
Copyright (C) 2018 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include <stringlib.h>
|
||||
#include "cl_util.h"
|
||||
#include "pm_defs.h"
|
||||
#include "event_api.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_studio.h"
|
||||
#include "gl_world.h"
|
||||
#include "gl_grass.h"
|
||||
|
||||
void CSolidEntry :: SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode )
|
||||
{
|
||||
m_bDrawType = DRAWTYPE_QUAD;
|
||||
m_iStartVertex = RI->frame.primverts.Count();
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
RI->frame.primverts.AddToTail( verts[i] );
|
||||
m_iColor = PackRGBA( color.x * 255, color.y * 255, color.z * 255, color.w * 255 );
|
||||
m_iRenderMode = rendermode;
|
||||
m_hTexture = texture;
|
||||
}
|
||||
|
||||
void CSolidEntry :: SetRenderSurface( msurface_t *surface, word hProgram )
|
||||
{
|
||||
m_bDrawType = DRAWTYPE_SURFACE;
|
||||
m_pSurf = surface;
|
||||
m_pParentEntity = RI->currententity;
|
||||
m_pRenderModel = RI->currentmodel;
|
||||
m_hProgram = hProgram;
|
||||
}
|
||||
|
||||
void CSolidEntry :: SetRenderMesh( vbomesh_t *mesh, word hProgram )
|
||||
{
|
||||
m_bDrawType = DRAWTYPE_MESH;
|
||||
m_pMesh = mesh;
|
||||
m_pParentEntity = RI->currententity;
|
||||
m_pRenderModel = RI->currentmodel;
|
||||
m_hProgram = hProgram;
|
||||
}
|
||||
|
||||
void CTransEntry :: ComputeViewDistance( const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
#if 1
|
||||
m_flViewDist = CalcSqrDistanceToAABB( absmin, absmax, GetVieworg( ));
|
||||
#else
|
||||
Vector origin = (absmin + absmax) * 0.5f;
|
||||
m_flViewDist = DotProduct( origin, GetVForward() ) - RI->view.planedist;
|
||||
// m_flViewDist = VectorDistance2( origin, GetVieworg( ));
|
||||
#endif
|
||||
}
|
||||
|
||||
void CTransEntry :: ComputeScissor( const Vector &absmin, const Vector &absmax )
|
||||
{
|
||||
ComputeViewDistance( absmin, absmax );
|
||||
|
||||
if( R_ScissorForAABB( absmin, absmax, &m_vecRect.x, &m_vecRect.y, &m_vecRect.z, &m_vecRect.w ))
|
||||
m_bScissorReady = true;
|
||||
else m_bScissorReady = false;
|
||||
}
|
||||
|
||||
void CTransEntry :: RequestScreenColor( void )
|
||||
{
|
||||
if( !m_bScissorReady ) return;
|
||||
|
||||
float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y;
|
||||
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 );
|
||||
}
|
||||
|
||||
void CTransEntry :: RequestScreenDepth( void )
|
||||
{
|
||||
if( !m_bScissorReady ) return;
|
||||
|
||||
float y2 = (float)RI->view.port[3] - m_vecRect.w - m_vecRect.y;
|
||||
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 );
|
||||
}
|
||||
|
||||
void CTransEntry :: RenderScissorDebug( void )
|
||||
{
|
||||
if( !m_bScissorReady ) return;
|
||||
|
||||
R_DrawScissorRectangle( m_vecRect.x, m_vecRect.y, m_vecRect.z, m_vecRect.w );
|
||||
}
|
|
@ -1,80 +1,80 @@
|
|||
/*
|
||||
gl_primitive.h - render primitives
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_PRIMITIVE_H
|
||||
#define GL_PRIMITIVE_H
|
||||
|
||||
#define DRAWTYPE_UNKNOWN 0
|
||||
#define DRAWTYPE_SURFACE 1
|
||||
#define DRAWTYPE_MESH 2
|
||||
#define DRAWTYPE_QUAD 3
|
||||
|
||||
//#pragma pack(1)
|
||||
|
||||
class CSolidEntry
|
||||
{
|
||||
public:
|
||||
void SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode );
|
||||
void SetRenderSurface( msurface_t *surface, word hProgram );
|
||||
void SetRenderMesh( struct vbomesh_s *mesh, word hProgram );
|
||||
virtual bool IsTranslucent( void ) { return false; }
|
||||
int GetType( void ) { return m_bDrawType; }
|
||||
|
||||
byte m_bDrawType; // type of entry
|
||||
|
||||
union
|
||||
{
|
||||
cl_entity_t *m_pParentEntity; // pointer to parent entity
|
||||
int m_iRenderMode; // rendermode for primitive
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
model_t *m_pRenderModel; // render model
|
||||
int m_iStartVertex; // offset in global heap
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
unsigned short m_hProgram; // handle to glsl program (may be 0)
|
||||
unsigned short m_hTexture; // texture for primitive
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
struct vbomesh_s *m_pMesh; // NULL or mesh
|
||||
msurface_t *m_pSurf; // NULL or surface
|
||||
int m_iColor; // primitive color
|
||||
};
|
||||
};
|
||||
|
||||
class CTransEntry : public CSolidEntry
|
||||
{
|
||||
public:
|
||||
void ComputeViewDistance( const Vector &absmin, const Vector &absmax );
|
||||
void ComputeScissor( const Vector &absmin, const Vector &absmax );
|
||||
virtual bool IsTranslucent( void ) { return true; }
|
||||
void RequestScreenColor( void );
|
||||
void RequestScreenDepth( void );
|
||||
void RenderScissorDebug( void );
|
||||
|
||||
float m_flViewDist;
|
||||
Vector4D m_vecRect;
|
||||
bool m_bScissorReady : 1;
|
||||
};
|
||||
//#pragma pack()
|
||||
|
||||
/*
|
||||
gl_primitive.h - render primitives
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_PRIMITIVE_H
|
||||
#define GL_PRIMITIVE_H
|
||||
|
||||
#define DRAWTYPE_UNKNOWN 0
|
||||
#define DRAWTYPE_SURFACE 1
|
||||
#define DRAWTYPE_MESH 2
|
||||
#define DRAWTYPE_QUAD 3
|
||||
|
||||
//#pragma pack(1)
|
||||
|
||||
class CSolidEntry
|
||||
{
|
||||
public:
|
||||
void SetRenderPrimitive( const Vector verts[4], const Vector4D &color, int texture, int rendermode );
|
||||
void SetRenderSurface( msurface_t *surface, word hProgram );
|
||||
void SetRenderMesh( struct vbomesh_s *mesh, word hProgram );
|
||||
virtual bool IsTranslucent( void ) { return false; }
|
||||
int GetType( void ) { return m_bDrawType; }
|
||||
|
||||
byte m_bDrawType; // type of entry
|
||||
|
||||
union
|
||||
{
|
||||
cl_entity_t *m_pParentEntity; // pointer to parent entity
|
||||
int m_iRenderMode; // rendermode for primitive
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
model_t *m_pRenderModel; // render model
|
||||
int m_iStartVertex; // offset in global heap
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
unsigned short m_hProgram; // handle to glsl program (may be 0)
|
||||
unsigned short m_hTexture; // texture for primitive
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
struct vbomesh_s *m_pMesh; // NULL or mesh
|
||||
msurface_t *m_pSurf; // NULL or surface
|
||||
int m_iColor; // primitive color
|
||||
};
|
||||
};
|
||||
|
||||
class CTransEntry : public CSolidEntry
|
||||
{
|
||||
public:
|
||||
void ComputeViewDistance( const Vector &absmin, const Vector &absmax );
|
||||
void ComputeScissor( const Vector &absmin, const Vector &absmax );
|
||||
virtual bool IsTranslucent( void ) { return true; }
|
||||
void RequestScreenColor( void );
|
||||
void RequestScreenDepth( void );
|
||||
void RenderScissorDebug( void );
|
||||
|
||||
float m_flViewDist;
|
||||
Vector4D m_vecRect;
|
||||
bool m_bScissorReady : 1;
|
||||
};
|
||||
//#pragma pack()
|
||||
|
||||
#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
|
@ -1,144 +1,144 @@
|
|||
/*
|
||||
gl_rpart.h - quake-like particles
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_RPART_H
|
||||
#define GL_RPART_H
|
||||
|
||||
#include "randomrange.h"
|
||||
|
||||
#define MAX_PARTICLES 8192
|
||||
#define MAX_PARTINFOS 256 // various types of part-system
|
||||
|
||||
// built-in particle-system flags
|
||||
#define FPART_BOUNCE (1<<0) // makes a bouncy particle
|
||||
#define FPART_FRICTION (1<<1)
|
||||
#define FPART_VERTEXLIGHT (1<<2) // give some ambient light for it
|
||||
#define FPART_STRETCH (1<<3)
|
||||
#define FPART_UNDERWATER (1<<4)
|
||||
#define FPART_INSTANT (1<<5)
|
||||
#define FPART_ADDITIVE (1<<6)
|
||||
#define FPART_NOTWATER (1<<7) // don't spawn in water
|
||||
|
||||
class CQuakePart
|
||||
{
|
||||
public:
|
||||
Vector m_vecOrigin; // position for current frame
|
||||
Vector m_vecLastOrg; // position from previous frame
|
||||
|
||||
Vector m_vecVelocity; // linear velocity
|
||||
Vector m_vecAccel;
|
||||
Vector m_vecColor;
|
||||
Vector m_vecColorVelocity;
|
||||
float m_flAlpha;
|
||||
float m_flAlphaVelocity;
|
||||
float m_flRadius;
|
||||
float m_flRadiusVelocity;
|
||||
float m_flLength;
|
||||
float m_flLengthVelocity;
|
||||
float m_flRotation; // texture ROLL angle
|
||||
float m_flBounceFactor;
|
||||
|
||||
CQuakePart *pNext; // linked list
|
||||
int m_hTexture;
|
||||
|
||||
float m_flTime;
|
||||
int m_iFlags;
|
||||
|
||||
bool Evaluate( float gravity );
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NORMAL_IGNORE = 0,
|
||||
NORMAL_OFFSET,
|
||||
NORMAL_DIRECTION,
|
||||
NORMAL_OFS_DIR,
|
||||
};
|
||||
|
||||
class CQuakePartInfo
|
||||
{
|
||||
public:
|
||||
char m_szName[32]; // effect name
|
||||
|
||||
struct model_s *m_pSprite; // sprite
|
||||
int m_hTexture; // tga texture
|
||||
|
||||
RandomRange offset[3];
|
||||
RandomRange velocity[3];
|
||||
RandomRange accel[3];
|
||||
RandomRange color[3];
|
||||
RandomRange colorVel[3];
|
||||
RandomRange alpha;
|
||||
RandomRange alphaVel;
|
||||
RandomRange radius;
|
||||
RandomRange radiusVel;
|
||||
RandomRange length;
|
||||
RandomRange lengthVel;
|
||||
RandomRange rotation;
|
||||
RandomRange bounce;
|
||||
RandomRange frame;
|
||||
RandomRange count; // particle count
|
||||
|
||||
int normal; // how to use normal
|
||||
int flags; // particle flags
|
||||
};
|
||||
|
||||
class CQuakePartSystem
|
||||
{
|
||||
CQuakePart *m_pActiveParticles;
|
||||
CQuakePart *m_pFreeParticles;
|
||||
CQuakePart m_pParticles[MAX_PARTICLES];
|
||||
|
||||
CQuakePartInfo m_pPartInfo[MAX_PARTINFOS];
|
||||
int m_iNumPartInfo;
|
||||
|
||||
// private partsystem shaders
|
||||
int m_hDefaultParticle;
|
||||
int m_hSparks;
|
||||
int m_hSmoke;
|
||||
int m_hWaterSplash;
|
||||
|
||||
cvar_t *m_pAllowParticles;
|
||||
cvar_t *m_pParticleLod;
|
||||
public:
|
||||
CQuakePartSystem( void );
|
||||
virtual ~CQuakePartSystem( void );
|
||||
|
||||
void Clear( void );
|
||||
void Update( void );
|
||||
void FreeParticle( CQuakePart *pCur );
|
||||
CQuakePart *AllocParticle( void );
|
||||
bool AddParticle( CQuakePart *src, int texture = 0, int flags = 0 );
|
||||
void ParsePartInfos( const char *filename );
|
||||
bool ParsePartInfo( CQuakePartInfo *info, char *&pfile );
|
||||
bool ParseRandomVector( char *&pfile, RandomRange out[3] );
|
||||
int ParseParticleFlags( char *pfile );
|
||||
CQuakePartInfo *FindPartInfo( const char *name );
|
||||
void CreateEffect( const char *name, const Vector &origin, const Vector &normal );
|
||||
|
||||
// example presets
|
||||
void ExplosionParticles( const Vector &pos );
|
||||
void BulletParticles( const Vector &org, const Vector &dir );
|
||||
void BubbleParticles( const Vector &org, int count, float magnitude );
|
||||
void SparkParticles( const Vector &org, const Vector &dir );
|
||||
void RicochetSparks( const Vector &org, float scale );
|
||||
void SmokeParticles( const Vector &pos, int count );
|
||||
void GunSmoke( const Vector &pos, int count );
|
||||
};
|
||||
|
||||
extern CQuakePartSystem g_pParticles;
|
||||
|
||||
/*
|
||||
gl_rpart.h - quake-like particles
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_RPART_H
|
||||
#define GL_RPART_H
|
||||
|
||||
#include "randomrange.h"
|
||||
|
||||
#define MAX_PARTICLES 8192
|
||||
#define MAX_PARTINFOS 256 // various types of part-system
|
||||
|
||||
// built-in particle-system flags
|
||||
#define FPART_BOUNCE (1<<0) // makes a bouncy particle
|
||||
#define FPART_FRICTION (1<<1)
|
||||
#define FPART_VERTEXLIGHT (1<<2) // give some ambient light for it
|
||||
#define FPART_STRETCH (1<<3)
|
||||
#define FPART_UNDERWATER (1<<4)
|
||||
#define FPART_INSTANT (1<<5)
|
||||
#define FPART_ADDITIVE (1<<6)
|
||||
#define FPART_NOTWATER (1<<7) // don't spawn in water
|
||||
|
||||
class CQuakePart
|
||||
{
|
||||
public:
|
||||
Vector m_vecOrigin; // position for current frame
|
||||
Vector m_vecLastOrg; // position from previous frame
|
||||
|
||||
Vector m_vecVelocity; // linear velocity
|
||||
Vector m_vecAccel;
|
||||
Vector m_vecColor;
|
||||
Vector m_vecColorVelocity;
|
||||
float m_flAlpha;
|
||||
float m_flAlphaVelocity;
|
||||
float m_flRadius;
|
||||
float m_flRadiusVelocity;
|
||||
float m_flLength;
|
||||
float m_flLengthVelocity;
|
||||
float m_flRotation; // texture ROLL angle
|
||||
float m_flBounceFactor;
|
||||
|
||||
CQuakePart *pNext; // linked list
|
||||
int m_hTexture;
|
||||
|
||||
float m_flTime;
|
||||
int m_iFlags;
|
||||
|
||||
bool Evaluate( float gravity );
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NORMAL_IGNORE = 0,
|
||||
NORMAL_OFFSET,
|
||||
NORMAL_DIRECTION,
|
||||
NORMAL_OFS_DIR,
|
||||
};
|
||||
|
||||
class CQuakePartInfo
|
||||
{
|
||||
public:
|
||||
char m_szName[32]; // effect name
|
||||
|
||||
struct model_s *m_pSprite; // sprite
|
||||
int m_hTexture; // tga texture
|
||||
|
||||
RandomRange offset[3];
|
||||
RandomRange velocity[3];
|
||||
RandomRange accel[3];
|
||||
RandomRange color[3];
|
||||
RandomRange colorVel[3];
|
||||
RandomRange alpha;
|
||||
RandomRange alphaVel;
|
||||
RandomRange radius;
|
||||
RandomRange radiusVel;
|
||||
RandomRange length;
|
||||
RandomRange lengthVel;
|
||||
RandomRange rotation;
|
||||
RandomRange bounce;
|
||||
RandomRange frame;
|
||||
RandomRange count; // particle count
|
||||
|
||||
int normal; // how to use normal
|
||||
int flags; // particle flags
|
||||
};
|
||||
|
||||
class CQuakePartSystem
|
||||
{
|
||||
CQuakePart *m_pActiveParticles;
|
||||
CQuakePart *m_pFreeParticles;
|
||||
CQuakePart m_pParticles[MAX_PARTICLES];
|
||||
|
||||
CQuakePartInfo m_pPartInfo[MAX_PARTINFOS];
|
||||
int m_iNumPartInfo;
|
||||
|
||||
// private partsystem shaders
|
||||
int m_hDefaultParticle;
|
||||
int m_hSparks;
|
||||
int m_hSmoke;
|
||||
int m_hWaterSplash;
|
||||
|
||||
cvar_t *m_pAllowParticles;
|
||||
cvar_t *m_pParticleLod;
|
||||
public:
|
||||
CQuakePartSystem( void );
|
||||
virtual ~CQuakePartSystem( void );
|
||||
|
||||
void Clear( void );
|
||||
void Update( void );
|
||||
void FreeParticle( CQuakePart *pCur );
|
||||
CQuakePart *AllocParticle( void );
|
||||
bool AddParticle( CQuakePart *src, int texture = 0, int flags = 0 );
|
||||
void ParsePartInfos( const char *filename );
|
||||
bool ParsePartInfo( CQuakePartInfo *info, char *&pfile );
|
||||
bool ParseRandomVector( char *&pfile, RandomRange out[3] );
|
||||
int ParseParticleFlags( char *pfile );
|
||||
CQuakePartInfo *FindPartInfo( const char *name );
|
||||
void CreateEffect( const char *name, const Vector &origin, const Vector &normal );
|
||||
|
||||
// example presets
|
||||
void ExplosionParticles( const Vector &pos );
|
||||
void BulletParticles( const Vector &org, const Vector &dir );
|
||||
void BubbleParticles( const Vector &org, int count, float magnitude );
|
||||
void SparkParticles( const Vector &org, const Vector &dir );
|
||||
void RicochetSparks( const Vector &org, float scale );
|
||||
void SmokeParticles( const Vector &pos, int count );
|
||||
void GunSmoke( const Vector &pos, int count );
|
||||
};
|
||||
|
||||
extern CQuakePartSystem g_pParticles;
|
||||
|
||||
#endif//GL_RPART_H
|
|
@ -1,99 +1,99 @@
|
|||
/*
|
||||
gl_rsurf.cpp - surface-related code
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
|
||||
static int rtable[MOD_FRAMES][MOD_FRAMES];
|
||||
|
||||
/*
|
||||
===============
|
||||
R_TextureAnimation
|
||||
|
||||
Returns the proper texture for a given time and base texture
|
||||
===============
|
||||
*/
|
||||
texture_t *R_TextureAnimation( msurface_t *s )
|
||||
{
|
||||
texture_t *base = s->texinfo->texture;
|
||||
int count, reletive = 0;
|
||||
|
||||
if(( RI->currententity != NULL ) && ( RI->currententity->curstate.frame != 0.0f ))
|
||||
{
|
||||
if( base->alternate_anims )
|
||||
base = base->alternate_anims;
|
||||
}
|
||||
|
||||
if( !base->anim_total )
|
||||
return base;
|
||||
|
||||
if( base->name[0] == '-' )
|
||||
{
|
||||
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;
|
||||
reletive = rtable[tx][ty] % base->anim_total;
|
||||
}
|
||||
else
|
||||
{
|
||||
reletive = (int)(tr.time * 20) % base->anim_total;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
||||
while( base->anim_min > reletive || base->anim_max <= reletive )
|
||||
{
|
||||
base = base->anim_next;
|
||||
|
||||
if( !base )
|
||||
{
|
||||
ALERT( at_error, "R_TextureAnimation: broken loop\n" );
|
||||
return s->texinfo->texture;
|
||||
}
|
||||
|
||||
if( ++count > MOD_FRAMES )
|
||||
{
|
||||
ALERT( at_error, "R_TextureAnimation: infinite loop\n" );
|
||||
return s->texinfo->texture;
|
||||
}
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
|
||||
WORLD MODEL
|
||||
|
||||
=============================================================
|
||||
*/
|
||||
void GL_InitRandomTable( void )
|
||||
{
|
||||
int tu, tv;
|
||||
|
||||
// make random predictable
|
||||
RANDOM_SEED( 255 );
|
||||
|
||||
for( tu = 0; tu < MOD_FRAMES; tu++ )
|
||||
{
|
||||
for( tv = 0; tv < MOD_FRAMES; tv++ )
|
||||
{
|
||||
rtable[tu][tv] = RANDOM_LONG( 0, 0x7FFF );
|
||||
}
|
||||
}
|
||||
|
||||
RANDOM_SEED( 0 );
|
||||
/*
|
||||
gl_rsurf.cpp - surface-related code
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
|
||||
static int rtable[MOD_FRAMES][MOD_FRAMES];
|
||||
|
||||
/*
|
||||
===============
|
||||
R_TextureAnimation
|
||||
|
||||
Returns the proper texture for a given time and base texture
|
||||
===============
|
||||
*/
|
||||
texture_t *R_TextureAnimation( msurface_t *s )
|
||||
{
|
||||
texture_t *base = s->texinfo->texture;
|
||||
int count, reletive = 0;
|
||||
|
||||
if(( RI->currententity != NULL ) && ( RI->currententity->curstate.frame != 0.0f ))
|
||||
{
|
||||
if( base->alternate_anims )
|
||||
base = base->alternate_anims;
|
||||
}
|
||||
|
||||
if( !base->anim_total )
|
||||
return base;
|
||||
|
||||
if( base->name[0] == '-' )
|
||||
{
|
||||
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;
|
||||
reletive = rtable[tx][ty] % base->anim_total;
|
||||
}
|
||||
else
|
||||
{
|
||||
reletive = (int)(tr.time * 20) % base->anim_total;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
||||
while( base->anim_min > reletive || base->anim_max <= reletive )
|
||||
{
|
||||
base = base->anim_next;
|
||||
|
||||
if( !base )
|
||||
{
|
||||
ALERT( at_error, "R_TextureAnimation: broken loop\n" );
|
||||
return s->texinfo->texture;
|
||||
}
|
||||
|
||||
if( ++count > MOD_FRAMES )
|
||||
{
|
||||
ALERT( at_error, "R_TextureAnimation: infinite loop\n" );
|
||||
return s->texinfo->texture;
|
||||
}
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
|
||||
WORLD MODEL
|
||||
|
||||
=============================================================
|
||||
*/
|
||||
void GL_InitRandomTable( void )
|
||||
{
|
||||
int tu, tv;
|
||||
|
||||
// make random predictable
|
||||
RANDOM_SEED( 255 );
|
||||
|
||||
for( tu = 0; tu < MOD_FRAMES; tu++ )
|
||||
{
|
||||
for( tv = 0; tv < MOD_FRAMES; tv++ )
|
||||
{
|
||||
rtable[tu][tv] = RANDOM_LONG( 0, 0x7FFF );
|
||||
}
|
||||
}
|
||||
|
||||
RANDOM_SEED( 0 );
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,262 +1,262 @@
|
|||
/*
|
||||
gl_shader.h - shader parsing and handling
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_SHADER_H
|
||||
#define GL_SHADER_H
|
||||
|
||||
#define MAX_OPTIONS_LENGTH 512
|
||||
#define MAX_GLSL_PROGRAMS 4096
|
||||
|
||||
#define SHADER_VERTEX_COMPILED BIT( 0 )
|
||||
#define SHADER_FRAGMENT_COMPILED BIT( 1 )
|
||||
#define SHADER_PROGRAM_LINKED BIT( 2 )
|
||||
#define SHADER_UBERSHADER BIT( 3 )
|
||||
#define SHADER_TRANSLUCENT BIT( 4 )
|
||||
#define SHADER_USE_CUBEMAPS BIT( 5 )
|
||||
#define SHADER_USE_SCREENCOPY BIT( 6 )
|
||||
#define SHADER_ADDITIVE BIT( 7 )
|
||||
|
||||
#define SHADER_STATUS_OK ( SHADER_PROGRAM_LINKED|SHADER_VERTEX_COMPILED|SHADER_FRAGMENT_COMPILED )
|
||||
#define CheckShader( shader ) ( shader && shader->status == SHADER_STATUS_OK )
|
||||
|
||||
enum
|
||||
{
|
||||
ATTR_INDEX_POSITION = 0,
|
||||
ATTR_INDEX_TANGENT,
|
||||
ATTR_INDEX_BINORMAL,
|
||||
ATTR_INDEX_NORMAL,
|
||||
ATTR_INDEX_TEXCOORD0, // texture coord
|
||||
ATTR_INDEX_TEXCOORD1, // lightmap coord (styles0-1)
|
||||
ATTR_INDEX_TEXCOORD2, // lightmap coord (styles2-3)
|
||||
ATTR_INDEX_BONE_INDEXES, // studiomodels only
|
||||
ATTR_INDEX_BONE_WEIGHTS, // studiomodels only
|
||||
ATTR_INDEX_LIGHT_STYLES, // brushmodels only
|
||||
ATTR_INDEX_LIGHT_COLOR, // studio & grass
|
||||
ATTR_INDEX_LIGHT_VECS, // studio & grass
|
||||
ATTR_INDEX_LIGHT_NUMS0, // brushmodels only
|
||||
ATTR_INDEX_LIGHT_NUMS1, // brushmodels only
|
||||
};
|
||||
|
||||
// shader->attribs
|
||||
#define FATTR_POSITION BIT( 0 )
|
||||
#define FATTR_TANGENT BIT( 1 )
|
||||
#define FATTR_BINORMAL BIT( 2 )
|
||||
#define FATTR_NORMAL BIT( 3 )
|
||||
#define FATTR_TEXCOORD0 BIT( 4 )
|
||||
#define FATTR_TEXCOORD1 BIT( 5 )
|
||||
#define FATTR_TEXCOORD2 BIT( 6 )
|
||||
#define FATTR_BONE_INDEXES BIT( 7 )
|
||||
#define FATTR_BONE_WEIGHTS BIT( 8 )
|
||||
#define FATTR_LIGHT_STYLES BIT( 9 )
|
||||
#define FATTR_LIGHT_COLOR BIT( 10 )
|
||||
#define FATTR_LIGHT_VECS BIT( 11 )
|
||||
#define FATTR_LIGHT_NUMS0 BIT( 12 )
|
||||
#define FATTR_LIGHT_NUMS1 BIT( 13 )
|
||||
|
||||
// uniform->flags
|
||||
#define UFL_GLOBAL_PARM BIT( 0 )
|
||||
#define UFL_TEXTURE_UNIT BIT( 1 )
|
||||
|
||||
// uniform->type
|
||||
typedef enum
|
||||
{
|
||||
UT_COLORMAP = 0,
|
||||
UT_DEPTHMAP,
|
||||
UT_NORMALMAP,
|
||||
UT_GLOSSMAP,
|
||||
UT_DETAILMAP,
|
||||
UT_PROJECTMAP, // spotlight texture
|
||||
UT_SHADOWMAP0,
|
||||
UT_SHADOWMAP1,
|
||||
UT_SHADOWMAP2,
|
||||
UT_SHADOWMAP3,
|
||||
UT_SHADOWMAP,
|
||||
UT_LIGHTMAP,
|
||||
UT_DELUXEMAP,
|
||||
UT_DECALMAP,
|
||||
UT_SCREENMAP,
|
||||
UT_VISLIGHTMAP0,
|
||||
UT_VISLIGHTMAP1,
|
||||
UT_ENVMAP0,
|
||||
UT_ENVMAP1,
|
||||
UT_ENVMAP,
|
||||
UT_GLOWMAP,
|
||||
UT_HEIGHTMAP,
|
||||
UT_LAYERMAP,
|
||||
UT_FRAGDATA0,
|
||||
UT_FRAGDATA1,
|
||||
UT_FRAGDATA2,
|
||||
UT_BSPPLANESMAP,
|
||||
UT_BSPNODESMAP,
|
||||
UT_BSPLIGHTSMAP,
|
||||
UT_BSPMODELSMAP,
|
||||
UT_FITNORMALMAP,
|
||||
UT_MODELMATRIX,
|
||||
UT_REFLECTMATRIX,
|
||||
UT_BONESARRAY,
|
||||
UT_BONEQUATERNION,
|
||||
UT_BONEPOSITION,
|
||||
UT_SCREENSIZEINV,
|
||||
UT_ZFAR,
|
||||
UT_LIGHTSTYLEVALUES,
|
||||
UT_LIGHTSTYLES,
|
||||
UT_REALTIME,
|
||||
UT_DETAILSCALE,
|
||||
UT_FOGPARAMS,
|
||||
UT_SHADOWPARMS,
|
||||
UT_TEXOFFSET,
|
||||
UT_VIEWORIGIN,
|
||||
UT_VIEWRIGHT,
|
||||
UT_RENDERCOLOR,
|
||||
UT_RENDERALPHA,
|
||||
UT_SMOOTHNESS,
|
||||
UT_SHADOWMATRIX,
|
||||
UT_SHADOWSPLITDIST,
|
||||
UT_TEXELSIZE,
|
||||
UT_GAMMATABLE,
|
||||
UT_LIGHTDIR,
|
||||
UT_LIGHTDIFFUSE,
|
||||
UT_LIGHTSHADE,
|
||||
UT_LIGHTORIGIN,
|
||||
UT_LIGHTVIEWPROJMATRIX,
|
||||
UT_DIFFUSEFACTOR,
|
||||
UT_AMBIENTFACTOR,
|
||||
UT_AMBIENTCUBE,
|
||||
UT_SUNREFRACT,
|
||||
UT_LERPFACTOR,
|
||||
UT_REFRACTSCALE,
|
||||
UT_REFLECTSCALE,
|
||||
UT_ABERRATIONSCALE,
|
||||
UT_BOXMINS,
|
||||
UT_BOXMAXS,
|
||||
UT_CUBEORIGIN,
|
||||
UT_CUBEMIPCOUNT,
|
||||
UT_LIGHTNUMS0,
|
||||
UT_LIGHTNUMS1,
|
||||
UT_GRASSPARAMS,
|
||||
UT_RELIEFPARAMS,
|
||||
UT_BLURFACTOR,
|
||||
UT_SCREENWIDTH,
|
||||
UT_SCREENHEIGHT,
|
||||
UT_FOCALDEPTH,
|
||||
UT_FOCALLENGTH,
|
||||
UT_DOFDEBUG,
|
||||
UT_FSTOP,
|
||||
UT_GRAYSCALE,
|
||||
UT_LIGHTGAMMA,
|
||||
UT_LIGHTSCALE,
|
||||
UT_LIGHTTHRESHOLD,
|
||||
UT_NUMVISIBLEMODELS,
|
||||
UT_UNDEFINED,
|
||||
} uniformType_t;
|
||||
|
||||
union unicache_t
|
||||
{
|
||||
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, 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( 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, 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; }
|
||||
|
||||
float fValue[4];
|
||||
int iValue[4];
|
||||
};
|
||||
|
||||
class uniform_t
|
||||
{
|
||||
public:
|
||||
char name[MAX_QPATH];
|
||||
uniformType_t type;
|
||||
int size;
|
||||
uint format;
|
||||
int location;
|
||||
int unit; // texture unit
|
||||
int flags; // hints
|
||||
unicache_t cache;
|
||||
|
||||
// helpers
|
||||
void SetValue( float v0 )
|
||||
{
|
||||
unicache_t pack( v0 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( float v0, float v1 )
|
||||
{
|
||||
unicache_t pack( v0, v1 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( float v0, float v1, float v2 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( float v0, float v1, float v2, float v3 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2, v3 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0 )
|
||||
{
|
||||
unicache_t pack( v0 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0, int v1 )
|
||||
{
|
||||
unicache_t pack( v0, v1 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0, int v1, int v2 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0, int v1, int v2, GLint v3 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2, v3 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
// passed any data here
|
||||
void SetValue( const void *pdata, int count = -1 );
|
||||
int GetSizeInBytes( void );
|
||||
};
|
||||
|
||||
typedef struct glsl_prog_s
|
||||
{
|
||||
char name[64];
|
||||
char options[MAX_OPTIONS_LENGTH]; // UberShader preprocess agrs
|
||||
GLhandleARB handle;
|
||||
unsigned short status;
|
||||
struct glsl_prog_s *nextHash;
|
||||
unsigned short attribs;
|
||||
uniform_t *uniforms;
|
||||
int numUniforms;
|
||||
} glsl_program_t;
|
||||
|
||||
extern glsl_program_t glsl_programs[MAX_GLSL_PROGRAMS];
|
||||
extern int num_glsl_programs;
|
||||
|
||||
/*
|
||||
gl_shader.h - shader parsing and handling
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2013 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_SHADER_H
|
||||
#define GL_SHADER_H
|
||||
|
||||
#define MAX_OPTIONS_LENGTH 512
|
||||
#define MAX_GLSL_PROGRAMS 4096
|
||||
|
||||
#define SHADER_VERTEX_COMPILED BIT( 0 )
|
||||
#define SHADER_FRAGMENT_COMPILED BIT( 1 )
|
||||
#define SHADER_PROGRAM_LINKED BIT( 2 )
|
||||
#define SHADER_UBERSHADER BIT( 3 )
|
||||
#define SHADER_TRANSLUCENT BIT( 4 )
|
||||
#define SHADER_USE_CUBEMAPS BIT( 5 )
|
||||
#define SHADER_USE_SCREENCOPY BIT( 6 )
|
||||
#define SHADER_ADDITIVE BIT( 7 )
|
||||
|
||||
#define SHADER_STATUS_OK ( SHADER_PROGRAM_LINKED|SHADER_VERTEX_COMPILED|SHADER_FRAGMENT_COMPILED )
|
||||
#define CheckShader( shader ) ( shader && shader->status == SHADER_STATUS_OK )
|
||||
|
||||
enum
|
||||
{
|
||||
ATTR_INDEX_POSITION = 0,
|
||||
ATTR_INDEX_TANGENT,
|
||||
ATTR_INDEX_BINORMAL,
|
||||
ATTR_INDEX_NORMAL,
|
||||
ATTR_INDEX_TEXCOORD0, // texture coord
|
||||
ATTR_INDEX_TEXCOORD1, // lightmap coord (styles0-1)
|
||||
ATTR_INDEX_TEXCOORD2, // lightmap coord (styles2-3)
|
||||
ATTR_INDEX_BONE_INDEXES, // studiomodels only
|
||||
ATTR_INDEX_BONE_WEIGHTS, // studiomodels only
|
||||
ATTR_INDEX_LIGHT_STYLES, // brushmodels only
|
||||
ATTR_INDEX_LIGHT_COLOR, // studio & grass
|
||||
ATTR_INDEX_LIGHT_VECS, // studio & grass
|
||||
ATTR_INDEX_LIGHT_NUMS0, // brushmodels only
|
||||
ATTR_INDEX_LIGHT_NUMS1, // brushmodels only
|
||||
};
|
||||
|
||||
// shader->attribs
|
||||
#define FATTR_POSITION BIT( 0 )
|
||||
#define FATTR_TANGENT BIT( 1 )
|
||||
#define FATTR_BINORMAL BIT( 2 )
|
||||
#define FATTR_NORMAL BIT( 3 )
|
||||
#define FATTR_TEXCOORD0 BIT( 4 )
|
||||
#define FATTR_TEXCOORD1 BIT( 5 )
|
||||
#define FATTR_TEXCOORD2 BIT( 6 )
|
||||
#define FATTR_BONE_INDEXES BIT( 7 )
|
||||
#define FATTR_BONE_WEIGHTS BIT( 8 )
|
||||
#define FATTR_LIGHT_STYLES BIT( 9 )
|
||||
#define FATTR_LIGHT_COLOR BIT( 10 )
|
||||
#define FATTR_LIGHT_VECS BIT( 11 )
|
||||
#define FATTR_LIGHT_NUMS0 BIT( 12 )
|
||||
#define FATTR_LIGHT_NUMS1 BIT( 13 )
|
||||
|
||||
// uniform->flags
|
||||
#define UFL_GLOBAL_PARM BIT( 0 )
|
||||
#define UFL_TEXTURE_UNIT BIT( 1 )
|
||||
|
||||
// uniform->type
|
||||
typedef enum
|
||||
{
|
||||
UT_COLORMAP = 0,
|
||||
UT_DEPTHMAP,
|
||||
UT_NORMALMAP,
|
||||
UT_GLOSSMAP,
|
||||
UT_DETAILMAP,
|
||||
UT_PROJECTMAP, // spotlight texture
|
||||
UT_SHADOWMAP0,
|
||||
UT_SHADOWMAP1,
|
||||
UT_SHADOWMAP2,
|
||||
UT_SHADOWMAP3,
|
||||
UT_SHADOWMAP,
|
||||
UT_LIGHTMAP,
|
||||
UT_DELUXEMAP,
|
||||
UT_DECALMAP,
|
||||
UT_SCREENMAP,
|
||||
UT_VISLIGHTMAP0,
|
||||
UT_VISLIGHTMAP1,
|
||||
UT_ENVMAP0,
|
||||
UT_ENVMAP1,
|
||||
UT_ENVMAP,
|
||||
UT_GLOWMAP,
|
||||
UT_HEIGHTMAP,
|
||||
UT_LAYERMAP,
|
||||
UT_FRAGDATA0,
|
||||
UT_FRAGDATA1,
|
||||
UT_FRAGDATA2,
|
||||
UT_BSPPLANESMAP,
|
||||
UT_BSPNODESMAP,
|
||||
UT_BSPLIGHTSMAP,
|
||||
UT_BSPMODELSMAP,
|
||||
UT_FITNORMALMAP,
|
||||
UT_MODELMATRIX,
|
||||
UT_REFLECTMATRIX,
|
||||
UT_BONESARRAY,
|
||||
UT_BONEQUATERNION,
|
||||
UT_BONEPOSITION,
|
||||
UT_SCREENSIZEINV,
|
||||
UT_ZFAR,
|
||||
UT_LIGHTSTYLEVALUES,
|
||||
UT_LIGHTSTYLES,
|
||||
UT_REALTIME,
|
||||
UT_DETAILSCALE,
|
||||
UT_FOGPARAMS,
|
||||
UT_SHADOWPARMS,
|
||||
UT_TEXOFFSET,
|
||||
UT_VIEWORIGIN,
|
||||
UT_VIEWRIGHT,
|
||||
UT_RENDERCOLOR,
|
||||
UT_RENDERALPHA,
|
||||
UT_SMOOTHNESS,
|
||||
UT_SHADOWMATRIX,
|
||||
UT_SHADOWSPLITDIST,
|
||||
UT_TEXELSIZE,
|
||||
UT_GAMMATABLE,
|
||||
UT_LIGHTDIR,
|
||||
UT_LIGHTDIFFUSE,
|
||||
UT_LIGHTSHADE,
|
||||
UT_LIGHTORIGIN,
|
||||
UT_LIGHTVIEWPROJMATRIX,
|
||||
UT_DIFFUSEFACTOR,
|
||||
UT_AMBIENTFACTOR,
|
||||
UT_AMBIENTCUBE,
|
||||
UT_SUNREFRACT,
|
||||
UT_LERPFACTOR,
|
||||
UT_REFRACTSCALE,
|
||||
UT_REFLECTSCALE,
|
||||
UT_ABERRATIONSCALE,
|
||||
UT_BOXMINS,
|
||||
UT_BOXMAXS,
|
||||
UT_CUBEORIGIN,
|
||||
UT_CUBEMIPCOUNT,
|
||||
UT_LIGHTNUMS0,
|
||||
UT_LIGHTNUMS1,
|
||||
UT_GRASSPARAMS,
|
||||
UT_RELIEFPARAMS,
|
||||
UT_BLURFACTOR,
|
||||
UT_SCREENWIDTH,
|
||||
UT_SCREENHEIGHT,
|
||||
UT_FOCALDEPTH,
|
||||
UT_FOCALLENGTH,
|
||||
UT_DOFDEBUG,
|
||||
UT_FSTOP,
|
||||
UT_GRAYSCALE,
|
||||
UT_LIGHTGAMMA,
|
||||
UT_LIGHTSCALE,
|
||||
UT_LIGHTTHRESHOLD,
|
||||
UT_NUMVISIBLEMODELS,
|
||||
UT_UNDEFINED,
|
||||
} uniformType_t;
|
||||
|
||||
union unicache_t
|
||||
{
|
||||
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, 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( 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, 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; }
|
||||
|
||||
float fValue[4];
|
||||
int iValue[4];
|
||||
};
|
||||
|
||||
class uniform_t
|
||||
{
|
||||
public:
|
||||
char name[MAX_QPATH];
|
||||
uniformType_t type;
|
||||
int size;
|
||||
uint format;
|
||||
int location;
|
||||
int unit; // texture unit
|
||||
int flags; // hints
|
||||
unicache_t cache;
|
||||
|
||||
// helpers
|
||||
void SetValue( float v0 )
|
||||
{
|
||||
unicache_t pack( v0 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( float v0, float v1 )
|
||||
{
|
||||
unicache_t pack( v0, v1 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( float v0, float v1, float v2 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( float v0, float v1, float v2, float v3 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2, v3 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0 )
|
||||
{
|
||||
unicache_t pack( v0 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0, int v1 )
|
||||
{
|
||||
unicache_t pack( v0, v1 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0, int v1, int v2 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
void SetValue( int v0, int v1, int v2, GLint v3 )
|
||||
{
|
||||
unicache_t pack( v0, v1, v2, v3 );
|
||||
SetValue( &pack );
|
||||
}
|
||||
|
||||
// passed any data here
|
||||
void SetValue( const void *pdata, int count = -1 );
|
||||
int GetSizeInBytes( void );
|
||||
};
|
||||
|
||||
typedef struct glsl_prog_s
|
||||
{
|
||||
char name[64];
|
||||
char options[MAX_OPTIONS_LENGTH]; // UberShader preprocess agrs
|
||||
GLhandleARB handle;
|
||||
unsigned short status;
|
||||
struct glsl_prog_s *nextHash;
|
||||
unsigned short attribs;
|
||||
uniform_t *uniforms;
|
||||
int numUniforms;
|
||||
} glsl_program_t;
|
||||
|
||||
extern glsl_program_t glsl_programs[MAX_GLSL_PROGRAMS];
|
||||
extern int num_glsl_programs;
|
||||
|
||||
#endif//GL_SHADER_H
|
|
@ -1,138 +1,138 @@
|
|||
/*
|
||||
gl_shadowmap.cpp - render shadowmaps for directional lights
|
||||
Copyright (C) 2018 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "gl_local.h"
|
||||
#include <mathlib.h>
|
||||
#include <stringlib.h>
|
||||
#include "gl_studio.h"
|
||||
#include "gl_sprite.h"
|
||||
#include "gl_world.h"
|
||||
#include "gl_grass.h"
|
||||
#include "pm_defs.h"
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
SHADOWMAP ALLOCATION
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
static void SM_InitBlock( void )
|
||||
{
|
||||
gl_shadowmap_t *sms = &tr.shadowmap;
|
||||
memset( sms->allocated, 0, sizeof( sms->allocated ));
|
||||
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 )
|
||||
{
|
||||
gl_shadowmap_t *sms = &tr.shadowmap;
|
||||
unsigned short i, j, best, best2;
|
||||
|
||||
best = SHADOW_SIZE;
|
||||
|
||||
for( i = 0; i < SHADOW_SIZE - w; i++ )
|
||||
{
|
||||
best2 = 0;
|
||||
|
||||
for( j = 0; j < w; j++ )
|
||||
{
|
||||
if( sms->allocated[i+j] >= best )
|
||||
break;
|
||||
if( sms->allocated[i+j] > best2 )
|
||||
best2 = sms->allocated[i+j];
|
||||
}
|
||||
|
||||
if( j == w )
|
||||
{
|
||||
// this is a valid spot
|
||||
*x = i;
|
||||
*y = best = best2;
|
||||
}
|
||||
}
|
||||
|
||||
// atlas is full
|
||||
if( best + h > SHADOW_SIZE )
|
||||
return false;
|
||||
|
||||
for( i = 0; i < w; i++ )
|
||||
sms->allocated[*x + i] = best + h;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_RenderShadowScene
|
||||
|
||||
fast version of R_RenderScene: no colors, no texcords etc
|
||||
================
|
||||
*/
|
||||
void R_RenderShadow( mworldlight_t *wl )
|
||||
{
|
||||
if( !wl->shadow_w || !wl->shadow_h )
|
||||
{
|
||||
wl->shadow_w = 256;
|
||||
wl->shadow_h = 256;
|
||||
SM_AllocBlock( wl->shadow_w, wl->shadow_h, &wl->shadow_x, &wl->shadow_y );
|
||||
}
|
||||
}
|
||||
|
||||
void R_RenderDeferredShadows( void )
|
||||
{
|
||||
unsigned int oldFBO;
|
||||
mworldlight_t *wl;
|
||||
int i;
|
||||
|
||||
if( R_FullBright() || !CVAR_TO_BOOL( r_shadows ) || tr.fGamePaused )
|
||||
return;
|
||||
|
||||
if( FBitSet( RI->params, ( RP_NOSHADOWS|RP_ENVVIEW|RP_SKYVIEW )))
|
||||
return;
|
||||
|
||||
// check for static lights
|
||||
if( !HasStaticLights( )) return;
|
||||
|
||||
R_PushRefState(); // make refinst backup
|
||||
oldFBO = glState.frameBuffer;
|
||||
|
||||
for( i = 0, wl = world->worldlights; i < world->numworldlights; i++, wl++ )
|
||||
{
|
||||
if( wl->emittype == emit_ignored )
|
||||
continue;
|
||||
|
||||
// single visible check
|
||||
if( !CHECKVISBIT( RI->view.vislight, i ))
|
||||
continue;
|
||||
|
||||
switch( wl->emittype )
|
||||
{
|
||||
case emit_surface:
|
||||
R_RenderShadow( wl );
|
||||
break;
|
||||
}
|
||||
|
||||
R_ResetRefState(); // restore ref instance
|
||||
}
|
||||
|
||||
R_PopRefState(); // restore ref instance
|
||||
|
||||
// restore FBO state
|
||||
GL_BindFBO( oldFBO );
|
||||
GL_BindShader( NULL );
|
||||
/*
|
||||
gl_shadowmap.cpp - render shadowmaps for directional lights
|
||||
Copyright (C) 2018 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "gl_local.h"
|
||||
#include <mathlib.h>
|
||||
#include <stringlib.h>
|
||||
#include "gl_studio.h"
|
||||
#include "gl_sprite.h"
|
||||
#include "gl_world.h"
|
||||
#include "gl_grass.h"
|
||||
#include "pm_defs.h"
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
SHADOWMAP ALLOCATION
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
static void SM_InitBlock( void )
|
||||
{
|
||||
gl_shadowmap_t *sms = &tr.shadowmap;
|
||||
memset( sms->allocated, 0, sizeof( sms->allocated ));
|
||||
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 )
|
||||
{
|
||||
gl_shadowmap_t *sms = &tr.shadowmap;
|
||||
unsigned short i, j, best, best2;
|
||||
|
||||
best = SHADOW_SIZE;
|
||||
|
||||
for( i = 0; i < SHADOW_SIZE - w; i++ )
|
||||
{
|
||||
best2 = 0;
|
||||
|
||||
for( j = 0; j < w; j++ )
|
||||
{
|
||||
if( sms->allocated[i+j] >= best )
|
||||
break;
|
||||
if( sms->allocated[i+j] > best2 )
|
||||
best2 = sms->allocated[i+j];
|
||||
}
|
||||
|
||||
if( j == w )
|
||||
{
|
||||
// this is a valid spot
|
||||
*x = i;
|
||||
*y = best = best2;
|
||||
}
|
||||
}
|
||||
|
||||
// atlas is full
|
||||
if( best + h > SHADOW_SIZE )
|
||||
return false;
|
||||
|
||||
for( i = 0; i < w; i++ )
|
||||
sms->allocated[*x + i] = best + h;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_RenderShadowScene
|
||||
|
||||
fast version of R_RenderScene: no colors, no texcords etc
|
||||
================
|
||||
*/
|
||||
void R_RenderShadow( mworldlight_t *wl )
|
||||
{
|
||||
if( !wl->shadow_w || !wl->shadow_h )
|
||||
{
|
||||
wl->shadow_w = 256;
|
||||
wl->shadow_h = 256;
|
||||
SM_AllocBlock( wl->shadow_w, wl->shadow_h, &wl->shadow_x, &wl->shadow_y );
|
||||
}
|
||||
}
|
||||
|
||||
void R_RenderDeferredShadows( void )
|
||||
{
|
||||
unsigned int oldFBO;
|
||||
mworldlight_t *wl;
|
||||
int i;
|
||||
|
||||
if( R_FullBright() || !CVAR_TO_BOOL( r_shadows ) || tr.fGamePaused )
|
||||
return;
|
||||
|
||||
if( FBitSet( RI->params, ( RP_NOSHADOWS|RP_ENVVIEW|RP_SKYVIEW )))
|
||||
return;
|
||||
|
||||
// check for static lights
|
||||
if( !HasStaticLights( )) return;
|
||||
|
||||
R_PushRefState(); // make refinst backup
|
||||
oldFBO = glState.frameBuffer;
|
||||
|
||||
for( i = 0, wl = world->worldlights; i < world->numworldlights; i++, wl++ )
|
||||
{
|
||||
if( wl->emittype == emit_ignored )
|
||||
continue;
|
||||
|
||||
// single visible check
|
||||
if( !CHECKVISBIT( RI->view.vislight, i ))
|
||||
continue;
|
||||
|
||||
switch( wl->emittype )
|
||||
{
|
||||
case emit_surface:
|
||||
R_RenderShadow( wl );
|
||||
break;
|
||||
}
|
||||
|
||||
R_ResetRefState(); // restore ref instance
|
||||
}
|
||||
|
||||
R_PopRefState(); // restore ref instance
|
||||
|
||||
// restore FBO state
|
||||
GL_BindFBO( oldFBO );
|
||||
GL_BindShader( NULL );
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,373 +1,373 @@
|
|||
//
|
||||
// written by BUzer for HL: Paranoia modification
|
||||
//
|
||||
// 2006
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_shader.h"
|
||||
|
||||
#define MAX_CLIP_VERTS 128 // skybox clip vertices
|
||||
|
||||
static const int r_skyTexOrder[6] = { 0, 2, 1, 3, 4, 5 };
|
||||
|
||||
static const Vector skyclip[6] =
|
||||
{
|
||||
Vector( 1, 1, 0 ),
|
||||
Vector( 1, -1, 0 ),
|
||||
Vector( 0, -1, 1 ),
|
||||
Vector( 0, 1, 1 ),
|
||||
Vector( 1, 0, 1 ),
|
||||
Vector( -1, 0, 1 )
|
||||
};
|
||||
|
||||
// 1 = s, 2 = t, 3 = 2048
|
||||
static const int st_to_vec[6][3] =
|
||||
{
|
||||
{ 3, -1, 2 },
|
||||
{ -3, 1, 2 },
|
||||
{ 1, 3, 2 },
|
||||
{ -1, -3, 2 },
|
||||
{ -2, -1, 3 }, // 0 degrees yaw, look straight up
|
||||
{ 2, -1, -3 } // look straight down
|
||||
};
|
||||
|
||||
// s = [0]/[2], t = [1]/[2]
|
||||
static const int vec_to_st[6][3] =
|
||||
{
|
||||
{ -2, 3, 1 },
|
||||
{ 2, 3, -1 },
|
||||
{ 1, 3, 2 },
|
||||
{ -1, 3, -2 },
|
||||
{ -2, -1, 3 },
|
||||
{ -2, 1, -3 }
|
||||
};
|
||||
|
||||
static void DrawSkyPolygon( int nump, Vector vecs[] )
|
||||
{
|
||||
int i, j, axis;
|
||||
float s, t, dv;
|
||||
Vector v, av;
|
||||
|
||||
// decide which face it maps to
|
||||
v = g_vecZero;
|
||||
|
||||
for( i = 0; i < nump; i++ )
|
||||
v += vecs[i];
|
||||
|
||||
av[0] = fabs( v[0] );
|
||||
av[1] = fabs( v[1] );
|
||||
av[2] = fabs( v[2] );
|
||||
|
||||
if( av[0] > av[1] && av[0] > av[2] )
|
||||
axis = (v[0] < 0) ? 1 : 0;
|
||||
else if( av[1] > av[2] && av[1] > av[0] )
|
||||
axis = (v[1] < 0) ? 3 : 2;
|
||||
else axis = (v[2] < 0) ? 5 : 4;
|
||||
|
||||
// project new texture coords
|
||||
for( i = 0; i < nump; i++ )
|
||||
{
|
||||
j = vec_to_st[axis][2];
|
||||
dv = (j > 0) ? (vecs[i])[j-1] : -(vecs[i])[-j-1];
|
||||
|
||||
j = vec_to_st[axis][0];
|
||||
s = (j < 0) ? -vecs[i][-j-1] / dv : (vecs[i])[j-1] / dv;
|
||||
|
||||
j = vec_to_st[axis][1];
|
||||
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( 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( t > RI->view.skyMaxs[1][axis] ) RI->view.skyMaxs[1][axis] = t;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
ClipSkyPolygon
|
||||
==============
|
||||
*/
|
||||
static void ClipSkyPolygon( int nump, Vector vecs[], int stage )
|
||||
{
|
||||
bool front, back;
|
||||
float dists[MAX_CLIP_VERTS + 1];
|
||||
int sides[MAX_CLIP_VERTS + 1];
|
||||
Vector newv[2][MAX_CLIP_VERTS + 1];
|
||||
int newc[2];
|
||||
float d, e;
|
||||
int i;
|
||||
|
||||
if( nump > MAX_CLIP_VERTS )
|
||||
HOST_ERROR( "ClipSkyPolygon: MAX_CLIP_VERTS\n" );
|
||||
loc1:
|
||||
if( stage == 6 )
|
||||
{
|
||||
// fully clipped, so draw it
|
||||
DrawSkyPolygon( nump, vecs );
|
||||
return;
|
||||
}
|
||||
|
||||
front = back = false;
|
||||
const Vector &norm = skyclip[stage];
|
||||
|
||||
for( i = 0; i < nump; i++ )
|
||||
{
|
||||
d = DotProduct( vecs[i], norm );
|
||||
if( d > ON_EPSILON )
|
||||
{
|
||||
front = true;
|
||||
sides[i] = SIDE_FRONT;
|
||||
}
|
||||
else if( d < -ON_EPSILON )
|
||||
{
|
||||
back = true;
|
||||
sides[i] = SIDE_BACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
sides[i] = SIDE_ON;
|
||||
}
|
||||
dists[i] = d;
|
||||
}
|
||||
|
||||
if( !front || !back )
|
||||
{
|
||||
// not clipped
|
||||
stage++;
|
||||
goto loc1;
|
||||
}
|
||||
|
||||
// clip it
|
||||
sides[i] = sides[0];
|
||||
dists[i] = dists[0];
|
||||
vecs[i] = vecs[0];
|
||||
newc[0] = newc[1] = 0;
|
||||
|
||||
for( i = 0; i < nump; i++ )
|
||||
{
|
||||
switch( sides[i] )
|
||||
{
|
||||
case SIDE_FRONT:
|
||||
newv[0][newc[0]] = vecs[i];
|
||||
newc[0]++;
|
||||
break;
|
||||
case SIDE_BACK:
|
||||
newv[1][newc[1]] = vecs[i];
|
||||
newc[1]++;
|
||||
break;
|
||||
case SIDE_ON:
|
||||
newv[0][newc[0]] = vecs[i];
|
||||
newc[0]++;
|
||||
newv[1][newc[1]] = vecs[i];
|
||||
newc[1]++;
|
||||
break;
|
||||
}
|
||||
|
||||
if( sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i] )
|
||||
continue;
|
||||
|
||||
d = dists[i] / ( dists[i] - dists[i+1] );
|
||||
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
e = (vecs[i])[j] + d * ( (vecs[i+1])[j] - (vecs[i])[j] );
|
||||
newv[0][newc[0]][j] = e;
|
||||
newv[1][newc[1]][j] = e;
|
||||
}
|
||||
newc[0]++;
|
||||
newc[1]++;
|
||||
}
|
||||
|
||||
// continue
|
||||
ClipSkyPolygon( newc[0], newv[0], stage + 1 );
|
||||
ClipSkyPolygon( newc[1], newv[1], stage + 1 );
|
||||
}
|
||||
|
||||
static void MakeSkyVec( float s, float t, int axis )
|
||||
{
|
||||
int j, k, farclip;
|
||||
Vector v, b;
|
||||
|
||||
farclip = RI->view.farClip;
|
||||
|
||||
b[0] = s * (farclip >> 1);
|
||||
b[1] = t * (farclip >> 1);
|
||||
b[2] = (farclip >> 1);
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
k = st_to_vec[axis][j];
|
||||
v[j] = (k < 0) ? -b[-k-1] : b[k-1];
|
||||
v[j] += GetVieworg()[j];
|
||||
}
|
||||
|
||||
// avoid bilerp seam
|
||||
s = (s + 1.0f) * 0.5f;
|
||||
t = (t + 1.0f) * 0.5f;
|
||||
|
||||
if( s < ( 1.0f / 512.0f ))
|
||||
s = (1.0f / 512.0f);
|
||||
else if( s > ( 511.0f / 512.0f ))
|
||||
s = (511.0f / 512.0f);
|
||||
if( t < ( 1.0f / 512.0f ))
|
||||
t = (1.0f / 512.0f);
|
||||
else if( t > ( 511.0f / 512.0f ))
|
||||
t = (511.0f / 512.0f);
|
||||
|
||||
t = 1.0f - t;
|
||||
|
||||
pglTexCoord2f( s, t );
|
||||
pglVertex3fv( v );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_AddSkyBoxSurface
|
||||
=================
|
||||
*/
|
||||
void R_AddSkyBoxSurface( msurface_t *fa )
|
||||
{
|
||||
Vector verts[MAX_CLIP_VERTS];
|
||||
|
||||
// calculate vertex values for sky box
|
||||
for( glpoly_t *p = fa->polys; p; p = p->next )
|
||||
{
|
||||
if( p->numverts >= MAX_CLIP_VERTS )
|
||||
HOST_ERROR( "R_AddSkyBoxSurface: numverts >= MAX_CLIP_VERTS\n" );
|
||||
|
||||
for( int i = 0; i < p->numverts; i++ )
|
||||
{
|
||||
verts[i][0] = p->verts[i][0] - GetVieworg().x;
|
||||
verts[i][1] = p->verts[i][1] - GetVieworg().y;
|
||||
verts[i][2] = p->verts[i][2] - GetVieworg().z;
|
||||
}
|
||||
|
||||
ClipSkyPolygon( p->numverts, verts, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
static void GL_DrawSkySide( int skyside )
|
||||
{
|
||||
pglBegin( GL_QUADS );
|
||||
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.skyMaxs[0][skyside], RI->view.skyMaxs[1][skyside], skyside );
|
||||
MakeSkyVec( RI->view.skyMaxs[0][skyside], RI->view.skyMins[1][skyside], skyside );
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
static void GL_DrawSkySide( word hProgram, int skyside )
|
||||
{
|
||||
if( hProgram <= 0 )
|
||||
{
|
||||
GL_BindShader( NULL );
|
||||
GL_BindTexture( GL_TEXTURE0, tr.skyboxTextures[r_skyTexOrder[skyside]] );
|
||||
GL_DrawSkySide( skyside );
|
||||
return; // old method
|
||||
}
|
||||
|
||||
if( RI->currentshader != &glsl_programs[hProgram] )
|
||||
{
|
||||
// force to bind new shader
|
||||
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_vec = tr.sky_normal.Normalize();
|
||||
glsl_program_t *shader = RI->currentshader;
|
||||
|
||||
ColorNormalize( sky_color, sky_color );
|
||||
|
||||
// setup specified uniforms (and texture bindings)
|
||||
for( int i = 0; i < shader->numUniforms; i++ )
|
||||
{
|
||||
uniform_t *u = &shader->uniforms[i];
|
||||
|
||||
switch( u->type )
|
||||
{
|
||||
case UT_COLORMAP:
|
||||
u->SetValue( tr.skyboxTextures[r_skyTexOrder[skyside]] );
|
||||
break;
|
||||
case UT_LIGHTDIR:
|
||||
u->SetValue( sky_vec.x, sky_vec.y, sky_vec.z );
|
||||
break;
|
||||
case UT_LIGHTDIFFUSE:
|
||||
u->SetValue( sky_color.x, sky_color.y, sky_color.z );
|
||||
break;
|
||||
case UT_VIEWORIGIN:
|
||||
u->SetValue( GetVieworg().x, GetVieworg().y, GetVieworg().z );
|
||||
break;
|
||||
case UT_FOGPARAMS:
|
||||
u->SetValue( tr.fogColor[0], tr.fogColor[1], tr.fogColor[2], tr.fogDensity * 0.5f );
|
||||
break;
|
||||
case UT_ZFAR:
|
||||
u->SetValue( RI->view.farClip );
|
||||
break;
|
||||
default:
|
||||
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GL_DrawSkySide( skyside );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
R_DrawSkybox
|
||||
==============
|
||||
*/
|
||||
void R_DrawSkyBox( void )
|
||||
{
|
||||
bool drawSun = true;
|
||||
float fogDenstity = tr.fogDensity;
|
||||
word hSkyShader = 0;
|
||||
int i;
|
||||
|
||||
if( !FBitSet( RI->view.flags, RF_SKYVISIBLE ))
|
||||
return;
|
||||
|
||||
GL_DepthRange( 0.9f, 1.0f );
|
||||
GL_DepthMask( GL_FALSE );
|
||||
GL_Blend( GL_FALSE );
|
||||
GL_AlphaTest( GL_FALSE );
|
||||
|
||||
// clipplane cut the sky if drawing through mirror. Disable it
|
||||
GL_ClipPlane( false );
|
||||
|
||||
int type = tr.sun_light_enabled ? 1 : 0;
|
||||
|
||||
if( FBitSet( RI->params, RP_SKYVIEW ) || ( FBitSet( RI->params, RP_WATERPASS ) && CVAR_TO_BOOL( cv_specular )))
|
||||
drawSun = false;
|
||||
|
||||
// disable sky fogging while underwater
|
||||
if( tr.waterlevel >= 3 || FBitSet( RI->params, RP_SKYVIEW ))
|
||||
fogDenstity = 0.0f;
|
||||
|
||||
// make sure what light_environment is present
|
||||
if( tr.sky_normal != g_vecZero && drawSun )
|
||||
{
|
||||
if( FBitSet( RI->params, RP_DEFERREDSCENE ))
|
||||
hSkyShader = tr.defSceneSky;
|
||||
else if( FBitSet( RI->params, RP_DEFERREDLIGHT ))
|
||||
hSkyShader = tr.defLightSky;
|
||||
else hSkyShader = tr.skyboxEnv[type];
|
||||
}
|
||||
|
||||
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] )
|
||||
continue;
|
||||
|
||||
GL_DrawSkySide( hSkyShader, i );
|
||||
}
|
||||
|
||||
GL_ClipPlane( true );
|
||||
GL_DepthMask( GL_TRUE );
|
||||
|
||||
// back to normal depth range
|
||||
GL_DepthRange( gldepthmin, gldepthmax );
|
||||
//
|
||||
// written by BUzer for HL: Paranoia modification
|
||||
//
|
||||
// 2006
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_shader.h"
|
||||
|
||||
#define MAX_CLIP_VERTS 128 // skybox clip vertices
|
||||
|
||||
static const int r_skyTexOrder[6] = { 0, 2, 1, 3, 4, 5 };
|
||||
|
||||
static const Vector skyclip[6] =
|
||||
{
|
||||
Vector( 1, 1, 0 ),
|
||||
Vector( 1, -1, 0 ),
|
||||
Vector( 0, -1, 1 ),
|
||||
Vector( 0, 1, 1 ),
|
||||
Vector( 1, 0, 1 ),
|
||||
Vector( -1, 0, 1 )
|
||||
};
|
||||
|
||||
// 1 = s, 2 = t, 3 = 2048
|
||||
static const int st_to_vec[6][3] =
|
||||
{
|
||||
{ 3, -1, 2 },
|
||||
{ -3, 1, 2 },
|
||||
{ 1, 3, 2 },
|
||||
{ -1, -3, 2 },
|
||||
{ -2, -1, 3 }, // 0 degrees yaw, look straight up
|
||||
{ 2, -1, -3 } // look straight down
|
||||
};
|
||||
|
||||
// s = [0]/[2], t = [1]/[2]
|
||||
static const int vec_to_st[6][3] =
|
||||
{
|
||||
{ -2, 3, 1 },
|
||||
{ 2, 3, -1 },
|
||||
{ 1, 3, 2 },
|
||||
{ -1, 3, -2 },
|
||||
{ -2, -1, 3 },
|
||||
{ -2, 1, -3 }
|
||||
};
|
||||
|
||||
static void DrawSkyPolygon( int nump, Vector vecs[] )
|
||||
{
|
||||
int i, j, axis;
|
||||
float s, t, dv;
|
||||
Vector v, av;
|
||||
|
||||
// decide which face it maps to
|
||||
v = g_vecZero;
|
||||
|
||||
for( i = 0; i < nump; i++ )
|
||||
v += vecs[i];
|
||||
|
||||
av[0] = fabs( v[0] );
|
||||
av[1] = fabs( v[1] );
|
||||
av[2] = fabs( v[2] );
|
||||
|
||||
if( av[0] > av[1] && av[0] > av[2] )
|
||||
axis = (v[0] < 0) ? 1 : 0;
|
||||
else if( av[1] > av[2] && av[1] > av[0] )
|
||||
axis = (v[1] < 0) ? 3 : 2;
|
||||
else axis = (v[2] < 0) ? 5 : 4;
|
||||
|
||||
// project new texture coords
|
||||
for( i = 0; i < nump; i++ )
|
||||
{
|
||||
j = vec_to_st[axis][2];
|
||||
dv = (j > 0) ? (vecs[i])[j-1] : -(vecs[i])[-j-1];
|
||||
|
||||
j = vec_to_st[axis][0];
|
||||
s = (j < 0) ? -vecs[i][-j-1] / dv : (vecs[i])[j-1] / dv;
|
||||
|
||||
j = vec_to_st[axis][1];
|
||||
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( 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( t > RI->view.skyMaxs[1][axis] ) RI->view.skyMaxs[1][axis] = t;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
ClipSkyPolygon
|
||||
==============
|
||||
*/
|
||||
static void ClipSkyPolygon( int nump, Vector vecs[], int stage )
|
||||
{
|
||||
bool front, back;
|
||||
float dists[MAX_CLIP_VERTS + 1];
|
||||
int sides[MAX_CLIP_VERTS + 1];
|
||||
Vector newv[2][MAX_CLIP_VERTS + 1];
|
||||
int newc[2];
|
||||
float d, e;
|
||||
int i;
|
||||
|
||||
if( nump > MAX_CLIP_VERTS )
|
||||
HOST_ERROR( "ClipSkyPolygon: MAX_CLIP_VERTS\n" );
|
||||
loc1:
|
||||
if( stage == 6 )
|
||||
{
|
||||
// fully clipped, so draw it
|
||||
DrawSkyPolygon( nump, vecs );
|
||||
return;
|
||||
}
|
||||
|
||||
front = back = false;
|
||||
const Vector &norm = skyclip[stage];
|
||||
|
||||
for( i = 0; i < nump; i++ )
|
||||
{
|
||||
d = DotProduct( vecs[i], norm );
|
||||
if( d > ON_EPSILON )
|
||||
{
|
||||
front = true;
|
||||
sides[i] = SIDE_FRONT;
|
||||
}
|
||||
else if( d < -ON_EPSILON )
|
||||
{
|
||||
back = true;
|
||||
sides[i] = SIDE_BACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
sides[i] = SIDE_ON;
|
||||
}
|
||||
dists[i] = d;
|
||||
}
|
||||
|
||||
if( !front || !back )
|
||||
{
|
||||
// not clipped
|
||||
stage++;
|
||||
goto loc1;
|
||||
}
|
||||
|
||||
// clip it
|
||||
sides[i] = sides[0];
|
||||
dists[i] = dists[0];
|
||||
vecs[i] = vecs[0];
|
||||
newc[0] = newc[1] = 0;
|
||||
|
||||
for( i = 0; i < nump; i++ )
|
||||
{
|
||||
switch( sides[i] )
|
||||
{
|
||||
case SIDE_FRONT:
|
||||
newv[0][newc[0]] = vecs[i];
|
||||
newc[0]++;
|
||||
break;
|
||||
case SIDE_BACK:
|
||||
newv[1][newc[1]] = vecs[i];
|
||||
newc[1]++;
|
||||
break;
|
||||
case SIDE_ON:
|
||||
newv[0][newc[0]] = vecs[i];
|
||||
newc[0]++;
|
||||
newv[1][newc[1]] = vecs[i];
|
||||
newc[1]++;
|
||||
break;
|
||||
}
|
||||
|
||||
if( sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i] )
|
||||
continue;
|
||||
|
||||
d = dists[i] / ( dists[i] - dists[i+1] );
|
||||
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
e = (vecs[i])[j] + d * ( (vecs[i+1])[j] - (vecs[i])[j] );
|
||||
newv[0][newc[0]][j] = e;
|
||||
newv[1][newc[1]][j] = e;
|
||||
}
|
||||
newc[0]++;
|
||||
newc[1]++;
|
||||
}
|
||||
|
||||
// continue
|
||||
ClipSkyPolygon( newc[0], newv[0], stage + 1 );
|
||||
ClipSkyPolygon( newc[1], newv[1], stage + 1 );
|
||||
}
|
||||
|
||||
static void MakeSkyVec( float s, float t, int axis )
|
||||
{
|
||||
int j, k, farclip;
|
||||
Vector v, b;
|
||||
|
||||
farclip = RI->view.farClip;
|
||||
|
||||
b[0] = s * (farclip >> 1);
|
||||
b[1] = t * (farclip >> 1);
|
||||
b[2] = (farclip >> 1);
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
k = st_to_vec[axis][j];
|
||||
v[j] = (k < 0) ? -b[-k-1] : b[k-1];
|
||||
v[j] += GetVieworg()[j];
|
||||
}
|
||||
|
||||
// avoid bilerp seam
|
||||
s = (s + 1.0f) * 0.5f;
|
||||
t = (t + 1.0f) * 0.5f;
|
||||
|
||||
if( s < ( 1.0f / 512.0f ))
|
||||
s = (1.0f / 512.0f);
|
||||
else if( s > ( 511.0f / 512.0f ))
|
||||
s = (511.0f / 512.0f);
|
||||
if( t < ( 1.0f / 512.0f ))
|
||||
t = (1.0f / 512.0f);
|
||||
else if( t > ( 511.0f / 512.0f ))
|
||||
t = (511.0f / 512.0f);
|
||||
|
||||
t = 1.0f - t;
|
||||
|
||||
pglTexCoord2f( s, t );
|
||||
pglVertex3fv( v );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_AddSkyBoxSurface
|
||||
=================
|
||||
*/
|
||||
void R_AddSkyBoxSurface( msurface_t *fa )
|
||||
{
|
||||
Vector verts[MAX_CLIP_VERTS];
|
||||
|
||||
// calculate vertex values for sky box
|
||||
for( glpoly_t *p = fa->polys; p; p = p->next )
|
||||
{
|
||||
if( p->numverts >= MAX_CLIP_VERTS )
|
||||
HOST_ERROR( "R_AddSkyBoxSurface: numverts >= MAX_CLIP_VERTS\n" );
|
||||
|
||||
for( int i = 0; i < p->numverts; i++ )
|
||||
{
|
||||
verts[i][0] = p->verts[i][0] - GetVieworg().x;
|
||||
verts[i][1] = p->verts[i][1] - GetVieworg().y;
|
||||
verts[i][2] = p->verts[i][2] - GetVieworg().z;
|
||||
}
|
||||
|
||||
ClipSkyPolygon( p->numverts, verts, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
static void GL_DrawSkySide( int skyside )
|
||||
{
|
||||
pglBegin( GL_QUADS );
|
||||
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.skyMaxs[0][skyside], RI->view.skyMaxs[1][skyside], skyside );
|
||||
MakeSkyVec( RI->view.skyMaxs[0][skyside], RI->view.skyMins[1][skyside], skyside );
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
static void GL_DrawSkySide( word hProgram, int skyside )
|
||||
{
|
||||
if( hProgram <= 0 )
|
||||
{
|
||||
GL_BindShader( NULL );
|
||||
GL_BindTexture( GL_TEXTURE0, tr.skyboxTextures[r_skyTexOrder[skyside]] );
|
||||
GL_DrawSkySide( skyside );
|
||||
return; // old method
|
||||
}
|
||||
|
||||
if( RI->currentshader != &glsl_programs[hProgram] )
|
||||
{
|
||||
// force to bind new shader
|
||||
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_vec = tr.sky_normal.Normalize();
|
||||
glsl_program_t *shader = RI->currentshader;
|
||||
|
||||
ColorNormalize( sky_color, sky_color );
|
||||
|
||||
// setup specified uniforms (and texture bindings)
|
||||
for( int i = 0; i < shader->numUniforms; i++ )
|
||||
{
|
||||
uniform_t *u = &shader->uniforms[i];
|
||||
|
||||
switch( u->type )
|
||||
{
|
||||
case UT_COLORMAP:
|
||||
u->SetValue( tr.skyboxTextures[r_skyTexOrder[skyside]] );
|
||||
break;
|
||||
case UT_LIGHTDIR:
|
||||
u->SetValue( sky_vec.x, sky_vec.y, sky_vec.z );
|
||||
break;
|
||||
case UT_LIGHTDIFFUSE:
|
||||
u->SetValue( sky_color.x, sky_color.y, sky_color.z );
|
||||
break;
|
||||
case UT_VIEWORIGIN:
|
||||
u->SetValue( GetVieworg().x, GetVieworg().y, GetVieworg().z );
|
||||
break;
|
||||
case UT_FOGPARAMS:
|
||||
u->SetValue( tr.fogColor[0], tr.fogColor[1], tr.fogColor[2], tr.fogDensity * 0.5f );
|
||||
break;
|
||||
case UT_ZFAR:
|
||||
u->SetValue( RI->view.farClip );
|
||||
break;
|
||||
default:
|
||||
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GL_DrawSkySide( skyside );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
R_DrawSkybox
|
||||
==============
|
||||
*/
|
||||
void R_DrawSkyBox( void )
|
||||
{
|
||||
bool drawSun = true;
|
||||
float fogDenstity = tr.fogDensity;
|
||||
word hSkyShader = 0;
|
||||
int i;
|
||||
|
||||
if( !FBitSet( RI->view.flags, RF_SKYVISIBLE ))
|
||||
return;
|
||||
|
||||
GL_DepthRange( 0.9f, 1.0f );
|
||||
GL_DepthMask( GL_FALSE );
|
||||
GL_Blend( GL_FALSE );
|
||||
GL_AlphaTest( GL_FALSE );
|
||||
|
||||
// clipplane cut the sky if drawing through mirror. Disable it
|
||||
GL_ClipPlane( false );
|
||||
|
||||
int type = tr.sun_light_enabled ? 1 : 0;
|
||||
|
||||
if( FBitSet( RI->params, RP_SKYVIEW ) || ( FBitSet( RI->params, RP_WATERPASS ) && CVAR_TO_BOOL( cv_specular )))
|
||||
drawSun = false;
|
||||
|
||||
// disable sky fogging while underwater
|
||||
if( tr.waterlevel >= 3 || FBitSet( RI->params, RP_SKYVIEW ))
|
||||
fogDenstity = 0.0f;
|
||||
|
||||
// make sure what light_environment is present
|
||||
if( tr.sky_normal != g_vecZero && drawSun )
|
||||
{
|
||||
if( FBitSet( RI->params, RP_DEFERREDSCENE ))
|
||||
hSkyShader = tr.defSceneSky;
|
||||
else if( FBitSet( RI->params, RP_DEFERREDLIGHT ))
|
||||
hSkyShader = tr.defLightSky;
|
||||
else hSkyShader = tr.skyboxEnv[type];
|
||||
}
|
||||
|
||||
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] )
|
||||
continue;
|
||||
|
||||
GL_DrawSkySide( hSkyShader, i );
|
||||
}
|
||||
|
||||
GL_ClipPlane( true );
|
||||
GL_DepthMask( GL_TRUE );
|
||||
|
||||
// back to normal depth range
|
||||
GL_DepthRange( gldepthmin, gldepthmax );
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,112 +1,112 @@
|
|||
/*
|
||||
gl_sprite.h - sprite model rendering
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_SPRITE_H
|
||||
#define GL_SPRITE_H
|
||||
|
||||
#include "sprite.h"
|
||||
|
||||
#define GLOW_NUM_TRACES 5
|
||||
#define GLOW_INTERP_SPEED 2.0f // time to fade glows
|
||||
|
||||
/*
|
||||
====================
|
||||
CSpriteModelRenderer
|
||||
|
||||
====================
|
||||
*/
|
||||
class CSpriteModelRenderer
|
||||
{
|
||||
public:
|
||||
// Construction/Destruction
|
||||
CSpriteModelRenderer( void );
|
||||
virtual ~CSpriteModelRenderer( void );
|
||||
|
||||
// Initialization
|
||||
virtual void Init( void );
|
||||
private:
|
||||
// Get Sprite description for frame
|
||||
virtual mspriteframe_t *GetSpriteFrame( int frame, float yaw );
|
||||
|
||||
virtual void SpriteComputeOrigin( cl_entity_t *e );
|
||||
|
||||
virtual void SpriteComputeBBox( cl_entity_t *e, Vector bbox[8] );
|
||||
|
||||
virtual bool CullSpriteModel( void );
|
||||
|
||||
virtual float GlowSightDistance( void );
|
||||
|
||||
virtual float SpriteGlowBlend( int rendermode, int renderfx, int alpha, float &scale );
|
||||
|
||||
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 int SpriteHasLightmap( int texFormat );
|
||||
|
||||
inline void *Mod_Extradata( model_t *mod )
|
||||
{
|
||||
if( mod && mod->type == mod_sprite )
|
||||
return mod->cache.data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Vector sprite_origin;
|
||||
Vector sprite_absmin, sprite_absmax;
|
||||
|
||||
// Client clock
|
||||
double m_clTime;
|
||||
// Old Client clock
|
||||
double m_clOldTime;
|
||||
// Current render frame #
|
||||
int m_nFrameCount;
|
||||
|
||||
// Cvars that sprite model code needs to reference
|
||||
cvar_t *m_pCvarLerping; // Use lerping for animation?
|
||||
cvar_t *m_pCvarLighting; // lighting mode
|
||||
|
||||
// The entity which we are currently rendering.
|
||||
cl_entity_t *m_pCurrentEntity;
|
||||
|
||||
// The model for the entity being rendered
|
||||
model_t *m_pRenderModel;
|
||||
|
||||
// Current model rendermode
|
||||
int m_iRenderMode;
|
||||
|
||||
// Pointer to header block for sprite model data
|
||||
msprite_t *m_pSpriteHeader;
|
||||
|
||||
// engine stuff (backend)
|
||||
public:
|
||||
void AddSpriteModelToDrawList( cl_entity_t *e, bool update = false );
|
||||
|
||||
// Draw generic spritemodel
|
||||
mspriteframe_t *GetSpriteFrame( const model_t *m_pSpriteModel, int frame );
|
||||
};
|
||||
|
||||
extern CSpriteModelRenderer g_SpriteRenderer;
|
||||
|
||||
inline mspriteframe_t *R_GetSpriteFrame( const model_t *m_pSpriteModel, int frame )
|
||||
{
|
||||
return g_SpriteRenderer.GetSpriteFrame( m_pSpriteModel, frame );
|
||||
}
|
||||
|
||||
inline void R_AddSpriteToDrawList( cl_entity_t *e, bool update = false )
|
||||
{
|
||||
g_SpriteRenderer.AddSpriteModelToDrawList( e, update );
|
||||
}
|
||||
|
||||
/*
|
||||
gl_sprite.h - sprite model rendering
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_SPRITE_H
|
||||
#define GL_SPRITE_H
|
||||
|
||||
#include "sprite.h"
|
||||
|
||||
#define GLOW_NUM_TRACES 5
|
||||
#define GLOW_INTERP_SPEED 2.0f // time to fade glows
|
||||
|
||||
/*
|
||||
====================
|
||||
CSpriteModelRenderer
|
||||
|
||||
====================
|
||||
*/
|
||||
class CSpriteModelRenderer
|
||||
{
|
||||
public:
|
||||
// Construction/Destruction
|
||||
CSpriteModelRenderer( void );
|
||||
virtual ~CSpriteModelRenderer( void );
|
||||
|
||||
// Initialization
|
||||
virtual void Init( void );
|
||||
private:
|
||||
// Get Sprite description for frame
|
||||
virtual mspriteframe_t *GetSpriteFrame( int frame, float yaw );
|
||||
|
||||
virtual void SpriteComputeOrigin( cl_entity_t *e );
|
||||
|
||||
virtual void SpriteComputeBBox( cl_entity_t *e, Vector bbox[8] );
|
||||
|
||||
virtual bool CullSpriteModel( void );
|
||||
|
||||
virtual float GlowSightDistance( void );
|
||||
|
||||
virtual float SpriteGlowBlend( int rendermode, int renderfx, int alpha, float &scale );
|
||||
|
||||
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 int SpriteHasLightmap( int texFormat );
|
||||
|
||||
inline void *Mod_Extradata( model_t *mod )
|
||||
{
|
||||
if( mod && mod->type == mod_sprite )
|
||||
return mod->cache.data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Vector sprite_origin;
|
||||
Vector sprite_absmin, sprite_absmax;
|
||||
|
||||
// Client clock
|
||||
double m_clTime;
|
||||
// Old Client clock
|
||||
double m_clOldTime;
|
||||
// Current render frame #
|
||||
int m_nFrameCount;
|
||||
|
||||
// Cvars that sprite model code needs to reference
|
||||
cvar_t *m_pCvarLerping; // Use lerping for animation?
|
||||
cvar_t *m_pCvarLighting; // lighting mode
|
||||
|
||||
// The entity which we are currently rendering.
|
||||
cl_entity_t *m_pCurrentEntity;
|
||||
|
||||
// The model for the entity being rendered
|
||||
model_t *m_pRenderModel;
|
||||
|
||||
// Current model rendermode
|
||||
int m_iRenderMode;
|
||||
|
||||
// Pointer to header block for sprite model data
|
||||
msprite_t *m_pSpriteHeader;
|
||||
|
||||
// engine stuff (backend)
|
||||
public:
|
||||
void AddSpriteModelToDrawList( cl_entity_t *e, bool update = false );
|
||||
|
||||
// Draw generic spritemodel
|
||||
mspriteframe_t *GetSpriteFrame( const model_t *m_pSpriteModel, int frame );
|
||||
};
|
||||
|
||||
extern CSpriteModelRenderer g_SpriteRenderer;
|
||||
|
||||
inline mspriteframe_t *R_GetSpriteFrame( const model_t *m_pSpriteModel, int frame )
|
||||
{
|
||||
return g_SpriteRenderer.GetSpriteFrame( m_pSpriteModel, frame );
|
||||
}
|
||||
|
||||
inline void R_AddSpriteToDrawList( cl_entity_t *e, bool update = false )
|
||||
{
|
||||
g_SpriteRenderer.AddSpriteModelToDrawList( e, update );
|
||||
}
|
||||
|
||||
#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
|
@ -1,59 +1,59 @@
|
|||
/*
|
||||
gl_studiodecal.h - studio decal rendering
|
||||
Copyright (C) 2018 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_STUDIODECAL_H
|
||||
#define GL_STUDIODECAL_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DECAL_CLIP_MINUSU = 0x1,
|
||||
DECAL_CLIP_MINUSV = 0x2,
|
||||
DECAL_CLIP_PLUSU = 0x4,
|
||||
DECAL_CLIP_PLUSV = 0x8,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector2D m_UV;
|
||||
word m_VertexIndex; // index into the DecalVertex_t list
|
||||
bool m_FrontFacing;
|
||||
bool m_InValidArea;
|
||||
} DecalVertexInfo_t;
|
||||
|
||||
// decal entry
|
||||
typedef struct studiodecal_s
|
||||
{
|
||||
// this part is goes to savelist
|
||||
byte flags;
|
||||
Vector normal;
|
||||
Vector position;
|
||||
word modelpose; // m_pModelInstance->pose_stamps[modelpose]
|
||||
const DecalGroupEntry *texinfo; // pointer to decal material
|
||||
|
||||
// history
|
||||
int depth; // equal for all the decal fragments (used to remove all frgaments)
|
||||
|
||||
// VBO cache
|
||||
vbomesh_t mesh; // decal private mesh
|
||||
|
||||
// shader cache
|
||||
vbomesh_t* modelmesh; // pointer to studio mesh who owned decal
|
||||
shader_t forwardScene;
|
||||
shader_t forwardLightSpot;
|
||||
shader_t forwardLightOmni;
|
||||
shader_t forwardLightProj;
|
||||
} studiodecal_t;
|
||||
|
||||
/*
|
||||
gl_studiodecal.h - studio decal rendering
|
||||
Copyright (C) 2018 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_STUDIODECAL_H
|
||||
#define GL_STUDIODECAL_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DECAL_CLIP_MINUSU = 0x1,
|
||||
DECAL_CLIP_MINUSV = 0x2,
|
||||
DECAL_CLIP_PLUSU = 0x4,
|
||||
DECAL_CLIP_PLUSV = 0x8,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector2D m_UV;
|
||||
word m_VertexIndex; // index into the DecalVertex_t list
|
||||
bool m_FrontFacing;
|
||||
bool m_InValidArea;
|
||||
} DecalVertexInfo_t;
|
||||
|
||||
// decal entry
|
||||
typedef struct studiodecal_s
|
||||
{
|
||||
// this part is goes to savelist
|
||||
byte flags;
|
||||
Vector normal;
|
||||
Vector position;
|
||||
word modelpose; // m_pModelInstance->pose_stamps[modelpose]
|
||||
const DecalGroupEntry *texinfo; // pointer to decal material
|
||||
|
||||
// history
|
||||
int depth; // equal for all the decal fragments (used to remove all frgaments)
|
||||
|
||||
// VBO cache
|
||||
vbomesh_t mesh; // decal private mesh
|
||||
|
||||
// shader cache
|
||||
vbomesh_t* modelmesh; // pointer to studio mesh who owned decal
|
||||
shader_t forwardScene;
|
||||
shader_t forwardLightSpot;
|
||||
shader_t forwardLightOmni;
|
||||
shader_t forwardLightProj;
|
||||
} studiodecal_t;
|
||||
|
||||
#endif//GL_STUDIODECAL_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,352 +1,352 @@
|
|||
/*
|
||||
gl_mirror.cpp - draw reflected surfaces
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_world.h"
|
||||
#include "mathlib.h"
|
||||
#include <stringlib.h>
|
||||
#include "gl_occlusion.h"
|
||||
|
||||
#define MIRROR_PLANE_EPSILON 0.1f
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
|
||||
MIRROR RENDERING
|
||||
|
||||
=============================================================
|
||||
*/
|
||||
/*
|
||||
================
|
||||
R_SetupMirrorView
|
||||
|
||||
Prepare view for mirroring
|
||||
================
|
||||
*/
|
||||
int R_SetupMirrorView( msurface_t *surf, ref_viewpass_t *rvp )
|
||||
{
|
||||
cl_entity_t *ent = surf->info->parent;
|
||||
matrix3x3 matAngles;
|
||||
mplane_t plane;
|
||||
gl_state_t *glm;
|
||||
float d;
|
||||
|
||||
// setup mirror plane
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
SetPlane( &plane, -surf->plane->normal, -surf->plane->dist );
|
||||
else SetPlane( &plane, surf->plane->normal, surf->plane->dist );
|
||||
|
||||
glm = GL_GetCache( ent->hCachedMatrix );
|
||||
|
||||
if( ent->hCachedMatrix != WORLD_MATRIX )
|
||||
glm->transform.TransformPositivePlane( plane, plane );
|
||||
|
||||
// reflect view by mirror plane
|
||||
d = -2.0f * ( DotProduct( GetVieworg(), plane.normal ) - plane.dist );
|
||||
Vector origin = GetVieworg() + d * plane.normal;
|
||||
|
||||
d = -2.0f * DotProduct( GetVForward(), plane.normal );
|
||||
Vector forward = ( GetVForward() + d * plane.normal ).Normalize();
|
||||
|
||||
d = -2.0f * DotProduct( GetVRight(), plane.normal );
|
||||
Vector right = ( GetVRight() + d * plane.normal ).Normalize();
|
||||
|
||||
d = -2.0f * DotProduct( GetVUp(), plane.normal );
|
||||
Vector up = ( GetVUp() + d * plane.normal ).Normalize();
|
||||
|
||||
// compute mirror angles
|
||||
matAngles.SetForward( forward );
|
||||
matAngles.SetRight( right );
|
||||
matAngles.SetUp( up );
|
||||
Vector angles = matAngles.GetAngles();
|
||||
|
||||
plane.dist += ON_EPSILON; // to prevent z-fighting with reflective water
|
||||
|
||||
rvp->flags = RP_MIRRORVIEW|RP_CLIPPLANE|RP_MERGE_PVS;
|
||||
RI->view.frustum.SetPlane( FRUSTUM_NEAR, plane.normal, plane.dist );
|
||||
RI->clipPlane = plane;
|
||||
|
||||
rvp->viewangles[0] = anglemod( angles[0] );
|
||||
rvp->viewangles[1] = anglemod( angles[1] );
|
||||
rvp->viewangles[2] = anglemod( angles[2] );
|
||||
rvp->vieworigin = origin;
|
||||
|
||||
rvp->fov_x = RI->view.fov_x;
|
||||
rvp->fov_y = RI->view.fov_y;
|
||||
|
||||
// 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);
|
||||
else origin = glm->transform.VectorTransform( surf->info->origin ) + (1.0f * plane.normal);
|
||||
material_t *mat = R_TextureAnimation( surf )->material;
|
||||
|
||||
RI->view.pvspoint = origin;
|
||||
rvp->viewport[0] = rvp->viewport[1] = 0;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE ))
|
||||
{
|
||||
rvp->viewport[2] = 192;
|
||||
rvp->viewport[3] = 192;
|
||||
}
|
||||
else
|
||||
{
|
||||
rvp->viewport[2] = RI->view.port[2];
|
||||
rvp->viewport[3] = RI->view.port[3];
|
||||
}
|
||||
|
||||
if( GL_Support( R_ARB_TEXTURE_NPOT_EXT ))
|
||||
{
|
||||
// allow screen size
|
||||
// rvp->viewport[2] = bound( 96, rvp->viewport[2], 1024 );
|
||||
// rvp->viewport[3] = bound( 72, rvp->viewport[3], 768 );
|
||||
}
|
||||
else
|
||||
{
|
||||
rvp->viewport[2] = NearestPOW( rvp->viewport[2], true );
|
||||
rvp->viewport[3] = NearestPOW( rvp->viewport[3], true );
|
||||
// rvp->viewport[2] = bound( 128, rvp->viewport[2], 1024 );
|
||||
// rvp->viewport[3] = bound( 64, rvp->viewport[3], 512 );
|
||||
}
|
||||
|
||||
if( FBitSet( mat->flags, BRUSH_LIQUID ))
|
||||
SetBits( rvp->flags, RP_WATERPASS );
|
||||
else if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE ))
|
||||
SetBits( rvp->flags, RP_NOSHADOWS|RP_WATERPASS|RP_NOGRASS ); // don't draw grass from puddles
|
||||
|
||||
return TF_SCREEN;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_AllocateSubviewTexture
|
||||
|
||||
Allocate the screen texture and make copy
|
||||
================
|
||||
*/
|
||||
int R_AllocateSubviewTexture( int viewport[4], int texFlags )
|
||||
{
|
||||
int i;
|
||||
|
||||
// first, search for available mirror texture
|
||||
for( i = 0; i < tr.num_subview_used; i++ )
|
||||
{
|
||||
if( tr.subviewTextures[i].texframe == tr.realframecount )
|
||||
continue; // already used for this frame
|
||||
|
||||
if( viewport[2] != RENDER_GET_PARM( PARM_TEX_WIDTH, tr.subviewTextures[i].texturenum ))
|
||||
continue; // width mismatched
|
||||
|
||||
if( viewport[3] != RENDER_GET_PARM( PARM_TEX_HEIGHT, tr.subviewTextures[i].texturenum ))
|
||||
continue; // height mismatched
|
||||
|
||||
// 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 ))
|
||||
continue; // mismatch texture flags
|
||||
|
||||
// found a valid spot
|
||||
tr.subviewTextures[i].texframe = tr.realframecount; // now used
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == tr.num_subview_used )
|
||||
{
|
||||
if( i == MAX_SUBVIEW_TEXTURES )
|
||||
{
|
||||
ALERT( at_error, "R_AllocSubviewTexture: texture limit exceeded (per frame)!\n" );
|
||||
return 0; // disable
|
||||
}
|
||||
|
||||
// create new mirror texture
|
||||
tr.subviewTextures[i].texturenum = CREATE_TEXTURE( va( "*subview%i", i ), viewport[2], viewport[3], NULL, texFlags );
|
||||
tr.subviewTextures[i].texframe = tr.realframecount; // now used
|
||||
if( GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
tr.subviewTextures[i].framebuffer = R_AllocFrameBuffer( viewport );
|
||||
tr.num_subview_used++; // allocate new one
|
||||
}
|
||||
|
||||
if( GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
{
|
||||
GL_BindFrameBuffer( tr.subviewTextures[i].framebuffer, tr.subviewTextures[i].texturenum );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_BindTexture( GL_TEXTURE0, tr.subviewTextures[i].texturenum );
|
||||
pglCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, viewport[0], viewport[1], viewport[2], viewport[3], 0 );
|
||||
}
|
||||
|
||||
return (i+1);
|
||||
}
|
||||
|
||||
bool R_CheckMirrorClone( msurface_t *surf, msurface_t *check )
|
||||
{
|
||||
if( !FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
|
||||
return false;
|
||||
|
||||
if( !FBitSet( check->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
|
||||
return false;
|
||||
|
||||
if( !check->info->subtexture[glState.stack_position-1] )
|
||||
return false;
|
||||
|
||||
if( surf->info->parent != check->info->parent )
|
||||
return false;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ) != FBitSet( check->flags, SURF_PLANEBACK ))
|
||||
return false;
|
||||
|
||||
if( surf->plane->normal != check->plane->normal )
|
||||
return false;
|
||||
|
||||
if( Q_sign( surf->plane->dist ) != Q_sign( check->plane->dist ))
|
||||
return false;
|
||||
|
||||
if( fabs( surf->plane->dist - check->plane->dist ) > MIRROR_PLANE_EPSILON )
|
||||
return false;
|
||||
|
||||
// just reuse the handle
|
||||
surf->info->subtexture[glState.stack_position-1] = check->info->subtexture[glState.stack_position-1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool R_CanSkipPass( int end, msurface_t *surf, ref_instance_t *prevRI )
|
||||
{
|
||||
// IMPORTANT: limit the recursion depth
|
||||
if( surf == prevRI->reject_face )
|
||||
return true;
|
||||
|
||||
for( int i = 0; i < end; i++ )
|
||||
{
|
||||
if( R_CheckMirrorClone( surf, prevRI->frame.subview_faces[i] ))
|
||||
return true;
|
||||
}
|
||||
|
||||
// occluded by query
|
||||
if( FBitSet( surf->flags, SURF_OCCLUDED ))
|
||||
{
|
||||
// don't use me
|
||||
surf->info->subtexture[glState.stack_position-1] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_CheckOutside
|
||||
|
||||
check if main view is outside level
|
||||
================
|
||||
*/
|
||||
bool R_CheckOutside( void )
|
||||
{
|
||||
// only main view should be tested
|
||||
if( !RP_NORMALPASS( ))
|
||||
return false;
|
||||
|
||||
mleaf_t *leaf = Mod_PointInLeaf( RI->view.origin, worldmodel->nodes );
|
||||
|
||||
if( RP_OUTSIDE( leaf ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_RenderSubview
|
||||
|
||||
Draw scene from another points
|
||||
e.g. for planar reflection,
|
||||
remote cameras etc
|
||||
================
|
||||
*/
|
||||
void R_RenderSubview( void )
|
||||
{
|
||||
ref_instance_t *prevRI;
|
||||
unsigned int oldFBO;
|
||||
ref_viewpass_t rvp;
|
||||
|
||||
// player is outside world. Don't draw subview for speedup reasons
|
||||
if( R_CheckOutside( ))
|
||||
return;
|
||||
|
||||
if( glState.stack_position > (unsigned int)r_recursion_depth->value )
|
||||
return; // too deep...
|
||||
|
||||
if( FBitSet( RI->params, RP_DRAW_OVERVIEW ))
|
||||
return;
|
||||
|
||||
if( !RI->frame.num_subview_faces )
|
||||
return; // nothing to render
|
||||
|
||||
R_PushRefState(); // make refinst backup
|
||||
prevRI = R_GetPrevInstance();
|
||||
|
||||
// draw the subviews through the list
|
||||
for( int i = 0; i < prevRI->frame.num_subview_faces; i++ )
|
||||
{
|
||||
msurface_t *surf = prevRI->frame.subview_faces[i];
|
||||
cl_entity_t *e = RI->currententity = surf->info->parent;
|
||||
mextrasurf_t *es = surf->info;
|
||||
int texFlags = 0, subview = 0;
|
||||
RI->currentmodel = e->model;
|
||||
|
||||
if( R_CanSkipPass( i, surf, prevRI ))
|
||||
continue;
|
||||
|
||||
ASSERT( RI->currententity != NULL );
|
||||
ASSERT( RI->currentmodel != NULL );
|
||||
|
||||
// NOTE: we can do additionaly culling here by PVS
|
||||
if( !e || e->curstate.messagenum != r_currentMessageNum )
|
||||
continue; // bad camera, ignore
|
||||
|
||||
// setup view apropriate by type
|
||||
if( FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
|
||||
{
|
||||
texFlags = R_SetupMirrorView( surf, &rvp );
|
||||
r_stats.c_subview_passes++;
|
||||
}
|
||||
else continue; // ???
|
||||
|
||||
oldFBO = glState.frameBuffer;
|
||||
|
||||
if( GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
{
|
||||
if(( subview = R_AllocateSubviewTexture( rvp.viewport, texFlags )) == 0 )
|
||||
continue;
|
||||
}
|
||||
|
||||
// reset the subinfo
|
||||
surf->info->subtexture[glState.stack_position-1] = 0;
|
||||
RI->reject_face = surf;
|
||||
R_RenderScene( &rvp, rvp.flags );
|
||||
RI->reject_face = NULL;
|
||||
|
||||
if( !GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
subview = R_AllocateSubviewTexture( rvp.viewport, texFlags );
|
||||
|
||||
ASSERT( subview > 0 && subview < MAX_SUBVIEW_TEXTURES );
|
||||
surf->info->subtexture[glState.stack_position-1] = subview; // now it's valid
|
||||
tr.subviewTextures[subview-1].matrix = RI->view.worldProjectionMatrix;
|
||||
|
||||
GL_BindFBO( oldFBO );
|
||||
R_ResetRefState();
|
||||
}
|
||||
|
||||
R_PopRefState(); // restore ref instance
|
||||
/*
|
||||
gl_mirror.cpp - draw reflected surfaces
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "gl_local.h"
|
||||
#include "gl_world.h"
|
||||
#include "mathlib.h"
|
||||
#include <stringlib.h>
|
||||
#include "gl_occlusion.h"
|
||||
|
||||
#define MIRROR_PLANE_EPSILON 0.1f
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
|
||||
MIRROR RENDERING
|
||||
|
||||
=============================================================
|
||||
*/
|
||||
/*
|
||||
================
|
||||
R_SetupMirrorView
|
||||
|
||||
Prepare view for mirroring
|
||||
================
|
||||
*/
|
||||
int R_SetupMirrorView( msurface_t *surf, ref_viewpass_t *rvp )
|
||||
{
|
||||
cl_entity_t *ent = surf->info->parent;
|
||||
matrix3x3 matAngles;
|
||||
mplane_t plane;
|
||||
gl_state_t *glm;
|
||||
float d;
|
||||
|
||||
// setup mirror plane
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
SetPlane( &plane, -surf->plane->normal, -surf->plane->dist );
|
||||
else SetPlane( &plane, surf->plane->normal, surf->plane->dist );
|
||||
|
||||
glm = GL_GetCache( ent->hCachedMatrix );
|
||||
|
||||
if( ent->hCachedMatrix != WORLD_MATRIX )
|
||||
glm->transform.TransformPositivePlane( plane, plane );
|
||||
|
||||
// reflect view by mirror plane
|
||||
d = -2.0f * ( DotProduct( GetVieworg(), plane.normal ) - plane.dist );
|
||||
Vector origin = GetVieworg() + d * plane.normal;
|
||||
|
||||
d = -2.0f * DotProduct( GetVForward(), plane.normal );
|
||||
Vector forward = ( GetVForward() + d * plane.normal ).Normalize();
|
||||
|
||||
d = -2.0f * DotProduct( GetVRight(), plane.normal );
|
||||
Vector right = ( GetVRight() + d * plane.normal ).Normalize();
|
||||
|
||||
d = -2.0f * DotProduct( GetVUp(), plane.normal );
|
||||
Vector up = ( GetVUp() + d * plane.normal ).Normalize();
|
||||
|
||||
// compute mirror angles
|
||||
matAngles.SetForward( forward );
|
||||
matAngles.SetRight( right );
|
||||
matAngles.SetUp( up );
|
||||
Vector angles = matAngles.GetAngles();
|
||||
|
||||
plane.dist += ON_EPSILON; // to prevent z-fighting with reflective water
|
||||
|
||||
rvp->flags = RP_MIRRORVIEW|RP_CLIPPLANE|RP_MERGE_PVS;
|
||||
RI->view.frustum.SetPlane( FRUSTUM_NEAR, plane.normal, plane.dist );
|
||||
RI->clipPlane = plane;
|
||||
|
||||
rvp->viewangles[0] = anglemod( angles[0] );
|
||||
rvp->viewangles[1] = anglemod( angles[1] );
|
||||
rvp->viewangles[2] = anglemod( angles[2] );
|
||||
rvp->vieworigin = origin;
|
||||
|
||||
rvp->fov_x = RI->view.fov_x;
|
||||
rvp->fov_y = RI->view.fov_y;
|
||||
|
||||
// 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);
|
||||
else origin = glm->transform.VectorTransform( surf->info->origin ) + (1.0f * plane.normal);
|
||||
material_t *mat = R_TextureAnimation( surf )->material;
|
||||
|
||||
RI->view.pvspoint = origin;
|
||||
rvp->viewport[0] = rvp->viewport[1] = 0;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE ))
|
||||
{
|
||||
rvp->viewport[2] = 192;
|
||||
rvp->viewport[3] = 192;
|
||||
}
|
||||
else
|
||||
{
|
||||
rvp->viewport[2] = RI->view.port[2];
|
||||
rvp->viewport[3] = RI->view.port[3];
|
||||
}
|
||||
|
||||
if( GL_Support( R_ARB_TEXTURE_NPOT_EXT ))
|
||||
{
|
||||
// allow screen size
|
||||
// rvp->viewport[2] = bound( 96, rvp->viewport[2], 1024 );
|
||||
// rvp->viewport[3] = bound( 72, rvp->viewport[3], 768 );
|
||||
}
|
||||
else
|
||||
{
|
||||
rvp->viewport[2] = NearestPOW( rvp->viewport[2], true );
|
||||
rvp->viewport[3] = NearestPOW( rvp->viewport[3], true );
|
||||
// rvp->viewport[2] = bound( 128, rvp->viewport[2], 1024 );
|
||||
// rvp->viewport[3] = bound( 64, rvp->viewport[3], 512 );
|
||||
}
|
||||
|
||||
if( FBitSet( mat->flags, BRUSH_LIQUID ))
|
||||
SetBits( rvp->flags, RP_WATERPASS );
|
||||
else if( FBitSet( surf->flags, SURF_REFLECT_PUDDLE ))
|
||||
SetBits( rvp->flags, RP_NOSHADOWS|RP_WATERPASS|RP_NOGRASS ); // don't draw grass from puddles
|
||||
|
||||
return TF_SCREEN;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_AllocateSubviewTexture
|
||||
|
||||
Allocate the screen texture and make copy
|
||||
================
|
||||
*/
|
||||
int R_AllocateSubviewTexture( int viewport[4], int texFlags )
|
||||
{
|
||||
int i;
|
||||
|
||||
// first, search for available mirror texture
|
||||
for( i = 0; i < tr.num_subview_used; i++ )
|
||||
{
|
||||
if( tr.subviewTextures[i].texframe == tr.realframecount )
|
||||
continue; // already used for this frame
|
||||
|
||||
if( viewport[2] != RENDER_GET_PARM( PARM_TEX_WIDTH, tr.subviewTextures[i].texturenum ))
|
||||
continue; // width mismatched
|
||||
|
||||
if( viewport[3] != RENDER_GET_PARM( PARM_TEX_HEIGHT, tr.subviewTextures[i].texturenum ))
|
||||
continue; // height mismatched
|
||||
|
||||
// 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 ))
|
||||
continue; // mismatch texture flags
|
||||
|
||||
// found a valid spot
|
||||
tr.subviewTextures[i].texframe = tr.realframecount; // now used
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == tr.num_subview_used )
|
||||
{
|
||||
if( i == MAX_SUBVIEW_TEXTURES )
|
||||
{
|
||||
ALERT( at_error, "R_AllocSubviewTexture: texture limit exceeded (per frame)!\n" );
|
||||
return 0; // disable
|
||||
}
|
||||
|
||||
// create new mirror texture
|
||||
tr.subviewTextures[i].texturenum = CREATE_TEXTURE( va( "*subview%i", i ), viewport[2], viewport[3], NULL, texFlags );
|
||||
tr.subviewTextures[i].texframe = tr.realframecount; // now used
|
||||
if( GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
tr.subviewTextures[i].framebuffer = R_AllocFrameBuffer( viewport );
|
||||
tr.num_subview_used++; // allocate new one
|
||||
}
|
||||
|
||||
if( GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
{
|
||||
GL_BindFrameBuffer( tr.subviewTextures[i].framebuffer, tr.subviewTextures[i].texturenum );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_BindTexture( GL_TEXTURE0, tr.subviewTextures[i].texturenum );
|
||||
pglCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, viewport[0], viewport[1], viewport[2], viewport[3], 0 );
|
||||
}
|
||||
|
||||
return (i+1);
|
||||
}
|
||||
|
||||
bool R_CheckMirrorClone( msurface_t *surf, msurface_t *check )
|
||||
{
|
||||
if( !FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
|
||||
return false;
|
||||
|
||||
if( !FBitSet( check->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
|
||||
return false;
|
||||
|
||||
if( !check->info->subtexture[glState.stack_position-1] )
|
||||
return false;
|
||||
|
||||
if( surf->info->parent != check->info->parent )
|
||||
return false;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ) != FBitSet( check->flags, SURF_PLANEBACK ))
|
||||
return false;
|
||||
|
||||
if( surf->plane->normal != check->plane->normal )
|
||||
return false;
|
||||
|
||||
if( Q_sign( surf->plane->dist ) != Q_sign( check->plane->dist ))
|
||||
return false;
|
||||
|
||||
if( fabs( surf->plane->dist - check->plane->dist ) > MIRROR_PLANE_EPSILON )
|
||||
return false;
|
||||
|
||||
// just reuse the handle
|
||||
surf->info->subtexture[glState.stack_position-1] = check->info->subtexture[glState.stack_position-1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool R_CanSkipPass( int end, msurface_t *surf, ref_instance_t *prevRI )
|
||||
{
|
||||
// IMPORTANT: limit the recursion depth
|
||||
if( surf == prevRI->reject_face )
|
||||
return true;
|
||||
|
||||
for( int i = 0; i < end; i++ )
|
||||
{
|
||||
if( R_CheckMirrorClone( surf, prevRI->frame.subview_faces[i] ))
|
||||
return true;
|
||||
}
|
||||
|
||||
// occluded by query
|
||||
if( FBitSet( surf->flags, SURF_OCCLUDED ))
|
||||
{
|
||||
// don't use me
|
||||
surf->info->subtexture[glState.stack_position-1] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_CheckOutside
|
||||
|
||||
check if main view is outside level
|
||||
================
|
||||
*/
|
||||
bool R_CheckOutside( void )
|
||||
{
|
||||
// only main view should be tested
|
||||
if( !RP_NORMALPASS( ))
|
||||
return false;
|
||||
|
||||
mleaf_t *leaf = Mod_PointInLeaf( RI->view.origin, worldmodel->nodes );
|
||||
|
||||
if( RP_OUTSIDE( leaf ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_RenderSubview
|
||||
|
||||
Draw scene from another points
|
||||
e.g. for planar reflection,
|
||||
remote cameras etc
|
||||
================
|
||||
*/
|
||||
void R_RenderSubview( void )
|
||||
{
|
||||
ref_instance_t *prevRI;
|
||||
unsigned int oldFBO;
|
||||
ref_viewpass_t rvp;
|
||||
|
||||
// player is outside world. Don't draw subview for speedup reasons
|
||||
if( R_CheckOutside( ))
|
||||
return;
|
||||
|
||||
if( glState.stack_position > (unsigned int)r_recursion_depth->value )
|
||||
return; // too deep...
|
||||
|
||||
if( FBitSet( RI->params, RP_DRAW_OVERVIEW ))
|
||||
return;
|
||||
|
||||
if( !RI->frame.num_subview_faces )
|
||||
return; // nothing to render
|
||||
|
||||
R_PushRefState(); // make refinst backup
|
||||
prevRI = R_GetPrevInstance();
|
||||
|
||||
// draw the subviews through the list
|
||||
for( int i = 0; i < prevRI->frame.num_subview_faces; i++ )
|
||||
{
|
||||
msurface_t *surf = prevRI->frame.subview_faces[i];
|
||||
cl_entity_t *e = RI->currententity = surf->info->parent;
|
||||
mextrasurf_t *es = surf->info;
|
||||
int texFlags = 0, subview = 0;
|
||||
RI->currentmodel = e->model;
|
||||
|
||||
if( R_CanSkipPass( i, surf, prevRI ))
|
||||
continue;
|
||||
|
||||
ASSERT( RI->currententity != NULL );
|
||||
ASSERT( RI->currentmodel != NULL );
|
||||
|
||||
// NOTE: we can do additionaly culling here by PVS
|
||||
if( !e || e->curstate.messagenum != r_currentMessageNum )
|
||||
continue; // bad camera, ignore
|
||||
|
||||
// setup view apropriate by type
|
||||
if( FBitSet( surf->flags, SURF_REFLECT|SURF_REFLECT_PUDDLE ))
|
||||
{
|
||||
texFlags = R_SetupMirrorView( surf, &rvp );
|
||||
r_stats.c_subview_passes++;
|
||||
}
|
||||
else continue; // ???
|
||||
|
||||
oldFBO = glState.frameBuffer;
|
||||
|
||||
if( GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
{
|
||||
if(( subview = R_AllocateSubviewTexture( rvp.viewport, texFlags )) == 0 )
|
||||
continue;
|
||||
}
|
||||
|
||||
// reset the subinfo
|
||||
surf->info->subtexture[glState.stack_position-1] = 0;
|
||||
RI->reject_face = surf;
|
||||
R_RenderScene( &rvp, rvp.flags );
|
||||
RI->reject_face = NULL;
|
||||
|
||||
if( !GL_Support( R_FRAMEBUFFER_OBJECT ))
|
||||
subview = R_AllocateSubviewTexture( rvp.viewport, texFlags );
|
||||
|
||||
ASSERT( subview > 0 && subview < MAX_SUBVIEW_TEXTURES );
|
||||
surf->info->subtexture[glState.stack_position-1] = subview; // now it's valid
|
||||
tr.subviewTextures[subview-1].matrix = RI->view.worldProjectionMatrix;
|
||||
|
||||
GL_BindFBO( oldFBO );
|
||||
R_ResetRefState();
|
||||
}
|
||||
|
||||
R_PopRefState(); // restore ref instance
|
||||
}
|
|
@ -1,183 +1,183 @@
|
|||
/*
|
||||
gl_world.h - local world data for rendering
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_WORLD_H
|
||||
#define GL_WORLD_H
|
||||
|
||||
#include "cubemap.h"
|
||||
#include "vertex_fmt.h"
|
||||
|
||||
// world features
|
||||
#define WORLD_HAS_MOVIES BIT( 0 )
|
||||
|
||||
#define WORLD_HAS_GRASS BIT( 2 )
|
||||
#define WORLD_HAS_DELUXEMAP BIT( 3 )
|
||||
#define WORLD_HAS_SKYBOX BIT( 4 )
|
||||
#define WORLD_WATERALPHA BIT( 5 )
|
||||
|
||||
#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
|
||||
|
||||
// rebuilding cubemap states
|
||||
#define CMREBUILD_INACTIVE 0
|
||||
#define CMREBUILD_CHECKING 1
|
||||
#define CMREBUILD_WAITING 2
|
||||
|
||||
typedef struct bvert_s
|
||||
{
|
||||
Vector vertex; // position
|
||||
Vector tangent; // tangent
|
||||
Vector binormal; // binormal
|
||||
Vector normal; // normal
|
||||
float stcoord0[4]; // ST texture coords
|
||||
float lmcoord0[4]; // LM texture coords for styles 0-1
|
||||
float lmcoord1[4]; // LM texture coords for styles 2-3
|
||||
byte styles[MAXLIGHTMAPS]; // light styles
|
||||
byte lights0[4]; // packed light numbers
|
||||
byte lights1[4]; // packed light numbers
|
||||
} bvert_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dlightcube_t cube;
|
||||
vec3_t origin;
|
||||
mleaf_t *leaf; // ambient linked into this leaf
|
||||
} mlightprobe_t;
|
||||
|
||||
typedef struct mworldlight_s
|
||||
{
|
||||
emittype_t emittype;
|
||||
int style;
|
||||
byte *pvs; // accumulated domain of the light
|
||||
vec3_t origin; // light abs origin
|
||||
vec3_t intensity; // RGB
|
||||
vec3_t normal; // for surfaces and spotlights
|
||||
float stopdot; // 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 radius; // light radius
|
||||
mleaf_t *leaf; // light linked into this leaf
|
||||
byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square
|
||||
msurface_t *surface; // surf pointer for emit_surface
|
||||
int lightnum; // important stuff!
|
||||
int modelnum; // unused
|
||||
unsigned short shadow_x; // offset by X in atlas
|
||||
unsigned short shadow_y; // offset by Y in atlas
|
||||
unsigned short shadow_w; // 0 is uninitialized
|
||||
unsigned short shadow_h; // 0 is uninitialized
|
||||
} mworldlight_t;
|
||||
|
||||
// leaf extradata
|
||||
typedef struct mextraleaf_s
|
||||
{
|
||||
// leaf specific
|
||||
vec3_t mins, maxs; // leaf size that updated with grass bounds
|
||||
|
||||
mlightprobe_t *ambient_light;
|
||||
byte num_lightprobes;
|
||||
|
||||
mworldlight_t *direct_lights;
|
||||
int num_directlights;
|
||||
} mextraleaf_t;
|
||||
|
||||
struct BmodelInstance_t
|
||||
{
|
||||
cl_entity_t *m_pEntity;
|
||||
|
||||
// bounds info
|
||||
Vector bbox[8];
|
||||
Vector absmin;
|
||||
Vector absmax;
|
||||
float radius;
|
||||
byte lights[MAXDYNLIGHTS];
|
||||
|
||||
matrix4x4 m_transform;
|
||||
GLfloat m_gltransform;
|
||||
};
|
||||
|
||||
struct LightShadowZBufferSample_t
|
||||
{
|
||||
float m_flTraceDistance; // how far we traced. 0 = invalid
|
||||
float m_flHitDistance; // where we hit
|
||||
};
|
||||
|
||||
typedef CCubeMap< LightShadowZBufferSample_t, SHADOW_ZBUF_RES> lightzbuffer_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[64]; // to avoid reloading on same
|
||||
|
||||
word features; // world features
|
||||
|
||||
int num_visible_models; // visible models
|
||||
|
||||
mextraleaf_t *leafs; // [worldmodel->numleafs]
|
||||
int totalleafs; // full leaf counting
|
||||
int numleafs; // [submodels[0].visleafs + 1]
|
||||
|
||||
material_t *materials; // [worldmodel->numtextures]
|
||||
|
||||
int numleaflights;
|
||||
mlightprobe_t *leaflights;
|
||||
|
||||
int numworldlights;
|
||||
mworldlight_t *worldlights;
|
||||
|
||||
dvertnorm_t *surfnormals; // is not NULL here a indexed normals
|
||||
dnormal_t *normals;
|
||||
int numnormals;
|
||||
|
||||
mcubemap_t cubemaps[MAX_MAP_CUBEMAPS];
|
||||
mcubemap_t defaultCubemap;
|
||||
int num_cubemaps;
|
||||
|
||||
terrain_t *terrains;
|
||||
unsigned int num_terrains;
|
||||
|
||||
bvert_t *vertexes;
|
||||
int numvertexes;
|
||||
|
||||
dvlightlump_t *vertex_lighting; // used for env_statics
|
||||
dvlightlump_t *surface_lighting; // used for env_statics
|
||||
|
||||
byte *vislightdata;
|
||||
color24 *deluxedata;
|
||||
byte *shadowdata;
|
||||
|
||||
lightzbuffer_t *shadowzbuffers;
|
||||
|
||||
// single buffer for all the models
|
||||
uint vertex_buffer_object;
|
||||
uint vertex_array_object;
|
||||
uint cacheSize;
|
||||
|
||||
unsigned short *sortedfaces; // surfaces sorted through all models
|
||||
unsigned short numsortedfaces;
|
||||
|
||||
// misc info
|
||||
Vector2D orthocenter; // overview stuff
|
||||
Vector2D orthohalf;
|
||||
|
||||
// cubemap builder internal state
|
||||
bool loading_cubemaps;
|
||||
bool build_default_cubemap;
|
||||
int rebuilding_cubemaps;
|
||||
int cubemap_build_number;
|
||||
} gl_world_t;
|
||||
|
||||
extern gl_world_t *world;
|
||||
|
||||
/*
|
||||
gl_world.h - local world data for rendering
|
||||
this code written for Paranoia 2: Savior modification
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GL_WORLD_H
|
||||
#define GL_WORLD_H
|
||||
|
||||
#include "cubemap.h"
|
||||
#include "vertex_fmt.h"
|
||||
|
||||
// world features
|
||||
#define WORLD_HAS_MOVIES BIT( 0 )
|
||||
|
||||
#define WORLD_HAS_GRASS BIT( 2 )
|
||||
#define WORLD_HAS_DELUXEMAP BIT( 3 )
|
||||
#define WORLD_HAS_SKYBOX BIT( 4 )
|
||||
#define WORLD_WATERALPHA BIT( 5 )
|
||||
|
||||
#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
|
||||
|
||||
// rebuilding cubemap states
|
||||
#define CMREBUILD_INACTIVE 0
|
||||
#define CMREBUILD_CHECKING 1
|
||||
#define CMREBUILD_WAITING 2
|
||||
|
||||
typedef struct bvert_s
|
||||
{
|
||||
Vector vertex; // position
|
||||
Vector tangent; // tangent
|
||||
Vector binormal; // binormal
|
||||
Vector normal; // normal
|
||||
float stcoord0[4]; // ST texture coords
|
||||
float lmcoord0[4]; // LM texture coords for styles 0-1
|
||||
float lmcoord1[4]; // LM texture coords for styles 2-3
|
||||
byte styles[MAXLIGHTMAPS]; // light styles
|
||||
byte lights0[4]; // packed light numbers
|
||||
byte lights1[4]; // packed light numbers
|
||||
} bvert_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dlightcube_t cube;
|
||||
vec3_t origin;
|
||||
mleaf_t *leaf; // ambient linked into this leaf
|
||||
} mlightprobe_t;
|
||||
|
||||
typedef struct mworldlight_s
|
||||
{
|
||||
emittype_t emittype;
|
||||
int style;
|
||||
byte *pvs; // accumulated domain of the light
|
||||
vec3_t origin; // light abs origin
|
||||
vec3_t intensity; // RGB
|
||||
vec3_t normal; // for surfaces and spotlights
|
||||
float stopdot; // 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 radius; // light radius
|
||||
mleaf_t *leaf; // light linked into this leaf
|
||||
byte falloff; // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square
|
||||
msurface_t *surface; // surf pointer for emit_surface
|
||||
int lightnum; // important stuff!
|
||||
int modelnum; // unused
|
||||
unsigned short shadow_x; // offset by X in atlas
|
||||
unsigned short shadow_y; // offset by Y in atlas
|
||||
unsigned short shadow_w; // 0 is uninitialized
|
||||
unsigned short shadow_h; // 0 is uninitialized
|
||||
} mworldlight_t;
|
||||
|
||||
// leaf extradata
|
||||
typedef struct mextraleaf_s
|
||||
{
|
||||
// leaf specific
|
||||
vec3_t mins, maxs; // leaf size that updated with grass bounds
|
||||
|
||||
mlightprobe_t *ambient_light;
|
||||
byte num_lightprobes;
|
||||
|
||||
mworldlight_t *direct_lights;
|
||||
int num_directlights;
|
||||
} mextraleaf_t;
|
||||
|
||||
struct BmodelInstance_t
|
||||
{
|
||||
cl_entity_t *m_pEntity;
|
||||
|
||||
// bounds info
|
||||
Vector bbox[8];
|
||||
Vector absmin;
|
||||
Vector absmax;
|
||||
float radius;
|
||||
byte lights[MAXDYNLIGHTS];
|
||||
|
||||
matrix4x4 m_transform;
|
||||
GLfloat m_gltransform;
|
||||
};
|
||||
|
||||
struct LightShadowZBufferSample_t
|
||||
{
|
||||
float m_flTraceDistance; // how far we traced. 0 = invalid
|
||||
float m_flHitDistance; // where we hit
|
||||
};
|
||||
|
||||
typedef CCubeMap< LightShadowZBufferSample_t, SHADOW_ZBUF_RES> lightzbuffer_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[64]; // to avoid reloading on same
|
||||
|
||||
word features; // world features
|
||||
|
||||
int num_visible_models; // visible models
|
||||
|
||||
mextraleaf_t *leafs; // [worldmodel->numleafs]
|
||||
int totalleafs; // full leaf counting
|
||||
int numleafs; // [submodels[0].visleafs + 1]
|
||||
|
||||
material_t *materials; // [worldmodel->numtextures]
|
||||
|
||||
int numleaflights;
|
||||
mlightprobe_t *leaflights;
|
||||
|
||||
int numworldlights;
|
||||
mworldlight_t *worldlights;
|
||||
|
||||
dvertnorm_t *surfnormals; // is not NULL here a indexed normals
|
||||
dnormal_t *normals;
|
||||
int numnormals;
|
||||
|
||||
mcubemap_t cubemaps[MAX_MAP_CUBEMAPS];
|
||||
mcubemap_t defaultCubemap;
|
||||
int num_cubemaps;
|
||||
|
||||
terrain_t *terrains;
|
||||
unsigned int num_terrains;
|
||||
|
||||
bvert_t *vertexes;
|
||||
int numvertexes;
|
||||
|
||||
dvlightlump_t *vertex_lighting; // used for env_statics
|
||||
dvlightlump_t *surface_lighting; // used for env_statics
|
||||
|
||||
byte *vislightdata;
|
||||
color24 *deluxedata;
|
||||
byte *shadowdata;
|
||||
|
||||
lightzbuffer_t *shadowzbuffers;
|
||||
|
||||
// single buffer for all the models
|
||||
uint vertex_buffer_object;
|
||||
uint vertex_array_object;
|
||||
uint cacheSize;
|
||||
|
||||
unsigned short *sortedfaces; // surfaces sorted through all models
|
||||
unsigned short numsortedfaces;
|
||||
|
||||
// misc info
|
||||
Vector2D orthocenter; // overview stuff
|
||||
Vector2D orthohalf;
|
||||
|
||||
// cubemap builder internal state
|
||||
bool loading_cubemaps;
|
||||
bool build_default_cubemap;
|
||||
int rebuilding_cubemaps;
|
||||
int cubemap_build_number;
|
||||
} gl_world_t;
|
||||
|
||||
extern gl_world_t *world;
|
||||
|
||||
#endif//GL_WORLD_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue