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


C++ GetSpeed函数代码示例

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


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

示例1: SetMode

void AirsideFollowMeCarInSim::ServicingFlight()
{
	double dDist = m_pServiceFlight->GetDistInResource() + m_pServiceFlight->GetLogEntry().GetAirsideDescStruct().dLength;
	CPoint2008 CarPos = m_pServiceFlight->GetResource()->GetDistancePoint(dDist);

	SetMode(OnService);
	SetSpeed(m_pServiceFlight->GetSpeed());
	ElapsedTime tTime = ElapsedTime(2.0*CarPos.distance(GetPosition())/GetSpeed()) + GetTime();
	SetTime(tTime);
	if(GetResource() != m_pServiceFlight->GetResource())
		GetResource()->SetExitTime(this,tTime);
	SetResource(m_pServiceFlight->GetResource());
	SetPosition(CarPos);
	SetDistInResource(dDist);
	WirteLog(CarPos,GetSpeed(),tTime);

	m_pServiceFlight->SetBeginFollowMeCarService();

	AirsideFollowMeCarServiceEvent* pEvent = new AirsideFollowMeCarServiceEvent(m_pServiceFlight);
	pEvent->setTime(tTime);
	pEvent->addEvent();
}
开发者ID:chenbk85,项目名称:tphProjects,代码行数:22,代码来源:AirsideFollowMeCarInSim.cpp

示例2: GetSpeed

void Asserv::stop(bool emergency)
{
    float actualSpeed = GetSpeed();
    /* distance theorique (temps continu) pour annuler la vitesse avec un freinage maximum et constant*/
    if (emergency){
        d_freinage  = (actualSpeed*actualSpeed) * .5 / decEmergency;
    } else {
        d_freinage  = (actualSpeed*actualSpeed) * .5 / dec;    
    }
    setTarget(initialSens * d_freinage, 0.0);
    emergencyStop = emergency;

}
开发者ID:RoseTeam,项目名称:CommandMot,代码行数:13,代码来源:Asserv.cpp

示例3: SingleLock

void CVideoReferenceClock::SetSpeed(double Speed)
{
  CSingleLock SingleLock(m_CritSection);
  //dvdplayer can change the speed to fit the rereshrate
  if (m_UseVblank)
  {
    if (Speed != m_ClockSpeed)
    {
      m_ClockSpeed = Speed;
      CLog::Log(LOGDEBUG, "CVideoReferenceClock: Clock speed %f%%", GetSpeed() * 100.0);
    }
  }
}
开发者ID:MrMC,项目名称:mrmc,代码行数:13,代码来源:VideoReferenceClock.cpp

示例4: SerializePathsTo

void PathBehavior::SerializeTo(gd::SerializerElement & element) const
{
    SerializePathsTo(element.AddChild("paths"));

    element.SetAttribute("currentPath", GetCurrentPathName());
    element.SetAttribute("speed", GetSpeed());
    element.SetAttribute("offsetX", GetOffsetX());
    element.SetAttribute("offsetY", GetOffsetY());
    element.SetAttribute("angleOffset", angleOffset);
    element.SetAttribute("reverseAtEnd", ReverseAtEnd());
    element.SetAttribute("stopAtEnd", StopAtEnd());
    element.SetAttribute("followAngle", FollowAngle());
}
开发者ID:sanyaade-teachings,项目名称:GD,代码行数:13,代码来源:PathBehavior.cpp

示例5: switch

void PhysicalObj::Collide(collision_t collision, PhysicalObj* collided_obj, const Point2d& position)
{
  Point2d contactPos;
  Double contactAngle;

  switch (collision) {
  case NO_COLLISION:
    // Nothing more to do!
    return;

  case COLLISION_ON_GROUND:
    ContactPointAngleOnGround(position, contactPos, contactAngle);
    ASSERT(!collided_obj);
    break;

  case COLLISION_ON_OBJECT:
    contactPos = position;
    contactAngle = - GetSpeedAngle();

    // Compute the new speed norm of this and collided_obj, new speed angle will be set
    // thanks to Rebound()

    // Get the current speed
    Double v1, v2, mass1, angle1, angle2, mass2;
    collided_obj->GetSpeed(v1, angle1);
    GetSpeed(v2, angle2);
    mass1 = GetMass();
    mass2 = collided_obj->GetMass();

    // Give speed to the other object
    // thanks to physic and calculations about chocs, we know that :
    //
    // v'1 =  ((m1 - m2) * v1 + 2m1 *v2) / (m1 + m2)
    // v'2 =  ((m2 - m1) * v2 + 2m1 *v1) / (m1 + m2)
    collided_obj->SetSpeed(abs(((mass1 - mass2) * v1 + 2 * mass1 *v2 * m_cfg.m_rebound_factor) / (mass1 + mass2)),
                           angle1);
    SetSpeed(abs(((mass2 - mass1) * v2 + 2 * mass1 *v1 * m_cfg.m_rebound_factor) / (mass1 + mass2)), angle2);
    break;
  }

  // Mark it as last collided object
  m_last_collided_object = collided_obj;

  // Make it rebound!!
  MSG_DEBUG("physic.state", "%s rebounds at %.3f,%.3f", GetName().c_str(),
            contactPos.x.tofloat(), contactPos.y.tofloat());

  Rebound(contactPos, contactAngle);
  CheckRebound();
}
开发者ID:Arnaud474,项目名称:Warmux,代码行数:50,代码来源:physical_obj.cpp

示例6: Precache

void CBubbling::Spawn( void )
{
	Precache();
	SetModel( GetModelName() );		// Set size

	SetSolidType( SOLID_NOT );							// Remove model & collisions
	SetRenderAmount( 0 );								// The engine won't draw this model if this is set to 0 and blending is on
	SetRenderMode( kRenderTransTexture );
	int speed = fabs( GetSpeed() );

	// HACKHACK!!! - Speed in rendercolor
	SetRenderColor( Vector( speed >> 8, speed & 255, ( GetSpeed() < 0 ) ? 1 : 0 ) );


	if( !GetSpawnFlags().Any( SF_BUBBLES_STARTOFF ) )
	{
		SetThink( &CBubbling::FizzThink );
		SetNextThink( gpGlobals->time + 2.0 );
		m_state = true;
	}
	else
		m_state = false;
}
开发者ID:oskarlh,项目名称:HLEnhanced,代码行数:23,代码来源:CBubbling.cpp

示例7: switch

void CTriggerPush::Touch( CBaseEntity *pOther )
{
	// UNDONE: Is there a better way than health to detect things that have physics? (clients/monsters)
	switch( pOther->GetMoveType() )
	{
	case MOVETYPE_NONE:
	case MOVETYPE_PUSH:
	case MOVETYPE_NOCLIP:
	case MOVETYPE_FOLLOW:
		return;

	default: break;
	}

	if( pOther->GetSolidType() != SOLID_NOT && pOther->GetSolidType() != SOLID_BSP )
	{
		// Instant trigger, just transfer velocity and remove
		if( GetSpawnFlags().Any( SF_TRIG_PUSH_ONCE ) )
		{
			pOther->SetAbsVelocity( pOther->GetAbsVelocity() + ( GetSpeed() * GetMoveDir() ) );
			if( pOther->GetAbsVelocity().z > 0 )
				pOther->GetFlags().ClearFlags( FL_ONGROUND );
			UTIL_Remove( this );
		}
		else
		{	// Push field, transfer to base velocity
			Vector vecPush = ( GetSpeed() * GetMoveDir() );
			if( pOther->GetFlags().Any( FL_BASEVELOCITY ) )
				vecPush = vecPush + pOther->GetBaseVelocity();

			pOther->SetBaseVelocity( vecPush );

			pOther->GetFlags() |= FL_BASEVELOCITY;
			//			ALERT( at_console, "Vel %f, base %f\n", pevToucher->velocity.z, pevToucher->basevelocity.z );
		}
	}
}
开发者ID:oskarlh,项目名称:HLEnhanced,代码行数:37,代码来源:CTriggerPush.cpp

示例8: CodeToDataBlock

// 添加到CByteArray
bool CShape::CodeToDataBlock(DBWriteSet& setWriteDB, bool bExData)
{
	CBaseObject::CodeToDataBlock(setWriteDB,bExData);
	setWriteDB.AddToByteArray((BYTE)GetCurRgnType());
	setWriteDB.AddToByteArray(GetRegionID());
	setWriteDB.AddToByteArray(GetRegionExID());
	setWriteDB.AddToByteArray(GetPosX());
	setWriteDB.AddToByteArray(GetPosY());
	setWriteDB.AddToByteArray(GetDir());
	setWriteDB.AddToByteArray(GetPos());
	setWriteDB.AddToByteArray(GetSpeed());
	setWriteDB.AddToByteArray(GetState());
	setWriteDB.AddToByteArray(GetAction());
	return true;
}
开发者ID:yuanxiubin1128,项目名称:mmo-resourse,代码行数:16,代码来源:Shape.cpp

示例9: SetPosX

void CRock_Fall::Update(float fElapsedTime)
{
	AnimationManager::GetInstance()->Update(fElapsedTime, *GetAnimInfo());
	//CEntity::Update(fElapsedTime);
	SetPosX(GetPosX());
	SetPosY(GetPosY() + GetSpeed() * fElapsedTime);
	CCamera* Game_Camera = CCamera::GetInstance();
	if(this->GetPosY() > Game_Camera->GetPosY() + Game_Camera->GetHeight())
	{
		CRemoveEntityMessage* pMsg = new CRemoveEntityMessage(this);
		CSGD_MessageSystem::GetInstance()->SendMsg(pMsg);
		pMsg = nullptr;
	}

}
开发者ID:kendellm,项目名称:Trials-of-Mastery,代码行数:15,代码来源:Rock_Fall.cpp

示例10: _AddToByteArray

// 添加到CByteArray
bool CShape::AddShapeToByteArray(vector<BYTE>* pByteArray)
{
	_AddToByteArray(pByteArray,(CGUID&)GetExID());
	_AddToByteArray(pByteArray, (long)GetCurRgnType());
	_AddToByteArray(pByteArray, GetRegionID());
	_AddToByteArray(pByteArray, GetRegionExID());
	_AddToByteArray(pByteArray, GetPosX());
	_AddToByteArray(pByteArray, GetPosY());
	_AddToByteArray(pByteArray, GetDir());
	_AddToByteArray(pByteArray, GetPos());
	_AddToByteArray(pByteArray, GetSpeed());
	_AddToByteArray(pByteArray, GetState());
	_AddToByteArray(pByteArray, GetAction());
	return true;
}
开发者ID:yuanxiubin1128,项目名称:mmo-resourse,代码行数:16,代码来源:Shape.cpp

示例11: msg

//发送变化的速度值到客户端
void CMoveShape::SendChangedSpeedToClients()
{
	//if(m_bSpeedLvlChanged)
	{
		m_bSpeedLvlChanged = false;
		CMessage msg(MSG_S2C_SHAPE_CHANGEMOVEMODE);
		msg.Add(GetType());
		msg.Add(GetExID());
		//移动模式
		msg.Add(static_cast<char>(GetIsRun()==false?0:1));
		//当前速度
		msg.Add( GetSpeed());
		//变化比率
		msg.Add(GetSpeedChangedRatio());
		msg.SendToAround(this);
	}
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:18,代码来源:ShapeMessage.cpp

示例12: Precache

void CBaseDoor::Spawn()
{
	Precache();
	SetMovedir( this );

	if( GetSkin() == 0 )
	{//normal door
		if( GetSpawnFlags().Any( SF_DOOR_PASSABLE ) )
			SetSolidType( SOLID_NOT );
		else
			SetSolidType( SOLID_BSP );
	}
	else
	{// special contents
		SetSolidType( SOLID_NOT );
		GetSpawnFlags().AddFlags( SF_DOOR_SILENT );	// water is silent for now
	}

	SetMoveType( MOVETYPE_PUSH );
	SetAbsOrigin( GetAbsOrigin() );
	SetModel( GetModelName() );

	if( GetSpeed() == 0 )
		SetSpeed( 100 );

	m_vecPosition1 = GetAbsOrigin();
	// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
	m_vecPosition2 = m_vecPosition1 + ( GetMoveDir() * ( fabs( GetMoveDir().x * ( GetBounds().x - 2 ) ) + fabs( GetMoveDir().y * ( GetBounds().y - 2 ) ) + fabs( GetMoveDir().z * ( GetBounds().z - 2 ) ) - m_flLip ) );
	ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" );
	if( GetSpawnFlags().Any( SF_DOOR_START_OPEN ) )
	{	// swap pos1 and pos2, put door at pos2
		SetAbsOrigin( m_vecPosition2 );
		m_vecPosition2 = m_vecPosition1;
		m_vecPosition1 = GetAbsOrigin();
	}

	m_toggle_state = TS_AT_BOTTOM;

	// if the door is flagged for USE button activation only, use NULL touch function
	if( GetSpawnFlags().Any( SF_DOOR_USE_ONLY ) )
	{
		SetTouch( NULL );
	}
	else // touchable button
		SetTouch( &CBaseDoor::DoorTouch );
}
开发者ID:oskarlh,项目名称:HLEnhanced,代码行数:46,代码来源:CBaseDoor.cpp

示例13: OnHitEntity

void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer())
	{
		// Not an entity that interacts with an arrow
		return;
	}
	
	int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
	if (m_IsCritical)
	{
		Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
	}
	a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
	
	Destroy();
}
开发者ID:jimfinnis,项目名称:MCServer,代码行数:17,代码来源:ProjectileEntity.cpp

示例14: GetSpeed

void clRailPositioner::Update( float dt )
{
	float S = GetSpeed( dt );

	// move to properties
	float PitchRate = 90.0f * dt;
	float PanRate = 90.0f * dt;

	PitchRate *= Env->Console->IsKeyPressed( LK_SHIFT ) ? 3.0f : 1.0f;
	PanRate *= Env->Console->IsKeyPressed( LK_SHIFT ) ? 3.0f : 1.0f;

	if ( Env->Console->IsKeyPressed( LK_LEFT  ) ) { FPitch -= PitchRate; }

	if ( Env->Console->IsKeyPressed( LK_RIGHT ) ) { FPitch += PitchRate; }

	if ( Env->Console->IsKeyPressed( LK_E ) )     { FPan -= PanRate; }

	if ( Env->Console->IsKeyPressed( LK_C ) )     { FPan += PanRate; }

	FPitch = Math::ClipAngleTo0_360( FPitch );
	FPan   = Math::ClipAngleTo0_360( FPan );

	LMatrix4 PitchMtx;
	PitchMtx.IdentityMatrix();
	PitchMtx.RotateMatrixAxis( Linderdaum::Math::DegToRad( -FPitch ), FUpVector );

	LVector3 ViewDir = -( PitchMtx * FDirVector );
	LVector3 SideDir = -( FUpVector.Cross( ViewDir ) );

	if ( Env->Console->IsKeyPressed( LK_Q ) || Env->Console->IsKeyPressed( LK_1 ) ) { FPosition += S * FUpVector; }

	if ( Env->Console->IsKeyPressed( LK_Z ) || Env->Console->IsKeyPressed( LK_2 ) ) { FPosition -= S * FUpVector; }

	if ( Env->Console->IsKeyPressed( LK_W ) || Env->Console->IsKeyPressed( LK_UP   ) ) { FPosition += -ViewDir * S; }

	if ( Env->Console->IsKeyPressed( LK_S ) || Env->Console->IsKeyPressed( LK_DOWN ) ) { FPosition += ViewDir * S; }

	if ( Env->Console->IsKeyPressed( LK_A ) ) { FPosition +=  SideDir * S; }

	if ( Env->Console->IsKeyPressed( LK_D ) ) { FPosition += -SideDir * S; }

	LMatrix4 Rotation = LMatrix4::GetRotateMatrixAxis( Math::DegToRad( FPan ), SideDir ) * LMatrix4::GetRotateMatrixAxis( Math::DegToRad( FPitch ), FUpVector );

	FCurrentTransform = LMatrix4::GetTranslateMatrix( -FPosition ) * Rotation;
}
开发者ID:berezhkovskaya,项目名称:Carousel3D,代码行数:45,代码来源:CameraPositioner.cpp

示例15: OnHitEntity

void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	super::OnHitEntity(a_EntityHit, a_HitPos);

	int Damage = static_cast<int>(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
	if (m_IsCritical)
	{
		Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
	}

	unsigned int PowerLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPower);
	if (PowerLevel > 0)
	{
		int ExtraDamage = static_cast<int>(ceil(0.25 * (PowerLevel + 1)));
		Damage += ExtraDamage;
	}

	// int KnockbackAmount = 1;
	unsigned int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
	if (PunchLevel > 0)
	{
		Vector3d LookVector = GetLookVector();
		Vector3f FinalSpeed = Vector3f(0, 0, 0);
		switch (PunchLevel)
		{
			case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5); break;
			case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8); break;
			default: break;
		}
		a_EntityHit.SetSpeed(FinalSpeed);
	}

	// a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);  // TODO fix knockback.
	a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 0);  // Until knockback is fixed.

	if (IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming())
	{
		a_EntityHit.StartBurning(100);
	}

	// Broadcast successful hit sound
	GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));

	Destroy();
}
开发者ID:Haxi52,项目名称:cuberite,代码行数:45,代码来源:ArrowEntity.cpp


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