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


C++ SetGravity函数代码示例

本文整理汇总了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);
		}
	}*/
}
开发者ID:jjiezheng,项目名称:lfant,代码行数:33,代码来源:Physics.cpp

示例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 );
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:25,代码来源:grenade_pathfollower.cpp

示例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;
}
开发者ID:MaestroFenix,项目名称:NewGrappleHook,代码行数:28,代码来源:c_weapon_grapple.cpp

示例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);
}
开发者ID:36451,项目名称:MCServer,代码行数:7,代码来源:Pawn.cpp

示例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 );
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:33,代码来源:dod_baserocket.cpp

示例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);
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:7,代码来源:Chicken.cpp

示例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);
}
开发者ID:UltraCoderRU,项目名称:MCServer,代码行数:7,代码来源:TNTEntity.cpp

示例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;
}
开发者ID:hitmen047,项目名称:TF2HLCoop,代码行数:28,代码来源:hl1_grenade_mp5.cpp

示例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;
}
开发者ID:BoXorz,项目名称:MasterSword-Source,代码行数:35,代码来源:basegrenade_contact.cpp

示例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 );
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:28,代码来源:asw_flamer_projectile.cpp

示例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 );
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:25,代码来源:explode.cpp

示例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() );
}
开发者ID:TalonBraveInfo,项目名称:InvasionASSource,代码行数:31,代码来源:asw_weapon.cpp

示例13: SetGravity

void ParticlePhysics::ParseAttribute(const TiXmlAttribute* attribute)
{
	if (IsEqual(attribute->Name(), "gravity"))
	{
		SetGravity(attribute->FloatValue());
	}
}
开发者ID:Rtyui,项目名称:PvpBattleProject,代码行数:7,代码来源:ParticlePhysics.cpp

示例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
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:29,代码来源:resource_chunk.cpp

示例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 );
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:31,代码来源:cbasehelicopter.cpp


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