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


C++ GetLocalAngles函数代码示例

本文整理汇总了C++中GetLocalAngles函数的典型用法代码示例。如果您正苦于以下问题:C++ GetLocalAngles函数的具体用法?C++ GetLocalAngles怎么用?C++ GetLocalAngles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetLocalAngles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Q_snprintf

//-----------------------------------------------------------------------------
// Purpose: Draw any debug text overlays
// Output : Current text offset from the top
//-----------------------------------------------------------------------------
int CMomentaryRotButton::DrawDebugTextOverlays(void) 
{
	int text_offset = BaseClass::DrawDebugTextOverlays();

	if (m_debugOverlays & OVERLAY_TEXT_BIT) 
	{
		char tempstr[255];
		
		Q_snprintf(tempstr,sizeof(tempstr),"QAngle: %.2f %.2f %.2f", GetLocalAngles()[0], GetLocalAngles()[1], GetLocalAngles()[2]);
		EntityText(text_offset,tempstr,0);
		text_offset++;

		Q_snprintf(tempstr,sizeof(tempstr),"AVelocity: %.2f %.2f %.2f", GetLocalAngularVelocity()[0], GetLocalAngularVelocity()[1], GetLocalAngularVelocity()[2]);
		EntityText(text_offset,tempstr,0);
		text_offset++;

		Q_snprintf(tempstr,sizeof(tempstr),"Target Pos:   %3.3f",m_IdealYaw);
		EntityText(text_offset,tempstr,0);
		text_offset++;

		float flCurPos = GetPos(GetLocalAngles());
		Q_snprintf(tempstr,sizeof(tempstr),"Current Pos:   %3.3f",flCurPos);
		EntityText(text_offset,tempstr,0);
		text_offset++;

		Q_snprintf(tempstr,sizeof(tempstr),"Direction: %s",(m_direction == 1) ? "Forward" : "Backward");
		EntityText(text_offset,tempstr,0);
		text_offset++;

	}
	return text_offset;
}
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:36,代码来源:buttons.cpp

示例2: GetOuter

//-----------------------------------------------------------------------------
// Purpose: Turns a npc towards its ideal yaw.
// Input  : yawSpeed - Yaw speed in degrees per 1/10th of a second.
//			flInterval - Time interval to turn, -1 uses time since last think.
// Output : Returns the number of degrees turned.
//-----------------------------------------------------------------------------
void CAI_Motor::UpdateYaw( int yawSpeed )
{
	// Don't do this if our yaw is locked
	if ( IsYawLocked() )
		return;

	GetOuter()->SetUpdatedYaw();

	float ideal, current, newYaw;
	
	if ( yawSpeed == -1 )
		yawSpeed = GetYawSpeed();

	// NOTE: GetIdealYaw() will never exactly be reached because UTIL_AngleMod
	// also truncates the angle to 16 bits of resolution. So lets truncate it here.
	current = UTIL_AngleMod( GetLocalAngles().y );
	ideal = UTIL_AngleMod( GetIdealYaw() );

	// FIXME: this needs a proper interval
	float dt = MIN( 0.2, gpGlobals->curtime - GetLastThink() );
	
	newYaw = AI_ClampYaw( (float)yawSpeed * 10.0, current, ideal, dt );
		
	if (newYaw != current)
	{
		QAngle angles = GetLocalAngles();
		angles.y = newYaw;
		SetLocalAngles( angles );
	}
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:36,代码来源:ai_motor.cpp

示例3: GetPos

//------------------------------------------------------------------------------
// Purpose: MoveDone function for the SetPosition input handler. Tracks our
//			progress toward a movement goal and updates our outputs.
//------------------------------------------------------------------------------
void CMomentaryRotButton::SetPositionMoveDone(void)
{
	float flCurPos = GetPos( GetLocalAngles() );

	if ((( flCurPos >= m_IdealYaw ) && ( m_direction == 1 )) ||
		(( flCurPos <= m_IdealYaw ) && ( m_direction == -1 )))
	{
		//
		// We reached or surpassed our movement goal.
		//
		SetLocalAngularVelocity( vec3_angle );
		// BUGBUG: Won't this get the player stuck?
		SetLocalAngles( m_start + m_vecMoveAng * ( m_IdealYaw * m_flMoveDistance ) );
		SetNextThink( TICK_NEVER_THINK );
		SetMoveDoneTime( -1 );
		UpdateTarget( m_IdealYaw, this );
		OutputMovementComplete();
		return;
	}

	// TODO: change this to use a Think function like ReturnThink.
	QAngle vecNewAngles = m_start + m_vecMoveAng * ( m_IdealYaw * m_flMoveDistance );
	float flAngleDelta = fabs( AxisDelta( m_spawnflags, vecNewAngles, GetLocalAngles() ));
	float dt = flAngleDelta / m_flSpeed;
	if ( dt < TICK_INTERVAL )
	{
		dt = TICK_INTERVAL;
		float speed = flAngleDelta / TICK_INTERVAL;
		SetLocalAngularVelocity( speed * m_vecMoveAng * m_direction );
	}
	dt = clamp( dt, TICK_INTERVAL, TICK_INTERVAL * 6);

	SetMoveDoneTime( dt );
}
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:38,代码来源:buttons.cpp

示例4: switch

void CWorldItem::Spawn( void )
{
	CBaseEntity *pEntity = NULL;

	switch (m_iType) 
	{
	case 44: // ITEM_BATTERY:
		pEntity = CBaseEntity::Create( "item_battery", GetLocalOrigin(), GetLocalAngles() );
		break;
	case 45: // ITEM_SUIT:
		pEntity = CBaseEntity::Create( "item_suit", GetLocalOrigin(), GetLocalAngles() );
		break;
	}

	if (!pEntity)
	{
		Warning("unable to create world_item %d\n", m_iType );
	}
	else
	{
		pEntity->m_target = m_target;
		pEntity->SetName( GetEntityName() );
		pEntity->ClearSpawnFlags();
		pEntity->AddSpawnFlags( m_spawnflags );
	}

	UTIL_RemoveImmediate( this );
}
开发者ID:Randdalf,项目名称:bliink,代码行数:28,代码来源:item_world.cpp

示例5: EmitSound

void CGERocket::IgniteThink( void )
{
	EmitSound( "Weapon_RocketLauncher.Ignite" );

	AngleVectors( GetLocalAngles(), &m_vForward );
	AngleVectors(GetLocalAngles() + QAngle(-90, 0, 0), &m_vUp);

	m_vRight = CrossProduct(m_vForward, m_vUp);

//	SetAbsVelocity( m_vForward * GE_ROCKET_MAXVEL * 0.1f );

	SetThink( &CGERocket::AccelerateThink );
	SetNextThink(gpGlobals->curtime + m_fthinktime);

	m_fthinktime = 0.1;
	m_fFuseTime = gpGlobals->curtime + GE_ROCKET_FUSETIME / max(phys_timescale.GetFloat(), 0.01);

	CreateSmokeTrail();

/*
	DevMsg("modifiers are..");
	if (m_iseed1 < 50) // Vertical Sine Wave
		DevMsg(", sine");
	if (m_iseed1 % 50 < 25) // Horizontal Cosine Wave, overlap with sine wave causes spiral.
		DevMsg(", cosine");
	if (m_iseed1 % 25 < 5) // Comes back
		DevMsg(", return");
	if (m_iseed1 % 20 < 5) // Gravity
		DevMsg(", gravity");
	if (m_iseed1 % 10 < 4) // Random Jitter
		DevMsg(", jitter");

	DevMsg(", and seed 1 is %d, seed 2 is %d, seed 3 is %d.", m_iseed1, m_iseed2, m_iseed3); 
*/
}
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:35,代码来源:grenade_rocket.cpp

示例6: ASSERTSZ

//-----------------------------------------------------------------------------
// Purpose: Calculate m_vecVelocity and m_flNextThink to reach vecDest from
//			GetLocalOrigin() traveling at flSpeed. Just like LinearMove, but rotational.
// Input  : vecDestAngle - 
//			flSpeed - 
//-----------------------------------------------------------------------------
void CBaseToggle::AngularMove( const QAngle &vecDestAngle, float flSpeed )
{
	ASSERTSZ(flSpeed != 0, "AngularMove:  no speed is defined!");
	
	m_vecFinalAngle = vecDestAngle;

	m_movementType = MOVE_TOGGLE_ANGULAR;
	// Already there?
	if (vecDestAngle == GetLocalAngles())
	{
		MoveDone();
		return;
	}
	
	// set destdelta to the vector needed to move
	QAngle vecDestDelta = vecDestAngle - GetLocalAngles();
	
	// divide by speed to get time to reach dest
	float flTravelTime = vecDestDelta.Length() / flSpeed;

	const float MinTravelTime = 0.01f;
	if ( flTravelTime < MinTravelTime )
	{
		// If we only travel for a short time, we can fail WillSimulateGamePhysics()
		flTravelTime = MinTravelTime;
		flSpeed = vecDestDelta.Length() / flTravelTime;
	}

	// set m_flNextThink to trigger a call to AngularMoveDone when dest is reached
	SetMoveDoneTime( flTravelTime );

	// scale the destdelta vector by the time spent traveling to get velocity
	SetLocalAngularVelocity( vecDestDelta * (1.0 / flTravelTime) );
}
开发者ID:FooGames,项目名称:SecobMod,代码行数:40,代码来源:subs.cpp

示例7: Precache

void CRotButton::Spawn( void )
{
	Precache();

	// set the axis of rotation
	AxisDir( pev );

	// check for clockwise rotation
	if( FBitSet( pev->spawnflags, SF_ROTBUTTON_ROTATE_BACKWARDS ))
		pev->movedir = pev->movedir * -1;

	pev->movetype = MOVETYPE_PUSH;
	
	if( FBitSet( pev->spawnflags, SF_ROTBUTTON_PASSABLE ))
		pev->solid = SOLID_NOT;
	else pev->solid = SOLID_BSP;

	// shared code use this flag as BUTTON_DONTMOVE so we need to clear it here
	ClearBits( pev->spawnflags, SF_ROTBUTTON_PASSABLE );
	ClearBits( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF );
	ClearBits( pev->spawnflags, SF_BUTTON_DAMAGED_AT_LASER );

	SET_MODEL( edict(), GetModel() );
	
	if( pev->speed == 0 )
		pev->speed = 40;

	if( m_flWait == 0 )
		m_flWait = 1;

	if( pev->health > 0 )
	{
		pev->takedamage = DAMAGE_YES;
	}

	m_iState = STATE_OFF;
	m_vecAngle1 = GetLocalAngles();
	m_vecAngle2 = GetLocalAngles() + pev->movedir * m_flMoveDistance;

	ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal" );

	m_fStayPushed = (m_flWait == -1) ? TRUE : FALSE;
	m_fRotating = TRUE;

	// if the button is flagged for USE button activation only, take away it's touch function and add a use function
	if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ))
	{
		SetTouch( NULL );
		SetUse( &CBaseButton::ButtonUse );
	}
	else
	{	
		// touchable button
		SetTouch( &CBaseButton::ButtonTouch );
	}

	UTIL_SetOrigin( this, GetLocalOrigin( ));
	m_pUserData = WorldPhysic->CreateKinematicBodyFromEntity( this );
}
开发者ID:FWGS,项目名称:XashXT,代码行数:59,代码来源:buttons.cpp

示例8: GetLocalAngles

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CRotDoor::Spawn( void )
{
	BaseClass::Spawn();

	// set the axis of rotation
	CBaseToggle::AxisDir();

	// check for clockwise rotation
	if ( HasSpawnFlags(SF_DOOR_ROTATE_BACKWARDS) )
		m_vecMoveAng = m_vecMoveAng * -1;
	
	//m_flWait			= 2; who the hell did this? (sjb)
	m_vecAngle1	= GetLocalAngles();
	m_vecAngle2	= GetLocalAngles() + m_vecMoveAng * m_flMoveDistance;

	ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal\n");

	// Starting open allows a func_door to be lighted in the closed position but
	// spawn in the open position
	//
	// SF_DOOR_START_OPEN_OBSOLETE is an old broken way of spawning open that has
	// been deprecated.
	if ( HasSpawnFlags(SF_DOOR_START_OPEN_OBSOLETE) )
	{	
		// swap pos1 and pos2, put door at pos2, invert movement direction
		QAngle vecNewAngles = m_vecAngle2;
		m_vecAngle2 = m_vecAngle1;
		m_vecAngle1 = vecNewAngles;
		m_vecMoveAng = -m_vecMoveAng;

		// We've already had our physics setup in BaseClass::Spawn, so teleport to our
		// current position. If we don't do this, our vphysics shadow will not update.
		Teleport( NULL, &m_vecAngle1, NULL );

		m_toggle_state = TS_AT_BOTTOM;
	}
	else if ( m_eSpawnPosition == FUNC_DOOR_SPAWN_OPEN )
	{	
		// We've already had our physics setup in BaseClass::Spawn, so teleport to our
		// current position. If we don't do this, our vphysics shadow will not update.
		Teleport( NULL, &m_vecAngle2, NULL );
		m_toggle_state = TS_AT_TOP;
	}
	else
	{
		m_toggle_state = TS_AT_BOTTOM;
	}

#ifdef HL1_DLL
	SetSolid( SOLID_VPHYSICS );
#endif
		
	// Slam the object back to solid - if we really want it to be solid.
	if ( m_bSolidBsp )
	{
		SetSolid( SOLID_BSP );
	}
}
开发者ID:KyleGospo,项目名称:City-17-Episode-One-Source,代码行数:61,代码来源:doors.cpp

示例9: SetPosition

void CMomentaryRotButton :: SetPosition( float value )
{
	pev->ideal_yaw = bound( 0.0f, value, 1 );

	float flCurPos = GetPos( GetLocalAngles( ));

	if( flCurPos < pev->ideal_yaw )
	{
		// moving forward (from start to end).
		SetLocalAvelocity( pev->speed * pev->movedir );
		m_direction = 1;
	}
	else if( flCurPos > pev->ideal_yaw )
	{
		// moving backward (from end to start).
		SetLocalAvelocity( -pev->speed * pev->movedir );
		m_direction = -1;
	}
	else
	{
		// we're there already; nothing to do.
		SetLocalAvelocity( g_vecZero );
		return;
	}

	// g-cont. to avoid moving by user in back direction
	if( FBitSet( pev->spawnflags, SF_MOMENTARY_ROT_BUTTON_AUTO_RETURN ) && m_returnSpeed > 0 )
		m_lastUsed = 1;

	// play sound on set new pos
	PlaySound();

	SetMoveDone( &CMomentaryRotButton::SetPositionMoveDone );
	SetThink( &CMomentaryRotButton::UpdateThink );
	SetNextThink( 0 );

	// Think again in 0.1 seconds or the time that it will take us to reach our movement goal,
	// whichever is the shorter interval. This prevents us from overshooting and stuttering when we
	// are told to change position in very small increments.
	Vector vecNewAngles = m_start + pev->movedir * ( pev->ideal_yaw * m_flMoveDistance );
	float flAngleDelta = fabs( AxisDelta( pev->spawnflags, vecNewAngles, GetLocalAngles( )));
	float dt = flAngleDelta / pev->speed;

	if( dt < gpGlobals->frametime )
	{
		dt = gpGlobals->frametime;
		float speed = flAngleDelta / gpGlobals->frametime;
		SetLocalAvelocity( speed * pev->movedir * m_direction );
	}

	dt = bound( gpGlobals->frametime, dt, gpGlobals->frametime * 6 );

	SetMoveDoneTime( dt );
}
开发者ID:FWGS,项目名称:XashXT,代码行数:54,代码来源:buttons.cpp

示例10: Precache

//-----------------------------------------
// Spawn
//-----------------------------------------
void CAPCController::Spawn( void )
{
	Precache();

	m_yawCenter			= GetLocalAngles().y;
	m_pitchCenter		= GetLocalAngles().x;

	if ( IsActive() )
	{
		SetNextThink( gpGlobals->curtime + 1.0f );
	}

	UpdateMatrix();
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:17,代码来源:point_apc_controller.cpp

示例11: GetLocalAngles

void C_MSS_Player::PreThink( void )
{
	QAngle vTempAngles = GetLocalAngles();

	if ( GetLocalPlayer() == this )
	{
		vTempAngles[PITCH] = EyeAngles()[PITCH];
	}
	else
	{
		vTempAngles[PITCH] = m_angEyeAngles[PITCH];
	}

	if ( vTempAngles[YAW] < 0.0f )
	{
		vTempAngles[YAW] += 360.0f;
	}

	SetLocalAngles( vTempAngles );

	BaseClass::PreThink();

	HandleSpeedChanges();

	if ( m_HL2Local.m_flSuitPower <= 0.0f )
	{
		if( IsSprinting() )
		{
			StopSprinting();
		}
	}
}
开发者ID:BoXorz,项目名称:MSS,代码行数:32,代码来源:c_MSS_player.cpp

示例12: GetLocalOrigin

//-----------------------------------------------------------------------------
// Purpose: Aim the offset barrel at a position in parent space
// Input  : parentTarget - the position of the target in parent space
// Output : Vector - angles in local space
//-----------------------------------------------------------------------------
QAngle CFuncTank::AimBarrelAt( const Vector &parentTarget )
{
	Vector target = parentTarget - GetLocalOrigin();
	float quadTarget = target.LengthSqr();
	float quadTargetXY = target.x*target.x + target.y*target.y;

	// Target is too close!  Can't aim at it
	if ( quadTarget <= m_barrelPos.LengthSqr() )
	{
		return GetLocalAngles();
	}
	else
	{
		// We're trying to aim the offset barrel at an arbitrary point.
		// To calculate this, I think of the target as being on a sphere with 
		// it's center at the origin of the gun.
		// The rotation we need is the opposite of the rotation that moves the target 
		// along the surface of that sphere to intersect with the gun's shooting direction
		// To calculate that rotation, we simply calculate the intersection of the ray 
		// coming out of the barrel with the target sphere (that's the new target position)
		// and use atan2() to get angles

		// angles from target pos to center
		float targetToCenterYaw = atan2( target.y, target.x );
		float centerToGunYaw = atan2( m_barrelPos.y, sqrt( quadTarget - (m_barrelPos.y*m_barrelPos.y) ) );

		float targetToCenterPitch = atan2( target.z, sqrt( quadTargetXY ) );
		float centerToGunPitch = atan2( -m_barrelPos.z, sqrt( quadTarget - (m_barrelPos.z*m_barrelPos.z) ) );
		return QAngle( -RAD2DEG(targetToCenterPitch+centerToGunPitch), RAD2DEG( targetToCenterYaw - centerToGunYaw ), 0 );		
	}
}
开发者ID:AgentAgrimar,项目名称:source-sdk-trilogy,代码行数:36,代码来源:hl1_func_tank.cpp

示例13: Precache

void CTripwireGrenade::Spawn( void )
{
	Precache( );

	SetMoveType( MOVETYPE_FLY );
	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_NOT_SOLID );

	SetModel( "models/Weapons/w_slam.mdl" );

	m_nMissileCount	= 0;
	
	UTIL_SetSize(this, Vector( -4, -4, -2), Vector(4, 4, 2));

	m_flPowerUp = gpGlobals->curtime + 1.2;//<<CHECK>>get rid of this
	
	SetThink( WarningThink );
	SetNextThink( gpGlobals->curtime + 1.0f );

	m_takedamage		= DAMAGE_YES;

	m_iHealth = 1;

	m_pRope = NULL;
	m_pHook = NULL;

	// Tripwire grenade sits at 90 on wall so rotate back to get m_vecDir
	QAngle angles = GetLocalAngles();
	angles.x -= 90;

	AngleVectors( angles, &m_vecDir );
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:32,代码来源:grenade_tripwire.cpp

示例14: SetThink

void CTripwireGrenade::MakeRope( void )
{
	SetThink( RopeBreakThink );

	// Delay first think slightly so rope has time
	// to appear if person right in front of it
	SetNextThink( gpGlobals->curtime + 1.0f );

	// Create hook for end of tripwire
	m_pHook = (CTripwireHook*)CBaseEntity::Create( "tripwire_hook", GetLocalOrigin(), GetLocalAngles() );
	if (m_pHook)
	{
		Vector vShootVel = 800*(m_vecDir + Vector(0,0,0.3)+RandomVector(-0.01,0.01));
		m_pHook->SetVelocity( vShootVel, vec3_origin);
		m_pHook->SetOwnerEntity( this );
		m_pHook->m_hGrenade		= this;

		m_pRope = CRopeKeyframe::Create(this,m_pHook,0,0);
		if (m_pRope)
		{
			m_pRope->m_Width		= 1;
			m_pRope->m_RopeLength	= 3;
			m_pRope->m_Slack		= 100;

			CPASAttenuationFilter filter( this,"TripwireGrenade.ShootRope" );
			EmitSound( filter, entindex(),"TripwireGrenade.ShootRope" );
		}
	}
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:29,代码来源:grenade_tripwire.cpp

示例15: AngleVectors

//-----------------------------------------------------------------------------
// Purpose: Keeps wobbling down by trying to keep the roller upright. 
//
//
// Output : 
//-----------------------------------------------------------------------------
void CNPC_Roller::RemainUpright( void )
{
	if( !m_RollerController.IsOn() )
	{
		// Don't bother with the math if the controller is off.
		return;
	}

	// We're going to examine the Z component of the Right vector 
	// to see how upright we are.
	Vector vecRight;

	AngleVectors( GetLocalAngles(), NULL, &vecRight, NULL );
	
	//Msg( "%f\n", vecRight.z );

	if( vecRight.z > 0.0001 )
	{
		Msg( "-torque\n" );
		m_RollerController.m_vecAngular.x = ROLLER_UPRIGHT_SPEED;
	}
	else if ( vecRight.z < -0.0001 )
	{
		Msg( "+torque\n" );
		m_RollerController.m_vecAngular.x = -ROLLER_UPRIGHT_SPEED;
	}
	else 
	{
		m_RollerController.m_vecAngular.x = 0;
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:37,代码来源:npc_roller.cpp


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