本文整理汇总了C++中Float3::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ Float3::Length方法的具体用法?C++ Float3::Length怎么用?C++ Float3::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Float3
的用法示例。
在下文中一共展示了Float3::Length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMoveDirection
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");
}
}
}
}
示例2: Update
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();
}
示例3: if
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);
}
示例4: MergeBoundingSpheres
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;
}