From 0c7d5e75122728fc5fd44173d8c9da62ac032fc5 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 28 Nov 2020 12:31:01 +0100 Subject: [PATCH] env_projectedtexture: Add support for FarZ, NearZ and updated QUAKED comment --- .../shared/env_projectedtexture.cpp | 70 +++++++++++++------ 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/src/gs-entbase/shared/env_projectedtexture.cpp b/src/gs-entbase/shared/env_projectedtexture.cpp index e4472062..640c3c70 100644 --- a/src/gs-entbase/shared/env_projectedtexture.cpp +++ b/src/gs-entbase/shared/env_projectedtexture.cpp @@ -14,26 +14,30 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/*QUAKED env_projectedtexture (1 0 0) (-8 -8 -8) (8 8 8) +/*QUAKED env_projectedtexture (1 0 0) (-8 -8 -8) (8 8 8) PRTEXSF_STARTON "targetname" Name "target" Name of an entity in the map that light will point at. -"_light" Color of the spotlight in RGB255 format. -"brightness" Intensity of the spotlight. -"_inner_cone" Angles of the inner spotlight beam. 0 = omnidirectional. -"_cone" Angles of the outer spotlight beam. 0 = omnidirectional. -"distance" Distance that light is allowed to cast, in inches. -"spotlight_radius" Radius of the resulting spotlight that's cast at a wall. -"style" Select one of the hard-coded lightstyles. -"start_active" Override for if the entity should start on or off. +"lightcolor" Color of the projected texture light + intensity (unused?) +"style" Light appearance style of the projected texture. +"texturename" Name of the texture to be cast as a light. +"farz" Distance to which this projected light will be cast. +"nearz" Clipping distance for near objects that won't get lit. -Dynamic light entity. Can be parented to things, it even has some inputs that -may be interesting. +Inputs: +"TurnOff" Turns the entity off. +"TurnOn" Turns the entity on. +"Toggle" Toggles the entity to an on/off state. +"SpotlightTexture" Sets the projected texture to a specified path. +"LightColor" Sets the color of the light in RGB255 form. +"SetLightStyle" Sets the light appearance integer. +"SetNearZ" Sets clipping distance for near objects that won't get lit. +"SetFarZ" Sets distance to which this projected light will be cast. -The 'start_active' is a Nuclide specific one. There is no way in Source engine -games to tell the entity to start inactive as far as I can tell. +Textured light projected. This is the type of lighting that's used for +flashlights, lamp spotlights and so on. Trivia: -This entity was introduced in Half-Life 2 (2004). +This entity was introduced in Half-Life 2: Episode One (2006). */ enumflags @@ -42,6 +46,8 @@ enumflags PRTEXFL_CHANGED_ANGLES, PRTEXFL_CHANGED_LIGHT, PRTEXFL_CHANGED_INTENSITY, + PRTEXFL_CHANGED_FARZ, + PRTEXFL_CHANGED_NEARZ, PRTEXFL_CHANGED_STYLE, PRTEXFL_CHANGED_STATE, PRTEXFL_CHANGED_TEXTURE, @@ -58,7 +64,8 @@ class env_projectedtexture:CBaseTrigger float m_flIntensity; float m_flInnerCone; float m_flCone; - float m_flDistance; + float m_flFarZ; + float m_flNearZ; float m_flRadius; float m_flStyle; string m_strTextureName; @@ -90,9 +97,10 @@ env_projectedtexture::predraw(void) } /* TODO: We need to handle the second cone light */ - float p = dynamiclight_add(origin, 512, m_vecLight, m_flStyle, m_strTextureName); + float p = dynamiclight_add(origin, m_flFarZ, m_vecLight, m_flStyle, m_strTextureName); dynamiclight_set(p, LFIELD_ANGLES, angles); dynamiclight_set(p, LFIELD_FLAGS, LFLAG_NORMALMODE | LFLAG_REALTIMEMODE | LFLAG_SHADOWMAP); + dynamiclight_set(p, LFIELD_NEARCLIP, m_flNearZ); if (!m_flStyle) dynamiclight_set(p, LFIELD_STYLESTRING, "z"); @@ -125,6 +133,10 @@ env_projectedtexture::ReceiveEntity(float flFlags) if (flFlags & PRTEXFL_CHANGED_INTENSITY) m_flIntensity = readfloat(); + if (flFlags & PRTEXFL_CHANGED_FARZ) + m_flFarZ = readfloat(); + if (flFlags & PRTEXFL_CHANGED_NEARZ) + m_flNearZ = readfloat(); if (flFlags & PRTEXFL_CHANGED_STYLE) m_flStyle = readbyte(); if (flFlags & PRTEXFL_CHANGED_STATE) @@ -203,6 +215,10 @@ env_projectedtexture::SendEntity(entity ePVSEnt, float flFlags) if (flFlags & PRTEXFL_CHANGED_INTENSITY) WriteFloat(MSG_ENTITY, m_flIntensity); + if (flFlags & PRTEXFL_CHANGED_FARZ) + WriteFloat(MSG_ENTITY, m_flFarZ); + if (flFlags & PRTEXFL_CHANGED_NEARZ) + WriteFloat(MSG_ENTITY, m_flNearZ); if (flFlags & PRTEXFL_CHANGED_STYLE) WriteByte(MSG_ENTITY, m_flStyle); if (flFlags & PRTEXFL_CHANGED_STATE) @@ -219,15 +235,19 @@ void env_projectedtexture::Input(entity eAct, string strInput, string strData) { switch (strInput) { - case "Color": + case "LightColor": m_vecLight = stov(strData); SendFlags |= PRTEXFL_CHANGED_LIGHT; break; - case "brightness": - m_flIntensity = stof(strData); - SendFlags |= PRTEXFL_CHANGED_INTENSITY; + case "SetNearZ": + m_flNearZ = stof(strData); + SendFlags |= PRTEXFL_CHANGED_NEARZ; break; - case "style": + case "SetFarZ": + m_flFarZ = stof(strData); + SendFlags |= PRTEXFL_CHANGED_FARZ; + break; + case "SetLightStyle": m_flStyle = stof(strData); SendFlags |= PRTEXFL_CHANGED_STYLE; break; @@ -269,6 +289,12 @@ env_projectedtexture::SpawnKey(string strKey, string strValue) case "lightfov": m_flFOV = stof(strValue); break; + case "farz": + m_flFarZ = stof(strValue); + break; + case "nearz": + m_flNearZ = stof(strValue); + break; default: CBaseTrigger::SpawnKey(strKey, strValue); } @@ -294,6 +320,8 @@ env_projectedtexture::env_projectedtexture(void) #else m_vecLight = [255,255,255]; m_flIntensity = 512; + m_flFarZ = 512; + m_flNearZ = 0; m_strTextureName = "textures/flashlight"; m_flFOV = 90;