コード例 #1
0
ファイル: CCmpSoundManager.cpp プロジェクト: stonefruit/0ad
    virtual void PlaySoundGroup(std::wstring name, entity_id_t source)
    {
#if CONFIG2_AUDIO
        // Make sure the sound group is loaded
        CSoundGroup* group;
        if (m_SoundGroups.find(name) == m_SoundGroups.end())
        {
            group = new CSoundGroup();
            if (!group->LoadSoundGroup(L"audio/" + name))
            {
                LOGERROR(L"Failed to load sound group '%ls'", name.c_str());
                delete group;
                group = NULL;
            }
            // Cache the sound group (or the null, if it failed)
            m_SoundGroups[name] = group;
        }
        else
        {
            group = m_SoundGroups[name];
        }

        // Failed to load group -> do nothing
        if (!group)
            return;

        // Only play the sound if the entity is visible
        CmpPtr<ICmpRangeManager> cmpRangeManager(GetSimContext(), SYSTEM_ENTITY);
        ICmpRangeManager::ELosVisibility vis = cmpRangeManager->GetLosVisibility(source, GetSimContext().GetCurrentDisplayedPlayer());

        if (vis == ICmpRangeManager::VIS_VISIBLE)
        {
            // Find the source's position, if possible
            // (TODO: we should do something more sensible if there's no position available)
            CVector3D sourcePos(0, 0, 0);
            if (source != INVALID_ENTITY)
            {
                CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), source);
                if (cmpPosition && cmpPosition->IsInWorld())
                    sourcePos = CVector3D(cmpPosition->GetPosition());
            }

            group->PlayNext(sourcePos);
        }
#else // !CONFIG2_AUDIO
        UNUSED2(name);
        UNUSED2(source);
#endif // !CONFIG2_AUDIO
    }
コード例 #2
0
ファイル: CGame.cpp プロジェクト: rpmessner/Marbles
void CGame::interpView ()
{
	CVector3 viewPos, viewCtr;
	CVector3 destPos(3, 40, 3);
	CVector3 sourcePos(m_tolleyPos.x + m_tolleyForward.x*10 , 5, m_tolleyPos.z + m_tolleyForward.z*10);
	if (m_viewInterp < 1) {
	m_viewInterp+=m_deltaT;
	viewPos =  sourcePos *(1-m_viewInterp) + destPos * m_viewInterp;
	viewCtr =  m_aimPos *(1-m_viewInterp)  + m_tolleyPos * m_viewInterp;
	} else {
	viewCtr = m_tolleyPos;
	viewPos = destPos;//CCamera::Instance().LookAt( 3, 20, 3, 0, 0, 0, 0, 1, 0 );
	}
	CCamera::Instance().LookAt(viewPos.x, viewPos.y, viewPos.z,
							   viewCtr.x, viewCtr.y, viewCtr.z,
							   0, 1, 0);
}