本文整理汇总了C++中CObj::GetOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ CObj::GetOrigin方法的具体用法?C++ CObj::GetOrigin怎么用?C++ CObj::GetOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CObj
的用法示例。
在下文中一共展示了CObj::GetOrigin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawScene
void CRenderer::DrawScene(const CFrustum& frustum,
CWorld* world,
int localctrlid,
bool generateShadowMap)
{
CObj* obj;
OBJITER iter;
// Draw the level
if(!generateShadowMap && world->GetBSP()->IsLoaded())
{
// Draw the level with lightmapping?
if(m_lightmapactive && m_shaderactive)
glUniform1i(m_uselightmap, 1);
world->GetBSP()->RenderGL(frustum.pos, frustum);
if(m_shaderactive)
glUniform1i(m_uselightmap, 0);
}
// Draw every object
for(iter=world->ObjBegin();iter!=world->ObjEnd();++iter)
{
obj = (*iter).second;
if((obj->GetFlags() & OBJ_FLAGS_GHOST) || // ghosts are invisible - duh
obj->GetID() == localctrlid || // don't draw the player object
!obj->GetMesh()) // object has no md5 model
continue;
// check if object is in view frustum
if(!generateShadowMap && !frustum.TestSphere(obj->GetOrigin(), obj->GetRadius()))
continue;
glPushMatrix();
glTranslatef(obj->GetOrigin().x, obj->GetOrigin().y, obj->GetOrigin().z);
glTranslatef(0.0f, -obj->GetRadius(), 0.0f);
glMultMatrixf(obj->GetRotMatrix()->pm);
obj->GetMesh()->Render(obj->GetMeshState());
#ifdef DRAW_NORMALS
obj->GetMesh()->RenderNormals(obj->GetMeshState()); // not implemented for md2s?
#endif
glPopMatrix();
}
}
示例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);
}
}
}
}