Exemplo n.º 1
0
/*
================
idBrittleFracture::Spawn
================
*/
void idBrittleFracture::Spawn( void ) {

	// get shard properties
	decalMaterial = declManager->FindMaterial( spawnArgs.GetString( "mtr_decal" ) );
	decalSize = spawnArgs.GetFloat( "decalSize", "40" );
	maxShardArea = spawnArgs.GetFloat( "maxShardArea", "600" );  //shard size.
	maxShardArea = idMath::ClampFloat( 100, 10000, maxShardArea );
	maxShatterRadius = spawnArgs.GetFloat( "maxShatterRadius", "60" ); //destruction radius
	minShatterRadius = spawnArgs.GetFloat( "minShatterRadius", "20" );
	linearVelocityScale = spawnArgs.GetFloat( "linearVelocityScale", "0.1" );
	angularVelocityScale = spawnArgs.GetFloat( "angularVelocityScale", "40" );
	fxFracture = spawnArgs.GetString( "fx" );

	// get rigid body properties
	shardMass = spawnArgs.GetFloat( "shardMass", "20" );
	shardMass = idMath::ClampFloat( 0.001f, 1000.0f, shardMass );
	spawnArgs.GetFloat( "density", "0.1", density );
	density = idMath::ClampFloat( 0.001f, 1000.0f, density );
	spawnArgs.GetFloat( "friction", "0.4", friction );
	friction = idMath::ClampFloat( 0.0f, 1.0f, friction );
	spawnArgs.GetFloat( "bouncyness", "0.01", bouncyness );
	bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness );

	disableFracture = spawnArgs.GetBool( "disableFracture", "0" );
	health = spawnArgs.GetInt( "health", "40" );
	fl.takedamage = true;

	// FIXME: set "bleed" so idProjectile calls AddDamageEffect
	spawnArgs.SetBool( "bleed", 1 );

#ifdef _D3XP
	// check for xray surface
	if ( 1 ) {
		const idRenderModel *model = renderEntity.hModel;

		isXraySurface = false;

		for ( int i = 0; i < model->NumSurfaces(); i++ ) {
			const modelSurface_t *surf = model->Surface( i );

			if ( idStr( surf->shader->GetName() ) == "textures/smf/window_scratch" ) {
				isXraySurface = true;
				break;
			}
		}
	}
#endif

	CreateFractures( renderEntity.hModel );

	FindNeighbours();

	renderEntity.hModel = renderModelManager->AllocModel();
	renderEntity.hModel->InitEmpty( brittleFracture_SnapshotName );
	renderEntity.callback = idBrittleFracture::ModelCallback;
	renderEntity.noShadow = true;
	renderEntity.noSelfShadow = true;
	renderEntity.noDynamicInteractions = false;
}
Exemplo n.º 2
0
/*
================
idBrittleFracture::Spawn
================
*/
void idBrittleFracture::Spawn( void ) {
float sbPercentage, sbDiverge;

	// get shard properties
	decalMaterial = declManager->FindMaterial( spawnArgs.GetString( "mtr_decal" ) );
	decalSize = spawnArgs.GetFloat( "decalSize", "40" );
	maxShardArea = spawnArgs.GetFloat( "maxShardArea", "200" );
	maxShardArea = idMath::ClampFloat( 10, 10000, maxShardArea ); //c4tnt: min changed. I couldn't create a small monastery windows
	maxShatterRadius = spawnArgs.GetFloat( "maxShatterRadius", "40" );
	minShatterRadius = spawnArgs.GetFloat( "minShatterRadius", "10" );
	linearVelocityScale = spawnArgs.GetFloat( "linearVelocityScale", "0.5" );
	angularVelocityScale = spawnArgs.GetFloat( "angularVelocityScale", "1" );
	fxFracture = spawnArgs.GetString( "fx" );

	// get rigid body properties
	shardMass = spawnArgs.GetFloat( "shardMass", "20" );
	shardMass = idMath::ClampFloat( 0.001f, 1000.0f, shardMass );
	spawnArgs.GetFloat( "density", "0.1", density );
	density = idMath::ClampFloat( 0.001f, 1000.0f, density );
	spawnArgs.GetFloat( "friction", "0.4", friction );
	friction = idMath::ClampFloat( 0.0f, 1.0f, friction );
	spawnArgs.GetFloat( "bouncyness", "0.01", bouncyness );
	bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness );

	disableFracture = spawnArgs.GetBool( "disableFracture", "0" );
	health = spawnArgs.GetInt( "health", "40" );
	fl.takedamage = true;

	// FIXME: set "bleed" so idProjectile calls AddDamageEffect
	spawnArgs.SetBool( "bleed", 1 );

	CreateFractures( renderEntity.hModel );

	FindNeighbours();

	spawnArgs.GetFloat( "broken", "0", sbPercentage );
	spawnArgs.GetFloat( "brokediversity", "0.5", sbDiverge );

	if (sbPercentage > 0) {
		StartBroken(sbPercentage,sbDiverge);
	}

	renderEntity.hModel = renderModelManager->AllocModel();
	renderEntity.hModel->InitEmpty( brittleFracture_SnapshotName );
	renderEntity.callback = idBrittleFracture::ModelCallback;
	renderEntity.noShadow = true;
	renderEntity.noSelfShadow = true;
	renderEntity.noDynamicInteractions = false;
}
Exemplo n.º 3
0
/*
================
idBrittleFracture::Spawn
================
*/
void idBrittleFracture::Spawn( void ) {

	// get shard properties
	decalMaterial = declManager->FindMaterial( spawnArgs.GetString( "mtr_decal" ) );
	decalSize = spawnArgs.GetFloat( "decalSize", "40" );
	maxShardArea = spawnArgs.GetFloat( "maxShardArea", "200" );
	maxShardArea = idMath::ClampFloat( 100, 10000, maxShardArea );
	maxShatterRadius = spawnArgs.GetFloat( "maxShatterRadius", "40" );
	minShatterRadius = spawnArgs.GetFloat( "minShatterRadius", "10" );
	linearVelocityScale = spawnArgs.GetFloat( "linearVelocityScale", "0.1" );
	angularVelocityScale = spawnArgs.GetFloat( "angularVelocityScale", "40" );
	fxFracture = spawnArgs.GetString( "fx" );

	// get rigid body properties
	shardMass = spawnArgs.GetFloat( "shardMass", "20" );
	shardMass = idMath::ClampFloat( 0.001f, 1000.0f, shardMass );
	spawnArgs.GetFloat( "density", "0.1", density );
	density = idMath::ClampFloat( 0.001f, 1000.0f, density );
	spawnArgs.GetFloat( "friction", "0.4", friction );
	friction = idMath::ClampFloat( 0.0f, 1.0f, friction );
	spawnArgs.GetFloat( "bouncyness", "0.01", bouncyness );
	bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness );

	disableFracture = spawnArgs.GetBool( "disableFracture", "0" );
	health = spawnArgs.GetInt( "health", "40" );
	fl.takedamage = true;

	// FIXME: set "bleed" so idProjectile calls AddDamageEffect
	spawnArgs.SetBool( "bleed", 1 );

	CreateFractures( renderEntity.hModel );

	FindNeighbours();

	renderEntity.hModel = renderModelManager->AllocModel();
	renderEntity.hModel->InitEmpty( brittleFracture_SnapshotName );
	renderEntity.callback = idBrittleFracture::ModelCallback;
	renderEntity.noShadow = true;
	renderEntity.noSelfShadow = true;
	renderEntity.noDynamicInteractions = false;

	// Dark Mod: see if we are on a visportal
	m_AreaPortal = gameRenderWorld->FindPortal( GetPhysics()->GetAbsBounds() );

	// schedule updating the sound loss for after soundprop gameplay has initialized
	PostEventMS( &EV_UpdateSoundLoss, 20 ); // grayman #3042 - wait for 20ms instead of 0,
											// to give portal entities time to spawn and
											// run their post-spawn
}
Exemplo n.º 4
0
/*
================
idBrittleFracture::Spawn
================
*/
void idBrittleFracture::Spawn()
{

	// get shard properties
	decalMaterial = declManager->FindMaterial( spawnArgs.GetString( "mtr_decal" ) );
	decalSize = spawnArgs.GetFloat( "decalSize", "40" );
	maxShardArea = spawnArgs.GetFloat( "maxShardArea", "200" ) * 2.0f ;
	maxShardArea = idMath::ClampFloat( 100, 10000, maxShardArea );
	maxShatterRadius = spawnArgs.GetFloat( "maxShatterRadius", "40" );
	minShatterRadius = spawnArgs.GetFloat( "minShatterRadius", "10" );
	linearVelocityScale = spawnArgs.GetFloat( "linearVelocityScale", "0.1" );
	angularVelocityScale = spawnArgs.GetFloat( "angularVelocityScale", "40" );
	fxFracture = spawnArgs.GetString( "fx" );
	
	// make sure that max is greater than min  ( otherwise negative number square root happens )
	if( maxShatterRadius < minShatterRadius )
	{
		idLib::Warning( "BrittleFracture, minShatterRadius(%2f) is greater than maxShatterRadius(%2f). Unknown results will ensue.", minShatterRadius, maxShatterRadius );
	}
	
	// get rigid body properties
	shardMass = spawnArgs.GetFloat( "shardMass", "20" );
	shardMass = idMath::ClampFloat( 0.001f, 1000.0f, shardMass );
	spawnArgs.GetFloat( "density", "0.1", density );
	density = idMath::ClampFloat( 0.001f, 1000.0f, density );
	spawnArgs.GetFloat( "friction", "0.4", friction );
	friction = idMath::ClampFloat( 0.0f, 1.0f, friction );
	spawnArgs.GetFloat( "bouncyness", "0.01", bouncyness );
	bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness );
	
	disableFracture = spawnArgs.GetBool( "disableFracture", "0" );
	health = spawnArgs.GetInt( "health", "40" );
	fl.takedamage = true;
	
	// FIXME: set "bleed" so idProjectile calls AddDamageEffect
	spawnArgs.SetBool( "bleed", 1 );
	
	// check for xray surface
	if( renderEntity.hModel != NULL )
	{
		const idRenderModel* model = renderEntity.hModel;
		
		isXraySurface = false;
		
		for( int i = 0; i < model->NumSurfaces(); i++ )
		{
			const modelSurface_t* surf = model->Surface( i );
			
			if( idStr( surf->shader->GetName() ) == "textures/smf/window_scratch" )
			{
				isXraySurface = true;
				break;
			}
		}
	}
	
	CreateFractures( renderEntity.hModel );
	
	FindNeighbours();
	
	defaultRenderModel = renderEntity.hModel;
	renderEntity.hModel = renderModelManager->AllocModel();
	renderEntity.hModel->InitEmpty( brittleFracture_SnapshotName );
	renderEntity.callback = idBrittleFracture::ModelCallback;
	renderEntity.noShadow = true;
	renderEntity.noSelfShadow = true;
	renderEntity.noDynamicInteractions = false;
}
Exemplo n.º 5
0
/*
================
idBrittleFracture::Restore
================
*/
void idBrittleFracture::Restore( idRestoreGame* savefile )
{

	savefile->ReadInt( health );
	savefile->Read( &fl, sizeof( fl ) );
	LittleBitField( &fl, sizeof( fl ) );
	
	// setttings
	savefile->ReadMaterial( material );
	savefile->ReadMaterial( decalMaterial );
	savefile->ReadFloat( decalSize );
	savefile->ReadFloat( maxShardArea );
	savefile->ReadFloat( maxShatterRadius );
	savefile->ReadFloat( minShatterRadius );
	savefile->ReadFloat( linearVelocityScale );
	savefile->ReadFloat( angularVelocityScale );
	savefile->ReadFloat( shardMass );
	savefile->ReadFloat( density );
	savefile->ReadFloat( friction );
	savefile->ReadFloat( bouncyness );
	savefile->ReadString( fxFracture );
	
	// state
	savefile->ReadBounds( bounds );
	savefile->ReadBool( disableFracture );
	
	savefile->ReadInt( lastRenderEntityUpdate );
	savefile->ReadBool( changed );
	
	savefile->ReadModel( defaultRenderModel );
	
	// Reset all brittle Fractures so we can re-break them if necessary
	fl.takedamage = true;
	CreateFractures( defaultRenderModel );
	FindNeighbours();
	
	int numEvents = 0;
	bool resolveBreaks = false;
	savefile->ReadInt( numEvents );
	for( int i = 0; i < numEvents; i++ )
	{
		fractureEvent_s restoredEvent;
		
		savefile->ReadInt( restoredEvent.eventType );
		savefile->ReadVec3( restoredEvent.point );
		savefile->ReadVec3( restoredEvent.vector );
		
		if( restoredEvent.eventType == EVENT_PROJECT_DECAL )
		{
			ProjectDecal( restoredEvent.point, restoredEvent.vector, gameLocal.time, NULL );
		}
		else
		{
			Shatter( restoredEvent.point, restoredEvent.vector, gameLocal.time );
		}
		resolveBreaks = true;
	}
	
	// remove any dropped shards
	for( int i = 0; resolveBreaks && i < shards.Num(); i++ )
	{
		if( shards[i]->droppedTime != -1 )
		{
			RemoveShard( i );
			i--;
		}
	}
	
	renderEntity.hModel = renderModelManager->AllocModel();
	renderEntity.hModel->InitEmpty( brittleFracture_SnapshotName );
	renderEntity.callback = idBrittleFracture::ModelCallback;
	renderEntity.noShadow = true;
	renderEntity.noSelfShadow = true;
	renderEntity.noDynamicInteractions = false;
	
	savefile->ReadBool( isXraySurface );
}