mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-13 22:22:05 +00:00
Introduced idLight::modelTarget key for TrenchBroom light group setup
This commit is contained in:
parent
729013311d
commit
f2acbbabde
4 changed files with 127 additions and 18 deletions
|
@ -38,8 +38,10 @@ entityDef light {
|
|||
"editor_var shaderParm7" "shaderParm 7"
|
||||
"editor_var count" "how many times light must be triggered to toggle."
|
||||
"editor_var break" "break when triggered."
|
||||
"editor_model model" "model to use."
|
||||
"editor_model broken" "model to use when the light is broken (defaults to model name with '_broken' appended to name)"
|
||||
// RB: modelTarget key to support light groups of lights and func_static models in TrenchBroom
|
||||
"editor_var modelTarget" "name of func_static entity as a replacement for model on this entity"
|
||||
"editor_model model" "model to use."
|
||||
"editor_model broken" "model to use when the light is broken (defaults to model name with '_broken' appended to name)"
|
||||
"editor_var hideModelOnBreak" "hides the model when broken"
|
||||
"editor_var health" "amount of damage to recieve before becoming broken. 0 is nonbreakable."
|
||||
"editor_var target" "entities to trigger if shot."
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2021 Justin Marshall
|
||||
Copyright (C) 2021-2024 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -49,6 +51,7 @@ const idEventDef EV_Light_On( "On", NULL );
|
|||
const idEventDef EV_Light_Off( "Off", NULL );
|
||||
const idEventDef EV_Light_FadeOut( "fadeOutLight", "f" );
|
||||
const idEventDef EV_Light_FadeIn( "fadeInLight", "f" );
|
||||
const idEventDef EV_Light_UpdateModelTarget( "<updateModelTarget>", NULL ); // RB
|
||||
|
||||
CLASS_DECLARATION( idEntity, idLight )
|
||||
EVENT( EV_Light_SetShader, idLight::Event_SetShader )
|
||||
|
@ -65,6 +68,8 @@ EVENT( EV_Activate, idLight::Event_ToggleOnOff )
|
|||
EVENT( EV_PostSpawn, idLight::Event_SetSoundHandles )
|
||||
EVENT( EV_Light_FadeOut, idLight::Event_FadeOut )
|
||||
EVENT( EV_Light_FadeIn, idLight::Event_FadeIn )
|
||||
EVENT( EV_Light_FadeIn, idLight::Event_FadeIn )
|
||||
EVENT( EV_Light_UpdateModelTarget, idLight::Event_UpdateModelTarget )
|
||||
END_CLASS
|
||||
|
||||
|
||||
|
@ -226,6 +231,14 @@ void idLight::UpdateChangeableSpawnArgs( const idDict* source )
|
|||
// RB: allow the ingame light editor to move the light
|
||||
GetPhysics()->SetOrigin( renderLight.origin );
|
||||
GetPhysics()->SetAxis( renderLight.axis );
|
||||
|
||||
// link func_static modelTarget
|
||||
modelTarget = NULL;
|
||||
const char* target = source->GetString( "modelTarget" );
|
||||
if( target != NULL && target[0] != '\0' )
|
||||
{
|
||||
PostEventMS( &EV_Light_UpdateModelTarget, 0 );
|
||||
}
|
||||
// RB end
|
||||
|
||||
UpdateVisuals();
|
||||
|
@ -455,7 +468,11 @@ void idLight::Spawn()
|
|||
idStr model = spawnArgs.GetString( "model" ); // get the visual model
|
||||
if( !model.Length() )
|
||||
{
|
||||
gameLocal.Error( "Breakable light without a model set on entity #%d(%s)", entityNumber, name.c_str() );
|
||||
model = spawnArgs.GetString( "modelTarget" );
|
||||
if( !model.Length() )
|
||||
{
|
||||
gameLocal.Error( "Breakable light without a model set on entity #%d(%s)", entityNumber, name.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
fl.takedamage = true;
|
||||
|
@ -523,9 +540,22 @@ void idLight::SetLightLevel()
|
|||
renderLight.shaderParms[ SHADERPARM_RED ] = color[ 0 ];
|
||||
renderLight.shaderParms[ SHADERPARM_GREEN ] = color[ 1 ];
|
||||
renderLight.shaderParms[ SHADERPARM_BLUE ] = color[ 2 ];
|
||||
renderEntity.shaderParms[ SHADERPARM_RED ] = color[ 0 ];
|
||||
renderEntity.shaderParms[ SHADERPARM_GREEN ] = color[ 1 ];
|
||||
renderEntity.shaderParms[ SHADERPARM_BLUE ] = color[ 2 ];
|
||||
|
||||
if( modelTarget )
|
||||
{
|
||||
renderEntity_t* rent = modelTarget->GetRenderEntity();
|
||||
|
||||
rent->shaderParms[ SHADERPARM_RED ] = color[ 0 ];
|
||||
rent->shaderParms[ SHADERPARM_GREEN ] = color[ 1 ];
|
||||
rent->shaderParms[ SHADERPARM_BLUE ] = color[ 2 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
renderEntity.shaderParms[ SHADERPARM_RED ] = color[ 0 ];
|
||||
renderEntity.shaderParms[ SHADERPARM_GREEN ] = color[ 1 ];
|
||||
renderEntity.shaderParms[ SHADERPARM_BLUE ] = color[ 2 ];
|
||||
}
|
||||
|
||||
PresentLightDefChange();
|
||||
PresentModelDefChange();
|
||||
}
|
||||
|
@ -630,10 +660,23 @@ void idLight::SetLightParms( float parm0, float parm1, float parm2, float parm3
|
|||
renderLight.shaderParms[ SHADERPARM_GREEN ] = parm1;
|
||||
renderLight.shaderParms[ SHADERPARM_BLUE ] = parm2;
|
||||
renderLight.shaderParms[ SHADERPARM_ALPHA ] = parm3;
|
||||
renderEntity.shaderParms[ SHADERPARM_RED ] = parm0;
|
||||
renderEntity.shaderParms[ SHADERPARM_GREEN ] = parm1;
|
||||
renderEntity.shaderParms[ SHADERPARM_BLUE ] = parm2;
|
||||
renderEntity.shaderParms[ SHADERPARM_ALPHA ] = parm3;
|
||||
|
||||
if( modelTarget )
|
||||
{
|
||||
renderEntity_t* rent = modelTarget->GetRenderEntity();
|
||||
|
||||
rent->shaderParms[ SHADERPARM_RED ] = parm0;
|
||||
rent->shaderParms[ SHADERPARM_GREEN ] = parm1;
|
||||
rent->shaderParms[ SHADERPARM_BLUE ] = parm2;
|
||||
rent->shaderParms[ SHADERPARM_ALPHA ] = parm3;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderEntity.shaderParms[ SHADERPARM_RED ] = parm0;
|
||||
renderEntity.shaderParms[ SHADERPARM_GREEN ] = parm1;
|
||||
renderEntity.shaderParms[ SHADERPARM_BLUE ] = parm2;
|
||||
renderEntity.shaderParms[ SHADERPARM_ALPHA ] = parm3;
|
||||
}
|
||||
PresentLightDefChange();
|
||||
PresentModelDefChange();
|
||||
}
|
||||
|
@ -670,6 +713,7 @@ idLight::On
|
|||
void idLight::On()
|
||||
{
|
||||
currentLevel = levels;
|
||||
|
||||
// offset the start time of the shader to sync it to the game time
|
||||
renderLight.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time );
|
||||
if( ( soundWasPlaying || refSound.waitfortrigger ) && refSound.shader )
|
||||
|
@ -689,6 +733,7 @@ idLight::Off
|
|||
void idLight::Off()
|
||||
{
|
||||
currentLevel = 0;
|
||||
|
||||
// kill any sound it was making
|
||||
if( refSound.referenceSound && refSound.referenceSound->CurrentlyPlaying() )
|
||||
{
|
||||
|
@ -844,6 +889,14 @@ idLight::PresentModelDefChange
|
|||
*/
|
||||
void idLight::PresentModelDefChange()
|
||||
{
|
||||
if( modelTarget )
|
||||
{
|
||||
modelTarget->BecomeActive( TH_UPDATEVISUALS );
|
||||
modelTarget->Present();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( !renderEntity.hModel || IsHidden() )
|
||||
{
|
||||
return;
|
||||
|
@ -884,12 +937,30 @@ void idLight::Present()
|
|||
if( lightParent )
|
||||
{
|
||||
renderLight.referenceSound = lightParent->GetSoundEmitter();
|
||||
renderEntity.referenceSound = lightParent->GetSoundEmitter();
|
||||
|
||||
if( modelTarget )
|
||||
{
|
||||
renderEntity_t* rent = modelTarget->GetRenderEntity();
|
||||
rent->referenceSound = lightParent->GetSoundEmitter();
|
||||
}
|
||||
else
|
||||
{
|
||||
renderEntity.referenceSound = lightParent->GetSoundEmitter();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderLight.referenceSound = refSound.referenceSound;
|
||||
renderEntity.referenceSound = refSound.referenceSound;
|
||||
|
||||
if( modelTarget )
|
||||
{
|
||||
renderEntity_t* rent = modelTarget->GetRenderEntity();
|
||||
rent->referenceSound = refSound.referenceSound;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderEntity.referenceSound = refSound.referenceSound;
|
||||
}
|
||||
}
|
||||
|
||||
// update the renderLight and renderEntity to render the light and flare
|
||||
|
@ -1186,7 +1257,14 @@ idLight::Event_Hide
|
|||
*/
|
||||
void idLight::Event_Hide()
|
||||
{
|
||||
Hide();
|
||||
if( modelTarget )
|
||||
{
|
||||
modelTarget->Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
PresentModelDefChange();
|
||||
Off();
|
||||
}
|
||||
|
@ -1198,7 +1276,14 @@ idLight::Event_Show
|
|||
*/
|
||||
void idLight::Event_Show()
|
||||
{
|
||||
Show();
|
||||
if( modelTarget )
|
||||
{
|
||||
modelTarget->Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Show();
|
||||
}
|
||||
PresentModelDefChange();
|
||||
On();
|
||||
}
|
||||
|
@ -1452,7 +1537,6 @@ idLight::ClientReceiveEvent
|
|||
*/
|
||||
bool idLight::ClientReceiveEvent( int event, int time, const idBitMsg& msg )
|
||||
{
|
||||
|
||||
switch( event )
|
||||
{
|
||||
case EVENT_BECOMEBROKEN:
|
||||
|
@ -1466,3 +1550,23 @@ bool idLight::ClientReceiveEvent( int event, int time, const idBitMsg& msg )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
RB idLight::Event_UpdateModelTarget
|
||||
|
||||
connects this light to its original and separate brush/patch model
|
||||
================
|
||||
*/
|
||||
void idLight::Event_UpdateModelTarget()
|
||||
{
|
||||
const char* target = spawnArgs.GetString( "modelTarget" );
|
||||
|
||||
idEntity* ent = gameLocal.FindEntity( target );
|
||||
if( ent->IsType( idStaticEntity::Type ) )
|
||||
{
|
||||
modelTarget = static_cast<idStaticEntity*>( ent );
|
||||
|
||||
//ent->UpdateVisuals();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2021 Justin Marshall
|
||||
Copyright (C) 2021-2024 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -176,7 +178,7 @@ private:
|
|||
bool soundWasPlaying;
|
||||
|
||||
// RB: pointing to static model because this light entity was split into 2 entities by convertMapToValve220
|
||||
//idEntityPtr<idStaticEntity> staticModel;
|
||||
idEntityPtr<idStaticEntity> modelTarget;
|
||||
|
||||
private:
|
||||
void PresentLightDefChange();
|
||||
|
@ -196,6 +198,7 @@ private:
|
|||
void Event_SetSoundHandles();
|
||||
void Event_FadeOut( float time );
|
||||
void Event_FadeIn( float time );
|
||||
void Event_UpdateModelTarget();
|
||||
|
||||
// jmarshall
|
||||
idList<idStr> light_styles;
|
||||
|
|
|
@ -3177,8 +3177,8 @@ bool idMapFile::ConvertToValve220Format()
|
|||
ent->epairs.Set( "name", uniqueName );
|
||||
ent->epairs.Set( "model", uniqueName );
|
||||
|
||||
// TODO replace this with other key that links idLight to func_static entity for syncing color/broken model
|
||||
lightEnt->epairs.Set( "model", uniqueName );
|
||||
// link idLight to func_static entity for syncing color/broken model using new modelTarget key
|
||||
lightEnt->epairs.Set( "modelTarget", uniqueName );
|
||||
ent->epairs.SetInt( "_tb_group", tbGroupID );
|
||||
|
||||
// strip any light specific data
|
||||
|
|
Loading…
Reference in a new issue