NSClient: add method UpdateAliveCam()

UITextbox: Misc polish regarding text entry
GLSL: Detail pass support for some materials
This commit is contained in:
Marco Cawthorne 2022-05-15 13:32:53 -07:00
parent 06efd9495d
commit bb2b7dbddf
Signed by: eukara
GPG key ID: C196CD8BA993248A
17 changed files with 201 additions and 39 deletions

View file

@ -15,6 +15,7 @@
!!permu DELUXE
!!permu LIGHTSTYLED
!!permu FULLBRIGHT
!!permu UPPERLOWER
!!samps diffuse
!!samps lightmap
@ -23,6 +24,7 @@
!!samps =DELUXE deluxemap
!!samps =LIGHTSTYLED =DELUXE deluxemap1 deluxemap2 deluxemap3
!!samps =FULLBRIGHT fullbright
!!samps =UPPERLOWER upper
!!permu FAKESHADOWS
!!cvardf r_glsl_pcf
@ -190,7 +192,7 @@ varying mat3 invsurface;
vec3 cube_c;
vec3 env_f;
float refl = texture2D(s_normalmap, tex_c).a;
cube_c = reflect(normalize(-eyevector), normal_f.rgb);
cube_c = reflect(normalize(-eyevector), vec3(0.0, 0.0, 1.0));
cube_c = cube_c.x * invsurface[0] +
cube_c.y * invsurface[1] +
cube_c.z * invsurface[2];
@ -212,6 +214,11 @@ varying mat3 invsurface;
if (alpha > 1.0)
alpha = 1.0;
#if defined(UPPERLOWER)
diffuse_f.rgb *= texture2D(s_upper, tex_c * 4.0).rgb;
#endif
gl_FragColor = vec4(fog3(diffuse_f.rgb), alpha);
}
#endif

View file

@ -15,12 +15,14 @@
!!permu FRAMEBLEND
!!permu SKELETAL
!!permu FOG
!!permu UPPERLOWER
!!cvardf r_glsl_pcf
!!samps diffuse
!!samps =BUMP normalmap reflectcube
!!samps =PCF shadowmap
!!samps =CUBE projectionmap
!!samps =UPPERLOWER upper
!!cvardf r_skipDiffuse
@ -170,6 +172,10 @@ varying vec3 lightvector;
diff *= colorscale * l_lightcolour;
diff.rgb *= vc.a;
#if defined(UPPERLOWER)
diff.rgb *= texture2D(s_upper, tex_c * 4.0).rgb;
#endif
gl_FragColor = vec4(fog3additive(diff), vc.a);
}
#endif

View file

@ -10,12 +10,14 @@
!!permu FOG
!!permu BUMP
!!permu DELUXE
!!permu UPPERLOWER
!!samps 6
!!samps lightmap
!!samps =LIGHTSTYLED lightmap1 lightmap2 lightmap3
!!samps =DELUXE deluxemap
!!samps =LIGHTSTYLED =DELUXE deluxemap1 deluxemap2 deluxemap3
!!samps =UPPERLOWER upper
!!permu FAKESHADOWS
!!cvardf r_glsl_pcf
@ -156,6 +158,10 @@ varying vec2 lm1, lm2, lm3;
output_f.rgb *= ShadowmapFilter(s_shadowmap, vtexprojcoord);
#endif
#if defined(UPPERLOWER)
output_f.rgb *= texture2D(s_upper, tex_c * 4.0).rgb;
#endif
gl_FragColor = fog4( vec4( output_f.rgb, 1.0 ) );
}
#endif

View file

@ -9,12 +9,14 @@
!!permu FOG
!!permu BUMP
!!permu DELUXE
!!permu UPPERLOWER
!!samps diffuse normalmap
!!samps lightmap
!!samps =LIGHTSTYLED lightmap1 lightmap2 lightmap3
!!samps =DELUXE deluxemap
!!samps =LIGHTSTYLED =DELUXE deluxemap1 deluxemap2 deluxemap3
!!samps =UPPERLOWER upper
!!permu FAKESHADOWS
!!cvardf r_glsl_pcf
@ -156,6 +158,11 @@ varying vec2 lm1, lm2, lm3;
diffuse_f *= ShadowmapFilter(s_shadowmap, vtexprojcoord);
#endif
#if defined(UPPERLOWER)
diffuse_f.rgb *= texture2D(s_upper, tex_c * 4.0).rgb;
#endif
gl_FragColor = vec4(fog3(diffuse_f), 1.0);
}
#endif

View file

@ -9,12 +9,14 @@
!!permu FOG
!!permu BUMP
!!permu DELUXE
!!permu UPPERLOWER
!!samps diffuse normalmap
!!samps lightmap
!!samps =LIGHTSTYLED lightmap1 lightmap2 lightmap3
!!samps =DELUXE deluxemap
!!samps =LIGHTSTYLED =DELUXE deluxemap1 deluxemap2 deluxemap3
!!samps =UPPERLOWER upper
!!permu FAKESHADOWS
!!cvardf r_glsl_pcf
@ -160,6 +162,11 @@ varying vec2 lm1, lm2, lm3;
diffuse_f *= ShadowmapFilter(s_shadowmap, vtexprojcoord);
#endif
#if defined(UPPERLOWER)
diffuse_f.rgb *= texture2D(s_upper, tex_c * 4.0).rgb;
#endif
gl_FragColor = vec4(fog3(diffuse_f), alpha);
}
#endif

View file

@ -9,12 +9,14 @@
!!permu FOG
!!permu BUMP
!!permu DELUXE
!!permu UPPERLOWER
!!samps diffuse normalmap
!!samps lightmap
!!samps =LIGHTSTYLED lightmap1 lightmap2 lightmap3
!!samps =DELUXE deluxemap
!!samps =LIGHTSTYLED =DELUXE deluxemap1 deluxemap2 deluxemap3
!!samps =UPPERLOWER upper
!!permu FAKESHADOWS
!!cvardf r_glsl_pcf
@ -161,6 +163,10 @@ varying vec2 lm1, lm2, lm3;
diffuse_f *= ShadowmapFilter(s_shadowmap, vtexprojcoord);
#endif
#if defined(UPPERLOWER)
diffuse_f.rgb *= texture2D(s_upper, tex_c * 4.0).rgb;
#endif
gl_FragColor = vec4(fog3(diffuse_f), 1.0);
}
#endif

View file

@ -287,25 +287,7 @@ CSQC_UpdateView(float w, float h, float focus)
} else {
/* we're not spectating at all */
if (!Client_IsSpectator(pl)) {
setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin + pl.view_ofs);
if (pl.vehicle) {
NSVehicle veh = (NSVehicle)pl.vehicle;
if (veh.UpdateView)
veh.UpdateView();
} else if (pl.health) {
if (autocvar_cl_thirdperson == TRUE) {
makevectors(view_angles);
vector vStart = [pSeat->m_vecPredictedOrigin[0], pSeat->m_vecPredictedOrigin[1], pSeat->m_vecPredictedOrigin[2] + 16] + (v_right * 4);
vector vEnd = vStart + (v_forward * -48) + [0,0,16] + (v_right * 4);
traceline(vStart, vEnd, FALSE, self);
setproperty(VF_ORIGIN, trace_endpos + (v_forward * 5));
}
}
Shake_Update(pl);
setproperty(VF_ANGLES, view_angles + pl.punchangle);
cl.UpdateAliveCam();
} else if (Client_IsSpectator(pl)) {
spec = (NSClientSpectator)self;
switch (spec.spec_mode) {
@ -338,10 +320,7 @@ CSQC_UpdateView(float w, float h, float focus)
}
if (Client_InIntermission()) {
view_angles = pSeat->m_vecCameraAngle;
view_angles += [sin(time), sin(time * 1.5f)] * 0.1f;
setproperty(VF_ORIGIN, pSeat->m_vecCameraOrigin);
setproperty(VF_CL_VIEWANGLES, view_angles);
cl.UpdateIntermissionCam();
}
}
#endif
@ -412,7 +391,9 @@ CSQC_UpdateView(float w, float h, float focus)
Fade_Update((int)video_mins[0],(int)video_mins[1], (int)w, (int)h);
View_PostDraw();
if (Client_InIntermission() || (!cl.IsFakeSpectator() && cl.IsDead())) {
int players = (int)serverkeyfloat("sv_playerslots");
if (players > 1 && !VGUI_Active() && (Client_InIntermission() || (!cl.IsFakeSpectator() && cl.IsDead()))) {
Scores_Draw();
} else if (focus == TRUE) {
GameText_Draw();

View file

@ -120,7 +120,6 @@ class func_door:NSRenderableEntity
virtual void(entity, string, string) Input;
};
void
func_door::Input(entity eAct, string strInput, string strData)
{
@ -149,6 +148,7 @@ func_door::PortalOpen(void)
setorigin(this, origin);
openportal(this, AREAPORTAL_OPEN);
}
void
func_door::PortalClose(void)
{

View file

@ -122,6 +122,11 @@ CGameRules::IntermissionStart(void)
m_iIntermission = TRUE;
m_flIntermissionTime = time + 5.0f;
for (entity p = world; (p = find(p, ::classname, "player"));) {
p.health = 0;
p.modelindex = 0;
}
}
void

View file

@ -194,6 +194,78 @@ Weapons_AddItem(NSClientPlayer pl, int w, int startammo)
return value;
}
int
Weapons_AddItemSilent(NSClientPlayer pl, int w, int startammo)
{
int value;
/* let's check if we've got a limit */
int maxit;
CGameRules rules = (CGameRules)g_grMode;
maxit = rules.MaxItemPerSlot(g_weapons[w].slot);
if (maxit > 0) {
int wantslot = g_weapons[w].slot;
int c = 0;
for (int i = 0; i < g_weapons.length; i++) {
if (pl.g_items & g_weapons[i].id && g_weapons[i].slot == wantslot) {
c++;
/* we're over the slot limit. */
if (c >= maxit) {
return (0);
}
}
}
}
/* in case programmer decided not to add a pickup callback */
if (g_weapons[w].pickup == __NULL__) {
if (pl.g_items & g_weapons[w].id) {
/* already present, skip */
value = FALSE;
} else {
/* new to our arsenal */
pl.g_items |= g_weapons[w].id;
value = TRUE;
/* it's new, so autoswitch? */
if (pl.activeweapon == 0 && autocvar_sv_forceweapondraw == 1) {
pl.activeweapon = w;
Weapons_Draw((player)pl);
}
}
} else {
/* call pickup to handle the ammo */
if (pl.g_items & g_weapons[w].id) {
/* we have the item already, se let's see if we hit maxammo */
value = g_weapons[w].pickup((player)pl, FALSE, startammo);
/* FALSE means maxammo is hit */
if (!value)
return value;
} else {
/* new to our arsenal */
if (g_weapons[w].pickup((player)pl, TRUE, startammo) == TRUE) {
pl.g_items |= g_weapons[w].id;
value = TRUE;
/* it's new, so autoswitch? */
if (pl.activeweapon == 0 && autocvar_sv_forceweapondraw == 1) {
pl.activeweapon = w;
Weapons_Draw((player)pl);
}
} else {
/* cannot pickup this weapon (weapon says no) */
return FALSE;
}
}
}
Weapons_RefreshAmmo(pl);
return value;
}
/*
=================
Weapons_RemoveItem

View file

@ -29,9 +29,15 @@ NSClient:NSSurfacePropEntity
/* gives the chance to override input variables before networking */
virtual void(void) ClientInputFrame;
/* our camera when we're alive */
virtual void(void) UpdateAliveCam;
/* our camera when we're dead */
virtual void(void) UpdateDeathcam;
/* our camera when we're in an intermission */
virtual void(void) UpdateIntermissionCam;
/* run every frame before renderscene() */
virtual float(void) predraw;
#endif

View file

@ -49,6 +49,13 @@ NSClient::ClientInputFrame(void)
{
}
void
NSClient::UpdateAliveCam(void)
{
setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin + view_ofs);
setproperty(VF_ANGLES, view_angles + punchangle);
}
void
NSClient::UpdateDeathcam(void)
{
@ -59,6 +66,15 @@ NSClient::UpdateDeathcam(void)
setproperty(VF_ANGLES, view_angles);
}
void
NSClient::UpdateIntermissionCam(void)
{
view_angles = pSeat->m_vecCameraAngle;
view_angles += [sin(time), sin(time * 1.5f)] * 0.1f;
setproperty(VF_ORIGIN, pSeat->m_vecCameraOrigin);
setproperty(VF_CL_VIEWANGLES, view_angles);
}
float
NSClient::predraw(void)
{

View file

@ -95,6 +95,7 @@ NSClientPlayer:NSClientSpectator
virtual void(void) PredictPreFrame;
virtual void(void) PredictPostFrame;
virtual void(void) ClientInputFrame;
virtual void(void) UpdateAliveCam;
#else
int voted;
int step;

View file

@ -141,6 +141,30 @@ NSClientPlayer::OnRemoveEntity(void)
super::OnRemoveEntity();
}
void
NSClientPlayer::UpdateAliveCam(void)
{
setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin + view_ofs);
if (vehicle) {
NSVehicle veh = (NSVehicle)vehicle;
if (veh.UpdateView)
veh.UpdateView();
} else if (health) {
if (autocvar_cl_thirdperson == TRUE) {
makevectors(view_angles);
vector vStart = [pSeat->m_vecPredictedOrigin[0], pSeat->m_vecPredictedOrigin[1], pSeat->m_vecPredictedOrigin[2] + 16] + (v_right * 4);
vector vEnd = vStart + (v_forward * -48) + [0,0,16] + (v_right * 4);
traceline(vStart, vEnd, FALSE, self);
setproperty(VF_ORIGIN, trace_endpos + (v_forward * 5));
}
}
Shake_Update(this);
setproperty(VF_ANGLES, view_angles + punchangle);
}
/*
=================
NSClientPlayer::ClientInputFrame
@ -245,9 +269,7 @@ NSClientPlayer::ReceiveEntity(float new, float fl)
gravity = 1.0f;
}
if (fl & PLAYER_MODELINDEX) {
modelindex = readshort();
}
modelindex = readint();
if (fl & PLAYER_ORIGIN) {
origin[0] = readcoord();
@ -556,6 +578,8 @@ NSClientPlayer::MakeTempSpectator(void)
activeweapon = 0;
effects = 0;
alpha = 0.0f;
forceinfokey(this, "*spectator", "0"); /* not a real spectator */
forceinfokey(this, "*dead", "0");
}
/*
@ -586,8 +610,10 @@ NSClientPlayer::Death(void)
SetGravity(1.0f);
customphysics = Empty;
iBleeds = FALSE;
forceinfokey(this, "*deaths", ftos(deaths));
setsize(this, [0,0,0], [0,0,0]);
forceinfokey(this, "*deaths", ftos(deaths));
forceinfokey(this, "*dead", "1");
forceinfokey(this, "*spectator", "0");
}
/*
@ -618,8 +644,10 @@ NSClientPlayer::MakePlayer(void)
SendFlags = UPDATE_ALL;
customphysics = Empty;
iBleeds = TRUE;
forceinfokey(this, "*deaths", ftos(deaths));
SetSize(VEC_HULL_MIN, VEC_HULL_MAX);
forceinfokey(this, "*spectator", "0");
forceinfokey(this, "*deaths", ftos(deaths));
forceinfokey(this, "*dead", "0");
}
/*
@ -634,10 +662,7 @@ at the top of player::EvaluateEntity
void
NSClientPlayer::EvaluateEntity(void)
{
SetSendFlags(PLAYER_KEEPALIVE);
if (ATTR_CHANGED(modelindex))
SetSendFlags(PLAYER_MODELINDEX);
SetSendFlags(PLAYER_MODELINDEX);
if (VEC_CHANGED(origin, 0))
SetSendFlags(PLAYER_ORIGIN);
@ -745,7 +770,7 @@ NSClientPlayer::SendEntity(entity ePEnt, float fChanged)
{
/* really trying to get our moneys worth with 23 bits of mantissa */
if (fChanged & PLAYER_MODELINDEX) {
WriteShort(MSG_ENTITY, modelindex);
WriteInt(MSG_ENTITY, modelindex);
}
/* if origin[0] changes, it's very likely [1] changes too, since

View file

@ -460,6 +460,10 @@ NSClientSpectator::NSClientSpectator(void)
maxspeed = 250;
spec_ent = 0;
spec_mode = 0;
#ifdef SERVER
forceinfokey(this, "*spectator", "1");
#endif
}
#ifdef CLIENT

View file

@ -233,7 +233,6 @@ memalloc(int size)
void
setorigin_safe(entity target, vector testorg)
{
for (int i = 0; i < 16; i++) {
tracebox(testorg, target.mins, target.maxs, testorg, MOVE_NORMAL, target);

View file

@ -76,16 +76,24 @@ void CUITextBox::Draw(void)
#endif
m_flTime += frametime * 2;
/* these are to deal with text going off-screen */
float len = Font_StringWidth(m_strText, TRUE, g_fntDefault);
float ofs = bound(0, len - (m_vecSize[0] - 16), len);
// blinking cursor
if (m_iFlags & TEXTBOX_FOCUS) {
if (rint(m_flTime) & 1) {
Font_DrawText(m_parent.m_vecOrigin + m_vecOrigin + [8, 8], sprintf("%s|", m_strText), g_fntDefault);
drawsetcliparea(m_parent.m_vecOrigin[0] + m_vecOrigin[0], m_parent.m_vecOrigin[1] + m_vecOrigin[1], m_vecSize[0], m_vecSize[1]);
Font_DrawText(m_parent.m_vecOrigin + m_vecOrigin + [8 - ofs, 8], sprintf("%s|", m_strText), g_fntDefault);
drawresetcliparea();
return;
}
}
if (m_strText) {
Font_DrawText(m_parent.m_vecOrigin + m_vecOrigin + [8, 8], m_strText, g_fntDefault);
drawsetcliparea(m_parent.m_vecOrigin[0] + m_vecOrigin[0], m_parent.m_vecOrigin[1] + m_vecOrigin[1], m_vecSize[0], m_vecSize[1]);
Font_DrawText(m_parent.m_vecOrigin + m_vecOrigin + [8 - ofs, 8], m_strText, g_fntDefault);
drawresetcliparea();
}
}
@ -107,9 +115,15 @@ void CUITextBox::Input (float flEVType, float flKey, float flChar, float flDevID
break;
default:
if (m_iFlags & TEXTBOX_FOCUS) {
#if 0
if ((flChar >= 48 && flChar <= 57) || (flChar >= 65 && flChar <= 90) || (flChar >= 97 && flChar <= 122)) {
m_strText = sprintf("%s%s", m_strText, chr2str(flChar));
}
#else
if ((flChar >= 32 && flChar <= 125)) {
m_strText = sprintf("%s%s", m_strText, chr2str(flChar));
}
#endif
}
}
} else if (flEVType == IE_KEYUP) {