Added: #1469 Function to resolve position for TPositionOrEntity objects

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 12 years ago
parent bd69090057
commit d833a222c5

@ -18,6 +18,9 @@
#include "camera_animation_manager/camera_animation_modifier_player_factory.h"
#include "game_share/position_or_entity_type.h"
#include "camera_animation_manager/camera_animation_info.h"
#include "camera_animation_manager/position_or_entity_pos_resolver.h"
#include "global.h"
#include "sound_manager.h"
/////////////////////////////////////////////////////////////////////////////
/// This animation modifier shakes the camera. The parameter is
@ -75,6 +78,10 @@ public:
impulse.serial(const_cast<TPositionOrEntity&>(SoundPos));
impulse.serial(const_cast<NLMISC::CSheetId&>(SoundId));
// We play the sound once here
NLMISC::CVector pos = resolvePositionOrEntityPosition(SoundPos);
SoundMngr->spawnSource(SoundId, pos);
return true;
}

@ -18,6 +18,7 @@
#include "camera_animation_manager/camera_animation_step_player_factory.h"
#include "game_share/position_or_entity_type.h"
#include "camera_animation_manager/camera_animation_info.h"
#include "camera_animation_manager/position_or_entity_pos_resolver.h"
/// Basic camera animation step that has generic values

@ -0,0 +1,46 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "camera_animation_manager/position_or_entity_pos_resolver.h"
#include "entity_cl.h"
#include "game_share/position_or_entity_type.h"
#include "entities.h"
NLMISC::CVector resolvePositionOrEntityPosition(const TPositionOrEntity& posOrEntity)
{
if (!posOrEntity.isValid())
{
nlwarning("<resolvePositionOrEntityPosition> invalid position or entity");
return NLMISC::CVector();
}
if (posOrEntity.isPosition())
return posOrEntity.getPosition();
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(posOrEntity.getEntityId());
if (!entity)
{
nlwarning("<resolvePositionOrEntityPosition> invalid entity with compressed id %d", posOrEntity.getEntityId());
return NLMISC::CVector();
}
else
{
NLMISC::CVector pos = entity->pos();
return pos;
}
return NLMISC::CVector();
}

@ -0,0 +1,30 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RY_POSITIONORENTITYPOSRESOLVER_H
#define RY_POSITIONORENTITYPOSRESOLVER_H
#include "nel/misc/entity_id.h"
#include "nel/misc/vector.h"
#include "game_share/position_or_entity_type.h"
/// Function that returns the stored position if it contains a position
/// Or the current entity's position if it contains an entity
NLMISC::CVector resolvePositionOrEntityPosition(const TPositionOrEntity& posOrEntity);
#endif /* RY_POSITIONORENTITYPOSRESOLVER_H */

@ -92,6 +92,7 @@
#include "nel/misc/entity_id.h"
#include "entity_cl.h"
#include "camera_animation_manager/camera_animation_player.h"
#include "camera_animation_manager/position_or_entity_pos_resolver.h"
#define OLD_STRING_SYSTEM
@ -3574,25 +3575,9 @@ void impulsePlaySoundTrigger(NLMISC::CBitMemStream& impulse)
nlwarning("<impulsePlaySoundTrigger> invalid SoundPosition");
return;
}
if (SoundPosition.isPosition())
SoundMngr->spawnSource(SoundId, SoundPosition.getPosition());
else
{
NLMISC::CVectorD pos;
TDataSetIndex compressedIndex = SoundPosition.getEntityId();
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(compressedIndex);
if (!entity)
{
nlwarning("<impulsePlaySoundTrigger> invalid entity with compressed id %d", compressedIndex);
return;
}
else
{
pos = entity->pos();
SoundMngr->spawnSource(SoundId, pos);
}
}
NLMISC::CVector pos = resolvePositionOrEntityPosition(SoundPosition);
SoundMngr->spawnSource(SoundId, pos);
}
void impulseCameraAnimationPlay(NLMISC::CBitMemStream& impulse)

Loading…
Cancel
Save