UTIL_Bubbles

From Valve Developer Community
Jump to: navigation, search

UTIL_Bubbles is a UTIL provided in the Source code for creating bubbles spread out within a cubic volume.


Usage

//-----------------------------------------------------------------------------
// Purpose: Creates bubbles spaced throughout the mins/maxes given.
//          
// Input  : &mins   | Vector of the Mins of the box to create
// Input  : &maxs   | Vector of the Maxs of the box to create
// Input  : count   | Number of bubbles
// Output :
//-----------------------------------------------------------------------------
void UTIL_Bubbles( const Vector& mins, const Vector& maxs, int count )
{
	Vector mid =  (mins + maxs) * 0.5;

	float flHeight = UTIL_WaterLevel( mid,  mid.z, mid.z + 1024 );
	flHeight = flHeight - mins.z;

	CPASFilter filter( mid );

	te->Bubbles( filter, 0.0,
		&mins, &maxs, flHeight, g_sModelIndexBubbles, count, 8.0 );
}

Examples

//pHurt->GetAbsOrigin()+ Vector( -32.0f, -32.0f, -32.0f)
//Gets the Origin of pHurt, and then goes 32 units down, 32 behind, and 32 to the right.
//pHurt->GetAbsOrigin()+ Vector( 32.0f, 32.0f, 32.0f )
//Gets the Origin of pHurt, and then goes 32 units up, 32 forwards, and 32 to the left.
//These combine form a 64x64x64 box around pHurt's origin.
//random->RandomInt( 16, 32 ) returns a random Int between 16 and 32 for amount of bubbles to create.

UTIL_Bubbles( pHurt->GetAbsOrigin()+Vector(-32.0f,-32.0f,-32.0f), pHurt->GetAbsOrigin()+Vector(32.0f,32.0f,0.0f), random->RandomInt( 16, 32 ) );
//This example creates bubbles around the end of a Traceline from a Stalker beam attack.
//bInWater is defined elsewhere.
if (bInWater)
{
	UTIL_Bubbles(tr.endpos-Vector(3,3,3),tr.endpos+Vector(3,3,3),10);
}