📄 cl_view.pas
字号:
unit cl_view;
{
---
cl_view.pas converted from cl_view.c by Ter Roshak
All MY comments begin with TER:
all other comments are ORIGINAL comments!
Tools used : Delphi 6 (unit checks),
Maybe someone can recheck this file for errors or advantages using the pchar vars! :)
---
ToDo :
- Make a nicer conversion of sscanf();
- Make compatible with delphi versions 3,4,5
- Declare all needed stuff to interface part.
04-jun-2002 Juha Hartikainen (juha@linearteam.org):
- The unit was missing "implementation" and "interface".
- Fixed some language errors.
- Added missing units from uses clause.
06-jun-2002 Juha Hartikainen (juha@linearteam.org):
- Fixed some more language errors.
- Unit compiles now with except of TODO section (!)
25-jul-2002 burnin (leonel@linuxbr.com.br
- Added CalcFov to interface section, needed by menu.pas
TODO:
- All todo things are within TODO define
}
{.$DEFINE TODO}
// cl_view.c -- player rendering positioning
interface
uses
Client,
ref,
g_local;
procedure V_ClearScene;
procedure V_AddLightStyle(style : integer; r, g, b : single);
procedure V_AddEntity (ent : entity_p);
procedure V_AddParticle (org : vec3_t; color : integer; alpha : single);
procedure V_AddLight (org : vec3_t; intensity : Single; r, g, b : Single);
procedure V_TestParticles;
procedure V_RenderView( stereo_separation: single );
procedure V_Init;
procedure CL_PrepRefresh;
function CalcFov(fov_x, width, height: Single): Single;
//=============
//
// development tools for weapons
//
var
gun_frame: integer;
gun_model: model_p; // *model_s
//=============
crosshair : cvar_p;
cl_testparticles : cvar_p;
cl_testentities : cvar_p;
cl_testlights : cvar_p;
cl_testblend : cvar_p;
cl_stats : cvar_p;
r_numdlights : integer;
r_dlights : array[0..MAX_DLIGHTS-1] of dlight_t;
r_numentities : integer;
r_entities : array[0..MAX_ENTITIES-1] of entity_t;
r_numparticles : integer;
r_particles : array[0..MAX_PARTICLES-1] of particle_t;
r_lightstyles : array[0..MAX_LIGHTSTYLES-1] of lightstyle_t;
cl_weaponmodels : array[0..MAX_CLIENTWEAPONMODELS-1] of array[0..MAX_QPATH-1] of char;
num_cl_weaponmodels : integer;
implementation
uses
q_shared,
cl_scrn,
cl_main,
sys_win,
q_shwin,
cd_win,
CModel,
CPas,
Cmd,
Common,
vid_dll,
cl_tent,
cl_parse,
cl_ents,
CVar,
Console,
sysutils, //TER: inttostr, floattostr, ...
math; //TER: tan();
{
====================
V_ClearScene
Specifies the model that will be used as the world
====================
}
procedure V_ClearScene;
begin
r_numdlights := 0;
r_numentities := 0;
r_numparticles := 0;
end;
{
=====================
V_AddEntity
=====================
}
procedure V_AddEntity (ent : entity_p);
begin
if (r_numentities >= MAX_ENTITIES) then exit;
r_entities[r_numentities] := ent^;
inc(r_numentities);
end;
{
=====================
V_AddParticle
=====================
}
procedure V_AddParticle (org : vec3_t; color : integer; alpha : single);
var
p : particle_p;
begin
if (r_numparticles >= MAX_PARTICLES) then
exit;
p := @r_particles[r_numparticles];
inc(r_numparticles);
VectorCopy (org, p.origin);
p.color := color;
p.alpha := alpha;
end;
{
=====================
V_AddLight
=====================
}
procedure V_AddLight (org : vec3_t; intensity : Single; r, g, b : Single);
var
dl: dlight_p;
begin
if (r_numdlights >= MAX_DLIGHTS) then
exit;
dl := @r_dlights[r_numdlights];
inc(r_numdlights);
VectorCopy (org, dl.origin);
dl.intensity := intensity;
dl.color[0] := r;
dl.color[1] := g;
dl.color[2] := b;
end;
{
=====================
V_AddLightStyle
=====================
}
procedure V_AddLightStyle(style : integer; r, g, b : single);
var
ls: lightstyle_p;
begin
if ((style < 0) or (style > MAX_LIGHTSTYLES)) then
Com_Error (ERR_DROP, 'Bad light style %d', [style]);
ls := @r_lightstyles[style];
ls.white := r+b+g;
ls.rgb[0] := r;
ls.rgb[1] := g;
ls.rgb[2] := b;
end;
{
================
V_TestParticles
If cl_testparticles is set, create 4096 particles in the view
================
}
procedure V_TestParticles;
var
p : particle_p;
i, j : integer;
d, r, u : Single;
begin
r_numparticles := MAX_PARTICLES;
for i := 0 to r_numparticles-1 do
begin
d := i*0.25;
r := 4*((i and 7) - 3.5);
u := 4*(((i shr 3) and 7) - 3.5);
p := @r_particles[i];
for j := 0 to 2 do
p.origin[j] := cl.refdef.vieworg[j] + cl.v_forward[j]*d +
cl.v_right[j]*r + cl.v_up[j]*u;
p.color := 8;
p.alpha := cl_testparticles.value;
end;
end;
{
================
V_TestEntities
If cl_testentities is set, create 32 player models
================
}
procedure V_TestEntities;
var
i, j : integer;
f, r : Single;
ent : entity_p;
begin
r_numentities := 32;
FillChar(r_entities, sizeof(r_entities), 0);
for i := 0 to r_numentities-1 do
begin
ent := @r_entities[i];
r := 64 * ((i mod 4) - 1.5);
f := 64 * (i / 4) + 128;
for j := 0 to 2 do
ent.origin[j] := cl.refdef.vieworg[j] + cl.v_forward[j]*f +
cl.v_right[j]*r;
ent.model := cl.baseclientinfo.model;
ent.skin := cl.baseclientinfo.skin;
end;
end;
{
================
V_TestLights
If cl_testlights is set, create 32 lights models
================
}
procedure V_TestLights;
var
i, j : integer;
f, r : Single;
dl : dlight_p;
begin
r_numdlights := 32;
FillChar(r_dlights, sizeof(r_dlights), 0);
for i := 0 to r_numdlights-1 do
begin
dl := @r_dlights[i];
r := 64 * ((i mod 4) - 1.5);
f := 64 * (i/4) + 128;
for j := 0 to 2 do
dl.origin[j] := cl.refdef.vieworg[j] + cl.v_forward[j]*f + cl.v_right[j]*r;
dl.color[0] := ((i mod 6)+1) and 1;
dl.color[1] := (((i mod 6)+1) and 2) shr 1;
dl.color[2] := (((i mod 6)+1) and 4) shr 2;
dl.intensity := 200;
end;
end;
//===================================================================
{
=================
CL_PrepRefresh
Call before entering a new level, or after changing dlls
=================
}
procedure CL_PrepRefresh;
var
mapname : array[0..31] of char;
i : integer;
name : array[0..MAX_QPATH-1] of char;
rotate : Single;
axis : vec3_t;
begin
if (cl.configstrings[CS_MODELS+1][0] = #0) then
exit; // no map loaded
SCR_AddDirtyPoint (0, 0);
SCR_AddDirtyPoint (viddef.width-1, viddef.height-1);
// let the render dll load the map
strcpy (mapname, cl.configstrings[CS_MODELS+1] + 5); // skip "maps/"
mapname[strlen(mapname)-4] := #0; // cut off ".bsp"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -