本文整理汇总了C++中C_BaseAnimating::GetHitboxSet方法的典型用法代码示例。如果您正苦于以下问题:C++ C_BaseAnimating::GetHitboxSet方法的具体用法?C++ C_BaseAnimating::GetHitboxSet怎么用?C++ C_BaseAnimating::GetHitboxSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_BaseAnimating
的用法示例。
在下文中一共展示了C_BaseAnimating::GetHitboxSet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FX_BuildTeslaHitbox
//-----------------------------------------------------------------------------
// Purpose: Tesla effect
//-----------------------------------------------------------------------------
void FX_BuildTeslaHitbox( const CEffectData &data )
{
Vector vColor( 1, 1, 1 );
C_BaseEntity *pEntity = ClientEntityList().GetEnt( data.entindex() );
C_BaseAnimating *pAnimating = pEntity ? pEntity->GetBaseAnimating() : NULL;
if (!pAnimating)
return;
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if (!pStudioHdr)
return;
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( !set )
return;
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( !pAnimating->HitboxToWorldTransforms( hitboxbones ) )
return;
int nBeamCount = (int)(data.m_flMagnitude + 0.5f);
for ( int i = 0; i < nBeamCount; ++i )
{
int nStartHitBox = random->RandomInt( 1, set->numhitboxes );
int nEndHitBox = random->RandomInt( 1, set->numhitboxes );
FX_BuildTeslaHitbox( pEntity, nStartHitBox, nEndHitBox, data.m_flScale, vColor, random->RandomFloat( 0.05f, 0.2f ) );
}
}
示例2: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_EntityParticleTrail::Update( float fTimeDelta )
{
float tempDelta = fTimeDelta;
studiohdr_t *pStudioHdr;
mstudiohitboxset_t *set;
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
C_BaseEntity *pMoveParent = GetMoveParent();
if ( !pMoveParent )
return;
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if (!pAnimating)
goto trailNoHitboxes;
if ( !pAnimating->HitboxToWorldTransforms( hitboxbones ) )
goto trailNoHitboxes;
pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if (!pStudioHdr)
goto trailNoHitboxes;
set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( !set )
goto trailNoHitboxes;
//Add new particles
while ( m_teParticleSpawn.NextEvent( tempDelta ) )
{
int nHitbox = random->RandomInt( 0, set->numhitboxes - 1 );
mstudiobbox_t *pBox = set->pHitbox(nHitbox);
AddParticle( tempDelta, pBox->bbmin, pBox->bbmax, *hitboxbones[pBox->bone] );
}
return;
trailNoHitboxes:
while ( m_teParticleSpawn.NextEvent( tempDelta ) )
{
AddParticle( tempDelta, pMoveParent->CollisionProp()->OBBMins(), pMoveParent->CollisionProp()->OBBMaxs(), pMoveParent->EntityToWorldTransform() );
}
}
示例3: DrawModel
//-----------------------------------------------------------------------------
// Purpose:
// Input : flags -
// Output : int
//-----------------------------------------------------------------------------
int C_EntityDissolve::DrawModel( int flags )
{
// See if we should draw
if ( gpGlobals->frametime == 0 || m_bReadyToDraw == false )
return 0;
C_BaseAnimating *pAnimating = GetMoveParent() ? GetMoveParent()->GetBaseAnimating() : NULL;
if ( pAnimating == NULL )
return 0;
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) == false )
return 0;
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr == NULL )
return false;
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( set == NULL )
return false;
// Make sure the emitter is setup properly
SetupEmitter();
// Get fade percentages for the effect
float fadeInPerc = GetFadeInPercentage();
float fadeOutPerc = GetFadeOutPercentage();
float fadePerc = ( fadeInPerc >= 1.0f ) ? fadeOutPerc : fadeInPerc;
Vector vecSkew = vec3_origin;
// Do extra effects under certain circumstances
if ( ( fadePerc < 0.99f ) && ( (m_nDissolveType == ENTITY_DISSOLVE_ELECTRICAL) || (m_nDissolveType == ENTITY_DISSOLVE_ELECTRICAL_LIGHT) ) )
{
DoSparks( set, hitboxbones );
}
// Skew the particles in front or in back of their targets
vecSkew = CurrentViewForward() * ( 8.0f - ( ( 1.0f - fadePerc ) * 32.0f ) );
float spriteScale = ( ( gpGlobals->curtime - m_flStartTime ) / m_flFadeOutLength );
spriteScale = clamp( spriteScale, 0.75f, 1.0f );
// Cache off this material reference
if ( g_Material_Spark == NULL )
{
g_Material_Spark = ParticleMgr()->GetPMaterial( "effects/spark" );
}
if ( g_Material_AR2Glow == NULL )
{
g_Material_AR2Glow = ParticleMgr()->GetPMaterial( "effects/combinemuzzle2" );
}
SimpleParticle *sParticle;
for ( int i = 0; i < set->numhitboxes; ++i )
{
Vector vecAbsOrigin, xvec, yvec;
mstudiobbox_t *pBox = set->pHitbox(i);
ComputeRenderInfo( pBox, *hitboxbones[pBox->bone], &vecAbsOrigin, &xvec, &yvec );
Vector offset;
Vector xDir, yDir;
xDir = xvec;
float xScale = VectorNormalize( xDir ) * 0.75f;
yDir = yvec;
float yScale = VectorNormalize( yDir ) * 0.75f;
int numParticles = clamp( 3.0f * fadePerc, 0.f, 3.f );
int iTempParts = 2;
if ( m_nDissolveType == ENTITY_DISSOLVE_CORE )
{
if ( m_bCoreExplode == true )
{
numParticles = 15;
iTempParts = 20;
}
}
for ( int j = 0; j < iTempParts; j++ )
{
// Skew the origin
offset = xDir * Helper_RandomFloat( -xScale*0.5f, xScale*0.5f ) + yDir * Helper_RandomFloat( -yScale*0.5f, yScale*0.5f );
offset += vecSkew;
if ( random->RandomInt( 0, 2 ) != 0 )
continue;
//.........这里部分代码省略.........
示例4: DrawModel
//-----------------------------------------------------------------------------
// Purpose:
// Input : flags -
// Output : int
//-----------------------------------------------------------------------------
int C_WeaponPhysCannon::DrawModel( int flags )
{
// If we're not ugrading, don't do anything special
if ( m_bIsCurrentlyUpgrading == false && m_bWasUpgraded == false )
return BaseClass::DrawModel( flags );
if ( gpGlobals->frametime == 0 )
return BaseClass::DrawModel( flags );
if ( !m_bReadyToDraw )
return 0;
m_bWasUpgraded = true;
// Create the particle emitter if it's not already
if ( SetupEmitter() )
{
// Add the power-up particles
// See if we should draw
if ( m_bReadyToDraw == false )
return 0;
C_BaseAnimating *pAnimating = GetBaseAnimating();
if (!pAnimating)
return 0;
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( !pAnimating->HitboxToWorldTransforms( hitboxbones ) )
return 0;
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if (!pStudioHdr)
return false;
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( !set )
return false;
int i;
float fadePerc = 1.0f;
if ( m_bIsCurrentlyUpgrading )
{
Vector vecSkew = vec3_origin;
// Skew the particles in front or in back of their targets
vecSkew = CurrentViewForward() * 4.0f;
float spriteScale = 1.0f;
spriteScale = clamp( spriteScale, 0.75f, 1.0f );
SimpleParticle *sParticle;
for ( i = 0; i < set->numhitboxes; ++i )
{
Vector vecAbsOrigin, xvec, yvec;
mstudiobbox_t *pBox = set->pHitbox(i);
ComputeRenderInfo( pBox, *hitboxbones[pBox->bone], &vecAbsOrigin, &xvec, &yvec );
Vector offset;
Vector xDir, yDir;
xDir = xvec;
float xScale = VectorNormalize( xDir ) * 0.75f;
yDir = yvec;
float yScale = VectorNormalize( yDir ) * 0.75f;
int numParticles = clamp( 4.0f * fadePerc, 1, 3 );
for ( int j = 0; j < numParticles; j++ )
{
offset = xDir * Helper_RandomFloat( -xScale*0.5f, xScale*0.5f ) + yDir * Helper_RandomFloat( -yScale*0.5f, yScale*0.5f );
offset += vecSkew;
sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/combinemuzzle1" ), vecAbsOrigin + offset );
if ( sParticle == NULL )
return 1;
sParticle->m_vecVelocity = vec3_origin;
sParticle->m_uchStartSize = 16.0f * spriteScale;
sParticle->m_flDieTime = 0.2f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = Helper_RandomFloat( -2.0f, 2.0f );
float alpha = 40;
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
//.........这里部分代码省略.........
示例5: IsPointInControllingObjectHitBox
bool CParticleSystemQuery::IsPointInControllingObjectHitBox(
CParticleCollection *pParticles,
int nControlPointNumber, Vector vecPos, bool bBBoxOnly )
{
bool bSuccess = false;
#ifndef GAME_DLL
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->m_ControlPoints[nControlPointNumber].m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
s_BoneMutex.Lock();
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
bool bInBBox = false;
Vector vecBBoxMin;
Vector vecBBoxMax;
Vector vecOrigin;
vecBBoxMin = pMoveParent->CollisionProp()->OBBMins();
vecBBoxMax = pMoveParent->CollisionProp()->OBBMaxs();
matrix3x4_t matOrientation;
matOrientation = pMoveParent->EntityToWorldTransform();
Vector vecLocalPos;
VectorITransform( vecPos, matOrientation, vecLocalPos );
if ( IsPointInBox( vecLocalPos, vecBBoxMin, vecBBoxMax ) )
bInBBox = true;
if ( bInBBox && bBBoxOnly )
bSuccess = true;
else if ( pAnimating && bInBBox )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( set )
{
// do a point in solid test
Ray_t ray;
trace_t tr;
ray.Init( vecPos, vecPos );
enginetrace->ClipRayToEntity( ray, MASK_ALL, pMoveParent, &tr );
if ( tr.startsolid )
bSuccess = true;
}
}
}
}
else if ( pMoveParent->IsBrushModel() && bInBBox )
{
// do a point in solid test
Ray_t ray;
trace_t tr;
ray.Init( vecPos, vecPos );
enginetrace->ClipRayToEntity( ray, MASK_ALL, pMoveParent, &tr );
if ( tr.startsolid )
bSuccess = true;
}
s_BoneMutex.Unlock();
}
#endif
return bSuccess;
}
示例6: GetControllingObjectHitBoxInfo
int CParticleSystemQuery::GetControllingObjectHitBoxInfo(
CParticleCollection *pParticles,
int nControlPointNumber,
int nBufSize, // # of output slots available
ModelHitBoxInfo_t *pHitBoxOutputBuffer )
{
int nRet = 0;
#ifndef GAME_DLL
s_BoneMutex.Lock();
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->m_ControlPoints[nControlPointNumber].m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if ( pAnimating )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( set )
{
nRet = min( nBufSize, set->numhitboxes );
for( int i=0 ; i < nRet; i++ )
{
mstudiobbox_t *pBox = set->pHitbox( i );
pHitBoxOutputBuffer[i].m_vecBoxMins.x = pBox->bbmin.x;
pHitBoxOutputBuffer[i].m_vecBoxMins.y = pBox->bbmin.y;
pHitBoxOutputBuffer[i].m_vecBoxMins.z = pBox->bbmin.z;
pHitBoxOutputBuffer[i].m_vecBoxMaxes.x = pBox->bbmax.x;
pHitBoxOutputBuffer[i].m_vecBoxMaxes.y = pBox->bbmax.y;
pHitBoxOutputBuffer[i].m_vecBoxMaxes.z = pBox->bbmax.z;
pHitBoxOutputBuffer[i].m_Transform = *hitboxbones[pBox->bone];
}
}
}
}
}
if ( pMoveParent->IsBrushModel() )
{
Vector vecMin;
Vector vecMax;
matrix3x4_t matOrientation;
pMoveParent->GetRenderBounds( vecMin, vecMax );
matOrientation = pMoveParent->EntityToWorldTransform();
pHitBoxOutputBuffer[0].m_vecBoxMins = vecMin;
pHitBoxOutputBuffer[0].m_vecBoxMaxes = vecMax;
pHitBoxOutputBuffer[0].m_Transform = matOrientation;
nRet = 1;
}
}
s_BoneMutex.Unlock();
#endif
return nRet;
}
示例7: GetRandomPointsOnControllingObjectHitBox
void CParticleSystemQuery::GetRandomPointsOnControllingObjectHitBox(
CParticleCollection *pParticles,
int nControlPointNumber,
int nNumPtsOut,
float flBBoxScale,
int nNumTrysToGetAPointInsideTheModel,
Vector *pPntsOut,
Vector vecDirectionalBias,
Vector *pHitBoxRelativeCoordOut,
int *pHitBoxIndexOut
)
{
bool bSucesss = false;
#ifndef GAME_DLL
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->m_ControlPoints[nControlPointNumber].m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
float flRandMax = flBBoxScale;
float flRandMin = 1.0 - flBBoxScale;
Vector vecBasePos;
pParticles->GetControlPointAtTime( nControlPointNumber, pParticles->m_flCurTime, &vecBasePos );
s_BoneMutex.Lock();
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if ( pAnimating )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( set )
{
bSucesss = true;
Vector vecWorldPosition;
float u = 0, v = 0, w = 0;
int nHitbox = 0;
int nNumIters = nNumTrysToGetAPointInsideTheModel;
if (! vecDirectionalBias.IsZero( 0.0001 ) )
nNumIters = max( nNumIters, 5 );
for( int i=0 ; i < nNumPtsOut; i++)
{
int nTryCnt = nNumIters;
float flBestPointGoodness = -1.0e20;
do
{
int nTryHitbox = pParticles->RandomInt( 0, set->numhitboxes - 1 );
mstudiobbox_t *pBox = set->pHitbox(nTryHitbox);
float flTryU = pParticles->RandomFloat( flRandMin, flRandMax );
float flTryV = pParticles->RandomFloat( flRandMin, flRandMax );
float flTryW = pParticles->RandomFloat( flRandMin, flRandMax );
Vector vecLocalPosition;
vecLocalPosition.x = GetSurfaceCoord( flTryU, pBox->bbmin.x, pBox->bbmax.x );
vecLocalPosition.y = GetSurfaceCoord( flTryV, pBox->bbmin.y, pBox->bbmax.y );
vecLocalPosition.z = GetSurfaceCoord( flTryW, pBox->bbmin.z, pBox->bbmax.z );
Vector vecTryWorldPosition;
VectorTransform( vecLocalPosition, *hitboxbones[pBox->bone], vecTryWorldPosition );
float flPointGoodness = pParticles->RandomFloat( 0, 72 )
+ DotProduct( vecTryWorldPosition - vecBasePos,
vecDirectionalBias );
if ( nNumTrysToGetAPointInsideTheModel )
{
// do a point in solid test
Ray_t ray;
trace_t tr;
ray.Init( vecTryWorldPosition, vecTryWorldPosition );
enginetrace->ClipRayToEntity( ray, MASK_ALL, pMoveParent, &tr );
if ( tr.startsolid )
flPointGoodness += 1000.; // got a point inside!
}
if ( flPointGoodness > flBestPointGoodness )
{
u = flTryU;
v = flTryV;
w = flTryW;
//.........这里部分代码省略.........
示例8: GetControllingObjectHitBoxInfo
int CParticleSystemQuery::GetControllingObjectHitBoxInfo(
CParticleCollection *pParticles,
int nControlPointNumber,
int nBufSize, // # of output slots available
ModelHitBoxInfo_t *pHitBoxOutputBuffer )
{
int nRet = 0;
#ifndef GAME_DLL
s_BoneMutex.Lock();
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->ControlPoint( nControlPointNumber ).m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if ( pAnimating )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
// Try to get the "effects" set first, otherwise use their current set
int nEffectsHitboxSet = FindHitboxSetByName( pAnimating->GetModelPtr(), "effects" );
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( nEffectsHitboxSet != -1 ? nEffectsHitboxSet : pAnimating->GetHitboxSet() );
if ( set )
{
for( int i=0 ; i < set->numhitboxes; i++ )
{
mstudiobbox_t *pBox = set->pHitbox( i );
// E3 HACK - check for hitboxes at the origin and ignore those
if ( fabs( (*hitboxbones[pBox->bone])[0][3] ) < POINT_AT_ORIGIN_EPSILON && fabs( (*hitboxbones[pBox->bone])[1][3] ) < POINT_AT_ORIGIN_EPSILON && fabs( (*hitboxbones[pBox->bone])[2][3] ) < POINT_AT_ORIGIN_EPSILON )
{
continue;
}
pHitBoxOutputBuffer[nRet].m_vecBoxMins.x = pBox->bbmin.x;
pHitBoxOutputBuffer[nRet].m_vecBoxMins.y = pBox->bbmin.y;
pHitBoxOutputBuffer[nRet].m_vecBoxMins.z = pBox->bbmin.z;
pHitBoxOutputBuffer[nRet].m_vecBoxMaxes.x = pBox->bbmax.x;
pHitBoxOutputBuffer[nRet].m_vecBoxMaxes.y = pBox->bbmax.y;
pHitBoxOutputBuffer[nRet].m_vecBoxMaxes.z = pBox->bbmax.z;
pHitBoxOutputBuffer[nRet].m_Transform = *hitboxbones[pBox->bone];
nRet++;
if ( nRet >= nBufSize )
{
break;
}
}
}
}
}
}
if ( pMoveParent->IsBrushModel() )
{
Vector vecMin;
Vector vecMax;
matrix3x4_t matOrientation;
pMoveParent->GetRenderBounds( vecMin, vecMax );
matOrientation = pMoveParent->EntityToWorldTransform();
pHitBoxOutputBuffer[0].m_vecBoxMins = vecMin;
pHitBoxOutputBuffer[0].m_vecBoxMaxes = vecMax;
pHitBoxOutputBuffer[0].m_Transform = matOrientation;
nRet = 1;
}
}
s_BoneMutex.Unlock();
#endif
return nRet;
}