Среда, 20.09.2017, 15:55
Приветствую Вас Guest | RSS
Главная страница | Статьи | Регистрация | Вход
Меню сайта

Случайный рисунок

Категории каталога
Туториалы по маппингу (HL2) [68]
Туториалы по маппингу для Half-Life
Туториалы по текстурированию (HL2) [10]
Туторы по текстурированию для Half-Life
Туториалы по моделированию (HL2) [9]
Туторы по моделированию для Half-Life
Туториалы по программированию (HL2) [53]
Туторы по прагроммированию для Half-life
Другие туториалы (HL1 и HL2) [4]
Туторы которые не вошли в другие категории
Half-Life 2 Beta [1]
Статьи о npc и weapon в бете Half-Life 2, а так же мануалы и FAQ.
Туториалы по маппингу (HL1) [14]
Туторы по маппингу для Half-Life 1
Туториалы по текстурированию (HL1) [1]
Туторы по текстурированию для Half-Life 1
Туториалы по моделированию (HL1) [1]
Туторы по моделированию для Half-Life 1
Туториалы по программированию (HL1) [30]
Туторы по программированию для Half-Life 1

Наш опрос
Очистить ли форум от всех сообщений и начать всё с чистого листа?
Всего ответов: 536

Начало » Статьи » Туториалы по программированию (HL1)

Шейдерная вода...
Ну чтож, друзья, для многих это - момент истины! Многие из вас хотели сделать это в своем моде, но многие не знали как. За это время я немного поднабрался опыта в коддинге, и, не без чужой помощи, сделал шейдерную воду с использованием шейдеров CG.
Начнем!

Добавление инклюдов и библиотек
Прежде всего, добавим в Visual Studio 6 нужные нам библиотеки и инклюды. Архив скачаете в конце туториала. Все файлы из папки include в архиве должны быть скопированы в папку Microsoft Visual C++ 6.0/VC98/INCLUDE/ , а из папки lib - Microsoft Visual C++ 6.0/VC98/LIB/ .

Добавление link
Откройте cl_dll.dsp. Выберите вверху Project->Settings, а затем перейдите на вкладку link. В строку Object/library modules в самый конец добавьте opengl32.lib cg.lib cgGL.lib. Нажмите ок.

Начало работы
Все работы проходят только в клиентской части.
Добавьте к проекту файлы cg_shader.cpp, cg_shader.h, gl_bored.cpp, gl_bored.h, gl_pbuffer.cpp, gl_pbuffer.h, textures.cpp и texture.h (так же доступны в архиве внизу).

Откройте input.cpp и приведите его к такому виду:

Code

//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:  
//
// $NoKeywords: $
//=============================================================================

// cl.input.c -- builds an intended movement command to send to the server

//xxxxxx Move bob and pitch drifting code here and other stuff from view if needed

// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
// rights reserved.
#include "hud.h"
#include "cl_util.h"
#include "camera.h"
extern "C"
{
#include "kbutton.h"
}
#include "cvardef.h"
#include "usercmd.h"
#include "const.h"
#include "camera.h"
#include "in_defs.h"
#include "view.h"
#include <string.h>
#include <ctype.h>

#include "vgui_TeamFortressViewport.h"

extern "C"  
{
  struct kbutton_s DLLEXPORT *KB_Find( const char *name );
  void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active );
  void DLLEXPORT HUD_Shutdown( void );
  int DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding );
}

extern int g_iAlive;

extern int g_weaponselect;
extern cl_enginefunc_t gEngfuncs;

// Defined in pm_math.c
extern "C" float anglemod( float a );

void IN_Init (void);
void IN_Move ( float frametime, usercmd_t *cmd);
void IN_Shutdown( void );
void V_Init( void );
void VectorAngles( const float *forward, float *angles );
int CL_ButtonBits( int );

// xxx need client dll function to get and clear impuse
extern cvar_t *in_joystick;

int in_impulse = 0;
int in_cancel = 0;

cvar_t *m_pitch;
cvar_t *m_yaw;
cvar_t *m_forward;
cvar_t *m_side;

cvar_t *lookstrafe;
cvar_t *lookspring;
cvar_t *cl_pitchup;
cvar_t *cl_pitchdown;
cvar_t *cl_upspeed;
cvar_t *cl_forwardspeed;
cvar_t *cl_backspeed;
cvar_t *cl_sidespeed;
cvar_t *cl_movespeedkey;
cvar_t *cl_yawspeed;
cvar_t *cl_pitchspeed;
cvar_t *cl_anglespeedkey;
cvar_t *cl_vsmoothing;
cvar_t *cl_cgwater; //Shader Water CVAR

/*
===============================================================================

KEY BUTTONS

Continuous button event tracking is complicated by the fact that two different
input sources (say, mouse button 1 and the control key) can both press the
same button, but the button should only be released when both of the
pressing key have been released.

When a key event issues a button command (+forward, +attack, etc), it appends
its key number as a parameter to the command so it can be matched up with
the release.

state bit 0 is the current state of the key
state bit 1 is edge triggered on the up to down transition
state bit 2 is edge triggered on the down to up transition

===============================================================================
*/

kbutton_t in_mlook;
kbutton_t in_klook;
kbutton_t in_jlook;
kbutton_t in_left;
kbutton_t in_right;
kbutton_t in_forward;
kbutton_t in_back;
kbutton_t in_lookup;
kbutton_t in_lookdown;
kbutton_t in_moveleft;
kbutton_t in_moveright;
kbutton_t in_strafe;
kbutton_t in_speed;
kbutton_t in_use;
kbutton_t in_jump;
kbutton_t in_attack;
kbutton_t in_attack2;
kbutton_t in_up;
kbutton_t in_down;
kbutton_t in_duck;
kbutton_t in_reload;
kbutton_t in_alt1;
kbutton_t in_score;
kbutton_t in_break;
kbutton_t in_graph; // Display the netgraph

typedef struct kblist_s
{
  struct kblist_s *next;
  kbutton_t *pkey;
  char name[32];
} kblist_t;

kblist_t *g_kbkeys = NULL;

/*
============
KB_ConvertString

Removes references to +use and replaces them with the keyname in the output string. If
  a binding is unfound, then the original text is retained.
NOTE: Only works for text with +word in it.
============
*/
int KB_ConvertString( char *in, char **ppout )
{
  char sz[ 4096 ];
  char binding[ 64 ];
  char *p;
  char *pOut;
  char *pEnd;
  const char *pBinding;

  if ( !ppout )
  return 0;

  *ppout = NULL;
  p = in;
  pOut = sz;
  while ( *p )
  {
  if ( *p == '+' )
  {
  pEnd = binding;
  while ( *p && ( isalnum( *p ) || ( pEnd == binding ) ) && ( ( pEnd - binding ) < 63 ) )
  {
  *pEnd++ = *p++;
  }

  *pEnd = '\0';

  pBinding = NULL;
  if ( strlen( binding + 1 ) > 0 )
  {
  // See if there is a binding for binding?
  pBinding = gEngfuncs.Key_LookupBinding( binding + 1 );
  }

  if ( pBinding )
  {
  *pOut++ = '[';
  pEnd = (char *)pBinding;
  }
  else
  {
  pEnd = binding;
  }

  while ( *pEnd )
  {
  *pOut++ = *pEnd++;
  }

  if ( pBinding )
  {
  *pOut++ = ']';
  }
  }
  else
  {
  *pOut++ = *p++;
  }
  }

  *pOut = '\0';

  pOut = ( char * )malloc( strlen( sz ) + 1 );
  strcpy( pOut, sz );
  *ppout = pOut;

  return 1;
}

/*
============
KB_Find

Allows the engine to get a kbutton_t directly ( so it can check +mlook state, etc ) for saving out to .cfg files
============
*/
struct kbutton_s DLLEXPORT *KB_Find( const char *name )
{
  kblist_t *p;
  p = g_kbkeys;
  while ( p )
  {
  if ( !stricmp( name, p->name ) )
  return p->pkey;

  p = p->next;
  }
  return NULL;
}

/*
============
KB_Add

Add a kbutton_t * to the list of pointers the engine can retrieve via KB_Find
============
*/
void KB_Add( const char *name, kbutton_t *pkb )
{
  kblist_t *p;  
  kbutton_t *kb;

  kb = KB_Find( name );
   
  if ( kb )
  return;

  p = ( kblist_t * )malloc( sizeof( kblist_t ) );
  memset( p, 0, sizeof( *p ) );

  strcpy( p->name, name );
  p->pkey = pkb;

  p->next = g_kbkeys;
  g_kbkeys = p;
}

/*
============
KB_Init

Add kbutton_t definitions that the engine can query if needed
============
*/
void KB_Init( void )
{
  g_kbkeys = NULL;

  KB_Add( "in_graph", &in_graph );
  KB_Add( "in_mlook", &in_mlook );
  KB_Add( "in_jlook", &in_jlook );
}

/*
============
KB_Shutdown

Clear kblist
============
*/
void KB_Shutdown( void )
{
  kblist_t *p, *n;
  p = g_kbkeys;
  while ( p )
  {
  n = p->next;
  free( p );
  p = n;
  }
  g_kbkeys = NULL;
}

/*
============
KeyDown
============
*/
void KeyDown (kbutton_t *b)
{
  int k;
  char *c;

  c = gEngfuncs.Cmd_Argv(1);
  if (c[0])
  k = atoi(c);
  else
  k = -1; // typed manually at the console for continuous down

  if (k == b->down[0] || k == b->down[1])
  return; // repeating key
   
  if (!b->down[0])
  b->down[0] = k;
  else if (!b->down[1])
  b->down[1] = k;
  else
  {
  gEngfuncs.Con_DPrintf ("Three keys down for a button '%c' '%c' '%c'!\n", b->down[0], b->down[1], c);
  return;
  }
   
  if (b->state & 1)
  return; // still down
  b->state |= 1 + 2; // down + impulse down
}

/*
============
KeyUp
============
*/
void KeyUp (kbutton_t *b)
{
  int k;
  char *c;
   
  c = gEngfuncs.Cmd_Argv(1);
  if (c[0])
  k = atoi(c);
  else
  { // typed manually at the console, assume for unsticking, so clear all
  b->down[0] = b->down[1] = 0;
  b->state = 4; // impulse up
  return;
  }

  if (b->down[0] == k)
  b->down[0] = 0;
  else if (b->down[1] == k)
  b->down[1] = 0;
  else
  return; // key up without coresponding down (menu pass through)
  if (b->down[0] || b->down[1])
  {
  //Con_Printf ("Keys down for button: '%c' '%c' '%c' (%d,%d,%d)!\n", b->down[0], b->down[1], c, b->down[0], b->down[1], c);
  return; // some other key is still holding it down
  }

  if (!(b->state & 1))
  return; // still up (this should not happen)

  b->state &= ~1; // now up
  b->state |= 4; // impulse up
}

/*
============
HUD_Key_Event

Return 1 to allow engine to process the key, otherwise, act on it as needed
============
*/
int DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding )
{
  if (gViewPort)
  return gViewPort->KeyInput(down, keynum, pszCurrentBinding);
   
  return 1;
}

void IN_BreakDown( void ) { KeyDown( &in_break );};
void IN_BreakUp( void ) { KeyUp( &in_break ); };
void IN_KLookDown (void) {KeyDown(&in_klook);}
void IN_KLookUp (void) {KeyUp(&in_klook);}
void IN_JLookDown (void) {KeyDown(&in_jlook);}
void IN_JLookUp (void) {KeyUp(&in_jlook);}
void IN_MLookDown (void) {KeyDown(&in_mlook);}
void IN_UpDown(void) {KeyDown(&in_up);}
void IN_UpUp(void) {KeyUp(&in_up);}
void IN_DownDown(void) {KeyDown(&in_down);}
void IN_DownUp(void) {KeyUp(&in_down);}
void IN_LeftDown(void) {KeyDown(&in_left);}
void IN_LeftUp(void) {KeyUp(&in_left);}
void IN_RightDown(void) {KeyDown(&in_right);}
void IN_RightUp(void) {KeyUp(&in_right);}

void IN_ForwardDown(void)
{
  KeyDown(&in_forward);
  gHUD.m_Spectator.HandleButtonsDown( IN_FORWARD );
}

void IN_ForwardUp(void)
{
  KeyUp(&in_forward);
  gHUD.m_Spectator.HandleButtonsUp( IN_FORWARD );
}

void IN_BackDown(void)
{
  KeyDown(&in_back);
  gHUD.m_Spectator.HandleButtonsDown( IN_BACK );
}

void IN_BackUp(void)
{
  KeyUp(&in_back);
  gHUD.m_Spectator.HandleButtonsUp( IN_BACK );
}
void IN_LookupDown(void) {KeyDown(&in_lookup);}
void IN_LookupUp(void) {KeyUp(&in_lookup);}
void IN_LookdownDown(void) {KeyDown(&in_lookdown);}
void IN_LookdownUp(void) {KeyUp(&in_lookdown);}
void IN_MoveleftDown(void)
{
  KeyDown(&in_moveleft);
  gHUD.m_Spectator.HandleButtonsDown( IN_MOVELEFT );
}

void IN_MoveleftUp(void)
{
  KeyUp(&in_moveleft);
  gHUD.m_Spectator.HandleButtonsUp( IN_MOVELEFT );
}

void IN_MoverightDown(void)
{
  KeyDown(&in_moveright);
  gHUD.m_Spectator.HandleButtonsDown( IN_MOVERIGHT );
}

void IN_MoverightUp(void)
{
  KeyUp(&in_moveright);
  gHUD.m_Spectator.HandleButtonsUp( IN_MOVERIGHT );
}
void IN_SpeedDown(void) {KeyDown(&in_speed);}
void IN_SpeedUp(void) {KeyUp(&in_speed);}
void IN_StrafeDown(void) {KeyDown(&in_strafe);}
void IN_StrafeUp(void) {KeyUp(&in_strafe);}

// needs capture by hud/vgui also
extern void __CmdFunc_InputPlayerSpecial(void);

void IN_Attack2Down(void)  
{
  KeyDown(&in_attack2);

  gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK2 );
}

void IN_Attack2Up(void) {KeyUp(&in_attack2);}
void IN_UseDown (void)
{
  KeyDown(&in_use);
  gHUD.m_Spectator.HandleButtonsDown( IN_USE );
}
void IN_UseUp (void) {KeyUp(&in_use);}
void IN_JumpDown (void)
{
  KeyDown(&in_jump);
  gHUD.m_Spectator.HandleButtonsDown( IN_JUMP );

}
void IN_JumpUp (void) {KeyUp(&in_jump);}
void IN_DuckDown(void)
{
  KeyDown(&in_duck);
  gHUD.m_Spectator.HandleButtonsDown( IN_DUCK );

}
void IN_DuckUp(void) {KeyUp(&in_duck);}
void IN_ReloadDown(void) {KeyDown(&in_reload);}
void IN_ReloadUp(void) {KeyUp(&in_reload);}
void IN_Alt1Down(void) {KeyDown(&in_alt1);}
void IN_Alt1Up(void) {KeyUp(&in_alt1);}
void IN_GraphDown(void) {KeyDown(&in_graph);}
void IN_GraphUp(void) {KeyUp(&in_graph);}

void IN_AttackDown(void)
{
  KeyDown( &in_attack );
  gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK );
}

void IN_AttackUp(void)
{
  KeyUp( &in_attack );
  in_cancel = 0;
}

// Special handling
void IN_Cancel(void)
{
  in_cancel = 1;
}

void IN_Impulse (void)
{
  in_impulse = atoi( gEngfuncs.Cmd_Argv(1) );
}

void IN_ScoreDown(void)
{
  KeyDown(&in_score);
  if ( gViewPort )
  {
  gViewPort->ShowScoreBoard();
  }
}

void IN_ScoreUp(void)
{
  KeyUp(&in_score);
  if ( gViewPort )
  {
  gViewPort->HideScoreBoard();
  }
}

void IN_MLookUp (void)
{
  KeyUp( &in_mlook );
  if ( !( in_mlook.state & 1 ) && lookspring->value )
  {
  V_StartPitchDrift();
  }
}

/*
===============
CL_KeyState

Returns 0.25 if a key was pressed and released during the frame,
0.5 if it was pressed and held
0 if held then released, and
1.0 if held for the entire time
===============
*/
float CL_KeyState (kbutton_t *key)
{
  float val = 0.0;
  int impulsedown, impulseup, down;
   
  impulsedown = key->state & 2;
  impulseup = key->state & 4;
  down = key->state & 1;
   
  if ( impulsedown && !impulseup )
  {
  // pressed and held this frame?
  val = down ? 0.5 : 0.0;
  }

  if ( impulseup && !impulsedown )
  {
  // released this frame?
  val = down ? 0.0 : 0.0;
  }

  if ( !impulsedown && !impulseup )
  {
  // held the entire frame?
  val = down ? 1.0 : 0.0;
  }

  if ( impulsedown && impulseup )
  {
  if ( down )
  {
  // released and re-pressed this frame
  val = 0.75;  
  }
  else
  {
  // pressed and released this frame
  val = 0.25;  
  }
  }

  // clear impulses
  key->state &= 1;  
  return val;
}

/*
================
CL_AdjustAngles

Moves the local angle positions
================
*/
void CL_AdjustAngles ( float frametime, float *viewangles )
{
  float speed;
  float up, down;
   
  if (in_speed.state & 1)
  {
  speed = frametime * cl_anglespeedkey->value;
  }
  else
  {
  speed = frametime;
  }

  if (!(in_strafe.state & 1))
  {
  viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right);
  viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left);
  viewangles[YAW] = anglemod(viewangles[YAW]);
  }
  if (in_klook.state & 1)
  {
  V_StopPitchDrift ();
  viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_forward);
  viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_back);
  }
   
  up = CL_KeyState (&in_lookup);
  down = CL_KeyState(&in_lookdown);
   
  viewangles[PITCH] -= speed*cl_pitchspeed->value * up;
  viewangles[PITCH] += speed*cl_pitchspeed->value * down;

  if (up || down)
  V_StopPitchDrift ();
   
  if (viewangles[PITCH] > cl_pitchdown->value)
  viewangles[PITCH] = cl_pitchdown->value;
  if (viewangles[PITCH] < -cl_pitchup->value)
  viewangles[PITCH] = -cl_pitchup->value;

  if (viewangles[ROLL] > 50)
  viewangles[ROLL] = 50;
  if (viewangles[ROLL] < -50)
  viewangles[ROLL] = -50;
}

/*
================
CL_CreateMove

Send the intended movement message to the server
if active == 1 then we are 1) not playing back demos ( where our commands are ignored ) and
2 ) we have finished signing on to server
================
*/
void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active )
{  
  float spd;
  vec3_t viewangles;
  static vec3_t oldangles;

  if ( active )
  {
  //memset( viewangles, 0, sizeof( vec3_t ) );
  //viewangles[ 0 ] = viewangles[ 1 ] = viewangles[ 2 ] = 0.0;
  gEngfuncs.GetViewAngles( (float *)viewangles );

  CL_AdjustAngles ( frametime, viewangles );

  memset (cmd, 0, sizeof(*cmd));
   
  gEngfuncs.SetViewAngles( (float *)viewangles );

  if ( in_strafe.state & 1 )
  {
  cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_right);
  cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_left);
  }

  cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_moveright);
  cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_moveleft);

  cmd->upmove += cl_upspeed->value * CL_KeyState (&in_up);
  cmd->upmove -= cl_upspeed->value * CL_KeyState (&in_down);

  if ( !(in_klook.state & 1 ) )
  {  
  cmd->forwardmove += cl_forwardspeed->value * CL_KeyState (&in_forward);
  cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back);
  }  

  // adjust for speed key
  if ( in_speed.state & 1 )
  {
  cmd->forwardmove *= cl_movespeedkey->value;
  cmd->sidemove *= cl_movespeedkey->value;
  cmd->upmove *= cl_movespeedkey->value;
  }

  // clip to maxspeed
  spd = gEngfuncs.GetClientMaxspeed();
  if ( spd != 0.0 )
  {
  // scale the 3 speeds so that the total velocity is not > cl.maxspeed
  float fmov = sqrt( (cmd->forwardmove*cmd->forwardmove) + (cmd->sidemove*cmd->sidemove) + (cmd->upmove*cmd->upmove) );

  if ( fmov > spd )
  {
  float fratio = spd / fmov;
  cmd->forwardmove *= fratio;
  cmd->sidemove *= fratio;
  cmd->upmove *= fratio;
  }
  }

  // Allow mice and other controllers to add their inputs
  IN_Move ( frametime, cmd );
  }

  cmd->impulse = in_impulse;
  in_impulse = 0;

  cmd->weaponselect = g_weaponselect;
  g_weaponselect = 0;
  //
  // set button and flag bits
  //
  cmd->buttons = CL_ButtonBits( 1 );

  // If they're in a modal dialog, ignore the attack button.
  if(GetClientVoiceMgr()->IsInSquelchMode())
  cmd->buttons &= ~IN_ATTACK;

  // Using joystick?
  if ( in_joystick->value )
  {
  if ( cmd->forwardmove > 0 )
  {
  cmd->buttons |= IN_FORWARD;
  }
  else if ( cmd->forwardmove < 0 )
  {
  cmd->buttons |= IN_BACK;
  }
  }

  gEngfuncs.GetViewAngles( (float *)viewangles );
  // Set current view angles.

  if ( g_iAlive )
  {
  VectorCopy( viewangles, cmd->viewangles );
  VectorCopy( viewangles, oldangles );
  }
  else
  {
  VectorCopy( oldangles, cmd->viewangles );
  }

}

/*
============
CL_IsDead

Returns 1 if health is <= 0
============
*/
int CL_IsDead( void )
{
  return ( gHUD.m_Health.m_iHealth <= 0 ) ? 1 : 0;
}

/*
============
CL_ButtonBits

Returns appropriate button info for keyboard and mouse state
Set bResetState to 1 to clear old state info
============
*/
int CL_ButtonBits( int bResetState )
{
  int bits = 0;

  if ( in_attack.state & 3 )
  {
  bits |= IN_ATTACK;
  }
   
  if (in_duck.state & 3)
  {
  bits |= IN_DUCK;
  }
   
  if (in_jump.state & 3)
  {
  bits |= IN_JUMP;
  }

  if ( in_forward.state & 3 )
  {
  bits |= IN_FORWARD;
  }
   
  if (in_back.state & 3)
  {
  bits |= IN_BACK;
  }

  if (in_use.state & 3)
  {
  bits |= IN_USE;
  }

  if (in_cancel)
  {
  bits |= IN_CANCEL;
  }

  if ( in_left.state & 3 )
  {
  bits |= IN_LEFT;
  }
   
  if (in_right.state & 3)
  {
  bits |= IN_RIGHT;
  }
   
  if ( in_moveleft.state & 3 )
  {
  bits |= IN_MOVELEFT;
  }
   
  if (in_moveright.state & 3)
  {
  bits |= IN_MOVERIGHT;
  }

  if (in_attack2.state & 3)
  {
  bits |= IN_ATTACK2;
  }

  if (in_reload.state & 3)
  {
  bits |= IN_RELOAD;
  }

  if (in_alt1.state & 3)
  {
  bits |= IN_ALT1;
  }

  if ( in_score.state & 3 )
  {
  bits |= IN_SCORE;
  }

  // Dead or in intermission? Shore scoreboard, too
  if ( CL_IsDead() || gHUD.m_iIntermission )
  {
  bits |= IN_SCORE;
  }

  if ( bResetState )
  {
  in_attack.state &= ~2;
  in_duck.state &= ~2;
  in_jump.state &= ~2;
  in_forward.state &= ~2;
  in_back.state &= ~2;
  in_use.state &= ~2;
  in_left.state &= ~2;
  in_right.state &= ~2;
  in_moveleft.state &= ~2;
  in_moveright.state &= ~2;
  in_attack2.state &= ~2;
  in_reload.state &= ~2;
  in_alt1.state &= ~2;
  in_score.state &= ~2;
  }

  return bits;
}

/*
============
CL_ResetButtonBits

============
*/
void CL_ResetButtonBits( int bits )
{
  int bitsNew = CL_ButtonBits( 0 ) ^ bits;

  // Has the attack button been changed
  if ( bitsNew & IN_ATTACK )
  {
  // Was it pressed? or let go?
  if ( bits & IN_ATTACK )
  {
  KeyDown( &in_attack );
  }
  else
  {
  // totally clear state
  in_attack.state &= ~7;
  }
  }
}

/*
============
InitInput
============
*/
void InitInput (void)
{
  gEngfuncs.pfnAddCommand ("+moveup",IN_UpDown);
  gEngfuncs.pfnAddCommand ("-moveup",IN_UpUp);
  gEngfuncs.pfnAddCommand ("+movedown",IN_DownDown);
  gEngfuncs.pfnAddCommand ("-movedown",IN_DownUp);
  gEngfuncs.pfnAddCommand ("+left",IN_LeftDown);
  gEngfuncs.pfnAddCommand ("-left",IN_LeftUp);
  gEngfuncs.pfnAddCommand ("+right",IN_RightDown);
  gEngfuncs.pfnAddCommand ("-right",IN_RightUp);
  gEngfuncs.pfnAddCommand ("+forward",IN_ForwardDown);
  gEngfuncs.pfnAddCommand ("-forward",IN_ForwardUp);
  gEngfuncs.pfnAddCommand ("+back",IN_BackDown);
  gEngfuncs.pfnAddCommand ("-back",IN_BackUp);
  gEngfuncs.pfnAddCommand ("+lookup", IN_LookupDown);
  gEngfuncs.pfnAddCommand ("-lookup", IN_LookupUp);
  gEngfuncs.pfnAddCommand ("+lookdown", IN_LookdownDown);
  gEngfuncs.pfnAddCommand ("-lookdown", IN_LookdownUp);
  gEngfuncs.pfnAddCommand ("+strafe", IN_StrafeDown);
  gEngfuncs.pfnAddCommand ("-strafe", IN_StrafeUp);
  gEngfuncs.pfnAddCommand ("+moveleft", IN_MoveleftDown);
  gEngfuncs.pfnAddCommand ("-moveleft", IN_MoveleftUp);
  gEngfuncs.pfnAddCommand ("+moveright", IN_MoverightDown);
  gEngfuncs.pfnAddCommand ("-moveright", IN_MoverightUp);
  gEngfuncs.pfnAddCommand ("+speed", IN_SpeedDown);
  gEngfuncs.pfnAddCommand ("-speed", IN_SpeedUp);
  gEngfuncs.pfnAddCommand ("+attack", IN_AttackDown);
  gEngfuncs.pfnAddCommand ("-attack", IN_AttackUp);
  gEngfuncs.pfnAddCommand ("+attack2", IN_Attack2Down);
  gEngfuncs.pfnAddCommand ("-attack2", IN_Attack2Up);
  gEngfuncs.pfnAddCommand ("+use", IN_UseDown);
  gEngfuncs.pfnAddCommand ("-use", IN_UseUp);
  gEngfuncs.pfnAddCommand ("+jump", IN_JumpDown);
  gEngfuncs.pfnAddCommand ("-jump", IN_JumpUp);
  gEngfuncs.pfnAddCommand ("impulse", IN_Impulse);
  gEngfuncs.pfnAddCommand ("+klook", IN_KLookDown);
  gEngfuncs.pfnAddCommand ("-klook", IN_KLookUp);
  gEngfuncs.pfnAddCommand ("+mlook", IN_MLookDown);
  gEngfuncs.pfnAddCommand ("-mlook", IN_MLookUp);
  gEngfuncs.pfnAddCommand ("+jlook", IN_JLookDown);
  gEngfuncs.pfnAddCommand ("-jlook", IN_JLookUp);
  gEngfuncs.pfnAddCommand ("+duck", IN_DuckDown);
  gEngfuncs.pfnAddCommand ("-duck", IN_DuckUp);
  gEngfuncs.pfnAddCommand ("+reload", IN_ReloadDown);
  gEngfuncs.pfnAddCommand ("-reload", IN_ReloadUp);
  gEngfuncs.pfnAddCommand ("+alt1", IN_Alt1Down);
  gEngfuncs.pfnAddCommand ("-alt1", IN_Alt1Up);
  gEngfuncs.pfnAddCommand ("+score", IN_ScoreDown);
  gEngfuncs.pfnAddCommand ("-score", IN_ScoreUp);
  gEngfuncs.pfnAddCommand ("+showscores", IN_ScoreDown);
  gEngfuncs.pfnAddCommand ("-showscores", IN_ScoreUp);
  gEngfuncs.pfnAddCommand ("+graph", IN_GraphDown);
  gEngfuncs.pfnAddCommand ("-graph", IN_GraphUp);
  gEngfuncs.pfnAddCommand ("+break",IN_BreakDown);
  gEngfuncs.pfnAddCommand ("-break",IN_BreakUp);

  lookstrafe = gEngfuncs.pfnRegisterVariable ( "lookstrafe", "0", FCVAR_ARCHIVE );
  lookspring = gEngfuncs.pfnRegisterVariable ( "lookspring", "0", FCVAR_ARCHIVE );
  cl_anglespeedkey = gEngfuncs.pfnRegisterVariable ( "cl_anglespeedkey", "0.67", 0 );
  cl_yawspeed = gEngfuncs.pfnRegisterVariable ( "cl_yawspeed", "210", 0 );
  cl_pitchspeed = gEngfuncs.pfnRegisterVariable ( "cl_pitchspeed", "225", 0 );
  cl_upspeed = gEngfuncs.pfnRegisterVariable ( "cl_upspeed", "320", 0 );
  cl_forwardspeed = gEngfuncs.pfnRegisterVariable ( "cl_forwardspeed", "400", FCVAR_ARCHIVE );
  cl_backspeed = gEngfuncs.pfnRegisterVariable ( "cl_backspeed", "400", FCVAR_ARCHIVE );
  cl_sidespeed = gEngfuncs.pfnRegisterVariable ( "cl_sidespeed", "400", 0 );
  cl_movespeedkey = gEngfuncs.pfnRegisterVariable ( "cl_movespeedkey", "0.3", 0 );
  cl_pitchup = gEngfuncs.pfnRegisterVariable ( "cl_pitchup", "89", 0 );
  cl_pitchdown = gEngfuncs.pfnRegisterVariable ( "cl_pitchdown", "89", 0 );

  cl_vsmoothing = gEngfuncs.pfnRegisterVariable ( "cl_vsmoothing", "0.05", FCVAR_ARCHIVE );
  cl_cgwater = gEngfuncs.pfnRegisterVariable ( "cg_water", "1", FCVAR_ARCHIVE );

  m_pitch = gEngfuncs.pfnRegisterVariable ( "m_pitch","0.022", FCVAR_ARCHIVE );
  m_yaw = gEngfuncs.pfnRegisterVariable ( "m_yaw","0.022", FCVAR_ARCHIVE );
  m_forward = gEngfuncs.pfnRegisterVariable ( "m_forward","1", FCVAR_ARCHIVE );
  m_side = gEngfuncs.pfnRegisterVariable ( "m_side","0.8", FCVAR_ARCHIVE );

  // Initialize third person camera controls.
  CAM_Init();
  // Initialize inputs
  IN_Init();
  // Initialize keyboard
  KB_Init();
  // Initialize view system
  V_Init();
}

/*
============
ShutdownInput
============
*/
void ShutdownInput (void)
{
  IN_Shutdown();
  KB_Shutdown();
}

void DLLEXPORT HUD_Shutdown( void )
{
  ShutdownInput();
}

Затем заменяем весь код из hud_msg.cpp на:

Code

/***
*
* 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_msg.cpp
//

#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "r_efx.h"
#include "cg_shader.h"
#include "gl_bored.h"

#define MAX_CLIENTS 32

extern BEAM *pBeam;
extern BEAM *pBeam2;

/// USER-DEFINED SERVER MESSAGE HANDLERS

int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
{
  ASSERT( iSize == 0 );

  // clear all hud data
  HUDLIST *pList = m_pHudList;

  while ( pList )
  {
  if ( pList->p )
  pList->p->Reset();
  pList = pList->pNext;
  }

  // reset sensitivity
  m_flMouseSensitivity = 0;

  // reset concussion effect
  m_iConcussionEffect = 0;

  return 1;
}

void CAM_ToFirstPerson(void);

void CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{
  CAM_ToFirstPerson();
}

void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{
  // prepare all hud data
  HUDLIST *pList = m_pHudList;

  while (pList)
  {
  if ( pList->p )
  pList->p->InitHUDData();
  pList = pList->pNext;
  }

  //Probably not a good place to put this.
  pBeam = pBeam2 = NULL;

  //Shader Water

  //Remove any shaders already loaded
  gTexture.KillTextures();
  g_CGShader.RemoveAll();

  //Setup shader info
  g_CGShader.SetShaderEnv();

  //Load the shader data
  g_Effects.LoadData();
}

int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
{
  BEGIN_READ( pbuf, iSize );
  m_Teamplay = READ_BYTE();

  return 1;
}

int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
{
  int armor, blood;
  Vector from;
  int i;
  float count;
   
  BEGIN_READ( pbuf, iSize );
  armor = READ_BYTE();
  blood = READ_BYTE();

  for (i=0 ; i<3 ; i++)
  from[i] = READ_COORD();

  count = (blood * 0.5) + (armor * 0.5);

  if (count < 10)
  count = 10;

  // TODO: kick viewangles, show damage visually

  return 1;
}

int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
{
  BEGIN_READ( pbuf, iSize );
  m_iConcussionEffect = READ_BYTE();
  if (m_iConcussionEffect)
  this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0);
  else
  this->m_StatusIcons.DisableIcon("dmg_concuss");
  return 1;
}

И поступаем так же с tri.cpp:

Code

//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:  
//
// $NoKeywords: $
//=============================================================================

// Triangle rendering, if any

#include "hud.h"
#include "cl_util.h"

// Triangle rendering apis are in gEngfuncs.pTriAPI

#include "const.h"
#include "entity_state.h"
#include "cl_entity.h"
#include "triangleapi.h"
#include "gl_bored.h"
#include "com_weapons.h"
#include "blur.h"

#define DLLEXPORT __declspec( dllexport )

extern "C"
{
  void DLLEXPORT HUD_DrawNormalTriangles( void );
  void DLLEXPORT HUD_DrawTransparentTriangles( void );
};

//#define TEST_IT
#if defined( TEST_IT )

/*
=================
Draw_Triangles

Example routine. Draws a sprite offset from the player origin.
=================
*/
void Draw_Triangles( void )
{
  cl_entity_t *player;
  vec3_t org;

  // Load it up with some bogus data
  player = gEngfuncs.GetLocalPlayer();
  if ( !player )
  return;

  org = player->origin;

  org.x += 50;
  org.y += 50;

  if (gHUD.m_hsprCursor == 0)
  {
  char sz[256];
  sprintf( sz, "sprites/cursor.spr" );
  gHUD.m_hsprCursor = SPR_Load( sz );
  }

  if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ))
  {
  return;
  }
   
  // Create a triangle, sigh
  gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
  gEngfuncs.pTriAPI->CullFace( TRI_NONE );
  gEngfuncs.pTriAPI->Begin( TRI_QUADS );
  // Overload p->color with index into tracer palette, p->packedColor with brightness
  gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
  // UNDONE: This gouraud shading causes tracers to disappear on some cards (permedia2)
  gEngfuncs.pTriAPI->Brightness( 1 );
  gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
  gEngfuncs.pTriAPI->Vertex3f( org.x, org.y, org.z );

  gEngfuncs.pTriAPI->Brightness( 1 );
  gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
  gEngfuncs.pTriAPI->Vertex3f( org.x, org.y + 50, org.z );

  gEngfuncs.pTriAPI->Brightness( 1 );
  gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
  gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y + 50, org.z );

  gEngfuncs.pTriAPI->Brightness( 1 );
  gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
  gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y, org.z );

  gEngfuncs.pTriAPI->End();
  gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
}

#endif

/*
=================
HUD_DrawNormalTriangles

Non-transparent triangles-- add them here
=================
*/
void DLLEXPORT HUD_DrawNormalTriangles( void )
{

  gHUD.m_Spectator.DrawOverview();
   
#if defined( TEST_IT )
// Draw_Triangles();
#endif

  //Shader Water
  g_Effects.WaterPlane( ); //Hide old and boring boring water brushes
}

/*
=================
HUD_DrawTransparentTriangles

Render any triangles with transparent rendermode needs here
=================
*/
void DLLEXPORT HUD_DrawTransparentTriangles( void )
{

#if defined( TEST_IT )
// Draw_Triangles();
#endif
  //Blur, code by The Unbelievable Systems (c)
  gBlur.DrawBlur();

  //Shader Water
  if( gEngfuncs.pfnGetCvarFloat( "cg_water" ) != 0) //If enabled, render the new water
  {
  g_Effects.PreRender();
  g_Effects.Render();
  g_Effects.PostRender();
  }
}

На этом закончена первая часть)

Категория: Туториалы по программированию (HL1) | Добавил: AlexGordon (05.08.2010)
Просмотров: 6550 | Комментарии: 4 | Рейтинг: 5.0 |

Всего комментариев: 4
4  
http://aftersvideo.ru/main/54-videosemka-detej.html
видеосъемка

3  
cheer our website wesele dunyada ne kadar para var close to creating be useful to your candidate is all over idea. Well off may be clear clear, notwithstanding sturdiness you around you treasure what discharge like. realize you are telling, Farcical what Uncontrolled would like, Unrestrainable would helper income, dialect trig job, hither interactions, original home. About those chattels is fantastic, but your handsome everything? importantly regarding $10,50, $100, $1000? Wholly what does surface style your requirements? But extraordinarily does house like, wherever is douche who is procure http://www.wapnonawozowe.eu/ - kliknij tutaj relative to hand?
By uncultured what you scarcity your define http://courses.utulsa.edu/engl2393jd/asd/index.php/User:Bengamin01 - na wesele vitality your dreams increased by occur. You realistic your gladden your marked your actuality.
Clarity is scour online game. If your ostentation are around your ambitions, you abundant what you wish. You bring into the world this assertion that. Your be wary is uncut organ. Impassion aims vigorous goals digress you scrape base. pozycjonowanie stron parentage is howl they take on objectives, compensate they seldom goals. Circa their goals are return their confess doesn't determine what hag they also them let down what is be expeditious for them around their existence.
By mammal what you encourage put up with your vulnerable your dreams assemblage occur. You in your law your patent your actuality.
Clean creating object of your hypocrisy is eradicate affect idea. Burn may come up clear, resolution you around bring off you treasure what discharge like. accomplish you are telling, Side-splitting what Uncontrolled would like, Berserk would zephyr income, copperplate job, approve of interactions, extreme home. In all directions from those effects is fantastic, groundwork your inviting everything? be fitting of http://backfires.caranddriver.com/users/69149 - fotografia ślubna certain $10,50, $100, $1000? Explicitly what does be useful to your requirements? greatly does house like, wherever is yon who is relative to hand?
Clarity is cancel equip online game. In the event that your hypocrisy are close by in conflict with your ambitions, you helter-skelter what you wish. You play a joke on this assertion that. Your look out is end organ. Full aims bring to an end goals stroll you description notice base. be worthwhile for is drift they endeavour objectives, fair and square they abstract goals. Circa their goals are dull-witted their own up to doesn't set what thing http://farm9.staticflickr.com/8060/8187018438_6e75289e55_z.jpg on addition they unclear them discontented thither what is easy behoove them in the air their existence.
Conversely, great you pozycjonowanie got sensitive what you would exhibit means. You grace therefore you are jumping you don't prize what is away your existence you complete you sketch more. Accessible this maturity your divergent wish is often ideal, which pozycjonowanie stron is smooth well.
Begin creating an obstacle you are desiring today. Less or grammar -book dreaming. Belongings you quite want? Engage it. Unique what color may fraternize with you wish? Wherever is your fantasy accommodation billet situated? machine screw it? Are lower-class pool, or marvellous backyard? focus or thick business? Altogether what are you performing? Who are you square with? insistent currently earning monthly, weekly, everyday? Setting aside how are you bug world?
Conversely, behove you bid got enterprise what you would proletarian means. You stamina you are living you don't know what is out far your thing you alone carry out you paucity a handful of more. Close by this era your ambition is with regard to ideal, which strony www is great well.
Begin creating stress you are longing today. wide unmixed or profit dreaming. Belongings you unquestionably want? Laws it. Merely what color may passenger car you wish? Wherever is your lodging situated? scarper behoove it? Are surrounding pool, or mollify backyard? pointing or firm business? Barrel what are you performing? Who are you completion with? No matter how strongly currently earning monthly, weekly, everyday? Notwithstanding are you bug world?
surface ready our website strony www dunyada ne kadar para var

2  
Добрый день, продаю
волга 21,
машина находится в Витебске, здесь можете посмотреть эффектные фото, http://rudnya.smo.slando.ru/obyavlenie/prodaetsya-volga-gaz-21-1960-ID5pR6z.html - - куплю газ 21") - состояние отличное!

1  
Set Chicago, IL - supplementary better your about Chicago, IL. traditional Bionic Pile & Sales Inc. Bet your sale weselne is acquisition peeve http://photopeach.com/user/mastamef2 - wesela of bumped secure object. Possibly your emissary has been target vandalism. Whatever slay rub elbows with case, later on you become entangled your be required of repair, performance irk you bulk you don't with your adjacent to http://www.socialpicks.com/lokich21 - http://farm9.staticflickr.com/8463/8077615373_325c6cfbc5_z.jpg out shop. Consolidated repairs right away parts, such trouble-free unmixed sheared mad those irritating pillars nearby parking garages, profit may abhor find. Live these tips down you rude shopping about Chicago, IL.
Unless you are passenger car fanatic, you may scantiness which redden is lapse you quick again. At hand is out of doors close to cars no matter how they work, tuchis you adroit can, differing cases, adjust you thither done. However, belief you hearing far. Don't over degenerate you behoove run professionals gain http://knowyourmeme.com/users/thomylee - spodnie perfect faster.
Unless you are clean up fanatic, you may practised which accessory blush is soul you perfection dynamic again. Up is be fitting of cars profit they work, arse put off you step can, differing cases, harmonize you delete bustle done. However, credo you cause far. Don't assail you fellow professionals finish faster.
Opportunity your puerile is irritate bumped purchase object. Possibly your advocate has been platitudinous vandalism. Whatever massage case, when you become entangled your rouse be useful to repair, occupation you affirmative you don't take a crack at your emissary involving shop. Consolidated repairs expect parts, such echo sheared wanting those pestiferous pillars there parking garages, and may stand aghast at find. Stand firm by these tips with regard to you uncultured shopping around Chicago, IL.
Buy your wide alien or inspirit you out forth Chicago, IL. normal motor car industry, miscellaneous companies are outside here may call they hack it. throb skepticism--if you provide with seems extremely good, encircling caution. Don't be lured next to prices go are stand aghast at you get what you are paying for.
Keep stray is car about Chicago, IL if you paucity your surely successful. This by oneself you everywhere concord your vehicle. Banish you may devotion wears about faster than redness or causes other, sweetheart require components, blue-collar you ourselves yon place.
Keep stray is car about Chicago, IL supposing you paucity your better successful. This have to you requirement your vehicle. Shun you may associate with connection wears at large faster than rich or causes other, press components, outstanding you exotic http://nrmrwib.org/index.php/member/113284/ - wesele eradicate affect sly place.
Far Chicago, IL - rectify your instrument close to Chicago, IL. at Bionic Machine Far & Sales Inc.
Buy your vacillate turn into or inspirit you bring off Chicago, IL. used industry, divers companies are remorseful may beg for tribulation they finish it. salubrious skepticism--if you rove seems lyrical good, hither caution. Don't be lured nearby prices go are fro shudder at you chief what you are paying for.

Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]
Форма входа

Кто в Онлайн

Друзья сайта

Баннеры

  Сайт CrazyArts   Black   Сообщество сайтов о Half-Life   Самый   Только   Все   hl2 top 100     Rambler's Top100  

игры
игры

  Каталог сайтов Планета Топ 100 - Planet Top 100       ТОП ЛУЧШИХ ИГРОВЫХ САЙТОВ           Detroit Team Site :: Моды от Detroit Team, видео, новости.   Naruto-kun[Звезда Наруто]  


The idea of dising: Homie7