/* ================ idLight::Present ================ */ void idLight::Present( void ) { // don't present to the renderer if the entity hasn't changed if ( !( thinkFlags & TH_UPDATEVISUALS ) ) { return; } // add the model idEntity::Present(); // current transformation renderLight.axis = localLightAxis * GetPhysics()->GetAxis(); renderLight.origin = GetPhysics()->GetOrigin() + GetPhysics()->GetAxis() * localLightOrigin; // reference the sound for shader synced effects if ( lightParent ) { renderLight.referenceSound = lightParent->GetSoundEmitter(); renderEntity.referenceSound = lightParent->GetSoundEmitter(); } else { renderLight.referenceSound = refSound.referenceSound; renderEntity.referenceSound = refSound.referenceSound; } // update the renderLight and renderEntity to render the light and flare PresentLightDefChange(); PresentModelDefChange(); }
/* ================ idLight::ReadFromSnapshot ================ */ void idLight::ReadFromSnapshot( const idBitMsgDelta &msg ) { idVec4 shaderColor; int oldCurrentLevel = currentLevel; idVec3 oldBaseColor = baseColor; GetPhysics()->ReadFromSnapshot( msg ); ReadBindFromSnapshot( msg ); currentLevel = msg.ReadByte(); if ( currentLevel != oldCurrentLevel ) { // need to call On/Off for flickering lights to start/stop the sound // while doing it this way rather than through events, the flickering is out of sync between clients // but at least there is no question about saving the event and having them happening globally in the world if ( currentLevel ) { On(); } else { Off(); } } UnpackColor( msg.ReadLong(), baseColor ); // lightParentEntityNum = msg.ReadBits( GENTITYNUM_BITS ); /* // only helps prediction UnpackColor( msg.ReadLong(), fadeFrom ); UnpackColor( msg.ReadLong(), fadeTo ); fadeStart = msg.ReadLong(); fadeEnd = msg.ReadLong(); */ // FIXME: read renderLight.shader renderLight.lightRadius[0] = msg.ReadFloat( 5, 10 ); renderLight.lightRadius[1] = msg.ReadFloat( 5, 10 ); renderLight.lightRadius[2] = msg.ReadFloat( 5, 10 ); UnpackColor( msg.ReadLong(), shaderColor ); renderLight.shaderParms[SHADERPARM_RED] = shaderColor[0]; renderLight.shaderParms[SHADERPARM_GREEN] = shaderColor[1]; renderLight.shaderParms[SHADERPARM_BLUE] = shaderColor[2]; renderLight.shaderParms[SHADERPARM_ALPHA] = shaderColor[3]; renderLight.shaderParms[SHADERPARM_TIMESCALE] = msg.ReadFloat( 5, 10 ); renderLight.shaderParms[SHADERPARM_TIMEOFFSET] = msg.ReadLong(); //renderLight.shaderParms[SHADERPARM_DIVERSITY] = msg.ReadFloat(); renderLight.shaderParms[SHADERPARM_MODE] = msg.ReadShort(); ReadColorFromSnapshot( msg ); if ( msg.HasChanged() ) { if ( ( currentLevel != oldCurrentLevel ) || ( baseColor != oldBaseColor ) ) { SetLightLevel(); } else { PresentLightDefChange(); PresentModelDefChange(); } } }
/* ================ idLight::SetLightParms ================ */ void idLight::SetLightParms( float parm0, float parm1, float parm2, float parm3 ) { renderLight.shaderParms[ SHADERPARM_RED ] = parm0; 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; PresentLightDefChange(); PresentModelDefChange(); }
/* ================ idLight::SetLightLevel ================ */ void idLight::SetLightLevel( void ) { idVec3 color; float intensity; intensity = ( float )currentLevel / ( float )levels; color = baseColor * intensity; 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 ]; PresentLightDefChange(); PresentModelDefChange(); }
/* ================ idLight::Event_Show ================ */ void idLight::Event_Show( void ) { Show(); PresentModelDefChange(); On(); }
/* ================ idLight::Event_Hide ================ */ void idLight::Event_Hide( void ) { Hide(); PresentModelDefChange(); Off(); }