本文整理汇总了C++中VPhysicsInitNormal函数的典型用法代码示例。如果您正苦于以下问题:C++ VPhysicsInitNormal函数的具体用法?C++ VPhysicsInitNormal怎么用?C++ VPhysicsInitNormal使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VPhysicsInitNormal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PhysModelParseSolid
bool CPhysBox::CreateVPhysics()
{
solid_t tmpSolid;
PhysModelParseSolid( tmpSolid, this, GetModelIndex() );
if ( m_massScale > 0 )
{
float mass = tmpSolid.params.mass * m_massScale;
mass = clamp( mass, 0.5, 1e6 );
tmpSolid.params.mass = mass;
}
PhysSolidOverride( tmpSolid, m_iszOverrideScript );
IPhysicsObject *pPhysics = VPhysicsInitNormal( GetSolid(), GetSolidFlags(), true, &tmpSolid );
if ( m_damageType == 1 )
{
PhysSetGameFlags( pPhysics, FVPHYSICS_DMG_SLICE );
}
// Wake it up if not asleep
if ( !HasSpawnFlags(SF_PHYSBOX_ASLEEP) )
{
VPhysicsGetObject()->Wake();
}
if ( HasSpawnFlags(SF_PHYSBOX_MOTIONDISABLED) || m_damageToEnableMotion > 0 )
{
VPhysicsGetObject()->EnableMotion( false );
}
// only send data when physics moves this object
NetworkStateManualMode( true );
return true;
}
示例2: Release
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pszModelName -
// vecOrigin -
// vecForceDir -
// vecAngularImp -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool C_Gib::InitializeGib( const char *pszModelName, Vector vecOrigin, Vector vecForceDir, AngularImpulse vecAngularImp, float flLifetime )
{
if ( InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false )
{
Release();
return false;
}
SetAbsOrigin( vecOrigin );
SetCollisionGroup( COLLISION_GROUP_DEBRIS );
solid_t tmpSolid;
PhysModelParseSolid( tmpSolid, this, GetModelIndex() );
m_pPhysicsObject = VPhysicsInitNormal( SOLID_VPHYSICS, 0, false, &tmpSolid );
if ( m_pPhysicsObject )
{
float flForce = m_pPhysicsObject->GetMass();
vecForceDir *= flForce;
m_pPhysicsObject->ApplyForceOffset( vecForceDir, GetAbsOrigin() );
m_pPhysicsObject->SetCallbackFlags( m_pPhysicsObject->GetCallbackFlags() | CALLBACK_GLOBAL_TOUCH | CALLBACK_GLOBAL_TOUCH_STATIC );
}
else
{
// failed to create a physics object
Release();
return false;
}
SetNextClientThink( gpGlobals->curtime + flLifetime );
return true;
}
示例3: EmitSound
//====================================================================================
// WEAPON SPAWNING
//====================================================================================
//-----------------------------------------------------------------------------
// Purpose: Make a weapon visible and tangible
//-----------------------------------------------------------------------------//
void CBaseCombatWeapon::Materialize( void )
{
if ( IsEffectActive( EF_NODRAW ) )
{
// changing from invisible state to visible.
#ifdef HL2MP
EmitSound( "AlyxEmp.Charge" );
#else
EmitSound( "BaseCombatWeapon.WeaponMaterialize" );
#endif
RemoveEffects( EF_NODRAW );
DoMuzzleFlash();
}
#ifdef HL2MP
if ( HasSpawnFlags( SF_NORESPAWN ) == false )
{
VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false );
SetMoveType( MOVETYPE_VPHYSICS );
HL2MPRules()->AddLevelDesignerPlacedObject( this );
}
#else
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_TRIGGER );
#endif
SetPickupTouch();
SetThink (NULL);
}
示例4: VPhysicsInitNormal
//-----------------------------------------------------------------------------
// Purpose:
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CCrossbowBolt::CreateVPhysics()
{
// Create the object in the physics system
VPhysicsInitNormal( SOLID_BBOX, FSOLID_NOT_STANDABLE, false );
return true;
}
示例5: GetSolidFlags
bool CItem::CreateItemVPhysicsObject( void )
{
// Create the object in the physics system
int nSolidFlags = GetSolidFlags() | FSOLID_NOT_STANDABLE;
if ( !m_bActivateWhenAtRest )
{
nSolidFlags |= FSOLID_TRIGGER;
}
if ( VPhysicsInitNormal( SOLID_VPHYSICS, nSolidFlags, false ) == NULL )
{
SetSolid( SOLID_BBOX );
AddSolidFlags( nSolidFlags );
// If it's not physical, drop it to the floor
if (UTIL_DropToFloor(this, MASK_SOLID) == 0)
{
Warning( "Item %s fell out of level at %f,%f,%f\n", GetClassname(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z);
UTIL_Remove( this );
return false;
}
}
return true;
}
示例6: VPhysicsInitNormal
//-----------------------------------------------------------------------------
// Purpose:
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CTDPBaseProjectile::CreateVPhysics( void )
{
// Create the object in the physics system
VPhysicsInitNormal( SOLID_BBOX, FSOLID_NOT_STANDABLE, false );
return true;
}
示例7: HasSpawnFlags
bool CPhysicsCannister::CreateVPhysics()
{
bool asleep = HasSpawnFlags(SF_CANNISTER_ASLEEP);
VPhysicsInitNormal( SOLID_VPHYSICS, 0, asleep );
return true;
}
示例8: Precache
void CGEGrenade::Spawn( void )
{
Precache();
BaseClass::Spawn();
SetModel( "models/weapons/grenade/w_grenade.mdl" );
// So NPC's can "see" us
AddFlag( FL_OBJECT );
m_takedamage = DAMAGE_YES;
m_iHealth = 1;
m_bHitSomething = false;
m_bDroppedOnDeath = false;
// Default Damages they should be modified by the thrower
SetDamage( 320 );
SetDamageRadius( 260 );
SetSize( -Vector(4,4,4), Vector(4,4,4) );
SetCollisionGroup( COLLISION_GROUP_MINE );
// Init our physics definition
VPhysicsInitNormal( SOLID_VPHYSICS, GetSolidFlags() | FSOLID_TRIGGER, false );
SetMoveType( MOVETYPE_VPHYSICS );
// Don't think until we have a time to think about!
SetThink( NULL );
// Bounce if we hit something!
SetTouch( &BaseClass::BounceTouch );
AddSolidFlags( FSOLID_NOT_STANDABLE );
}
示例9: EmitSound
void CWeaponHL2MPBase::Materialize( void )
{
if ( IsEffectActive( EF_NODRAW ) )
{
// changing from invisible state to visible.
EmitSound( "AlyxEmp.Charge" );
RemoveEffects( EF_NODRAW );
DoMuzzleFlash();
}
if ( HasSpawnFlags( SF_NORESPAWN ) == false )
{
VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false );
SetMoveType( MOVETYPE_VPHYSICS );
HL2MPRules()->AddLevelDesignerPlacedObject( this );
}
if ( HasSpawnFlags( SF_NORESPAWN ) == false )
{
if ( GetOriginalSpawnOrigin() == vec3_origin )
{
m_vOriginalSpawnOrigin = GetAbsOrigin();
m_vOriginalSpawnAngles = GetAbsAngles();
}
}
SetPickupTouch();
SetThink (NULL);
}
示例10: Precache
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CGETKnife::Spawn( void )
{
Precache();
BaseClass::Spawn();
SetModel( "models/weapons/knife/w_tknife.mdl" );
SetSize( -Vector(8,8,8), Vector(8,8,8) );
// Init our physics definition
VPhysicsInitNormal( SOLID_VPHYSICS, GetSolidFlags() | FSOLID_TRIGGER, false );
SetMoveType( MOVETYPE_VPHYSICS );
SetCollisionGroup( COLLISION_GROUP_GRENADE );
// No Air-Drag, lower gravity
VPhysicsGetObject()->EnableDrag( false );
SetGravity( UTIL_ScaleForGravity( 540.0f ) );
m_bInAir = true;
m_takedamage = DAMAGE_NO;
AddSolidFlags( FSOLID_NOT_STANDABLE );
m_flStopFlyingTime = gpGlobals->curtime + 4.5f;
// const CBaseEntity *host = te->GetSuppressHost();
// te->SetSuppressHost( NULL );
// DispatchParticleEffect( "tracer_tknife", PATTACH_POINT_FOLLOW, this, "tip" );
// te->SetSuppressHost( (CBaseEntity*)host );
SetTouch( &CGETKnife::DamageTouch );
SetThink( &CGETKnife::SoundThink );
SetNextThink( gpGlobals->curtime );
}
示例11: Precache
void CSatchelCharge::Spawn( void )
{
Precache( );
SetModel( "models/Weapons/w_slam.mdl" );
VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false );
SetMoveType( MOVETYPE_VPHYSICS );
SetCollisionGroup( COLLISION_GROUP_WEAPON );
UTIL_SetSize(this, Vector( -6, -6, -2), Vector(6, 6, 2));
SetThink( &CSatchelCharge::SatchelThink );
SetNextThink( gpGlobals->curtime + 0.1f );
m_flDamage = sk_plr_dmg_satchel.GetFloat();
m_DmgRadius = sk_satchel_radius.GetFloat();
m_takedamage = DAMAGE_YES;
m_iHealth = 1;
SetGravity( UTIL_ScaleForGravity( 560 ) ); // slightly lower gravity
SetFriction( 1.0 );
SetSequence( 1 );
SetDamage( 150 );
m_bIsAttached = false;
m_bInAir = true;
m_flNextBounceSoundTime = 0;
m_vLastPosition = vec3_origin;
m_hGlowSprite = NULL;
CreateEffects();
}
示例12: VPhysicsInitNormal
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
bool CAI_BasePhysicsFlyingBot::CreateVPhysics( void )
{
// Create the object in the physics system
IPhysicsObject *pPhysicsObject = VPhysicsInitNormal( SOLID_BBOX, FSOLID_NOT_STANDABLE, false );
m_pMotionController = physenv->CreateMotionController( this );
m_pMotionController->AttachObject( pPhysicsObject, true );
return true;
}
示例13: Vector
//------------------------------------------------------------------------------
// Purpose : Initialize a gibs position and velocity
// Input :
// Output :
//------------------------------------------------------------------------------
void CGib::InitGib( CBaseEntity *pVictim, float fMinVelocity, float fMaxVelocity )
{
// ------------------------------------------------------------------------
// If have a pVictim spawn the gib somewhere in the pVictim's bounding volume
// ------------------------------------------------------------------------
if ( pVictim )
{
// Find a random position within the bounding box (add 1 to Z to get it out of the ground)
Vector vecOrigin;
pVictim->CollisionProp()->RandomPointInBounds( vec3_origin, Vector( 1, 1, 1 ), &vecOrigin );
vecOrigin.z += 1.0f;
SetAbsOrigin( vecOrigin );
// make the gib fly away from the attack vector
Vector vecNewVelocity = g_vecAttackDir * -1;
// mix in some noise
vecNewVelocity.x += random->RandomFloat ( -0.25, 0.25 );
vecNewVelocity.y += random->RandomFloat ( -0.25, 0.25 );
vecNewVelocity.z += random->RandomFloat ( -0.25, 0.25 );
vecNewVelocity *= random->RandomFloat ( fMaxVelocity, fMinVelocity );
QAngle vecNewAngularVelocity = GetLocalAngularVelocity();
vecNewAngularVelocity.x = random->RandomFloat ( 100, 200 );
vecNewAngularVelocity.y = random->RandomFloat ( 100, 300 );
SetLocalAngularVelocity( vecNewAngularVelocity );
// copy owner's blood color
SetBloodColor( pVictim->BloodColor() );
AdjustVelocityBasedOnHealth( pVictim->m_iHealth, vecNewVelocity );
// Attempt to be physical if we can
if ( VPhysicsInitNormal( SOLID_BBOX, 0, false ) )
{
IPhysicsObject *pObj = VPhysicsGetObject();
if ( pObj != NULL )
{
AngularImpulse angImpulse = RandomAngularImpulse( -500, 500 );
pObj->AddVelocity( &vecNewVelocity, &angImpulse );
}
}
else
{
SetSolid( SOLID_BBOX );
SetCollisionBounds( vec3_origin, vec3_origin );
SetAbsVelocity( vecNewVelocity );
}
SetCollisionGroup( COLLISION_GROUP_DEBRIS );
}
LimitVelocity();
}
示例14: Precache
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CNPC_Roller::Spawn( void )
{
Precache();
m_pRollSound = NULL;
m_flForwardSpeed = ROLLER_FORWARD_SPEED;
SetModel( "models/roller.mdl" );
SetHullType( HULL_TINY_CENTERED );
SetHullSizeNormal();
m_bloodColor = DONT_BLEED;
m_iHealth = 20;
m_flFieldOfView = 0.5;
m_NPCState = NPC_STATE_NONE;
m_fHACKJustSpawned = true;
m_RollerController.Off();
m_flTimeMarcoSound = gpGlobals->curtime + ROLLER_MARCO_FREQUENCY * random->RandomFloat( 1, 3 );
m_flTimePoloSound = TIME_NEVER;
CapabilitiesClear();
CapabilitiesAdd( bits_CAP_MOVE_GROUND );
m_iFail = 0;
// Create the object in the physics system
IPhysicsObject *pPhysicsObject = VPhysicsInitNormal( SOLID_BBOX, FSOLID_NOT_STANDABLE, false );
m_pMotionController = physenv->CreateMotionController( &m_RollerController );
m_pMotionController->AttachObject( pPhysicsObject );
NPCInit();
// Generate me an access code
int i;
int iLastDigit = -10;
for( i = 0 ; i < ROLLER_CODE_DIGITS ; i++ )
{
// Generate a digit, and make sure it's not the same
// or sequential to the previous digit.
do
{
m_iAccessCode[ i ] = rand() % 6;
} while( abs(m_iAccessCode[ i ] - iLastDigit) <= 1 );
iLastDigit = m_iAccessCode[ i ];
}
// this suppresses boatloads of warnings in the movement code.
// (code that assumes everyone is propelled by animation).
m_flGroundSpeed = 20;
}
示例15: VPhysicsInitNormal
bool CPushable::CreateVPhysics( void )
{
VPhysicsInitNormal( SOLID_VPHYSICS, 0, false );
IPhysicsObject *pPhysObj = VPhysicsGetObject();
if ( pPhysObj )
{
pPhysObj->SetMass( 30 );
// Vector vecInertia = Vector(800, 800, 800);
// pPhysObj->SetInertia( vecInertia );
}
return true;
}