Пример #1
0
void CParticleSystemLibrary::MakeQuad()
{
	if (Get()->m_iQuadVBO != ~0)
		return;

	CRenderingContext c(GameServer()->GetRenderer());

	float flRadius = 1;
	Vector vecOrigin(0, 0, 0);

	Vector vecParticleUp = Vector(0, 0, flRadius);
	Vector vecParticleRight = Vector(0, flRadius, 0);

	Vector vecTL = vecOrigin - vecParticleRight + vecParticleUp;
	Vector vecTR = vecOrigin + vecParticleRight + vecParticleUp;
	Vector vecBL = vecOrigin - vecParticleRight - vecParticleUp;
	Vector vecBR = vecOrigin + vecParticleRight - vecParticleUp;

	c.BeginRenderTris();

	c.TexCoord(0.0f, 1.0f);
	c.Vertex(vecTL);
	c.TexCoord(1.0f, 0.0f);
	c.Vertex(vecBR);
	c.TexCoord(1.0f, 1.0f);
	c.Vertex(vecTR);
	c.TexCoord(0.0f, 1.0f);
	c.Vertex(vecTL);
	c.TexCoord(0.0f, 0.0f);
	c.Vertex(vecBL);
	c.TexCoord(1.0f, 0.0f);
	c.Vertex(vecBR);

	c.CreateVBO(Get()->m_iQuadVBO, Get()->m_iQuadVBOSize);
}
Пример #2
0
// Glory to the maker of Zeus TF2 base for getting the math part down
bool TF2Player::GetHitboxPos(Vector& v, int hitboxindex, BonePos::Enum pos)
{
    if (hitboxindex == -1){
        v = vecOrigin();
        return true;
    }
    int correctedhitbox = CorrectedHitbox(hitboxindex);
        
    if (correctedhitbox > 20)
        return false;

    matrix3x4_t pmatrix[MAXSTUDIOBONES];

    IClientEntity* clientent = ValveInterfaces::pClientEntList->GetClientEntity( this->index() );

    if(!clientent || !clientent->SetupBones(pmatrix, MAXSTUDIOBONES, BONE_USED_BY_HITBOX, 0)) return false;

    studiohdr_t* pStudioHdr = 0;

    if(isDisguised())
    {
        const int ispyindex = ValveInterfaces::pModelInfo->GetModelIndex("models/player/spy.mdl");
        const model_t *pSpyModel = ValveInterfaces::pModelInfo->GetModel( ispyindex );
        pStudioHdr = ValveInterfaces::pModelInfo->GetStudiomodel( pSpyModel );
    }
    else
    {
        const model_t* modelinfo = clientent->GetModel();
        pStudioHdr = ValveInterfaces::pModelInfo->GetStudiomodel(modelinfo);
    }

    mstudiobbox_t* hitbox = pStudioHdr->pHitbox(correctedhitbox, 0);

    MatrixAngles( pmatrix[ hitbox->bone ], angEyeAngles(), v );

    Vector min,max;
    VectorTransform( hitbox->bbmin, pmatrix[ hitbox->bone ], min );
    VectorTransform( hitbox->bbmax, pmatrix[ hitbox->bone ], max );

    if (pos == BonePos::MIDDLE)
        v = ((min + max) * 0.5f);//LOL FLOATING POINT OPTIMIZATIONS
    else if (pos == BonePos::MIN)
        v = min;
    else 
        v = max;
    return true;
}
Пример #3
0
void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ 
	TraceResult tr;

	pev->model = iStringNull;//invisible
	pev->solid = SOLID_NOT;// intangible

	Vector		vecSpot;// trace starts here!

	//LRC
	if (FStringNull(pev->target))
	{
		vecSpot = pev->origin;
	}
	else
	{
		vecSpot = CalcLocus_Position(this, pActivator, STRING(pev->target));
	}
		
	UTIL_TraceLine ( vecSpot + Vector( 0, 0, 8 ), vecSpot + Vector ( 0, 0, -32 ),  ignore_monsters, ENT(pev), & tr);
	
	// Pull out of the wall a bit
	if ( tr.flFraction != 1.0 )
	{
		pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6);
	}
	else
	{
		pev->origin = vecSpot; //LRC
	}

	// draw decal
	if (! ( pev->spawnflags & SF_ENVEXPLOSION_NODECAL))
	{
		if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 )
		{
			UTIL_DecalTrace( &tr, DECAL_SCORCH1 );
		}
		else
		{
			UTIL_DecalTrace( &tr, DECAL_SCORCH2 );
		}
	}

	// draw fireball
	if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) )
	{
		Vector vecOrigin(pev->origin.x, pev->origin.y, pev->origin.z);
		MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
			WRITE_BYTE( TE_EXPLOSION);
			WRITE_COORD(vecOrigin.x);
			WRITE_COORD(vecOrigin.y);
			WRITE_COORD(vecOrigin.z);
			WRITE_SHORT( g_sModelIndexFireball );
			WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10
			WRITE_BYTE( 15  ); // framerate
			WRITE_BYTE(TE_EXPLFLAG_NOSOUND);
		MESSAGE_END();

		UTIL_EmitAmbientSound(ENT(pev), vecOrigin, "weapons/explode3.wav", VOL_NORM, 0.6, 0, 100);
	}
	else
	{
		Vector vecOrigin(pev->origin.x, pev->origin.y, pev->origin.z);
		MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
			WRITE_BYTE( TE_EXPLOSION);
			WRITE_COORD(vecOrigin.x);
			WRITE_COORD(vecOrigin.y);
			WRITE_COORD(vecOrigin.z);
			WRITE_SHORT( g_sModelIndexFireball );
			WRITE_BYTE( 0 ); // no sprite
			WRITE_BYTE( 15  ); // framerate
			WRITE_BYTE(TE_EXPLFLAG_NOSOUND);
		MESSAGE_END();

		UTIL_EmitAmbientSound(ENT(pev), vecOrigin, "weapons/explode3.wav", VOL_NORM, 0.6, 0, 100);
	}

	// do damage
	if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) )
	{
		RadiusDamage ( pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST );
	}

	SetThink(&CEnvExplosion:: Smoke );
	SetNextThink( 0.3 );

	// draw sparks
	if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) )
	{
		int sparkCount = RANDOM_LONG(0,3);

		for ( int i = 0; i < sparkCount; i++ )
		{
			Create( "spark_shower", pev->origin, tr.vecPlaneNormal, NULL );
		}
	}
}