Ejemplo n.º 1
0
		void Actor::SetMoveDirection( const Float3& v )
		{
			m_vMoveDir.x	=	v.x;
			m_vMoveDir.z	=	v.z;
			
			if(v.Length()	<0.00001){
				if(m_MoveState!=enAMS_NoMove){
					m_pModel->SetActionState("stand.CAF");
					m_MoveState	=	enAMS_NoMove;
				}
			}else{
				float fRun	=	m_vMoveDir.Dot(m_vFaceDir);
				if(fRun	>	0){
					
					if(m_MoveState!=enAMS_CustomRun){
						m_MoveState	=	enAMS_CustomRun;
						m_pModel->SetActionState("run.CAF");
					}
				}else{
					if(m_MoveState!=enAMS_CustomBack){
						m_MoveState	=	enAMS_CustomBack;
						m_pModel->SetActionState("runback.CAF");
					}
				}

				
			}


		}
Ejemplo n.º 2
0
	void SLSound::Update(const Float3 & listener)
	{
		float vol = mVolume * AudioSystem::Instance()->GetGlobalVolume(mCategory);

		if (mFlags & AUDIO_FLAG_3DSOUND)
		{
			Float3 d = mPosition - listener;
			float len = d.Length();

			if (len > mAttenStart)
			{
				float k = (len - mAttenStart) * mInvAttenDist;
				k = 1.0f - Math::Clamp(k, 0.0f, 1.0f);
				vol *= k;
			}
		}

		float fade = 1;

		if (mFadeMode == FADE_IN)
			mFadeTime += Root::Instance()->GetFrameTime();
		else if (mFadeMode == FADE_OUT)
			mFadeTime -= Root::Instance()->GetFrameTime();

		mFadeTime = Math::Clamp(mFadeTime, 0.0f, SL_FADETIME);
		fade = mFadeTime / SL_FADETIME;
		vol *= fade;

		if (mVolumeAbs != vol)
		{
			SLmillibel volume = _getVolumeLevel(vol);

			(*mVolumeI)->SetVolumeLevel(mVolumeI, volume);
			(*mVolumeI)->SetMute(mVolumeI, vol > 0 ? FALSE : TRUE);

			mVolumeAbs = vol;
		}

		if (fade == 0 && mFadeMode == FADE_OUT)
			Stop();
		else if (IsTimeOut())
			Stop();
		else if (i_thread == NULL)
			Track();
	}
Ejemplo n.º 3
0
Float3 Float3::Perpendicular(const Float3& vec)
{
    Assert_(vec.Length() >= 0.00001f);

    Float3 perp;

    float x = std::abs(vec.x);
    float y = std::abs(vec.y);
    float z = std::abs(vec.z);
    float minVal = std::min(x, y);
    minVal = std::min(minVal, z);

    if(minVal == x)
        perp = Float3::Cross(vec, Float3(1.0f, 0.0f, 0.0f));
    else if(minVal == y)
        perp = Float3::Cross(vec, Float3(0.0f, 1.0f, 0.0f));
    else
        perp = Float3::Cross(vec, Float3(0.0f, 0.0f, 1.0f));

    return Float3::Normalize(perp);
}
Ejemplo n.º 4
0
BSphere MergeBoundingSpheres(const std::vector<BSphere> &bspheres)
{
	BSphere sphere = bspheres[0];
	
	for (uint32 i = 1; i < bspheres.size(); i++)
	{
		BSphere &sphere1 = sphere;
		const BSphere &sphere2 = bspheres[i];

		Float3 sphere2Center(sphere2.Center);
		Float3 sphere1Center(sphere1.Center);
		Float3 difference = sphere2Center - sphere1Center;

		float length = difference.Length();
		float radius = sphere1.Radius;
		float radius2 = sphere2.Radius;

		if (radius + radius2 >= length)
		{
			if (radius - radius2 >= length)
				return sphere1;

			if (radius2 - radius >= length)
				return sphere2;
		}

		Float3 vector = difference * (1.0f / length);
		float min = Min(-radius, length - radius2);
		float max = (Max(radius, length + radius2) - min) * 0.5f;

		sphere.Center = *(XMFLOAT3 *)&(sphere1Center + vector * (max + min));
		sphere.Radius = max;
	}

	return sphere;
}