本文整理汇总了C++中SetGravity函数的典型用法代码示例。如果您正苦于以下问题:C++ SetGravity函数的具体用法?C++ SetGravity怎么用?C++ SetGravity使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetGravity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGravity
void Physics::Serialize(Properties* prop)
{
Subsystem::Serialize(prop);
vec3 grav {0.0f};
if(prop->mode == Properties::Mode::Output)
grav = GetGravity();
prop->Value("gravity", &grav);
if(prop->mode == Properties::Mode::Input)
SetGravity(grav);
auto add_pt_func = [](GravPoint& gp, Properties* prop)
{
prop->Value("name", &gp.name);
prop->Value("force", &gp.force);
};
prop->ValueArray<GravPoint>("gravityPoint", gravityPoints, add_pt_func);
/* Properties* gravPts = prop->Child("gravityPoints", "");
if(gravPts)
{
for(auto& pgpt : gravPts->children)
{
GravPoint* gpt = new GravPoint;
pgpt->Value("name", gpt->name);
pgpt->Value("force", gpt->force);
gravityPoints.push_back(*gpt);
}
}*/
}
示例2: Precache
void CGrenadePathfollower::Spawn( void )
{
Precache( );
// -------------------------
// Inert when first spawned
// -------------------------
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_NOT_SOLID );
SetMoveType( MOVETYPE_NONE );
AddFlag( FL_OBJECT ); // So can be shot down
AddEffects( EF_NODRAW );
UTIL_SetSize(this, Vector(0, 0, 0), Vector(0, 0, 0));
m_flDamage = sk_dmg_pathfollower_grenade.GetFloat();
m_DmgRadius = sk_pathfollower_grenade_radius.GetFloat();
m_takedamage = DAMAGE_YES;
m_iHealth = 200;
SetGravity( 0.00001 );
SetFriction( 0.8 );
SetSequence( 1 );
}
示例3: Precache
//-----------------------------------------------------------------------------
// Purpose: Spawn
//-----------------------------------------------------------------------------
void CGrappleHook::Spawn( void )
{
Precache( );
SetModel( HOOK_MODEL );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM );
UTIL_SetSize( this, -Vector(1,1,1), Vector(1,1,1) );
SetSolid( SOLID_BBOX );
SetGravity( 0.05f );
// The rock is invisible, the crossbow bolt is the visual representation
AddEffects( EF_NODRAW );
// Make sure we're updated if we're underwater
UpdateWaterState();
SetTouch( &CGrappleHook::HookTouch );
SetThink( &CGrappleHook::FlyThink );
SetNextThink( gpGlobals->curtime + 0.1f );
m_pSpring = NULL;
m_fSpringLength = 0.0f;
m_bPlayerWasStanding = false;
}
示例4: super
cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) :
super(a_EntityType, 0, 0, 0, a_Width, a_Height)
, m_EntityEffects(tEffectMap())
{
SetGravity(-32.0f);
SetAirDrag(0.02f);
}
示例5: Precache
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDODBaseRocket::Spawn( void )
{
Precache();
SetSolid( SOLID_BBOX );
Assert( GetModel() ); //derived classes must have set model
UTIL_SetSize( this, -Vector(2,2,2), Vector(2,2,2) );
SetTouch( &CDODBaseRocket::RocketTouch );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM );
m_takedamage = DAMAGE_NO;
SetGravity( 0.1 );
SetDamage( mp_rocketdamage.GetFloat() );
AddFlag( FL_OBJECT );
SetCollisionGroup( COLLISION_GROUP_PROJECTILE );
EmitSound( "Weapon_Bazooka.Shoot" );
// Smoke trail.
CreateSmokeTrail();
SetThink( &CDODBaseRocket::FlyThink );
SetNextThink( gpGlobals->curtime );
}
示例6: super
cChicken::cChicken(void) :
super("Chicken", mtChicken, "entity.chicken.hurt", "entity.chicken.death", 0.4, 0.7),
m_EggDropTimer(0)
{
SetGravity(-2.0f);
SetAirDrag(0.0f);
}
示例7: super
cTNTEntity::cTNTEntity(Vector3d a_Pos, int a_FuseTicks) :
super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
m_FuseTicks(a_FuseTicks)
{
SetGravity(-16.0f);
SetAirDrag(0.4f);
}
示例8: Precache
void CGrenadeMP5::Spawn( void )
{
Precache( );
SetSolid( SOLID_BBOX );
SetMoveType( MOVETYPE_FLY );
AddFlag( FL_GRENADE );
SetModel( "models/grenade.mdl" );
//UTIL_SetSize(this, Vector(-3, -3, -3), Vector(3, 3, 3));
UTIL_SetSize(this, Vector(0, 0, 0), Vector(0, 0, 0));
SetUse( &CBaseGrenade::DetonateUse );
SetTouch( &CGrenadeMP5::GrenadeMP5Touch );
SetNextThink( gpGlobals->curtime + 0.1f );
m_flDamage = sk_plr_dmg_mp5_grenade.GetFloat();
m_DmgRadius = sk_mp5_grenade_radius.GetFloat();
m_takedamage = DAMAGE_YES;
m_bIsLive = true;
m_iHealth = 1;
SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see
SetFriction( 0.8 );
SetSequence( 0 );
m_fSpawnTime = gpGlobals->curtime;
}
示例9: SetMoveType
void CBaseGrenadeContact::Spawn( void )
{
// point sized, solid, bouncing
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetSolid( SOLID_BBOX );
SetCollisionGroup( COLLISION_GROUP_PROJECTILE );
SetModel( "models/weapons/w_grenade.mdl" ); // BUG: wrong model
UTIL_SetSize(this, vec3_origin, vec3_origin);
// contact grenades arc lower
SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see
QAngle angles;
VectorAngles(GetAbsVelocity(), angles);
SetLocalAngles( angles );
// make NPCs afaid of it while in the air
SetThink( &CBaseGrenadeContact::DangerSoundThink );
SetNextThink( gpGlobals->curtime );
// Tumble in air
QAngle vecAngVelocity( random->RandomFloat ( -100, -500 ), 0, 0 );
SetLocalAngularVelocity( vecAngVelocity );
// Explode on contact
SetTouch( &CBaseGrenadeContact::ExplodeTouch );
m_flDamage = 100; // BOXBOX was sk_plr_dmg_grenade.GetFloat();
// Allow player to blow this puppy up in the air
m_takedamage = DAMAGE_YES;
m_iszBounceSound = NULL_STRING;
}
示例10: Precache
void CASW_Flamer_Projectile::Spawn( void )
{
Precache( );
//SetModel( PELLET_MODEL );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM );
m_flDamage = sk_plr_dmg_asw_f.GetFloat();
m_takedamage = DAMAGE_NO;
SetSize( -Vector(1,1,1), Vector(1,1,1) );
SetSolid( SOLID_BBOX );
SetGravity( 0.05f );
SetCollisionGroup( ASW_COLLISION_GROUP_FLAMER_PELLETS ); // ASW_COLLISION_GROUP_SHOTGUN_PELLET
SetTouch( &CASW_Flamer_Projectile::ProjectileTouch );
CreateEffects();
m_vecOldPos = vec3_origin;
m_fDieTime = gpGlobals->curtime + 1.0f; // will need to change size scale algos below if this changes
SetThink( &CASW_Flamer_Projectile::CollideThink );
SetNextThink( gpGlobals->curtime );
// flamer projectile only lasts 1 second
//SetThink( &CASW_Flamer_Projectile::SUB_Remove );
//SetNextThink( gpGlobals->curtime + 1.0f );
}
示例11: AngleVectors
void CShower::Spawn( void )
{
Vector vecForward;
AngleVectors( GetLocalAngles(), &vecForward );
Vector vecNewVelocity;
vecNewVelocity = random->RandomFloat( 200, 300 ) * vecForward;
vecNewVelocity.x += random->RandomFloat(-100.f,100.f);
vecNewVelocity.y += random->RandomFloat(-100.f,100.f);
if ( vecNewVelocity.z >= 0 )
vecNewVelocity.z += 200;
else
vecNewVelocity.z -= 200;
SetAbsVelocity( vecNewVelocity );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetGravity( UTIL_ScaleForGravity( 400 ) ); // fall a bit more slowly than normal
SetNextThink( gpGlobals->curtime + 0.1f );
SetSolid( SOLID_NONE );
UTIL_SetSize(this, vec3_origin, vec3_origin );
AddEffects( EF_NODRAW );
m_flSpeed = random->RandomFloat( 0.5, 1.5 );
SetLocalAngles( vec3_angle );
}
示例12: StopAnimation
//-----------------------------------------------------------------------------
// Purpose: Drop/throw the weapon with the given velocity.
//-----------------------------------------------------------------------------
void CASW_Weapon::Drop( const Vector &vecVelocity )
{
StopAnimation();
StopFollowingEntity( );
SetMoveType( MOVETYPE_FLYGRAVITY );
// clear follow stuff, setup for collision
SetGravity(1.0);
m_iState = WEAPON_NOT_CARRIED;
RemoveEffects( EF_NODRAW );
FallInit();
SetGroundEntity( NULL );
SetTouch(NULL);
IPhysicsObject *pObj = VPhysicsGetObject();
if ( pObj != NULL )
{
AngularImpulse angImp( 200, 200, 200 );
pObj->AddVelocity( &vecVelocity, &angImp );
}
else
{
SetAbsVelocity( vecVelocity );
}
SetNextThink( gpGlobals->curtime + 1.0f );
SetOwnerEntity( NULL );
SetOwner( NULL );
SetModel( GetWorldModel() );
}
示例13: SetGravity
void ParticlePhysics::ParseAttribute(const TiXmlAttribute* attribute)
{
if (IsEqual(attribute->Name(), "gravity"))
{
SetGravity(attribute->FloatValue());
}
}
示例14: SetModelName
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CResourceChunk::Spawn( )
{
// Init model
if ( IsProcessed() )
{
SetModelName( AllocPooledString( sProcessedResourceChunkModel ) );
}
else
{
SetModelName( AllocPooledString( sResourceChunkModel ) );
}
BaseClass::Spawn();
UTIL_SetSize( this, Vector(-4,-4,-4), Vector(4,4,4) );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_TRIGGER );
CollisionProp()->UseTriggerBounds( true, 24 );
SetCollisionGroup( TFCOLLISION_GROUP_RESOURCE_CHUNK );
SetGravity( 1.0 );
SetFriction( 1 );
SetTouch( ChunkTouch );
SetThink( ChunkRemove );
SetNextThink( gpGlobals->curtime + random->RandomFloat( 50.0, 80.0 ) ); // Remove myself the
}
示例15: SetMoveType
void CBaseHelicopter::Event_Killed( const CTakeDamageInfo &info )
{
m_lifeState = LIFE_DYING;
SetMoveType( MOVETYPE_FLYGRAVITY );
SetGravity( UTIL_ScaleForGravity( 240 ) ); // use a lower gravity
StopLoopingSounds();
UTIL_SetSize( this, Vector( -32, -32, -64), Vector( 32, 32, 0) );
SetThink( &CBaseHelicopter::CallDyingThink );
SetTouch( &CBaseHelicopter::CrashTouch );
SetNextThink( gpGlobals->curtime + 0.1f );
m_iHealth = 0;
m_takedamage = DAMAGE_NO;
/*
if (m_spawnflags & SF_NOWRECKAGE)
{
m_flNextRocket = gpGlobals->curtime + 4.0;
}
else
{
m_flNextRocket = gpGlobals->curtime + 15.0;
}
*/
StopRotorWash();
m_OnDeath.FireOutput( info.GetAttacker(), this );
}