当前位置: 首页>>代码示例>>C++>>正文


C++ CSmartPtr::AddParticle方法代码示例

本文整理汇总了C++中CSmartPtr::AddParticle方法的典型用法代码示例。如果您正苦于以下问题:C++ CSmartPtr::AddParticle方法的具体用法?C++ CSmartPtr::AddParticle怎么用?C++ CSmartPtr::AddParticle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSmartPtr的用法示例。


在下文中一共展示了CSmartPtr::AddParticle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ClientThink

//-----------------------------------------------------------------------------
// Purpose: Trail smoke
//-----------------------------------------------------------------------------
void CASW_Shotgun_Pellet_Predicted::ClientThink( void )
{
return;

	CSmartPtr<CSimpleEmitter> pEmitter = CSimpleEmitter::Create( "CASW_Shotgun_Pellet_Predicted::Effect" );
	PMaterialHandle	hSphereMaterial = pEmitter->GetPMaterial( "sprites/chargeball" );

	// Add particles at the target.
	float flCur = gpGlobals->frametime;
	while ( m_ParticleEvent.NextEvent( flCur ) )
	{
		Vector vecOrigin = GetAbsOrigin() + RandomVector( -2,2 );
		pEmitter->SetSortOrigin( vecOrigin );

		SimpleParticle *pParticle = (SimpleParticle *) pEmitter->AddParticle( sizeof(SimpleParticle), hSphereMaterial, vecOrigin );
		if ( pParticle == NULL )
			return;

		pParticle->m_flLifetime	= 0.0f;
		pParticle->m_flDieTime	= random->RandomFloat( 0.1f, 0.3f );

		pParticle->m_uchStartSize	= random->RandomFloat(2,4);
		pParticle->m_uchEndSize		= pParticle->m_uchStartSize + 2;

		pParticle->m_vecVelocity = vec3_origin;
		pParticle->m_uchStartAlpha = 128;
		pParticle->m_uchEndAlpha = 0;
		pParticle->m_flRoll	= random->RandomFloat( 180, 360 );
		pParticle->m_flRollDelta = random->RandomFloat( -1, 1 );

		pParticle->m_uchColor[0] = 128;
		pParticle->m_uchColor[1] = 128;
		pParticle->m_uchColor[2] = 128;
	}
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:38,代码来源:asw_shotgun_pellet_predicted_shared.cpp

示例2: sizeof

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &origin - 
//			&velocity - 
//			scale - 
//			numParticles - 
//			*pColor - 
//			iAlpha - 
//			*pMaterial - 
//			flRoll - 
//			flRollDelta - 
//-----------------------------------------------------------------------------
CSmartPtr<CSimpleEmitter> FX_Smoke( const Vector &origin, const Vector &velocity, float scale, int numParticles, float flDietime, unsigned char *pColor, int iAlpha, const char *pMaterial, float flRoll, float flRollDelta )
{
	VPROF_BUDGET( "FX_Smoke", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
	CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create( "FX_Smoke" );
	pSimple->SetSortOrigin( origin );

	SimpleParticle *pParticle;

	// Smoke
	for ( int i = 0; i < numParticles; i++ )
	{
		PMaterialHandle hMaterial = pSimple->GetPMaterial( pMaterial );
		pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), hMaterial, origin );			
		if ( pParticle == NULL )
			return NULL;

		pParticle->m_flLifetime = 0.0f;
		pParticle->m_flDieTime = flDietime;
		pParticle->m_vecVelocity = velocity;
		for( int i = 0; i < 3; ++i )
		{
			pParticle->m_uchColor[i] = pColor[i];
		}
		pParticle->m_uchStartAlpha	= iAlpha;
		pParticle->m_uchEndAlpha	= 0;
		pParticle->m_uchStartSize	= scale;
		pParticle->m_uchEndSize		= pParticle->m_uchStartSize*2;
		pParticle->m_flRoll	= flRoll;
		pParticle->m_flRollDelta = flRollDelta;
	}

	return pSimple;
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:45,代码来源:fx.cpp

示例3: ClientThink

//-----------------------------------------------------------------------------
// Purpose: Spawn effects if I'm sapping
//-----------------------------------------------------------------------------
void C_GrenadeAntiPersonnel::ClientThink( void )
{
	// Fire smoke puffs out the side
	CSmartPtr<CSimpleEmitter> pSmokeEmitter = CSimpleEmitter::Create( "AntipersonnelGrenade::Effect" );
	pSmokeEmitter->SetSortOrigin( GetAbsOrigin() );
	int iSmokeClouds = random->RandomInt(1,2);
	for ( int i = 0; i < iSmokeClouds; i++ )
	{
		SimpleParticle *pParticle = (SimpleParticle *) pSmokeEmitter->AddParticle( sizeof(SimpleParticle), g_Mat_DustPuff[1], GetAbsOrigin() );
		if ( pParticle == NULL )
			return;

		pParticle->m_flLifetime	= 0.0f;
		pParticle->m_flDieTime	= random->RandomFloat( 0.1f, 0.3f );

		pParticle->m_uchStartSize	= random->RandomFloat(2,5);
		pParticle->m_uchEndSize		= pParticle->m_uchStartSize + 2;

		pParticle->m_vecVelocity = vec3_origin;
		pParticle->m_uchStartAlpha = 255;
		pParticle->m_uchEndAlpha = 64;
		pParticle->m_flRoll	= random->RandomFloat( 180, 360 );
		pParticle->m_flRollDelta = random->RandomFloat( -1, 1 );

		pParticle->m_uchColor[0] = 50;
		pParticle->m_uchColor[1] = 250;
		pParticle->m_uchColor[2] = 50;
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:32,代码来源:c_grenade_antipersonnel.cpp

示例4: FX_CreateImpactDust

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &origin - 
//			&normal - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void FX_CreateImpactDust( Vector &origin, Vector &normal )
{
	VPROF_BUDGET( "FX_CreateImpactDust", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
	Vector	offset		= origin + ( normal * 4.0f );;

	float	totalScale	= random->RandomFloat( 0.5f, 1.25f );
	float	scale		= random->RandomFloat( 3.0f, 4.0f ) * totalScale;

	CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create( "FX_CreateImpactDust" );

	pSimple->SetSortOrigin( origin );
	
	SimpleParticle *pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof(SimpleParticle), pSimple->GetPMaterial( "particle/particle_sphere" ), offset );
	
	if (pParticle)
	{
		pParticle->m_flLifetime	= 0.0f;
		pParticle->m_flDieTime	= 0.1f;
		
		pParticle->m_uchColor[0] = pParticle->m_uchColor[1] = pParticle->m_uchColor[2] = 255;
		
		pParticle->m_uchStartAlpha	= random->RandomInt( 32, 64 );;
		pParticle->m_uchEndAlpha	= 0;

		pParticle->m_uchStartSize	= scale;
		pParticle->m_uchEndSize		= scale*4.0f;
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:34,代码来源:c_impact_effects.cpp

示例5: UpdateParticles_Active

void C_EnvPortalPathTrack::UpdateParticles_Active ( void )
{
	// Emitters must be valid
	if ( SetupEmitters() == false )
		return;

	// Reset our sort origin
	m_pSimpleEmitter->SetSortOrigin( GetAbsOrigin() );

	SimpleParticle *sParticle;

	// Do the charging particles
	m_pAttractorEmitter->SetAttractorOrigin( GetAbsOrigin() );

	Vector forward, right, up;
	AngleVectors( GetAbsAngles(), &forward, &right, &up );

	Vector	offset;
	float	dist;

	int numParticles = floor( 4.0f );

	for ( int i = 0; i < numParticles; i++ )
	{
		dist = random->RandomFloat( 4.0f, 64.0f );

		offset = forward * dist;

		dist = RemapValClamped( dist, 4.0f, 64.0f, 6.0f, 1.0f );
		offset += right * random->RandomFloat( -4.0f * dist, 4.0f * dist );
		offset += up * random->RandomFloat( -4.0f * dist, 4.0f * dist );

		offset += GetAbsOrigin();

		sParticle = (SimpleParticle *) m_pAttractorEmitter->AddParticle( sizeof(SimpleParticle), m_pAttractorEmitter->GetPMaterial( "effects/strider_muzzle" ), offset );

		if ( sParticle == NULL )
			return;
		
		sParticle->m_vecVelocity	= Vector(0,0,8);
		sParticle->m_flDieTime		= 0.5f;
		sParticle->m_flLifetime		= 0.0f;

		sParticle->m_flRoll			= Helper_RandomInt( 0, 360 );
		sParticle->m_flRollDelta	= 0.0f;

		float alpha = 255;

		sParticle->m_uchColor[0]	= alpha;
		sParticle->m_uchColor[1]	= alpha;
		sParticle->m_uchColor[2]	= alpha;
		sParticle->m_uchStartAlpha	= alpha;
		sParticle->m_uchEndAlpha	= 0;

		sParticle->m_uchStartSize	= random->RandomFloat( 1, 2 );
		sParticle->m_uchEndSize		= 0;
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:58,代码来源:c_env_portal_path_track.cpp

示例6: FX_MetalScrape

void FX_MetalScrape(Vector &position, Vector &normal)
{
    VPROF_BUDGET("FX_MetalScrape", VPROF_BUDGETGROUP_PARTICLE_RENDERING);
    Vector	offset = position + (normal * 1.0f);

    CSmartPtr<CTrailParticles> sparkEmitter = CTrailParticles::Create("FX_MetalScrape 1");

    if (!sparkEmitter)
        return;

    sparkEmitter->SetSortOrigin(offset);

    //Setup our collision information
    sparkEmitter->Setup(offset,
        &normal,
        METAL_SCRAPE_SPREAD,
        METAL_SCRAPE_MINSPEED,
        METAL_SCRAPE_MAXSPEED,
        METAL_SCRAPE_GRAVITY,
        METAL_SCRAPE_DAMPEN,
        bitsPARTICLE_TRAIL_VELOCITY_DAMPEN);

    int	numSparks = random->RandomInt(4, 8);

    if (g_Material_Spark == NULL)
    {
        g_Material_Spark = sparkEmitter->GetPMaterial("effects/spark");
    }

    Vector	dir;
    TrailParticle *pParticle;
    float	length = 0.06f;

    //Dump out sparks
    for (int i = 0; i < numSparks; i++)
    {
        pParticle = (TrailParticle *) sparkEmitter->AddParticle(sizeof(TrailParticle), g_Material_Spark, offset);

        if (pParticle == NULL)
            return;

        pParticle->m_flLifetime = 0.0f;

        float	spreadOfs = random->RandomFloat(0.0f, 2.0f);

        dir[0] = normal[0] + random->RandomFloat(-(METAL_SCRAPE_SPREAD*spreadOfs), (METAL_SCRAPE_SPREAD*spreadOfs));
        dir[1] = normal[1] + random->RandomFloat(-(METAL_SCRAPE_SPREAD*spreadOfs), (METAL_SCRAPE_SPREAD*spreadOfs));
        dir[2] = normal[2] + random->RandomFloat(-(METAL_SCRAPE_SPREAD*spreadOfs), (METAL_SCRAPE_SPREAD*spreadOfs));

        pParticle->m_flWidth = random->RandomFloat(2.0f, 5.0f);
        pParticle->m_flLength = random->RandomFloat(length*0.25f, length);
        pParticle->m_flDieTime = random->RandomFloat(2.0f, 2.0f);

        pParticle->m_vecVelocity = dir * random->RandomFloat((METAL_SCRAPE_MINSPEED*(2.0f - spreadOfs)), (METAL_SCRAPE_MAXSPEED*(2.0f - spreadOfs)));

        Color32Init(pParticle->m_color, 255, 255, 255, 255);
    }
}
开发者ID:Yosam02,项目名称:game,代码行数:58,代码来源:fx_sparks.cpp

示例7: HunterDamageCallback

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void HunterDamageCallback( const CEffectData &data )
{
	CSmartPtr<CSimple3DEmitter> pGlassEmitter = CSimple3DEmitter::Create( "HunterDamage" );
	if ( pGlassEmitter == NULL )
		return;

	pGlassEmitter->SetSortOrigin( data.m_vOrigin );

	// Handle increased scale
	const float flMaxSpeed = 400.0f;
	const float flMinSpeed = 50.0f;
	float flAngularSpray = 1.0f;

	// Setup our collision information
	pGlassEmitter->m_ParticleCollision.Setup( data.m_vOrigin, &data.m_vNormal, flAngularSpray, flMinSpeed, flMaxSpeed, 600.0f, 0.2f );

	Vector	dir, end;

	int	numFlecks = 32;

	Particle3D *pFleckParticle;
	Vector spawnOffset;

	//Dump out flecks
	for ( int i = 0; i < numFlecks; i++ )
	{
		spawnOffset = data.m_vOrigin + RandomVector( -32.0f, 32.0f );
		pFleckParticle = (Particle3D *) pGlassEmitter->AddParticle( sizeof(Particle3D), g_Mat_Fleck_Antlion[random->RandomInt(0,1)], spawnOffset );

		if ( pFleckParticle == NULL )
			break;

		pFleckParticle->m_flLifeRemaining	= random->RandomFloat( 2.0f, 3.0f );

		dir[0] = data.m_vNormal[0] + random->RandomFloat( -flAngularSpray, flAngularSpray );
		dir[1] = data.m_vNormal[1] + random->RandomFloat( -flAngularSpray, flAngularSpray );
		dir[2] = data.m_vNormal[2] + random->RandomFloat( -flAngularSpray, flAngularSpray );

		pFleckParticle->m_uchSize		= random->RandomInt( 3, 8 );

		pFleckParticle->m_vecVelocity	= dir * random->RandomFloat( flMinSpeed, flMaxSpeed);

		pFleckParticle->m_vAngles		= RandomAngle( 0, 360 );
		pFleckParticle->m_flAngSpeed	= random->RandomFloat( -800, 800 );

		unsigned char color = 255;
		pFleckParticle->m_uchFrontColor[0]	= color;
		pFleckParticle->m_uchFrontColor[1]	= color;
		pFleckParticle->m_uchFrontColor[2]	= color;
		pFleckParticle->m_uchBackColor[0]	= color * 0.25f;
		pFleckParticle->m_uchBackColor[1]	= color * 0.25f;
		pFleckParticle->m_uchBackColor[2]	= color * 0.25f;
	}
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:56,代码来源:fx_blood.cpp

示例8: Simulate

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_EntityFlame::Simulate( void )
{
	if (m_bAttachedToHitboxes)
	{
		UpdateHitBoxFlames();
	}
	else
	{
		m_pEmitter->SetSortOrigin( GetAbsOrigin() );

		float tempDelta = gpGlobals->frametime;
		
		SimpleParticle *pParticle;

		Vector	offset;

		while( m_ParticleSpawn.NextEvent( tempDelta ) )
		{
			offset.Random( -m_flSize, m_flSize );

			pParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_MaterialHandle[random->RandomInt( 0, NUM_FLAMELETS-1 )], GetAbsOrigin() + offset );

			if ( pParticle )
			{
				pParticle->m_flDieTime	= 0.4f;
				pParticle->m_flLifetime	= 0.0f;
				
				pParticle->m_flRoll		= random->RandomInt( 0, 360 );
				pParticle->m_flRollDelta= random->RandomFloat( -2.0f, 2.0f );
				
				pParticle->m_uchStartSize	= random->RandomInt( 4, 6 );
				pParticle->m_uchEndSize		= random->RandomInt( 12, 16 );
				pParticle->m_uchStartAlpha	= 255;
				pParticle->m_uchEndAlpha	= 0;
				
				int	cScale = 255;//random->RandomInt( 192, 255 );
				pParticle->m_uchColor[0]	= cScale;
				pParticle->m_uchColor[1]	= cScale;
				pParticle->m_uchColor[2]	= cScale;
				
				Vector dir;

				dir.x = random->RandomFloat( -1.0f, 1.0f );
				dir.y = random->RandomFloat( -1.0f, 1.0f );
				dir.z = random->RandomFloat( 0.5f, 1.0f );

				pParticle->m_vecVelocity	= dir * random->RandomInt( 4, 32 );
				pParticle->m_vecVelocity[2] = random->RandomInt( 32, 64 );
			}
		}
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:55,代码来源:c_fire_smoke.cpp

示例9: MuzzleFlash_Chopper

//-----------------------------------------------------------------------------
// Chopper muzzle flashes
//-----------------------------------------------------------------------------
void MuzzleFlash_Chopper( ClientEntityHandle_t hEntity, int attachmentIndex )
{
	VPROF_BUDGET( "MuzzleFlash_Chopper", VPROF_BUDGETGROUP_PARTICLE_RENDERING );

	matrix3x4_t	matAttachment;
	// If the client hasn't seen this entity yet, bail.
	if ( !FX_GetAttachmentTransform( hEntity, attachmentIndex, matAttachment ) )
		return;
	
	CSmartPtr<CLocalSpaceEmitter> pSimple = CLocalSpaceEmitter::Create( "MuzzleFlash", hEntity, attachmentIndex );

	SimpleParticle *pParticle;
	Vector			forward(1,0,0), offset; //NOTENOTE: All coords are in local space

	float flScale = random->RandomFloat( 2.5f, 4.5f );

	// Flash
	for ( int i = 1; i < 7; i++ )
	{
		offset = (forward * (i*2.0f*flScale));

		pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), pSimple->GetPMaterial( VarArgs( "effects/combinemuzzle%d", random->RandomInt(1,2) ) ), offset );
			
		if ( pParticle == NULL )
			return;

		pParticle->m_flLifetime		= 0.0f;
		pParticle->m_flDieTime		= random->RandomFloat( 0.05f, 0.1f );

		pParticle->m_vecVelocity.Init();

		pParticle->m_uchColor[0]	= 255;
		pParticle->m_uchColor[1]	= 255;
		pParticle->m_uchColor[2]	= 255;

		pParticle->m_uchStartAlpha	= 255;
		pParticle->m_uchEndAlpha	= 128;

		pParticle->m_uchStartSize	= ( (random->RandomFloat( 6.0f, 8.0f ) * (10-(i))/7) * flScale );
		pParticle->m_uchEndSize		= pParticle->m_uchStartSize;
		pParticle->m_flRoll			= random->RandomInt( 0, 360 );
		pParticle->m_flRollDelta	= 0.0f;
	}
	
	// Grab the origin out of the transform for the attachment
	Vector		origin;
	MatrixGetColumn( matAttachment, 3, &origin );	
	CreateMuzzleflashELight( origin, 6, 128, 256, hEntity );
}
开发者ID:Yosam02,项目名称:game,代码行数:52,代码来源:fx_hl2_tracers.cpp

示例10: ClientThink

//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void C_PlasmaBeamNode::ClientThink(void)
{
	if (!m_bSprayOn)
	{
		return;
	}
	
	trace_t trace;
	Vector vEndTrace = GetAbsOrigin() + (0.3*GetAbsVelocity());
	UTIL_TraceLine( GetAbsOrigin(), vEndTrace, MASK_SHOT, NULL, COLLISION_GROUP_NONE, &trace );
	if ( trace.fraction != 1.0f || trace.startsolid)
	{
		m_bSprayOn = false;
		return;
	}

	PMaterialHandle handle = m_pFirePlasmaSpray->GetPMaterial( "sprites/plasmaember" );
	for (int i=0;i<SPRAYS_PER_THINK;i++)
	{
		SimpleParticle	*sParticle;

		//Make a new particle
		if ( random->RandomInt( 0, 2 ) == 0 )
		{
			float ranx = random->RandomFloat( -28.0f, 28.0f );
			float rany = random->RandomFloat( -28.0f, 28.0f );
			float ranz = random->RandomFloat( -28.0f, 28.0f );

			Vector vNewPos	=  GetAbsOrigin();
			Vector vAdd		=  Vector(GetAbsAngles().x,GetAbsAngles().y,GetAbsAngles().z)*random->RandomFloat(-60,120);
			vNewPos			+= vAdd;

			sParticle = (SimpleParticle *) m_pFirePlasmaSpray->AddParticle( sizeof(SimpleParticle), handle, vNewPos );
			
			sParticle->m_flLifetime		= 0.0f;
			sParticle->m_flDieTime		= PLASMASPARK_LIFETIME;

			sParticle->m_vecVelocity	= GetAbsVelocity();
			sParticle->m_vecVelocity.x	+= ranx;
			sParticle->m_vecVelocity.y	+= rany;
			sParticle->m_vecVelocity.z	+= ranz;
			m_pFirePlasmaSpray->m_pOwner	=  this;
		}
	}

	SetNextClientThink(gpGlobals->curtime + 0.05);
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:52,代码来源:c_plasma_beam_node.cpp

示例11: WheelDustCallback

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &data - 
//-----------------------------------------------------------------------------
void WheelDustCallback( const CEffectData &data )
{
	CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create( "dust" );
	pSimple->SetSortOrigin( data.m_vOrigin );
	pSimple->SetNearClip( 32, 64 );

	SimpleParticle	*pParticle;

	Vector	offset;

	//FIXME: Better sampling area
	offset = data.m_vOrigin + ( data.m_vNormal * data.m_flScale );
	
	//Find area ambient light color and use it to tint smoke
	Vector	worldLight = WorldGetLightForPoint( offset, true );

	//Throw puffs
	offset.Random( -(data.m_flScale*16.0f), data.m_flScale*16.0f );
	offset.z = 0.0f;
	offset += data.m_vOrigin + ( data.m_vNormal * data.m_flScale );

	pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof(SimpleParticle), g_Mat_DustPuff[0], offset );

	if ( pParticle != NULL )
	{			
		pParticle->m_flLifetime		= 0.0f;
		pParticle->m_flDieTime		= random->RandomFloat( 0.25f, 0.5f );
		
		pParticle->m_vecVelocity = RandomVector( -1.0f, 1.0f );
		VectorNormalize( pParticle->m_vecVelocity );
		pParticle->m_vecVelocity[2] += random->RandomFloat( 16.0f, 32.0f ) * (data.m_flScale*2.0f);

		int	color = random->RandomInt( 100, 150 );

		pParticle->m_uchColor[0] = 16 + ( worldLight[0] * (float) color );
		pParticle->m_uchColor[1] = 8 + ( worldLight[1] * (float) color );
		pParticle->m_uchColor[2] = ( worldLight[2] * (float) color );

		pParticle->m_uchStartAlpha	= random->RandomInt( 64.0f*data.m_flScale, 128.0f*data.m_flScale );
		pParticle->m_uchEndAlpha	= 0;
		pParticle->m_uchStartSize	= random->RandomInt( 16, 24 ) * data.m_flScale;
		pParticle->m_uchEndSize		= random->RandomInt( 32, 48 ) * data.m_flScale;
		pParticle->m_flRoll			= random->RandomInt( 0, 360 );
		pParticle->m_flRollDelta	= random->RandomFloat( -2.0f, 2.0f );
	}
}
开发者ID:BerntA,项目名称:tfo-code,代码行数:50,代码来源:c_vehicle_jeep.cpp

示例12: AddRisingParticles

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : flPerc - 
//-----------------------------------------------------------------------------
void C_MortarShell::AddRisingParticles( float flPerc )
{
	SimpleParticle *sParticle;

	Vector offset;
	float radius = m_flRadius * 0.25f * flPerc;

	float val = RemapValClamped( gpGlobals->curtime, m_flStarttime, m_flStarttime + m_flLifespan, 0.0f, 1.0f );

	float flCur = gpGlobals->frametime;

	// Anime ground effects
	while ( m_ParticleEvent.NextEvent( flCur ) )
	{
		offset.x = random->RandomFloat( -radius, radius );
		offset.y = random->RandomFloat( -radius, radius );
		offset.z = random->RandomFloat( -8.0f, 8.0f );

		offset += GetAbsOrigin();

		sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/spark" ), offset );
		
		if ( sParticle == NULL )
			return;

		sParticle->m_vecVelocity = Vector( Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( 32.0f, 256.0f ) * Bias( val, 0.25f ) );
		
		sParticle->m_uchStartSize	= random->RandomFloat( 4, 8 ) * flPerc;

		sParticle->m_flDieTime = random->RandomFloat( 0.5f, 1.0f );
		
		sParticle->m_flLifetime		= 0.0f;

		sParticle->m_flRoll			= Helper_RandomInt( 0, 360 );

		float alpha = 255 * flPerc;

		sParticle->m_flRollDelta	= Helper_RandomFloat( -8.0f * flPerc, 8.0f * flPerc );
		sParticle->m_uchColor[0]	= alpha;
		sParticle->m_uchColor[1]	= alpha;
		sParticle->m_uchColor[2]	= alpha;
		sParticle->m_uchStartAlpha	= alpha;
		sParticle->m_uchEndAlpha	= 0;
		sParticle->m_uchEndSize		= 0;
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:50,代码来源:c_func_tankmortar.cpp

示例13: ClientThink

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_EnvStarfield::ClientThink( void )
{
	if ( !m_bOn || !m_flDensity ) 
		return;

	PMaterialHandle	hParticleMaterial = m_pEmitter->GetPMaterial( "effects/spark_noz" );

	// Find a start & end point for the particle
	// Start particles straight ahead of the client
	Vector vecViewOrigin = MainViewOrigin(engine->GetActiveSplitScreenPlayerSlot());

	// Determine the number of particles
	m_flNumParticles += 1.0 * (m_flDensity);
	int iNumParticles = floor(m_flNumParticles);
	m_flNumParticles -= iNumParticles;

	// Add particles
	for ( int i = 0; i < iNumParticles; i++ )
	{
		float flDiameter = cl_starfield_diameter.GetFloat();

		Vector vecStart = vecViewOrigin + (MainViewForward(engine->GetActiveSplitScreenPlayerSlot()) * cl_starfield_distance.GetFloat() );
		Vector vecEnd = vecViewOrigin + (MainViewRight(engine->GetActiveSplitScreenPlayerSlot()) * RandomFloat(-flDiameter,flDiameter)) + (MainViewUp(engine->GetActiveSplitScreenPlayerSlot()) * RandomFloat(-flDiameter,flDiameter));
		Vector vecDir = (vecEnd - vecStart);
		float flDistance = VectorNormalize( vecDir );
		float flTravelTime = 2.0;
		
		// Start a random amount along the path
		vecStart += vecDir * ( RandomFloat(0.1,0.3) * flDistance );

		TrailParticle *pParticle = (TrailParticle *) m_pEmitter->AddParticle( sizeof(TrailParticle), hParticleMaterial, vecStart );
		if ( pParticle )
		{
			pParticle->m_vecVelocity = vecDir * (flDistance / flTravelTime);
			pParticle->m_flDieTime = flTravelTime;
			pParticle->m_flLifetime = 0;
			pParticle->m_flWidth = RandomFloat( 1, 3 );
			pParticle->m_flLength = RandomFloat( 0.05, 0.4 );
			pParticle->m_color.r	= 255;
			pParticle->m_color.g	= 255;
			pParticle->m_color.b	= 255;
			pParticle->m_color.a	= 255;
		}
	}
}
开发者ID:Muini,项目名称:Nag-asw,代码行数:48,代码来源:c_env_starfield.cpp

示例14: AddExplodingParticles

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : flPerc - 
//-----------------------------------------------------------------------------
void C_MortarShell::AddExplodingParticles( float flPerc )
{
	SimpleParticle *sParticle;

	Vector offset;
	float radius = 48.0f * flPerc;

	float flCur = gpGlobals->frametime;

	// Anime ground effects
	while ( m_ParticleEvent.NextEvent( flCur ) )
	{
		offset.x = random->RandomFloat( -radius, radius );
		offset.y = random->RandomFloat( -radius, radius );
		offset.z = random->RandomFloat( -8.0f, 8.0f );

		offset += GetAbsOrigin();

		sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/spark" ), offset );
		
		if ( sParticle == NULL )
			return;

		sParticle->m_vecVelocity = RandomVector( -1.0f, 1.0f ) + Vector( 0, 0, 1 );
		sParticle->m_vecVelocity *= ( 750.0f * flPerc );
		
		sParticle->m_uchStartSize	= random->RandomFloat( 2, 4 ) * flPerc;

		sParticle->m_flDieTime = random->RandomFloat( 0.25f, 0.5f );
		
		sParticle->m_flLifetime		= 0.0f;

		sParticle->m_flRoll			= Helper_RandomInt( 0, 360 );

		float alpha = 255 * flPerc;

		sParticle->m_flRollDelta	= Helper_RandomFloat( -8.0f * flPerc, 8.0f * flPerc );
		sParticle->m_uchColor[0]	= alpha;
		sParticle->m_uchColor[1]	= alpha;
		sParticle->m_uchColor[2]	= alpha;
		sParticle->m_uchStartAlpha	= alpha;
		sParticle->m_uchEndAlpha	= 0;
		sParticle->m_uchEndSize		= 0;
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:49,代码来源:c_func_tankmortar.cpp

示例15: PostDataUpdate

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bool - 
//-----------------------------------------------------------------------------
void C_TEShowLine::PostDataUpdate( DataUpdateType_t updateType )
{
	Vector		vec;
	float		len;
	StandardParticle_t	*p;
	int			dec;
	static int	tracercount;

	VectorSubtract (m_vecEnd, m_vecOrigin, vec);
	len = VectorNormalize (vec);

	dec = 3;

	VectorScale(vec, dec, vec);

	CSmartPtr<CTEParticleRenderer> pRen = CTEParticleRenderer::Create( "TEShowLine", m_vecOrigin );
	if( !pRen )
		return;
	
	while (len > 0)
	{
		len -= dec;

		p = pRen->AddParticle();
		if ( p )
		{
			p->m_Velocity.Init();

			pRen->SetParticleLifetime(p, 30);
			
			p->SetColor(0, 1, 1);
			p->SetAlpha(1);
			pRen->SetParticleType(p, pt_static);

			p->m_Pos = m_vecOrigin;
			
			m_vecOrigin += vec;
		}
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:44,代码来源:c_te_showline.cpp


注:本文中的CSmartPtr::AddParticle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。