本文整理汇总了C++中vec3_t::Abs方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3_t::Abs方法的具体用法?C++ vec3_t::Abs怎么用?C++ vec3_t::Abs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3_t
的用法示例。
在下文中一共展示了vec3_t::Abs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acosf
float vec3_t::GetAngleDeg(const vec3_t& a, const vec3_t& b)
{
float d = a.Abs() * b.Abs();
#ifdef _DEBUG
if(fabsf(d) < lynxmath::EPSILON)
{
assert(0);
return 0.0f;
}
#endif
return acosf((a * b) / d) * lynxmath::RADTODEG;
}
示例2: Update
void CMixer::Update(const float dt, const uint32_t ticks)
{
OBJITER iter;
CObj* obj;
bool success;
for(iter=m_world->ObjBegin();iter!=m_world->ObjEnd();iter++)
{
obj = (*iter).second;
if(obj->GetSound() && !obj->GetSoundState()->is_playing)
{
success = obj->GetSound()->Play(obj->GetSoundState());
CObj* localplayer = m_world->GetLocalObj();
if(success && localplayer)
{
// Distance to sound source
const vec3_t diff = localplayer->GetOrigin() - obj->GetOrigin();
const float dist = std::min(diff.Abs(), SOUND_MAX_DIST);
int volume = (int)(dist*255/SOUND_MAX_DIST);
if(volume > 255)
volume = 255;
uint16_t angle; // 0-360 deg. for Mix_SetPosition
vec3_t playerlook; // player is looking in this direction
float fAlpha; // riwi to sound source
float fBeta; // riwi look dir
m_world->GetLocalController()->GetDir(&playerlook, NULL, NULL);
fAlpha = atan2(diff.x, -diff.z);
fBeta = atan2(playerlook.x, -playerlook.z);
angle = (uint16_t)((fAlpha - fBeta)*180/lynxmath::PI);
Mix_SetPosition(obj->GetSoundState()->cur_channel,
angle, (uint8_t)volume);
}
}
}
}