예제 #1
0
/*
================
ReadRenderLight
================
*/
void	idRenderWorldLocal::ReadRenderLight( ) {
	renderLight_t	light;
	int				index;

	session->readDemo->ReadInt( index );
	if ( index < 0 ) {
		common->Error( "ReadRenderLight: index < 0 " );
	}

	session->readDemo->ReadMat3( light.axis );
	session->readDemo->ReadVec3( light.origin );
	session->readDemo->ReadInt( light.suppressLightInViewID );
	session->readDemo->ReadInt( light.allowLightInViewID );
	session->readDemo->ReadBool( light.noShadows );
	session->readDemo->ReadBool( light.noSpecular );
	session->readDemo->ReadBool( light.pointLight );
	session->readDemo->ReadBool( light.parallel );
	session->readDemo->ReadVec3( light.lightRadius );
	session->readDemo->ReadVec3( light.lightCenter );
	session->readDemo->ReadVec3( light.target );
	session->readDemo->ReadVec3( light.right );
	session->readDemo->ReadVec3( light.up );
	session->readDemo->ReadVec3( light.start );
	session->readDemo->ReadVec3( light.end );
	session->readDemo->ReadInt( (int&)light.prelightModel );
	session->readDemo->ReadInt( light.lightId );
	session->readDemo->ReadInt( (int&)light.shader );
	for ( int i = 0; i < MAX_ENTITY_SHADER_PARMS; i++)
		session->readDemo->ReadFloat( light.shaderParms[i] );
	session->readDemo->ReadInt( (int&)light.referenceSound );

	light.smLodBias = 0;
	light.occlusionModel = nullptr;
	light.shadowMode = shadowMode_t::Default;

	if ( light.prelightModel ) {
		const char* name = session->readDemo->ReadHashString();

		light.prelightModel = renderModelManager->FindModel( name );

		//"_prelight_light_xyz"
		if(name && strlen(name) > 10) {
			light.occlusionModel = renderModelManager->CheckModel( va( "_occluder_%s", &name[10] ) );
		}
	}
	if ( light.shader ) {
		light.shader = declManager->FindMaterial( session->readDemo->ReadHashString() );
	}
	if ( light.referenceSound ) {
		int	index;
		session->readDemo->ReadInt( index );
		light.referenceSound = session->sw->EmitterForIndex( index );
	}

	UpdateLightDef( index, &light );

	if ( r_showDemo.GetBool() ) {
		common->Printf( "DC_UPDATE_LIGHTDEF: %i\n", index );
	}
}
예제 #2
0
void rvMonsterStroggHover::StartHeadlight( void )
{
	if ( jointHeadlight != INVALID_JOINT )
	{
		lightHandle = -1;
		if ( cvarSystem->GetCVarInteger( "com_machineSpec"	) > 1 && spawnArgs.GetString("mtr_light") ) {
			idVec3		color;
			//const char* temp;

			const idMaterial *headLightMaterial = declManager->FindMaterial( spawnArgs.GetString ( "mtr_light", "lights/muzzleflash" ), false );
			if ( headLightMaterial )
			{
				renderLight.shader	  = declManager->FindMaterial( spawnArgs.GetString ( "mtr_light", "lights/muzzleflash" ), false );
				renderLight.pointLight  = spawnArgs.GetBool( "light_pointlight", "1" );
// RAVEN BEGIN
// dluetscher: added detail levels to render lights
				renderLight.detailLevel = DEFAULT_LIGHT_DETAIL_LEVEL;
// RAVEN END
				spawnArgs.GetVector( "light_color", "0 0 0", color );
				renderLight.shaderParms[ SHADERPARM_RED ]		= color[0];
				renderLight.shaderParms[ SHADERPARM_GREEN ]		= color[1];
				renderLight.shaderParms[ SHADERPARM_BLUE ]		= color[2];
				renderLight.shaderParms[ SHADERPARM_TIMESCALE ] = 1.0f;

				renderLight.lightRadius[0] = renderLight.lightRadius[1] = 
					renderLight.lightRadius[2] = (float)spawnArgs.GetInt( "light_radius" );

				if ( !renderLight.pointLight ) {
					renderLight.target = spawnArgs.GetVector( "light_target" );
					renderLight.up	   = spawnArgs.GetVector( "light_up" );
					renderLight.right  = spawnArgs.GetVector( "light_right" );
					renderLight.end	   = spawnArgs.GetVector( "light_target" );;
				}

				//lightOn = spawnArgs.GetBool( "start_on", "1" );

				lightHandle = gameRenderWorld->AddLightDef( &renderLight );
			}
		}
		// Hide flare surface if there is one
		/*
		temp = spawnArgs.GetString ( "light_flaresurface", "" );
		if ( temp && *temp ) {
			parent->ProcessEvent ( &EV_HideSurface, temp );
		}
		*/

		// Sounds shader when turning light
		//spawnArgs.GetString ( "snd_on", "", soundOn );
		
		// Sound shader when turning light off
		//spawnArgs.GetString ( "snd_off", "", soundOff);
		
		UpdateLightDef ( );
	}
}
예제 #3
0
/*
================
ReadRenderLight
================
*/
void	idRenderWorldLocal::ReadRenderLight( )
{
	renderLight_t	light;
	int				index;
	
	common->ReadDemo()->ReadInt( index );
	if( index < 0 )
	{
		common->Error( "ReadRenderLight: index < 0 " );
	}
	
	common->ReadDemo()->ReadMat3( light.axis );
	common->ReadDemo()->ReadVec3( light.origin );
	common->ReadDemo()->ReadInt( light.suppressLightInViewID );
	common->ReadDemo()->ReadInt( light.allowLightInViewID );
	common->ReadDemo()->ReadBool( light.noShadows );
	common->ReadDemo()->ReadBool( light.noSpecular );
	common->ReadDemo()->ReadBool( light.pointLight );
	common->ReadDemo()->ReadBool( light.parallel );
	common->ReadDemo()->ReadVec3( light.lightRadius );
	common->ReadDemo()->ReadVec3( light.lightCenter );
	common->ReadDemo()->ReadVec3( light.target );
	common->ReadDemo()->ReadVec3( light.right );
	common->ReadDemo()->ReadVec3( light.up );
	common->ReadDemo()->ReadVec3( light.start );
	common->ReadDemo()->ReadVec3( light.end );
	common->ReadDemo()->ReadInt( ( int& )light.prelightModel );
	common->ReadDemo()->ReadInt( light.lightId );
	common->ReadDemo()->ReadInt( ( int& )light.shader );
	for( int i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ )
		common->ReadDemo()->ReadFloat( light.shaderParms[i] );
	common->ReadDemo()->ReadInt( ( int& )light.referenceSound );
	if( light.prelightModel )
	{
		light.prelightModel = renderModelManager->FindModel( common->ReadDemo()->ReadHashString() );
	}
	if( light.shader )
	{
		light.shader = declManager->FindMaterial( common->ReadDemo()->ReadHashString() );
	}
	if( light.referenceSound )
	{
		int	index;
		common->ReadDemo()->ReadInt( index );
		light.referenceSound = common->SW()->EmitterForIndex( index );
	}
	
	UpdateLightDef( index, &light );
	
	if( r_showDemo.GetBool() )
	{
		common->Printf( "DC_UPDATE_LIGHTDEF: %i\n", index );
	}
}
예제 #4
0
/*
================
rvMonsterStroggHover::Think
================
*/
void rvMonsterStroggHover::Think ( void ) {
	idAI::Think ( );
	
	if ( !aifl.dead )
	{
		// If thinking we should play an effect on the ground under us
		if ( !fl.hidden && !fl.isDormant && (thinkFlags & TH_THINK ) && !aifl.dead ) {
			trace_t tr;
			idVec3	origin;
			idMat3	axis;
			
			// Project the effect 80 units down from the bottom of our bbox
			GetJointWorldTransform ( jointDust, gameLocal.time, origin, axis );
			
	// RAVEN BEGIN
	// ddynerman: multiple clip worlds
			gameLocal.TracePoint ( this, tr, origin, origin + axis[0] * (GetPhysics()->GetBounds()[0][2]+80.0f), CONTENTS_SOLID, this );
	// RAVEN END

			// Start the dust effect if not already started
			if ( !effectDust ) {
				effectDust = gameLocal.PlayEffect ( gameLocal.GetEffect ( spawnArgs, "fx_dust" ), tr.endpos, tr.c.normal.ToMat3(), true );
			}
			
			// If the effect is playing we should update its attenuation as well as its origin and axis
			if ( effectDust ) {
				effectDust->Attenuate ( 1.0f - idMath::ClampFloat ( 0.0f, 1.0f, (tr.endpos - origin).LengthFast ( ) / 127.0f ) );
				effectDust->SetOrigin ( tr.endpos );
				effectDust->SetAxis ( tr.c.normal.ToMat3() );
			}
			
			// If the hover effect is playing we can set its end origin to the ground
			/*
			if ( effectHover ) {
				effectHover->SetEndOrigin ( tr.endpos );
			}
			*/
		} else if ( effectDust ) {
			effectDust->Stop ( );
			effectDust = NULL;
		}

		//Try to circle strafe or pursue
		if ( circleStrafing )
		{
			CircleStrafe();
		}
		else if ( !inPursuit )
		{
			if ( !aifl.action && move.fl.done && !aifl.scripted )
			{
				if ( GetEnemy() )
				{
					if ( DistanceTo( GetEnemy() ) > 2000.0f 
						|| (GetEnemy()->GetPhysics()->GetLinearVelocity()*(GetEnemy()->GetPhysics()->GetOrigin()-GetPhysics()->GetOrigin())) > 1000.0f )
					{//enemy is far away or moving away from us at a pretty decent speed
						TryStartPursuit();
					}
				}
			}
		}
		else
		{
			Pursue();
		}

		//Dodge
		if ( !circleStrafing ) {
			if( combat.shotAtTime && gameLocal.GetTime() - combat.shotAtTime < 1000.0f ) {
				if ( nextBombFireTime < gameLocal.GetTime() - 3000 ) {
					if ( gameLocal.random.RandomFloat() > evadeChance ) {
						//40% chance of ignoring it - makes them dodge rockets less often but bullets more often?
						combat.shotAtTime = 0;
					} else if ( evadeDebounce < gameLocal.GetTime() ) {
						//ramps down from 400 to 100 over 1 second
						float speed = evadeSpeed - ((((float)(gameLocal.GetTime()-combat.shotAtTime))/1000.0f)*(evadeSpeed-(evadeSpeed*0.25f)));
						idVec3 evadeVel = viewAxis[1] * ((combat.shotAtAngle >= 0)?-1:1) * speed;
						evadeVel.z *= 0.5f;
						move.addVelocity += evadeVel;
						move.addVelocity.Normalize();
						move.addVelocity *= speed;
						/*
						if ( move.moveCommand < NUM_NONMOVING_COMMANDS ) {
							//just need to do it once?
							combat.shotAtTime = 0;
						}
						*/
						if ( evadeDebounceRate > 1 )
						{
							evadeDebounce = gameLocal.GetTime() + gameLocal.random.RandomInt( evadeDebounceRate ) + (ceil(((float)evadeDebounceRate)/2.0f));
						}
					}
				}
			}
		}

		//If using melee rush to nav to him, stop when we're close enough to attack
		if ( combat.tacticalCurrent == AITACTICAL_MELEE 
			&& move.moveCommand == MOVE_TO_ENEMY
			&& !move.fl.done
			&& nextBombFireTime < gameLocal.GetTime() - 3000
			&& enemy.fl.visible && DistanceTo( GetEnemy() ) < 2000.0f ) {
			StopMove( MOVE_STATUS_DONE );
			ForceTacticalUpdate();
		} else {
			//whenever we're not in the middle of something, force an update of our tactical
			if ( !aifl.action ) {
				if ( !aasFind ) {
					if ( move.fl.done ) {
						if ( !inPursuit && !circleStrafing ) {
							ForceTacticalUpdate();
						}
					}
				}
			}
		}
	}

	//update light
//	if ( lightOn ) {
		UpdateLightDef ( );
//	}
}