From 29dca7b9d70deda161523a822d80965523e934b5 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Wed, 25 Jul 2012 22:18:11 +0200 Subject: [PATCH] Added: #1469 Base declaration of the CCameraAnimationPlayer class in the client --HG-- branch : gsoc2012-fabien --- code/ryzom/client/src/CMakeLists.txt | 4 +- .../camera_animation_player.cpp | 52 +++++++++++++ .../camera_animation_player.h | 75 +++++++++++++++++++ code/ryzom/client/src/net_manager.cpp | 13 +++- code/ryzom/client/src/release.cpp | 4 + .../position_or_entity_type_helper.cpp | 12 +-- 6 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp create mode 100644 code/ryzom/client/src/camera_animation_manager/camera_animation_player.h diff --git a/code/ryzom/client/src/CMakeLists.txt b/code/ryzom/client/src/CMakeLists.txt index 26c8eb12a..88f83a666 100644 --- a/code/ryzom/client/src/CMakeLists.txt +++ b/code/ryzom/client/src/CMakeLists.txt @@ -10,6 +10,7 @@ ADD_SUBDIRECTORY(seven_zip) FILE(GLOB CFG ../*.cfg ../*.cfg.in) FILE(GLOB SRC *.cpp *.h motion/*.cpp motion/*.h client.rc) FILE(GLOB SRC_INTERFACE interface_v3/*.h interface_v3/*.cpp) +FILE(GLOB SRC_CAMERA_ANIMATION_MANAGER camera_animation_manager/*.h camera_animation_manager/*.cpp) FILE(GLOB SRC_MODE motion/modes/*.cpp motion/modes/*.h) FILE(GLOB SRC_R2 r2/*.h r2/*.cpp r2/dmc/*.h r2/dmc/*.cpp) @@ -37,6 +38,7 @@ LIST(REMOVE_ITEM SRC_INTERFACE SOURCE_GROUP("" FILES ${SRC}) SOURCE_GROUP("cfg" FILES ${CFG}) SOURCE_GROUP("interface_v3" FILES ${SRC_INTERFACE}) +SOURCE_GROUP("Camera animation manager" FILES ${SRC_CAMERA_ANIMATION_MANAGER}) SOURCE_GROUP("mode" FILES ${SRC_MODE}) SOURCE_GROUP("r2" FILES ${SRC_R2}) @@ -60,7 +62,7 @@ if(APPLE) SET(MAC_RESOURCES_DIR ${CMAKE_SOURCE_DIR}/ryzom/client/macosx) ENDIF(APPLE) -ADD_EXECUTABLE(ryzom_client WIN32 MACOSX_BUNDLE ${SRC} ${SRC_INTERFACE} ${SRC_MODE} ${SRC_R2}) +ADD_EXECUTABLE(ryzom_client WIN32 MACOSX_BUNDLE ${SRC} ${SRC_INTERFACE} ${SRC_CAMERA_ANIMATION_MANAGER} ${SRC_MODE} ${SRC_R2}) IF(APPLE) SET_TARGET_PROPERTIES(ryzom_client PROPERTIES OUTPUT_NAME ${MACOSX_BUNDLE_BUNDLE_NAME}) diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp new file mode 100644 index 000000000..b80257b3d --- /dev/null +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp @@ -0,0 +1,52 @@ +// Ryzom - MMORPG Framework +// 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 . +// + + +#include "camera_animation_manager/camera_animation_player.h" + +using namespace std; +using namespace NLMISC; +using namespace NLLIGO; +using namespace NLNET; + +CCameraAnimationPlayer* CCameraAnimationPlayer::_Instance = NULL; + + +CCameraAnimationPlayer::CCameraAnimationPlayer() +{ + +} + +CCameraAnimationPlayer::~CCameraAnimationPlayer() +{ + +} + +void CCameraAnimationPlayer::start() +{ + +} + +void CCameraAnimationPlayer::stop() +{ + +} + +void CCameraAnimationPlayer::playStep( const std::string& stepName, NLMISC::CBitMemStream& impulse ) +{ + +} \ No newline at end of file diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_player.h b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.h new file mode 100644 index 000000000..622557bba --- /dev/null +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.h @@ -0,0 +1,75 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef RY_CAMERAANIMATIONPLAYER_H +#define RY_CAMERAANIMATIONPLAYER_H + + +#include +#include "nel\misc\bit_mem_stream.h" + + +/************************************************************************/ +/* Class that manages the camera animations. (singleton). + * It's responsible of : + * - Parsing camera animations in primitives + * - Sending a specified animation to the client + * + * \author Fabien Henon + * \date 2012 + */ +/************************************************************************/ +class CCameraAnimationPlayer +{ +public: + /// Gets the current instance of the manager + static CCameraAnimationPlayer* getInstance() + { + if (_Instance == NULL) + _Instance = new CCameraAnimationPlayer(); + return _Instance; + } + /// Releases the instance + static void release() + { + if (_Instance != NULL) + { + delete _Instance; + _Instance = NULL; + } + } + + /// Starts playing an animation + void start(); + + /// Stops an animation + void stop(); + + /// Loads and play the specified step + void playStep(const std::string& stepName, NLMISC::CBitMemStream& impulse); + +private: + /// Constructor + CCameraAnimationPlayer(); + /// Destructor + ~CCameraAnimationPlayer(); + + /// Instance of the manager + static CCameraAnimationPlayer* _Instance; +}; + + +#endif /* RY_CAMERAANIMATIONPLAYER_H */ diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index c15a3f0fb..3648d931f 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -91,6 +91,7 @@ #include "nel/misc/vector.h" #include "nel/misc/entity_id.h" #include "entity_cl.h" +#include "camera_animation_manager/camera_animation_player.h" #define OLD_STRING_SYSTEM @@ -3596,17 +3597,25 @@ void impulsePlaySoundTrigger(NLMISC::CBitMemStream& impulse) void impulseCameraAnimationPlay(NLMISC::CBitMemStream& impulse) { - + // We start playing an animation + CCameraAnimationPlayer::getInstance()->start(); } void impulseCameraAnimationStep(NLMISC::CBitMemStream& impulse) { + // We got a new step + // We first get its name + std::string stepName = ""; + impulse.serial(stepName); + // We tell the camera animation player to load and play this instruction + CCameraAnimationPlayer::getInstance()->playStep(stepName, impulse); } void impulseCameraAnimationFinished(NLMISC::CBitMemStream& impulse) { - + // We stop an animation + CCameraAnimationPlayer::getInstance()->stop(); } //----------------------------------------------- diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 3032cfe57..a584ddf05 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -90,6 +90,7 @@ #include "faction_war_manager.h" #include "interface_v3/interface_ddx.h" #include "bg_downloader_access.h" +#include "camera_animation_manager/camera_animation_player.h" /////////// @@ -356,6 +357,8 @@ void releaseMainLoopReselect() // Btw the 2 methods should have strong similarities void releaseMainLoop(bool closeConnection) { + CCameraAnimationPlayer::release(); + ProgressBar.release(); // Release R2 editor if applicable @@ -602,6 +605,7 @@ void release() CSheetId::uninit(); // shutdown a few other singletons + CCameraAnimationPlayer::release(); CLoginProgressPostThread::releaseInstance(); CAttackListManager::releaseInstance(); CFactionWarManager::release(); diff --git a/code/ryzom/server/src/entities_game_service/camera_animation_manager/position_or_entity_type_helper.cpp b/code/ryzom/server/src/entities_game_service/camera_animation_manager/position_or_entity_type_helper.cpp index cf6132ceb..a9b227020 100644 --- a/code/ryzom/server/src/entities_game_service/camera_animation_manager/position_or_entity_type_helper.cpp +++ b/code/ryzom/server/src/entities_game_service/camera_animation_manager/position_or_entity_type_helper.cpp @@ -32,10 +32,10 @@ TPositionOrEntity CPositionOrEntityHelper::fromString(const std::string& s) std::string str = s; CMissionParser::removeBlanks(str); - std::vector res; - NLMISC::splitString(str, ";", res); + std::vector resS; + NLMISC::splitString(str, ";", resS); // If we don't have 3 components, it's an entity - if (res.size() != 3) + if (resS.size() != 3) { std::vector res; CAIAliasTranslator::getInstance()->getNPCAliasesFromName(str, res); @@ -63,9 +63,9 @@ TPositionOrEntity CPositionOrEntityHelper::fromString(const std::string& s) else { // It's a position - std::string xStr = res[0]; - std::string yStr = res[1]; - std::string zStr = res[2]; + std::string xStr = resS[0]; + std::string yStr = resS[1]; + std::string zStr = resS[2]; CMissionParser::removeBlanks(xStr); CMissionParser::removeBlanks(yStr);