Compare commits

...

117 Commits

Author SHA1 Message Date
kaetemi d2a267c531 Merge with develop
--HG--
branch : gsoc2012-fabien
10 years ago
kaetemi dd91970e9e Merge with default
--HG--
branch : gsoc2012-fabien
11 years ago
kaetemi 804fe05b9d Cleanup merge
--HG--
branch : gsoc2012-fabien
11 years ago
kaetemi cdb8646529 Merge with default
--HG--
branch : gsoc2012-fabien
11 years ago
kaetemi 82fd552aaa Merge with default
--HG--
branch : gsoc2012-fabien
11 years ago
kaetemi 72a647afb9 Merge with default
--HG--
branch : gsoc2012-fabien
11 years ago
kaetemi f75ba5b5e3 Merge with default
--HG--
branch : gsoc2012-fabien
11 years ago
Fabien_HENON ed54bcf00b Changed: #1469 Computations for the new magic step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON c21fbc5a9f Changed: #1469 Parsing of steps in client and only one magic step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 55582b6d05 Changed: #1469 Don't send the animation step name any more because we only have one magic step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 7ab6ede55c Changed: #1469 TPositionOrEntity becomes an abstract class
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 9d592fdc63 Changed: #1469 TPositionOrEntity from string conversion changed to support previous pos and return pos
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 716a7aedc7 Changed: #1469 Changed the entityorposition type to support PreviousPos and ReturnPos and to optimize serialization. Position and Entity variables are not in union because CVector has the copy constructor
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 2e50568194 Changed: #1469 Only one magic step that parses the primitive and send optimized packets
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 2fd91e5277 Changed: #1469 Small change in the description of the msg.xml
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 714b2bf86a Changed: #1469 Camera animation steps in world editor
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON d16b48632a Changed: #1469 hgeol
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 8252d36db8 Changed: #1469 Increasing camera speed for transitions
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 450204439a Merge with default
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 9c838c39ed Changed: #1469 Shake frequency
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 1774ee7278 Changed: #1469 Fixed last bugs
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 9f4d2fea74 Changed: #1469 Making sure animation cannot be played if the player is dead
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 0553079378 Changed: #1469 Small debug changes
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 3e6ffa8b43 Added: #1469 Implementation of the Shake modifier
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON e218106b3e Added: #1469 Implementation of the Return step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 15ae25878f Added: #1469 Implementation of the TurnAround step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON ce627c7923 Added: #1469 Implementation of the FollowEntity step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 1fca8f4b6a Changed: #1469 Input and output structures for steps and modifiers. Now 2 structures instead of one
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 050f3f644a Added: #1469 Config variable to define the maximum speed of the camera in camera animation
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON c2770d9ae5 Added: #1469 Implementation of the GoTo step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON f5912260b2 Changed: #1469 Correction of the algorithm to compute the current look at direction
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 39d4791628 Changed: #1469 Computation for look at direction put in a method
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON c29dc1bf43 Added: #1469 Implementation of the static step
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON d833a222c5 Added: #1469 Function to resolve position for TPositionOrEntity objects
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON bd69090057 Changed: #1469 Remembering view and viewPos at the start of a step only
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 46a64b06b5 Changed: #1469 Backslashes to slashes in include paths
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON d638e71f79 Changed: #1469 currentView and currentViewPos to view and viewPos
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 24461197d5 Added: #1469 Integration of the camera animation player in the CamAnimMode and storing and restoring of view info at animation start and stop
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 55725c21b3 Added: #1469 Basic update mechanics implemented for the camera animation player with a changement of the prototypes from steps and modifiers
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 666ff05c42 Changed: #1469 currentView, currentViewPos and currentCameraTarget functions for CamAnimMode and DeathMode
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 16daae2b6e Added: #1469 Basic implementation of a CamAnimMode in the UserControls
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 4fecf73407 Added: #1469 Base implementation of the steps players
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 162f63a6f4 Added: #1469 Base implementation of the modifiers players
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON a27c34c705 Added: #1469 Integration of the modifiers in the processus of steps
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON af59474d9c Changed: #1469 Message for sound triggers
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 160ec7ea91 Changed: #1469 Removing blanks when getting sound name and animation name in mission actions parsing
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 69545610b5 Added: #1469 factory for modifiers player
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON e61d13566e Changed: #1469 Base implementation of the function that plays steps
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 64b1ba3752 Added: #1469 factory for step player
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 5f2b62c32c Changed: #1469 parsing string to TPositionOrEntity when launching instead of during parsing because entityIds where not properly set at this moment
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 29dca7b9d7 Added: #1469 Base declaration of the CCameraAnimationPlayer class in the client
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 448d822b4d Reverted: local changes
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 1ffab89cd1 Reverted: Local changes
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON b22e255762 Merged: default in gsoc2012-fabien
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON b0858977e7 Changed: #1469 Changed header for TheDataset define. Compiles now
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 55297dbe65 Changed: #1469 Added .c_str() to strings in logs
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON a66aa09e61 Changed: #1469 backslash to slash in include directive
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 0cb700b1bd Changed: #1469 Include files path for position_or_entity_type_helper.h
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 117379cae0 Changed: #1469 changed location of some headers
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON ea7a53b717 Changed: #1469 removed a useless header that failed compilation
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON 1eadeb0ed5 Changed: #1469 Sound trigger client impulse implemented
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON a019880cbd Changed: #1469 CEntityId to TDataSetIndex
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON bda94764fa Changed: #1469 Adding sound triggers and camera animation messages
--HG--
branch : gsoc2012-fabien
12 years ago
Fabien_HENON f48f4d25aa Added: #1469 use of class TPositionOrEntity in actions, steps, modifiers, etc... + added serial function for this class
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON e0084d7f4b Added: #1469 class TPositionOrEntity and TPositionOrEntityHelper to contain either an entityId or a vector (DOES NOT COMPILE YET)
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON a46165e97f Added: #1469 deserialize information for sound triggers
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON e3edccf3ea Changed: #1469 location of position_or_entity_type.h because it's also used by the client +
Added: #1469 Declaration of impulses in the client

--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON fa194fa246 Added: #1469 Implementation of the shake modifier impulse
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 95b28dc3bb Added: #1469 Implementation of sound trigger modifier impulse
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON a2acbb4988 Added: #1469 Base functions to send camera animation modifiers to the client
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 0451f31350 Changed: #1469 All variables' type representing either a position or an entity to a TPositionOrEntity so that i can easily change what it contains
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 2334512d63 Added: #1469 A way to get a modifier name
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 1095975a3f Changed: #1469 The way to get the animation step name and to pass it to the serial function
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON e584749c5a Added: #1469 Impulse to tell the client when the animation is finished
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 73d578b764 Added: #1469 First impulse sent to the client to tell him the animation starts + function to get the name of a step (defined using a define)
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 5075bc80ef Added: #1469 sendCameraStep implementation for return animations
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON f7a1e6cdbe Added: #1469 sendCameraStep implementation for turn around animations
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 5b8c34b25e Added: #1469 sendCameraStep implementation for follow entity animations
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 027ec2ca98 Added: #1469 sendCameraStep implementation for go to animations
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON eb5769e0ef Added: #1469 Implementation of the sendCameraStep function for the basic animation + changing variables that express either a position or an entity from string to a type (to change it easily if needed)
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON b99cfc1557 Added: #1469 Base of the impulses for camera animation steps
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 2d3b82ff57 Added: #1469 timer implementation to send camera animation steps in service
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 2629c3cf5f Added: #1469 base functions to send the camera animation instructions
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 2b954a23db Added: #1469 getDuration function to get the duration of the step (useful for timers)
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON e72956026a Added: #1469 Basis of the implementation of the camera animation action : function created but still empty
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 5f51257a7d Added: #1469 Implementation of the sound trigger action
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON ec6af57aa6 Changed: #1469 Getting rid of a variable
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON a1c8c9dc8a Added: #1469 Camera animations current source files in CMake
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON be0fdfc666 Changed: #1469 Converting sound names to sheet id when parsing sound triggers (camera modifier and mission action)
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON ae6aeb5c22 Added: #1469 Parsing of sound_trigger action in missions
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON c997a32bf0 Added: #1469 Parsing of camera_animation action in missions
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 4973f33005 Fixed: #1469 Bug in parsing camera animations
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON bb1740cfae Added: #1469 Parsing of camera animation sound trigger modifier
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 3bf06cb247 Added: #1469 Parsing of camera animation shake modifier
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON d89477ff21 Added: #1469 Camera animation modifiers are added to camera animation steps
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 2f8696133a Added: #1469 Base factory implementation for camera animation modifiers
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON a1c8a2561e Added: #1469 Base for parsing of camera animation modifiers
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON ed42786901 Added: #1469 Parsing of camera animation return step
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 4a153d8e55 Added: #1469 Parsing of camera animation turn around step
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 9df8440d38 Added: #1469 Parsing of camera animation entity to follow step
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 043437e9b1 Added: #1469 Parsing of camera animation go to step
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 10fdd4d28c Added: #1469 Base camera animation step and static animation step
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 94c3b7b47c Added: #1469 Base containers for animation instructions
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 0af5c0518b Added: #1469 Factory used in the CCameraAnimationManager class when parsing animations
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 072d2e0385 Added: #1469 Factory for camera animation steps
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON a609fb6c4c Added: #1469 Basis of the camera animations parsing
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 99b9ef33b8 Added: #1469 CCameraAnimationManager base singleton class for camera animation parsing and execution
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 1e92233953 Merge with sound_dev
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 7b8e98834d Added: #1469 speed parameter for camera movement: turn around
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON afbbced99b Added: #1469 A check in the mission compiler to be sure camera animations referenced by missions exist in the primitive
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 477c53fd61 Added: #1469 A return camera animation action that make the camera returns to its starting position
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 012a9d1897 Changed: #1469 Simplied camera animation parameters in world_editor_classes.xml
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 8fd4987016 Added: #1469 sound_trigger and camera_animation step contents in mission compiler
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 49509937fe Changed: #1469 Modified world_editor_classes.xml to add modifiers and sound triggers to camera movement instructions
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 128cf1c517 Changed: #1469 Modified world_editor_classes.xml to add camera movement instructions
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON e9ace5fde1 Added: EOL extension
--HG--
branch : gsoc2012-fabien
13 years ago
Fabien_HENON 8d3d1fcfcf Changed: #1469 Added primitives in world_editor_classes.xml for sound triggers and camera animations
--HG--
branch : gsoc2012-fabien
13 years ago

@ -15,6 +15,7 @@ ENDIF(WITH_RYZOM_PATCH)
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)
@ -42,6 +43,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})
@ -61,7 +63,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})

@ -0,0 +1,102 @@
// 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_CAMERAANIMATIONINFO_H
#define RY_CAMERAANIMATIONINFO_H
#include "nel/misc/vector.h"
/************************************************************************/
/* Class that contains new information about the camera
*
* \author Fabien Henon
* \date 2012
*/
/************************************************************************/
struct TCameraAnimationOutputInfo
{
TCameraAnimationOutputInfo() {}
NLMISC::CVector CamPos; /// Camera position
NLMISC::CVector CamLookAtDir; /// Camera look at direction
};
/************************************************************************/
/* Class that contains current information about the camera
*
* \author Fabien Henon
* \date 2012
*/
/************************************************************************/
struct TCameraAnimationInputInfo
{
TCameraAnimationInputInfo(const NLMISC::CVector& currCamPos, const NLMISC::CVector& currCamLookAtDir,
const NLMISC::CVector& startCamPos, const NLMISC::CVector& startCamLookAtDir,
const NLMISC::CVector& animStartCamPos, const NLMISC::CVector& animStartCamLookAtDir,
float elapsedTimeSinceStartStep)
{
CamPos = currCamPos;
CamLookAtDir = currCamLookAtDir;
StartCamPos = startCamPos;
StartCamLookAtDir = startCamLookAtDir;
AnimStartCamPos = animStartCamPos;
AnimStartCamLookAtDir = animStartCamLookAtDir;
ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep;
}
TCameraAnimationInputInfo(const TCameraAnimationOutputInfo& output, const TCameraAnimationInputInfo& input)
{
CamPos = output.CamPos;
CamLookAtDir = output.CamLookAtDir;
StartCamPos = input.StartCamPos;
StartCamLookAtDir = input.StartCamLookAtDir;
AnimStartCamPos = input.AnimStartCamPos;
AnimStartCamLookAtDir = input.AnimStartCamLookAtDir;
ElapsedTimeSinceStartStep = input.ElapsedTimeSinceStartStep;
}
TCameraAnimationOutputInfo toOutput() const
{
TCameraAnimationOutputInfo output;
output.CamPos = CamPos;
output.CamLookAtDir = CamLookAtDir;
return output;
}
NLMISC::CVector CamPos; /// Current camera position
NLMISC::CVector CamLookAtDir; /// Current camera look at direction
NLMISC::CVector StartCamPos; /// Start camera position
NLMISC::CVector StartCamLookAtDir; /// Start camera look at direction
NLMISC::CVector AnimStartCamPos; /// Camera position at animation start
NLMISC::CVector AnimStartCamLookAtDir; /// Camera look at direction an animation start
float ElapsedTimeSinceStartStep; /// Elapsed time in second since the beginning of this step
};
#endif /* RY_CAMERAANIMATIONINFO_H */

@ -0,0 +1,57 @@
// 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/camera_animation_modifier_player_factory.h"
std::vector<std::pair<std::string, ICameraAnimationModifierPlayerFactory*> >* ICameraAnimationModifierPlayerFactory::Entries;
ICameraAnimationModifierPlayer* ICameraAnimationModifierPlayerFactory::initModifier(const std::string& name, NLMISC::CBitMemStream& impulse)
{
if (!Entries)
return NULL;
// We search the correct modifier type in our entries
for (uint i = 0; i < Entries->size(); i++)
{
if (name == (*Entries)[i].first)
{
ICameraAnimationModifierPlayer* ret = (*Entries)[i].second->instanciate();
if (!ret)
{
nlwarning("BUG IN CAMERA ANIMATION MODIFIER PLAYER FACTORY : BAD INIT CODE %s", name.c_str());
return NULL;
}
// We init the modifier
if (!ret->initModifier(impulse))
{
nlwarning("building camera animation modifier player failed %s", name.c_str());
delete ret;
return NULL;
}
return ret;
}
}
return NULL;
}
void ICameraAnimationModifierPlayerFactory::init()
{
if (!Entries)
Entries = new std::vector<std::pair<std::string, ICameraAnimationModifierPlayerFactory*> >;
}

@ -0,0 +1,90 @@
// 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_CAMERAANIMATIONMODIFIERPLAYERFACTORY_H
#define RY_CAMERAANIMATIONMODIFIERPLAYERFACTORY_H
#include <string>
#include <vector>
#include "nel/misc/bit_mem_stream.h"
#include "camera_animation_manager/camera_animation_info.h"
/************************************************************************/
/* Interface for camera animation modifiers.
* It has to be able to parse the modifier from an impulse and to play it
*/
/************************************************************************/
class ICameraAnimationModifierPlayer
{
public:
/// This function is called when it's time to init the modifier from an impulse
virtual bool initModifier(NLMISC::CBitMemStream& impulse) = 0;
/// Function that updates the modifier
/// currCamInfo contains information about the current camera position and look at position
/// The function must return the new camera information
virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo) = 0;
/// Function called when the modifier is stopped
virtual void stopModifier() = 0;
protected:
};
/************************************************************************/
/* Factory class that can instanciate the correct camera animation modifier player.
*
* \author Fabien Henon
* \date 2012
*/
/************************************************************************/
class ICameraAnimationModifierPlayerFactory
{
public:
/// Function that will instanciate the correct camera animation modifier player in function of the modifier name
static ICameraAnimationModifierPlayer* initModifier(const std::string& name, NLMISC::CBitMemStream& impulse);
protected:
/// Functions used to be able to create the camera animation modifiers players
static void init();
virtual ICameraAnimationModifierPlayer* instanciate() = 0;
static std::vector<std::pair<std::string, ICameraAnimationModifierPlayerFactory*> >* Entries;
};
// Define used to register the different types of camera animation modifiers players
#define CAMERA_ANIMATION_REGISTER_MODIFIER_PLAYER(_class_,_name_) \
class _class_##CameraAnimationModifierPlayerFactory : public ICameraAnimationModifierPlayerFactory \
{\
public:\
_class_##CameraAnimationModifierPlayerFactory()\
{\
init();\
std::string str = std::string(_name_); \
for (uint i = 0; i < (*Entries).size(); i++ ) \
{\
if ( (*Entries)[i].first == str || (*Entries)[i].second == this )nlstop;\
}\
(*Entries).push_back( std::make_pair( str, this ) );\
}\
ICameraAnimationModifierPlayer* instanciate()\
{ \
return new _class_;\
} \
};\
static _class_##CameraAnimationModifierPlayerFactory* _class_##CameraAnimationModifierPlayerFactoryInstance = new _class_##CameraAnimationModifierPlayerFactory;
#endif /* RY_CAMERAANIMATIONMODIFIERPLAYERFACTORY_H */

@ -0,0 +1,139 @@
// 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/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"
#include "nel/misc/random.h"
#include "nel/misc/time_nl.h"
#include "time_client.h"
/////////////////////////////////////////////////////////////////////////////
/// This animation modifier shakes the camera. The parameter is
/// - strength
class CCameraAnimationModifierPlayerShake : public ICameraAnimationModifierPlayer
{
protected:
float Strength;
float _Dir;
float _WaitTime;
float _CurrTime;
NLMISC::CVector _CurrVec;
public:
CCameraAnimationModifierPlayerShake()
{
Strength = 0.f;
_Dir = 1.f;
_CurrTime = 0.f;
_WaitTime = 0.f;
}
/// This function is called when it's time to init the modifier from an impulse
virtual bool initModifier(NLMISC::CBitMemStream& impulse)
{
impulse.serial(const_cast<float&>(Strength));
_Dir = 1.f;
_CurrTime = 0.f;
_WaitTime = 0.f;
return true;
}
/// Function that plays the modifier
virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo)
{
TCameraAnimationOutputInfo output;
_CurrTime += DT;
if (_CurrTime >= _WaitTime)
{
/*NLMISC::CRandom rnd;
rnd.srand((sint32)NLMISC::CTime::getLocalTime());*/
// We find a normal vector to the look at dir
NLMISC::CVector newVec(currCamInfo.CamLookAtDir.y * -1.f, currCamInfo.CamLookAtDir.x, currCamInfo.CamLookAtDir.z);
newVec.normalize();
newVec = newVec * (Strength * _Dir);
_Dir *= -1.f;
_CurrVec = newVec;
_CurrTime = 0.f;
_WaitTime = 0.05f;
}
output.CamLookAtDir = currCamInfo.CamLookAtDir;
output.CamPos = currCamInfo.CamPos + _CurrVec;
return output;
}
virtual void stopModifier()
{
}
};
CAMERA_ANIMATION_REGISTER_MODIFIER_PLAYER(CCameraAnimationModifierPlayerShake, "camera_modifier_shake");
/////////////////////////////////////////////////////////////////////////////
/// This animation modifier plays a sound. The parameters are
/// - sound_name
/// - sound_position
class CCameraAnimationModifierPlayerSoundTrigger : public ICameraAnimationModifierPlayer
{
protected:
CPositionOrEntity SoundPos;
NLMISC::CSheetId SoundId;
public:
CCameraAnimationModifierPlayerSoundTrigger()
{
SoundId = NLMISC::CSheetId::Unknown;
}
/// This function is called when it's time to init the modifier from an impulse
virtual bool initModifier(NLMISC::CBitMemStream& impulse)
{
impulse.serial(const_cast<CPositionOrEntity&>(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;
}
/// Function that plays the modifier
virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo)
{
return currCamInfo.toOutput();
}
virtual void stopModifier()
{
}
};
CAMERA_ANIMATION_REGISTER_MODIFIER_PLAYER(CCameraAnimationModifierPlayerSoundTrigger, "sound_trigger");

@ -0,0 +1,163 @@
// 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/camera_animation_player.h"
#include "camera_animation_manager/camera_animation_step_player_factory.h"
#include "time_client.h"
#include "view.h"
#include "motion/user_controls.h"
using namespace std;
using namespace NLMISC;
using namespace NLLIGO;
using namespace NLNET;
CCameraAnimationPlayer* CCameraAnimationPlayer::_Instance = NULL;
CCameraAnimationPlayer::CCameraAnimationPlayer()
{
_IsPlaying = false;
_CurrStep = NULL;
_ElapsedTimeForCurrStep = 0.f;
_HasLastViewInfo = false;
}
CCameraAnimationPlayer::~CCameraAnimationPlayer()
{
stop();
}
void CCameraAnimationPlayer::start()
{
if (isPlaying())
stop();
// If the player is dead, we do nothing
if (UserControls.mode() == CUserControls::DeathMode)
return;
_IsPlaying = true;
// We set the user controls in camAnimMode and we remember the current view and viewPos
_LastView = View.view();
_LastViewPos = View.viewPos();
_AnimStartCamPos = View.currentViewPos();
_AnimStartCamLookAtDir = View.currentView();
_LastMode = UserControls.mode();
UserControls.mode(CUserControls::CamAnimMode);
_HasLastViewInfo = true;
// We set the animation start views so that the camera begins at the real previous position
View.view(_AnimStartCamLookAtDir);
View.viewPos(_AnimStartCamPos);
}
void CCameraAnimationPlayer::stop(bool interrupt)
{
if (!isPlaying())
return;
_IsPlaying = false;
stopStep();
// We reset view and viewPos and the usercontrols mode
if (_HasLastViewInfo)
{
if (!interrupt)
UserControls.mode(_LastMode);
View.view(_LastView);
View.viewPos(_LastViewPos);
_HasLastViewInfo = false;
}
}
void CCameraAnimationPlayer::stopStep()
{
// We release the step and modifiers
if (_CurrStep)
{
// We first tell the step we stop it
_CurrStep->stopStepAndModifiers();
delete _CurrStep;
_CurrStep = NULL;
_ElapsedTimeForCurrStep = 0.f;
}
}
void CCameraAnimationPlayer::playStep(const std::string& stepName, NLMISC::CBitMemStream& impulse)
{
// We check if we are playing an animation
if (!isPlaying())
{
nlwarning("CameraAnimationPlayer: animation not playing, cannot play step %s", stepName.c_str());
return;
}
// We stop the current step if there is one
stopStep();
// We initialize the step with the factory
_CurrStep = ICameraAnimationStepPlayerFactory::initStep(stepName, impulse);
if (_CurrStep == NULL)
{
nlwarning("CameraAnimationPlayer: cannot create step player %s", stepName.c_str());
_IsPlaying = false;
return;
}
_ElapsedTimeForCurrStep = 0.f;
// We get the current camera information
_StartStepCamLookAtDir = View.currentView();
_StartStepCamPos = View.currentViewPos();
}
bool CCameraAnimationPlayer::isPlaying()
{
return _IsPlaying;
}
TCameraAnimationOutputInfo CCameraAnimationPlayer::update()
{
// We update the elapsed time for this step
_ElapsedTimeForCurrStep += DT;
NLMISC::CVector currCamPos = View.currentViewPos();
NLMISC::CVector currLookAtDir = View.currentView();
TCameraAnimationInputInfo currCamInfo(currCamPos, currLookAtDir,
_StartStepCamPos, _StartStepCamLookAtDir,
_AnimStartCamPos, _AnimStartCamLookAtDir,
_ElapsedTimeForCurrStep);
if (!isPlaying())
return currCamInfo.toOutput();
if (_CurrStep == NULL)
return currCamInfo.toOutput();
// We update the current step
TCameraAnimationOutputInfo newCamInfo = _CurrStep->updateStepAndModifiers(currCamInfo);
return newCamInfo;
}

@ -0,0 +1,103 @@
// 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_CAMERAANIMATIONPLAYER_H
#define RY_CAMERAANIMATIONPLAYER_H
#include <string>
#include "nel/misc/bit_mem_stream.h"
#include "camera_animation_manager/camera_animation_step_player_factory.h"
#include "nel/misc/vector.h"
#include "camera_animation_manager/camera_animation_info.h"
#include "motion/user_controls.h"
/************************************************************************/
/* Class that manages the camera animations. (singleton).
* It's responsible of playing camera animations
*
* \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(bool interrupt = false);
/// Loads and play the specified step
void playStep(const std::string& stepName, NLMISC::CBitMemStream& impulse);
/// Checks if an animation is being played
bool isPlaying();
/// Updates the camera by calling the update function of the current step and modifiers
TCameraAnimationOutputInfo update();
private:
/// Constructor
CCameraAnimationPlayer();
/// Destructor
~CCameraAnimationPlayer();
/// Stops the current step
void stopStep();
/// Instance of the manager
static CCameraAnimationPlayer* _Instance;
bool _IsPlaying;
ICameraAnimationStepPlayer* _CurrStep;
float _ElapsedTimeForCurrStep;
NLMISC::CVector _LastView;
NLMISC::CVector _LastViewPos;
CUserControls::TMoveMode _LastMode;
bool _HasLastViewInfo;
NLMISC::CVector _StartStepCamLookAtDir;
NLMISC::CVector _StartStepCamPos;
NLMISC::CVector _AnimStartCamLookAtDir;
NLMISC::CVector _AnimStartCamPos;
};
#endif /* RY_CAMERAANIMATIONPLAYER_H */

@ -0,0 +1,150 @@
// 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/camera_animation_step_player_factory.h"
std::vector<std::pair<std::string, ICameraAnimationStepPlayerFactory*> >* ICameraAnimationStepPlayerFactory::Entries;
ICameraAnimationStepPlayer* ICameraAnimationStepPlayerFactory::initStep(const std::string& name, NLMISC::CBitMemStream& impulse)
{
if (!Entries)
return NULL;
// We search the correct step type in our entries
for (uint i = 0; i < Entries->size(); i++)
{
if (name == (*Entries)[i].first)
{
ICameraAnimationStepPlayer* ret = (*Entries)[i].second->instanciate();
if (!ret)
{
nlwarning("BUG IN CAMERA ANIMATION STEP PLAYER FACTORY : BAD INIT CODE %s", name.c_str());
return NULL;
}
// We init the step
if (!ret->initStep(impulse))
{
nlwarning("building camera animation step player failed %s", name.c_str());
delete ret;
return NULL;
}
// We look for children (modifiers or sound triggers)
uint8 nbModifiers = 0;
impulse.serial(nbModifiers);
for (uint8 i = 0; i < nbModifiers; i++)
{
// We get the modifier name
std::string modifierName = "";
impulse.serial(modifierName);
ICameraAnimationModifierPlayer* modifier = ICameraAnimationModifierPlayerFactory::initModifier(modifierName, impulse);
// We add the modifier to the list
if (modifier)
{
ret->addModifier(modifier);
}
else
{
nlwarning("impossible to init the modifier named %s in step named %s", modifierName.c_str(), name.c_str());
}
}
return ret;
}
}
return NULL;
}
void ICameraAnimationStepPlayerFactory::init()
{
if (!Entries)
Entries = new std::vector<std::pair<std::string, ICameraAnimationStepPlayerFactory*> >;
}
ICameraAnimationStepPlayer::~ICameraAnimationStepPlayer()
{
// We release all the modifiers
for (std::vector<ICameraAnimationModifierPlayer*>::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it)
{
ICameraAnimationModifierPlayer* modifier = *it;
delete modifier;
}
Modifiers.clear();
}
void ICameraAnimationStepPlayer::addModifier(ICameraAnimationModifierPlayer* modifier)
{
Modifiers.push_back(modifier);
}
TCameraAnimationOutputInfo ICameraAnimationStepPlayer::updateStepAndModifiers(const TCameraAnimationInputInfo& currCamInfo)
{
// Updates the step
TCameraAnimationOutputInfo newInfo = updateStep(currCamInfo);
// Updates the modifiers
for (std::vector<ICameraAnimationModifierPlayer*>::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it)
{
ICameraAnimationModifierPlayer* modifier = *it;
TCameraAnimationInputInfo input(newInfo, currCamInfo);
// We update the modifier
newInfo = modifier->updateModifier(input);
}
return newInfo;
}
void ICameraAnimationStepPlayer::stopStepAndModifiers()
{
// Stops the step
stopStep();
// Stops the modifiers
for (std::vector<ICameraAnimationModifierPlayer*>::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it)
{
ICameraAnimationModifierPlayer* modifier = *it;
// We stop the modifier
modifier->stopModifier();
}
}
NLMISC::CVector ICameraAnimationStepPlayer::computeCurrentLookAtDir(float ratio, const NLMISC::CVector& startLookAtDir,
const NLMISC::CVector& endLookAtDir)
{
// We normalize the start look at direction
NLMISC::CVector startDir = startLookAtDir;
startDir.normalize();
// We normalize the final look at direction
NLMISC::CVector finalDir = endLookAtDir;
finalDir.normalize();
// We compute a vector that goes from the starting look at dir to the final look at dir
NLMISC::CVector startToFinal = finalDir - startDir;
// We multiply this vector by the ratio so that we can have a vector that represent the current position we are looking at
startToFinal = startToFinal * ratio;
// We compute the direction we are looking at
NLMISC::CVector currLookAtDir = startDir + startToFinal;
currLookAtDir.normalize();
return currLookAtDir;
}

@ -0,0 +1,112 @@
// 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_CAMERAANIMATIONSTEPPLAYERFACTORY_H
#define RY_CAMERAANIMATIONSTEPPLAYERFACTORY_H
#include <string>
#include <vector>
#include "nel/misc/bit_mem_stream.h"
#include "camera_animation_manager/camera_animation_modifier_player_factory.h"
#include "camera_animation_manager/camera_animation_info.h"
#include "nel/misc/vector.h"
/************************************************************************/
/* Interface for camera animation steps.
* It has to be able to parse the step from an impulse and to play it
*/
/************************************************************************/
class ICameraAnimationStepPlayer
{
public:
virtual ~ICameraAnimationStepPlayer();
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse) = 0;
/// Function that updates the camera with the step
/// currCamInfo contains information about the current camera position and look at position
/// The function must return the new camera information
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) = 0;
/// Function called when the step stops
virtual void stopStep() = 0;
/// Function that adds a camera animation modifier to this step
void addModifier(ICameraAnimationModifierPlayer* modifier);
// Plays the step and its modifiers
TCameraAnimationOutputInfo updateStepAndModifiers(const TCameraAnimationInputInfo& currCamInfo);
// Stops the step and its modifiers
void stopStepAndModifiers();
protected:
/// Compute the current look at direction depending on the starting look at direction,
/// the ending look at direction and the progression expressed as a ratio (value between 0 and 1 that expresses the
/// progression)
NLMISC::CVector computeCurrentLookAtDir(float ratio, const NLMISC::CVector& startLookAtDir,
const NLMISC::CVector& endLookAtDir);
// The list of modifiers
std::vector<ICameraAnimationModifierPlayer*> Modifiers;
};
/************************************************************************/
/* Factory class that can instanciate the correct camera animation step player.
*
* \author Fabien Henon
* \date 2012
*/
/************************************************************************/
class ICameraAnimationStepPlayerFactory
{
public:
/// Function that will instanciate the correct camera animation step player in function of the step name
static ICameraAnimationStepPlayer* initStep(const std::string& name, NLMISC::CBitMemStream& impulse);
protected:
/// Functions used to be able to create the camera animation steps players
static void init();
virtual ICameraAnimationStepPlayer* instanciate() = 0;
static std::vector<std::pair<std::string, ICameraAnimationStepPlayerFactory*> >* Entries;
};
// Define used to register the different types of camera animation steps players
#define CAMERA_ANIMATION_REGISTER_STEP_PLAYER(_class_,_name_) \
class _class_##CameraAnimationStepPlayerFactory : public ICameraAnimationStepPlayerFactory \
{\
public:\
_class_##CameraAnimationStepPlayerFactory()\
{\
init();\
std::string str = std::string(_name_); \
for (uint i = 0; i < (*Entries).size(); i++ ) \
{\
if ( (*Entries)[i].first == str || (*Entries)[i].second == this )nlstop;\
}\
(*Entries).push_back( std::make_pair( str, this ) );\
}\
ICameraAnimationStepPlayer* instanciate()\
{ \
return new _class_;\
} \
};\
static _class_##CameraAnimationStepPlayerFactory* _class_##CameraAnimationStepPlayerFactoryInstance = new _class_##CameraAnimationStepPlayerFactory;
#endif /* RY_CAMERAANIMATIONSTEPPLAYERFACTORY_H */

@ -0,0 +1,522 @@
// 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/camera_animation_step_player_factory.h"
#include "game_share/position_or_entity_type.h"
#include "camera_animation_manager/position_or_entity_helper.h"
#include "camera_animation_manager/camera_animation_info.h"
#include "camera_animation_manager/position_or_entity_pos_resolver.h"
#include "client_cfg.h"
#include "time_client.h"
#include "game_share/camera_anim_type_parser.h"
/// Magic camera animation step
class CCameraAnimationStepPlayerStep: public ICameraAnimationStepPlayer
{
protected:
CPositionOrEntityHelper LookAtTarget;
float DirectionTransitionTime;
CPositionOrEntityHelper PositionTarget;
float PositionTransitionTime;
float DistanceTo;
bool HasTurnAround;
float TurnAroundSpeed;
public:
CCameraAnimationStepPlayerStep()
{
DirectionTransitionTime = 0.f;
PositionTransitionTime = 0.f;
DistanceTo = 0.f;
HasTurnAround = false;
TurnAroundSpeed = 0.f;
}
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& bms)
{
bms.serial(const_cast<CPositionOrEntityHelper&>(LookAtTarget));
if (!LookAtTarget.isPreviousPos())
{
NLMISC::serialDuration(bms, DirectionTransitionTime);
}
bms.serial(const_cast<CPositionOrEntityHelper&>(PositionTarget));
if (!PositionTarget.isPreviousPos())
{
NLMISC::serialDistance(bms, DistanceTo);
NLMISC::serialDuration(bms, PositionTransitionTime);
bms.serialBit(const_cast<bool&>(HasTurnAround));
if (HasTurnAround)
{
NLMISC::serialSpeed(bms, TurnAroundSpeed);
}
}
return true;
}
/// Function that plays the step
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{
TCameraAnimationOutputInfo camInfo;
NLMISC::CVector targetPos = resolvePositionOrEntityPosition(PositionTarget, currCamInfo);
//////////////////////////////////////////////////////////////////////////
// Position
{
float ratio = 1.f;
if (PositionTransitionTime > 0.f)
ratio = currCamInfo.ElapsedTimeSinceStartStep / PositionTransitionTime;
if (ratio > 1.f)
ratio = 1.f;
// We compute the current position between the starting position and the final position
NLMISC::CVector movementVector = targetPos - currCamInfo.StartCamPos;
// We substract the distance
float currDist = movementVector.norm();
float substractRatio = 0.f;
if (currDist > 0.f)
substractRatio = (currDist - DistanceTo) / currDist;
if ((currDist - DistanceTo) < 0.f)
substractRatio = 0.f;
movementVector = movementVector * substractRatio;
// We current position is computed using the ratio and the starting position
NLMISC::CVector offset = movementVector * ratio;
camInfo.CamPos = currCamInfo.StartCamPos + offset;
}
//////////////////////////////////////////////////////////////////////////
// Turn around
if (HasTurnAround)
{
// Now we compute the current angle between our position and the target's position
NLMISC::CVector2f currTopVector(camInfo.CamPos.x - targetPos.x, camInfo.CamPos.y - targetPos.y);
float distance2D = currTopVector.norm();
currTopVector.normalize();
float angle = acosf(currTopVector.x);
if (currTopVector.y < 0)
angle *= -1.f;
// We compute an angle to travail in function of the speed
float angleOffset = DT * TurnAroundSpeed;
float newAngle = angle + angleOffset;
// We compute the new position for this angle
NLMISC::CVector2f new2DPos(cosf(newAngle), sinf(newAngle));
new2DPos = new2DPos * distance2D;
// We integrate this new position in the world
NLMISC::CVector newDir(new2DPos.x, new2DPos.y, camInfo.CamPos.z - targetPos.z);
camInfo.CamPos = targetPos + newDir;
}
//////////////////////////////////////////////////////////////////////////
// Look at target
{
float ratio = 1.f;
if (DirectionTransitionTime > 0.f)
ratio = currCamInfo.ElapsedTimeSinceStartStep / DirectionTransitionTime;
if (ratio > 1.f)
ratio = 1.f;
// We compute the final look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityTargetDir(LookAtTarget, currCamInfo, camInfo.CamPos);
// We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir);
}
//////////////////////////////////////////////////////////////////////////
return camInfo;
}
virtual void stopStep()
{
}
};
CAMERA_ANIMATION_REGISTER_STEP_PLAYER(CCameraAnimationStepPlayerStep, "camera_animation_step");
/*/// Basic camera animation step that has generic values
/// - look_at_position
/// - text
/// - duration
class CCameraAnimationStepPlayerBasic : public ICameraAnimationStepPlayer
{
protected:
TPositionOrEntity LookAtPos;
std::string Text;
float Duration;
public:
CCameraAnimationStepPlayerBasic()
{
Text = "";
Duration = 0.f;
}
virtual float getDuration() const
{
return Duration;
}
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse)
{
impulse.serial(const_cast<TPositionOrEntity&>(LookAtPos));
impulse.serial(const_cast<std::string&>(Text));
impulse.serial(const_cast<float&>(Duration));
return true;
}
virtual void stopStep()
{
}
}; // This class must not be registered because it's a base class
/////////////////////////////////////////////////////////////////////////////
/// Static camera animation step (that does not have specific variables)
class CCameraAnimationStepPlayerStatic : public CCameraAnimationStepPlayerBasic
{
public:
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse)
{
CCameraAnimationStepPlayerBasic::initStep(impulse);
return true;
}
/// Function that plays the step
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{
TCameraAnimationOutputInfo camInfo;
// We don't change the position
camInfo.CamPos = currCamInfo.StartCamPos;
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
// We compute the final look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
// We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir);
return camInfo;
}
virtual void stopStep()
{
}
};
CAMERA_ANIMATION_REGISTER_STEP_PLAYER(CCameraAnimationStepPlayerStatic, "camera_animation_static");
/////////////////////////////////////////////////////////////////////////////
/// Go to camera animation step
/// - end_position
class CCameraAnimationStepPlayerGoTo: public CCameraAnimationStepPlayerBasic
{
protected:
TPositionOrEntity EndPos;
public:
CCameraAnimationStepPlayerGoTo()
{
}
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse)
{
CCameraAnimationStepPlayerBasic::initStep(impulse);
impulse.serial(const_cast<TPositionOrEntity&>(EndPos));
return true;
}
/// Function that plays the step
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{
TCameraAnimationOutputInfo camInfo;
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
// We compute the current position between the starting position and the final position
NLMISC::CVector movementVector = resolvePositionOrEntityPosition(EndPos) - currCamInfo.StartCamPos;
// If the position is an entity, we substract a minimum distance to the entity
if (EndPos.isEntityId())
{
float currDist = movementVector.norm();
float substractRatio = (currDist - ClientCfg.CameraAnimMinEntityDistance) / currDist;
if ((currDist - ClientCfg.CameraAnimMinEntityDistance) < 0.f)
substractRatio = 0.f;
movementVector = movementVector * substractRatio;
}
// We current position is computed using the ratio and the starting position
NLMISC::CVector offset = movementVector * ratio;
camInfo.CamPos = currCamInfo.StartCamPos + offset;
// Now we compute the current look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
// We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir);
return camInfo;
}
virtual void stopStep()
{
}
};
CAMERA_ANIMATION_REGISTER_STEP_PLAYER(CCameraAnimationStepPlayerGoTo, "camera_animation_go_to");
/////////////////////////////////////////////////////////////////////////////
/// Follow entity camera animation step
/// - entity_to_follow
/// - distance_to_entity
class CCameraAnimationStepPlayerFollowEntity: public CCameraAnimationStepPlayerBasic
{
protected:
TPositionOrEntity EntityToFollow;
float DistanceToEntity;
public:
CCameraAnimationStepPlayerFollowEntity()
{
DistanceToEntity = 0.f;
}
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse)
{
CCameraAnimationStepPlayerBasic::initStep(impulse);
impulse.serial(const_cast<TPositionOrEntity&>(EntityToFollow));
impulse.serial(const_cast<float&>(DistanceToEntity));
return true;
}
/// Function that plays the step
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{
TCameraAnimationOutputInfo camInfo;
// We compute the distance between the entity to follow and our current position
NLMISC::CVector entityPos = resolvePositionOrEntityPosition(EntityToFollow);
NLMISC::CVector distanceVec = entityPos - currCamInfo.CamPos;
float distance = distanceVec.norm();
// We compute the difference with the expected distance
float difference = distance - DistanceToEntity;
// We compute the distance we can travel
float travellingDistance = DT * ClientCfg.MaxCameraAnimationSpeed * (difference < 0.f ? -1.f : 1.f);
// We check if we are not going to far
if (abs(travellingDistance) > abs(difference))
travellingDistance = difference;
// We normalize the vector from our position to the entity
distanceVec.normalize();
// We multiply this vector with the distance to travel
distanceVec = distanceVec * travellingDistance;
// We add this vector to our position to know our new position
camInfo.CamPos = currCamInfo.CamPos + distanceVec;
// We compute the final look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
finalDir.normalize();
// We get the current look at direction
camInfo.CamLookAtDir = finalDir;
return camInfo;
}
virtual void stopStep()
{
}
};
CAMERA_ANIMATION_REGISTER_STEP_PLAYER(CCameraAnimationStepPlayerFollowEntity, "camera_animation_follow_entity");
/////////////////////////////////////////////////////////////////////////////
/// Turn around camera animation step
/// - point_to_turn_around
/// - distance_to_point
/// - speed
class CCameraAnimationStepPlayerTurnAround: public CCameraAnimationStepPlayerBasic
{
protected:
TPositionOrEntity PointToTurnAround;
float DistanceToPoint;
float Speed;
public:
CCameraAnimationStepPlayerTurnAround()
{
DistanceToPoint = 0.f;
Speed = 0.f;
}
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse)
{
CCameraAnimationStepPlayerBasic::initStep(impulse);
impulse.serial(const_cast<TPositionOrEntity&>(PointToTurnAround));
impulse.serial(const_cast<float&>(DistanceToPoint));
impulse.serial(const_cast<float&>(Speed));
return true;
}
/// Function that plays the step
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{
TCameraAnimationOutputInfo camInfo;
// We compute the distance between the point to turn around and our current position
NLMISC::CVector pointPos = resolvePositionOrEntityPosition(PointToTurnAround);
NLMISC::CVector distanceVec = pointPos - currCamInfo.CamPos;
float distance = distanceVec.norm();
// We compute the difference with the expected distance
float difference = distance - DistanceToPoint;
// We compute the distance we can travel
float travellingDistance = DT * ClientCfg.MaxCameraAnimationSpeed * (difference < 0.f ? -1.f : 1.f);
// We check if we are not going to far
if (abs(travellingDistance) > abs(difference))
travellingDistance = difference;
// We normalize the vector from our position to the point
distanceVec.normalize();
// We multiply this vector with the distance to travel
distanceVec = distanceVec * travellingDistance;
// We add this vector to our position to know our new position
NLMISC::CVector newPos = currCamInfo.CamPos + distanceVec;
// Now we compute the current angle between our position and the point's position
NLMISC::CVector2f currTopVector(newPos.x - pointPos.x, newPos.y - pointPos.y);
float distance2D = currTopVector.norm();
currTopVector.normalize();
float angle = acosf(currTopVector.x);
if (currTopVector.y < 0)
angle *= -1.f;
// We compute an angle to travail in function of the speed
float angleOffset = DT * Speed;
float newAngle = angle + angleOffset;
// We compute the new position for this angle
NLMISC::CVector2f new2DPos(cosf(newAngle), sinf(newAngle));
new2DPos = new2DPos * distance2D;
// We integrate this new position in the world
NLMISC::CVector newDir(new2DPos.x, new2DPos.y, newPos.z - pointPos.z);
camInfo.CamPos = pointPos + newDir;
// We compute the final look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
finalDir.normalize();
// We get the current look at direction
camInfo.CamLookAtDir = finalDir;
return camInfo;
}
virtual void stopStep()
{
}
};
CAMERA_ANIMATION_REGISTER_STEP_PLAYER(CCameraAnimationStepPlayerTurnAround, "camera_animation_turn_around");
/////////////////////////////////////////////////////////////////////////////
/// Animation step that returns to the starting position. It directly inherits from the interface because it
/// does not need all the parameters of a basic step
/// - duration
class CCameraAnimationStepPlayerReturn : public ICameraAnimationStepPlayer
{
protected:
float Duration;
public:
CCameraAnimationStepPlayerReturn()
{
Duration = 0.f;
}
virtual float getDuration() const
{
return Duration;
}
/// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse)
{
impulse.serial(const_cast<float&>(Duration));
return true;
}
/// Function that plays the step
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{
TCameraAnimationOutputInfo camInfo;
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
// We compute the current position between the starting position and the final position
NLMISC::CVector movementVector = resolvePositionOrEntityPosition(currCamInfo.AnimStartCamPos) - currCamInfo.StartCamPos;
// We current position is computed using the ratio and the starting position
NLMISC::CVector offset = movementVector * ratio;
camInfo.CamPos = currCamInfo.StartCamPos + offset;
// We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, currCamInfo.AnimStartCamLookAtDir);
return camInfo;
}
virtual void stopStep()
{
}
};
CAMERA_ANIMATION_REGISTER_STEP_PLAYER(CCameraAnimationStepPlayerReturn, "camera_animation_return");*/

@ -0,0 +1,35 @@
// 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_helper.h"
#include "game_share/mirror.h"
#include "game_share/mirrored_data_set.h"
#include "game_share/base_types.h"
#include "user_entity.h"
/*NLMISC::CVector CPositionOrEntityHelper::getDiffPos(const NLMISC::CVector& targetPos) const
{
return Position;
}
NLMISC::CVector CPositionOrEntityHelper::setPositionFromDiffPos(const NLMISC::CVector& diffPos)
{
return Position;
}
*/

@ -0,0 +1,63 @@
// 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_POSITIONORENTITYTYPEHELPER_H
#define RY_POSITIONORENTITYTYPEHELPER_H
#include "game_share/position_or_entity_type.h"
//////////////////////////////////////////////////////////////////////////
/************************************************************************/
/* Class that can contain either an entity id or a position */
/************************************************************************/
class CPositionOrEntityHelper: public CPositionOrEntity
{
public:
CPositionOrEntityHelper(): CPositionOrEntity()
{
}
CPositionOrEntityHelper(const NLMISC::CVector& position): CPositionOrEntity(position)
{
}
CPositionOrEntityHelper(const TDataSetIndex& eid): CPositionOrEntity(eid)
{
}
CPositionOrEntityHelper(PositionOrEntityType type): CPositionOrEntity(type)
{
}
CPositionOrEntityHelper(const CPositionOrEntity& c): CPositionOrEntity(c)
{
}
// Declares abstract methods
/// This function returns the difference between the player's position and the specified position
/*NLMISC::CVector getDiffPos(const NLMISC::CVector& targetPos) const;
/// This function returns the target position given the difference between the player's position and this target position
NLMISC::CVector setPositionFromDiffPos(const NLMISC::CVector& diffPos);*/
};
#endif /* RY_POSITIONORENTITYTYPEHELPER_H */

@ -0,0 +1,133 @@
// 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 CPositionOrEntity& posOrEntity, const TCameraAnimationInputInfo& currCamInfo)
{
if (!posOrEntity.isValid())
{
nlwarning("<resolvePositionOrEntityPosition> invalid position or entity");
return NLMISC::CVector();
}
if (posOrEntity.isPosition())
return posOrEntity.getPosition();
else if (posOrEntity.isPreviousPos())
{
return currCamInfo.StartCamPos;
}
else if (posOrEntity.isReturnPos())
{
return currCamInfo.AnimStartCamPos;
}
else if (posOrEntity.isEntityId())
{
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;
if (!entity->getHeadPos(pos))
pos = entity->pos();
return pos;
}
}
return NLMISC::CVector();
}
NLMISC::CVector resolvePositionOrEntityPosition(const CPositionOrEntity& posOrEntity)
{
if (!posOrEntity.isValid())
{
nlwarning("<resolvePositionOrEntityPosition> invalid position or entity");
return NLMISC::CVector();
}
if (posOrEntity.isPosition())
return posOrEntity.getPosition();
else if (posOrEntity.isEntityId())
{
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;
if (!entity->getHeadPos(pos))
pos = entity->pos();
return pos;
}
}
return NLMISC::CVector();
}
NLMISC::CVector resolvePositionOrEntityTargetDir(const CPositionOrEntity& posOrEntity, const TCameraAnimationInputInfo& currCamInfo,
const NLMISC::CVector& currCamPos)
{
if (!posOrEntity.isValid())
{
nlwarning("<resolvePositionOrEntityPosition> invalid position or entity");
return NLMISC::CVector();
}
if (posOrEntity.isPosition())
{
NLMISC::CVector dir = posOrEntity.getPosition() - currCamPos;
dir.normalize();
return dir;
}
else if (posOrEntity.isPreviousPos())
{
return currCamInfo.StartCamLookAtDir;
}
else if (posOrEntity.isReturnPos())
{
return currCamInfo.AnimStartCamLookAtDir;
}
else if (posOrEntity.isEntityId())
{
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;
if (!entity->getHeadPos(pos))
pos = entity->pos();
NLMISC::CVector dir = pos - currCamPos;
dir.normalize();
return dir;
}
}
return NLMISC::CVector();
}

@ -0,0 +1,36 @@
// 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"
#include "camera_animation_manager/position_or_entity_helper.h"
#include "camera_animation_manager/camera_animation_info.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 CPositionOrEntity& posOrEntity, const TCameraAnimationInputInfo& currCamInfo);
NLMISC::CVector resolvePositionOrEntityPosition(const CPositionOrEntity& posOrEntity);
/// Functions that returns the stored look at target as a normalized direction vector
NLMISC::CVector resolvePositionOrEntityTargetDir(const CPositionOrEntity& posOrEntity, const TCameraAnimationInputInfo& currCamInfo,
const NLMISC::CVector& currCamPos);
#endif /* RY_POSITIONORENTITYPOSRESOLVER_H */

@ -343,6 +343,9 @@ CClientConfig::CClientConfig()
DmWalk = 6.0f; // Default Velocity for the Walk in Ring/DM or Ring/Editor.
DmRun = 20.0f; // Default Velocity for the Run in Ring/DM or Ring/Editor.
MaxCameraAnimationSpeed = 10.f; // Default maximum speed for camera animation
CameraAnimMinEntityDistance = 0.8f; // Default distance between the camera and the entity during camera animations
FlyAccel = 1000.f; // Default Acceleration for the fly, in m.s-2
AllowDebugCommands = false; // Add debug commands at startup
@ -923,6 +926,11 @@ void CClientConfig::setValues()
READ_FLOAT_DEV(DmRun)
// Maximum camera animation speed
READ_FLOAT_DEV(MaxCameraAnimationSpeed);
// Default distance between camera and entity in camera animations
READ_FLOAT_DEV(CameraAnimMinEntityDistance);
// Fly
READ_FLOAT_DEV(Fly)

@ -184,6 +184,10 @@ struct CClientConfig
/// Acceleration for the Fly.
float FlyAccel;
/// Maximum speed for camera animation
float MaxCameraAnimationSpeed;
float CameraAnimMinEntityDistance;
/// Allow debug commands
bool AllowDebugCommands;

@ -0,0 +1,93 @@
// 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/>.
//////////////
// INCLUDES //
//////////////
#include "stdpch.h"
// Client.
#include "../../input.h"
#include "../user_controls.h"
#include "../../user_entity.h"
#include "../../view.h"
#include "../../interface_v3/interface_manager.h"
#include "../../entities.h"
#include "camera_animation_manager/camera_animation_info.h"
#include "camera_animation_manager/camera_animation_player.h"
///////////
// USING //
///////////
////////////
// EXTERN //
////////////
///////////////
// Functions //
///////////////
//-----------------------------------------------
// camAnimModeStart :
// Manage interactions in interactive mode (start).
//-----------------------------------------------
void CUserControls::camAnimModeStart()
{
// No more Velocity.
UserEntity->frontVelocity(0);
UserEntity->lateralVelocity(0);
// No more autowalk
_DirectionMove = none;
// Third person view but player dead, user is not selectable.
UserEntity->selectable(false);
_InternalView = false;
// Show/hide all or parts of the user body (after _InternaView is set).
UserEntity->updateVisualDisplay();
}// camAnimModeStart //
//-----------------------------------------------
// camAnimModeStop :
// Manage interactions in interactive mode (stop).
//-----------------------------------------------
void CUserControls::camAnimModeStop()
{
// We tell the camera animation player to stop (by interruption)
// If the camera animation player was not playing any animation it will have no effect but this function
// is usefull if the mode has changed (player is dead) to interrupt the animation
CCameraAnimationPlayer::getInstance()->stop(true);
}// camAnimModeStop //
//-----------------------------------------------
// camAnimMode :
// Manage interactions in free head mode.
//-----------------------------------------------
void CUserControls::camAnimMode()
{
// Call the camera animation update function to update the view
TCameraAnimationOutputInfo newCamInfo = CCameraAnimationPlayer::getInstance()->update();
// We normalize the look at direction
newCamInfo.CamLookAtDir.normalize();
// We udpate the view
View.view(newCamInfo.CamLookAtDir);
View.viewPos(newCamInfo.CamPos);
}// camAnimMode //

@ -242,6 +242,11 @@ void CUserControls::update()
deathMode();
break;
// Camera animation mode
case CamAnimMode:
camAnimMode();
break;
// Mount Mode
case MountMode:
mountMode();
@ -1085,6 +1090,11 @@ void CUserControls::mode(const TMoveMode mode)
deathModeStop();
break;
// Camera animation Mode
case CamAnimMode:
camAnimModeStop();
break;
// Mount Mode
case MountMode:
mountModeStop();
@ -1121,6 +1131,11 @@ void CUserControls::mode(const TMoveMode mode)
deathModeStart();
break;
// Camera animation Mode
case CamAnimMode:
camAnimModeStart();
break;
// Mount Mode
case MountMode:
mountModeStart();
@ -1156,6 +1171,10 @@ string CUserControls::modeStr() const
case CUserControls::DeathMode:
return "DeathMode";
// Camera animation Mode
case CUserControls::CamAnimMode:
return "CamAnimMode";
// Mount Mode
case CUserControls::MountMode:
return "MountMode";

@ -58,6 +58,7 @@ public:
DeathMode, // Mode for the Death.
MountMode, // Mode for the Mount.
ThirdMode, // Third Person View Mode
CamAnimMode, // Mode for camera animation
nbMode // Not really a mode, just here to know how many modes are there.
};
@ -112,6 +113,13 @@ private:
/// Manage the Death Mode.
void deathMode();
/// Manage the camera animation Mode (start).
void camAnimModeStart();
/// Manage the camera animation Mode (stop).
void camAnimModeStop();
/// Manage the camera animation Mode.
void camAnimMode();
/// Manage the Mount Mode (start).
void mountModeStart();
/// Manage the Mount Mode (stop).

@ -88,6 +88,12 @@
// Std.
#include <vector>
#include "game_share/position_or_entity_type.h"
#include "nel/misc/vector.h"
#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
@ -3577,6 +3583,47 @@ void impulseSetNpcIconTimer(NLMISC::CBitMemStream &impulse)
CNPCIconCache::getInstance().setMissionGiverTimer(delay);
}
void impulsePlaySoundTrigger(NLMISC::CBitMemStream& impulse)
{
NLMISC::CSheetId SoundId;
CPositionOrEntity SoundPosition;
impulse.serial(SoundId);
impulse.serial(SoundPosition);
if (!SoundPosition.isValid())
{
nlwarning("<impulsePlaySoundTrigger> invalid SoundPosition");
return;
}
NLMISC::CVector pos = resolvePositionOrEntityPosition(SoundPosition);
SoundMngr->spawnSource(SoundId, pos);
}
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 = "camera_animation_step";
//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();
}
//-----------------------------------------------
// initializeNetwork :
//-----------------------------------------------
@ -3726,6 +3773,12 @@ void initializeNetwork()
GenericMsgHeaderMngr.setCallback( "NPC_ICON:SET_DESC", impulseSetNpcIconDesc );
GenericMsgHeaderMngr.setCallback( "NPC_ICON:SVR_EVENT_MIS_AVL", impulseServerEventForMissionAvailability );
GenericMsgHeaderMngr.setCallback( "NPC_ICON:SET_TIMER", impulseSetNpcIconTimer );
GenericMsgHeaderMngr.setCallback( "SOUND_TRIGGER", impulsePlaySoundTrigger );
GenericMsgHeaderMngr.setCallback( "CAMERA_ANIMATION:PLAY", impulseCameraAnimationPlay );
GenericMsgHeaderMngr.setCallback( "CAMERA_ANIMATION:STEP", impulseCameraAnimationStep );
GenericMsgHeaderMngr.setCallback( "CAMERA_ANIMATION:FINISHED", impulseCameraAnimationFinished );
}

@ -93,6 +93,7 @@
#include "interface_v3/interface_ddx.h"
#include "bg_downloader_access.h"
#include "nel/gui/lua_manager.h"
#include "camera_animation_manager/camera_animation_player.h"
///////////
@ -358,6 +359,8 @@ void releaseMainLoopReselect()
// Btw the 2 methods should have strong similarities
void releaseMainLoop(bool closeConnection)
{
CCameraAnimationPlayer::release();
ProgressBar.release();
// Release R2 editor if applicable
@ -625,6 +628,7 @@ void release()
CSheetId::uninit();
// shutdown a few other singletons
CCameraAnimationPlayer::release();
CLoginProgressPostThread::releaseInstance();
CAttackListManager::releaseInstance();
CFactionWarManager::release();

@ -148,10 +148,14 @@ void CView::update()
//-----------------------------------------------
CVector CView::currentViewPos() const
{
// If we are in camanimmode we just return the viewpos
if (UserControls.mode() == CUserControls::CamAnimMode)
return _ViewPos;
// clamp to the collisioned camera distance
float minCamDist= min(_CurrentCameraDist, _CollisionCameraDist);
if(_RearView)
if (_RearView && UserControls.mode() != CUserControls::DeathMode)
{
CVector v;
if(UserEntity->viewMode() == CUserEntity::FirstPV || _ForceFirstPersonView)
@ -186,7 +190,11 @@ CVector CView::currentViewPos() const
//-----------------------------------------------
CVector CView::currentView() const
{
if(_RearView)
// If we are in camanimmode we just return the view
if (UserControls.mode() == CUserControls::CamAnimMode)
return _View;
if (_RearView && UserControls.mode() != CUserControls::DeathMode)
{
CVector v;
v.x = -UserEntity->front().x;
@ -212,11 +220,15 @@ NLMISC::CQuat CView::currentViewQuat() const
//-----------------------------------------------
CVector CView::currentCameraTarget() const
{
// If we are in camanimmode we just return the viewpos
if (UserControls.mode() == CUserControls::CamAnimMode)
return _ViewPos;
if(UserEntity->viewMode() == CUserEntity::FirstPV || _ForceFirstPersonView)
return currentViewPos();
else
{
if(_RearView)
if (_RearView && UserControls.mode() != CUserControls::DeathMode)
{
return UserEntity->pos() + CVector(0.0f, 0.0f, 2.0f);
}

@ -1162,4 +1162,14 @@
<leaf name="SET_TIMER"
description="server sets a new timer period" />
</branch>
<branch name="CAMERA_ANIMATION">
<leaf name="PLAY"
description="Tell the client an animation will start" />
<leaf name="FINISHED"
description="Tell the client the camera animation is finished" />
<leaf name="STEP"
description="Sends a camera animation instruction to the client." />
</branch>
<leaf name="SOUND_TRIGGER"
description="Ask the client to play a sound at a given position or entity position. The parameters are the sound id and the position or the entity" />
</client_messages_description>

@ -57,6 +57,7 @@
<DYNAMIC_CHILD CLASS_NAME="spire"/>
<DYNAMIC_CHILD CLASS_NAME="user_model_list"/>
<DYNAMIC_CHILD CLASS_NAME="custom_loot_tables"/>
<DYNAMIC_CHILD CLASS_NAME="camera_animations_editor"/>
</PRIMITIVE>
<!-- the alias class, used by all other class that need persistent aliases-->
@ -251,6 +252,37 @@
<DYNAMIC_CHILD CLASS_NAME="step_player_reconnect"/>
<DYNAMIC_CHILD CLASS_NAME="jump_to"/>
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="camera_animations_editor" TYPE="node" AUTO_INIT="true" DELETABLE="true" NUMBERIZE="false">
<PARAMETER NAME="name" TYPE="string" VISIBLE="true"/>
<DYNAMIC_CHILD CLASS_NAME="camera_animation_tree"/>
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="camera_animation_tree" TYPE="node" AUTO_INIT="true" DELETABLE="true" NUMBERIZE="false">
<PARAMETER NAME="name" TYPE="string" VISIBLE="true"/>
<DYNAMIC_CHILD CLASS_NAME="camera_animation_step"/>
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="camera_animation_step" TYPE="node" AUTO_INIT="true" DELETABLE="true" NUMBERIZE="false">
<PARAMETER NAME="name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="look_at_target" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="direction_transition_time" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="position_target" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="position_transition_time" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="distance_to" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="has_turn_around" TYPE="boolean" VISIBLE="true"/>
<PARAMETER NAME="turn_around_speed" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="duration" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="text" TYPE="string" VISIBLE="true"/>
<DYNAMIC_CHILD CLASS_NAME="sound_trigger"/>
<DYNAMIC_CHILD CLASS_NAME="camera_modifier_shake"/>
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="camera_modifier_shake" TYPE="node" AUTO_INIT="true" DELETABLE="true" NUMBERIZE="false">
<PARAMETER NAME="name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="strength" TYPE="string" VISIBLE="true"/>
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="pre_requisite" TYPE="node" AUTO_INIT="true" DELETABLE="false" NUMBERIZE="false">
<PARAMETER NAME="name" TYPE="string" VISIBLE="true"/>
@ -688,6 +720,8 @@
<DYNAMIC_CHILD CLASS_NAME="recv_named_item"/>
<DYNAMIC_CHILD CLASS_NAME="recv_xp"/>
<DYNAMIC_CHILD CLASS_NAME="destroy_item"/>
<DYNAMIC_CHILD CLASS_NAME="sound_trigger" />
<DYNAMIC_CHILD CLASS_NAME="camera_animation" />
</PRIMITIVE>
@ -1026,6 +1060,17 @@
<PARAMETER NAME="item/quantity/quality" TYPE="string_array" VISIBLE="true"/>
<PARAMETER NAME="guild" TYPE="boolean" VISIBLE="true" />
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="sound_trigger" TYPE="node" AUTO_INIT="false" DELETABLE="true" NUMBERIZE="false">
<PARAMETER NAME="name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="sound_name" TYPE="string" VISIBLE="true" />
<PARAMETER NAME="sound_position" TYPE="string" VISIBLE="true"/>
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="camera_animation" TYPE="node" AUTO_INIT="false" DELETABLE="true" NUMBERIZE="false">
<PARAMETER NAME="name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="animation_name" TYPE="string" VISIBLE="true" />
</PRIMITIVE>
<!-- Fin actions -->
@ -1099,6 +1144,8 @@
<DYNAMIC_CHILD CLASS_NAME="recv_named_item"/>
<DYNAMIC_CHILD CLASS_NAME="recv_xp"/>
<DYNAMIC_CHILD CLASS_NAME="destroy_item"/>
<DYNAMIC_CHILD CLASS_NAME="sound_trigger"/>
<DYNAMIC_CHILD CLASS_NAME="camera_animation" />
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="kill" TYPE="node" PARENT_CLASS="objective_parent">

@ -0,0 +1,135 @@
// 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_CAMERAANIMTYPEPARSER_H
#define RY_CAMERAANIMTYPEPARSER_H
#include "nel/misc/vector.h"
#include "nel/misc/stream.h"
#include <math.h>
namespace NLMISC
{
/// Function that serializes durations (in seconds)
/// Duration is converted to 1/100 second and cannot be greater than 2^12-1 = 4095
/// Result is serialized in 12 bits
inline void serialDuration(NLMISC::CBitMemStream &f, float& duration)
{
static uint32 maxVal = (uint32)pow((float)2, 12) - 1;
if (f.isReading())
{
uint32 d = 0;
f.serial(d, 12);
duration = (float)d / 100.f;
}
else
{
uint32 d = (uint32)(duration * 100);
if (d > maxVal)
d = maxVal;
f.serial(d, 12);
}
}
/// Function that serializes distances (in meters)
/// Distance is converted to centimeters and cannot be greater than 2^16-1 = 65535
/// Result is serialized in 2 bytes
inline void serialDistance(NLMISC::CBitMemStream &f, float& distance)
{
static uint32 maxVal = (uint32)pow((float)2, 16) - 1;
if (f.isReading())
{
uint32 d = 0;
f.serial(d, 16);
distance = (float)d / 100.f;
}
else
{
uint32 d = (uint32)(distance * 100);
if (d > maxVal)
d = maxVal;
f.serial(d, 16);
}
}
/// Function that serializes speeds (in m/s)
/// Speed is converted to cm/s and cannot be greater than 2^12-1 = 4095
/// Result is serialized in 12 bits
inline void serialSpeed(NLMISC::CBitMemStream &f, float& speed)
{
static uint32 maxVal = (uint32)pow((float)2, 12) - 1;
if (f.isReading())
{
uint32 d = 0;
f.serial(d, 12);
speed = (float)d / 100.f;
}
else
{
uint32 d = (uint32)(speed * 100);
if (d > maxVal)
d = maxVal;
f.serial(d, 12);
}
}
/// Serializes the difference between 2 positions
/// The difference is converted in cm and cannot be greater than 2^15-1 = 32767
/// Result is serialized in 3 x 2 bytes = 6 bytes
inline void serialPositionDifference(NLMISC::CBitMemStream &f, NLMISC::CVector& diffPos)
{
if (f.isReading())
{
sint16 x = 0;
sint16 y = 0;
sint16 z = 0;
f.serial(x);
f.serial(y);
f.serial(z);
diffPos.x = (float)(x) / 100.f;
diffPos.y = (float)(y) / 100.f;
diffPos.z = (float)(z) / 100.f;
}
else
{
sint16 x = (sint16)(diffPos.x * 100.f);
sint16 y = (sint16)(diffPos.y * 100.f);
sint16 z = (sint16)(diffPos.z * 100.f);
f.serial(x);
f.serial(y);
f.serial(z);
}
}
}
#endif /* RY_CAMERAANIMTYPEPARSER_H */

@ -0,0 +1,201 @@
// 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_POSITIONORENTITYTYPE_H
#define RY_POSITIONORENTITYTYPE_H
#include "nel/misc/entity_id.h"
#include "nel/misc/vector.h"
#include "nel/misc/stream.h"
#include "game_share/camera_anim_type_parser.h"
//////////////////////////////////////////////////////////////////////////
/************************************************************************/
/* Class that can contain either an entity id or a position */
/************************************************************************/
class CPositionOrEntity
{
public:
enum PositionOrEntityType
{
EUnknown = -1,
EPosition = 0,
EEntity,
EPreviousPos,
EReturnPos
};
CPositionOrEntity()
{
_type = EUnknown;
}
CPositionOrEntity(const NLMISC::CVector& position)
{
_type = EPosition;
Position = position;
}
CPositionOrEntity(const TDataSetIndex& eid)
{
_type = EEntity;
EntityId = eid;
}
CPositionOrEntity(PositionOrEntityType type)
{
_type = type;
}
CPositionOrEntity(const CPositionOrEntity& c)
{
_type = c._type;
if (c.isPosition())
Position = c.getPosition();
else
EntityId = c.getEntityId();
}
CPositionOrEntity& operator=(const CPositionOrEntity& c)
{
_type = c._type;
if (c.isPosition())
Position = c.getPosition();
else if (c.isEntityId())
EntityId = c.getEntityId();
return *this;
}
bool operator==(const CPositionOrEntity& c)
{
if (_type != c._type)
return false;
if (isPosition())
return Position == c.getPosition();
else if (isEntityId())
return EntityId == c.getEntityId();
return true;
}
void setPosition(const NLMISC::CVector& position)
{
_type = EPosition;
Position = position;
}
void setEntityId(const TDataSetIndex& eid)
{
_type = EEntity;
EntityId = eid;
}
void setPreviousPos()
{
_type = EPreviousPos;
}
void setReturnPos()
{
_type = EReturnPos;
}
bool isPosition() const
{
return _type == EPosition;
}
bool isEntityId() const
{
return _type == EEntity;
}
bool isPreviousPos() const
{
return _type == EPreviousPos;
}
bool isReturnPos() const
{
return _type == EReturnPos;
}
NLMISC::CVector getPosition() const
{
if (!isPosition())
return NLMISC::CVector();
return Position;
}
/// This function returns the difference between the player's position and the specified position
/*virtual NLMISC::CVector getDiffPos(const NLMISC::CVector& targetPos) const = 0;
/// This function returns the target position given the difference between the player's position and this target position
virtual NLMISC::CVector setPositionFromDiffPos(const NLMISC::CVector& diffPos) = 0;*/
TDataSetIndex getEntityId() const
{
if (!isEntityId())
return TDataSetIndex();
return EntityId;
}
bool isValid() const
{
return _type != EUnknown;
}
void serial(NLMISC::CBitMemStream &f)
{
if (f.isReading())
{
uint32 t = 0;
f.serial(t, 2);
_type = (PositionOrEntityType)t;
}
else
{
uint32 t = (uint32)_type;
f.serial(t, 2);
}
if (isPosition())
{
if (f.isReading())
{
/*NLMISC::CVector diffPos = NLMISC::CVector();
NLMISC::serialPositionDifference(f, diffPos);
setPositionFromDiffPos(diffPos);*/
f.serial(Position);
}
else
{
/*NLMISC::CVector diffPos = getDiffPos(getPosition());
NLMISC::serialPositionDifference(f, diffPos);*/
f.serial(Position);
}
}
else if (isEntityId())
f.serial(EntityId);
}
protected:
PositionOrEntityType _type;
NLMISC::CVector Position;
TDataSetIndex EntityId;
};
#endif /* RY_POSITIONORENTITYTYPE_H */

@ -102,4 +102,4 @@ rem wait 2s (yes, i didn't find a better way to wait N seconds)
ping -n 2 127.0.0.1 > NUL 2>&1
rem ras
start %MODE%\ryzom_admin_service --fulladminname=admin_service --shortadminname=AS --writepid
start %MODE%\ryzom_admin_service --fulladminname=admin_service --shortadminname=AS --writepid

@ -9,6 +9,7 @@ FILE(GLOB SRC_ENTITY_STRUCTURE entity_structure/*.h entity_structure/*.cpp)
FILE(GLOB SRC_GAME_ITEM_MANAGER game_item_manager/*.h game_item_manager/*.cpp)
FILE(GLOB SRC_GUILD_MANAGER guild_manager/*.h guild_manager/*.cpp)
FILE(GLOB SRC_MISSION_MANAGER mission_manager/*.h mission_manager/*.cpp)
FILE(GLOB SRC_CAMERA_ANIMATIONS camera_animation_manager/*.h camera_animation_manager/*.cpp)
FILE(GLOB SRC_MODULES modules/*.h modules/*.cpp)
FILE(GLOB SRC_OUTPOST_MANAGER outpost_manager/*.h outpost_manager/*.cpp)
FILE(GLOB SRC_PHRASE_MANAGER phrase_manager/*.h phrase_manager/*.cpp)
@ -55,6 +56,7 @@ SOURCE_GROUP("Entity Structure" FILES ${SRC_ENTITY_STRUCTURE})
SOURCE_GROUP("Game Item Manager" FILES ${SRC_GAME_ITEM_MANAGER})
SOURCE_GROUP("Guild Manager" FILES ${SRC_GUILD_MANAGER})
SOURCE_GROUP("Mission Manager" FILES ${SRC_MISSION_MANAGER})
SOURCE_GROUP("Camera Animation Manager" FILES ${SRC_CAMERA_ANIMATIONS})
SOURCE_GROUP("Modules" FILES ${SRC_MODULES})
SOURCE_GROUP("Outpost Manager" FILES ${SRC_OUTPOST_MANAGER})
SOURCE_GROUP("Phrase Manager" FILES ${SRC_PHRASE_MANAGER})
@ -71,6 +73,7 @@ ADD_EXECUTABLE(ryzom_entities_game_service WIN32
${SRC_BACKWARD_COMPATIBILITY}
${SRC_BUILDING_MANAGER}
${SRC_CHARACTER_STRUCTURE}
${SRC_CAMERA_ANIMATIONS}
${SRC_CREATURE_MANAGER}
${SRC_EGS_SHEETS}
${SRC_ENTITY_MANAGER}

@ -0,0 +1,209 @@
// 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 "stdpch.h"
#include "camera_animation_manager/camera_animation_manager.h"
#include "primitives_parser.h"
#include "nel/ligo/primitive.h"
#include "camera_animation_manager/camera_animation_step_factory.h"
#include "player_manager/player_manager.h"
using namespace std;
using namespace NLMISC;
using namespace NLLIGO;
using namespace NLNET;
CCameraAnimationManager* CCameraAnimationManager::_Instance = NULL;
void CCameraAnimationManager::init()
{
// Just asserts the instance is not already created and we create the manager that will load the camera animations
nlassert(_Instance == NULL);
_Instance = new CCameraAnimationManager();
}
void CCameraAnimationManager::release()
{
// We delete the instance of the manager which will delete the allocated resources
delete _Instance;
_Instance = NULL;
}
CCameraAnimationManager::CCameraAnimationManager()
{
// We get the loaded primitives
const CPrimitivesParser::TPrimitivesList & primsList = CPrimitivesParser::getInstance().getPrimitives();
nlinfo("parsing the camera animations");
// We begin to parse the camera animations
CPrimitivesParser::TPrimitivesList::const_iterator first, last;
for (first = primsList.begin(), last = primsList.end(); first != last; ++first)
{
// parse camera animations
if (!parseCameraAnimations(first->Primitive.RootNode, first->FileName))
{
nlwarning("<CCameraAnimationManager constructor> Error while parsing the camera animations in primitive number '%s'", first->FileName.c_str());
}
}
}
CCameraAnimationManager::~CCameraAnimationManager()
{
// Delete the list of animations
TCameraAnimationContainer::iterator first = Animations.begin();
for (; first != Animations.end(); ++first)
{
first->second.release();
}
Animations.clear();
}
bool CCameraAnimationManager::parseCameraAnimations(const IPrimitive* prim, const std::string& filename)
{
string value;
// if the node is a camera animation parse it
if (prim->getPropertyByName("class", value) && !nlstricmp(value.c_str(), "camera_animation_tree"))
{
// We get the name of the mission
prim->getPropertyByName("name", value);
string animName = value;
TCameraAnimInfo animInfo;
animInfo.Name = animName;
// We now parse the instructions which are children of the camera animation
for (uint i = 0; i < prim->getNumChildren(); i++)
{
const IPrimitive* child;
prim->getChild(child, i);
// We tell the factory to load the instructions in function of the type of instruction we have
string stepType;
if (!child->getPropertyByName("class", stepType))
{
nlwarning("<CCameraAnimationManager parseCameraAnimations> Error while getting the class of a camera animation step in primitive number '%s'", filename.c_str());
continue;
}
ICameraAnimationStep* step = ICameraAnimationStepFactory::parseStep(child, filename, stepType);
// We add the instruction to the list
if (step)
{
animInfo.Steps.push_back(step);
}
}
// We add the camera animation to the container
Animations[animName] = animInfo;
return true;
}
else
{
// lookup recursively in the children
bool ok = true;
for (uint i = 0; i < prim->getNumChildren(); ++i)
{
const IPrimitive *child;
if (!prim->getChild(child,i) || !parseCameraAnimations(child, filename))
ok = false;
}
return ok;
}
}
void CCameraAnimationManager::sendAnimation(const NLMISC::CEntityId& eid, const std::string& animationName)
{
// We search for the correct camera animation
TCameraAnimationContainer::iterator it;
for (it = Animations.begin(); it != Animations.end(); ++it)
{
if (it->first == animationName)
{
it->second.sendAnimationSteps(eid);
break;
}
}
}
void CCameraAnimationManager::TCameraAnimInfo::sendAnimationSteps(const NLMISC::CEntityId& eid)
{
// We first send an impulse to the client to tell him an animation will start (this way he can remember its current position)
nldebug("CameraAnimation sending impulse for starting anim, eidDynamicId: %d", (int)eid.getDynamicId());
PlayerManager.sendImpulseToClient(eid, "CAMERA_ANIMATION:PLAY");
// We send the first step, and then the others
sendAnimationStepsFrom(eid, 0);
}
bool CCameraAnimationManager::TCameraAnimInfo::sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep)
{
// We can send the current step
// We first check if the step exists
if (currentStep < 0 || currentStep >= Steps.size())
return false;
ICameraAnimationStep* step = Steps[currentStep];
// We send the animation step to the client
NLNET::CMessage msgout("IMPULSION_ID");
msgout.serial(const_cast<NLMISC::CEntityId&>(eid));
NLMISC::CBitMemStream bms;
GenericMsgManager.pushNameToStream("CAMERA_ANIMATION:STEP", bms);
// We tell the step to fill the message
step->sendAnimationFullStep(bms);
// We add the buffer to the message
msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length());
nldebug("CameraAnimation sending impulse for step %s, buffer length: %d, eidDynamicId: %d", step->getStepName().c_str(),
bms.length(), (int)eid.getDynamicId());
NLNET::CUnifiedNetwork::getInstance()->send(NLNET::TServiceId(eid.getDynamicId()), msgout);
return true;
}
void CCameraAnimationManager::TCameraAnimInfo::sendAnimationStepsFrom(const NLMISC::CEntityId& eid, int firstStep, TCameraAnimTimerEvent* event)
{
// We send the current step
if (sendAnimationStep(eid, firstStep))
{
if (event == 0)
event = new TCameraAnimTimerEvent(this, firstStep + 1, eid);
else
event->nextStep();
// Now we send the other steps after the duration
//_Timer->reset();
NLMISC::TGameCycle duration = (NLMISC::TGameCycle)(Steps[firstStep]->getDuration() / CTickEventHandler::getGameTimeStep());
_Timer->setRemaining(duration, event);
}
else
{
// There was no other step, so we send an impulse to tell the client it's finished
nldebug("CameraAnimation sending impulse for finished anim, eidDynamicId: %d", (int)eid.getDynamicId());
PlayerManager.sendImpulseToClient(eid, "CAMERA_ANIMATION:FINISHED");
}
}

@ -0,0 +1,147 @@
// 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_CAMERAANIMATIONMANAGER_H
#define RY_CAMERAANIMATIONMANAGER_H
#include "nel/ligo/primitive.h"
#include <string>
#include "camera_animation_manager/camera_animation_step_factory.h"
#include "nel/misc/entity_id.h"
#include "game_share/timer.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 CCameraAnimationManager
{
public:
/// Gets the current instance of the manager
static CCameraAnimationManager* getInstance() { return _Instance; }
/// Creates the instance of the manager and parse the animations
static void init();
/// Releases the animations
static void release();
/// Function that sends all the instructions of a camera animation to the specified entity
void sendAnimation(const NLMISC::CEntityId& eid, const std::string& animationName);
private:
/// Constructor
CCameraAnimationManager();
/// Destructor
~CCameraAnimationManager();
/// Function that parses the camera animations
bool parseCameraAnimations(const NLLIGO::IPrimitive* prim, const std::string& filename);
/// Instance of the manager
static CCameraAnimationManager* _Instance;
/// Class that contains information about an animation
class TCameraAnimInfo
{
private:
class TCameraAnimTimerEvent;
public:
TCameraAnimInfo()
{
Name = "";
_Timer = new CTimer();
}
/// Function called to release the animations
void release()
{
// We delete the camera animation steps
for (std::vector<ICameraAnimationStep*>::iterator it = Steps.begin(); it != Steps.end(); ++it)
{
ICameraAnimationStep* step = *it;
delete step;
}
Steps.clear();
Name = "";
delete _Timer;
}
/// Function called to send the camera animation instruction specified by the current step to the client
/// The function returns false if the animation step does not exist
bool sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep);
/// Function called to send all the camera animation instructions to the client
void sendAnimationSteps(const NLMISC::CEntityId& eid);
/// Function that sends the animation steps from the specified one to the last one
void sendAnimationStepsFrom(const NLMISC::CEntityId& eid, int firstStep, TCameraAnimTimerEvent* event = 0);
std::string Name;
std::vector<ICameraAnimationStep*> Steps;
private:
CTimer* _Timer;
class TCameraAnimTimerEvent: public CTimerEvent
{
public:
TCameraAnimTimerEvent(TCameraAnimInfo* info, int nextStep, const NLMISC::CEntityId& eid): _Eid(eid)
{
_Infos = info;
_Next = nextStep;
nldebug("TCameraAnimTimerEvent constructor for step %s, eidDynamicId: %d", info->Name.c_str(),
(int)eid.getDynamicId());
}
~TCameraAnimTimerEvent()
{
nldebug("TCameraAnimTimerEvent destructor");
}
// Callback called when the timer finished
void timerCallback(CTimer* owner)
{
// We tell the camera anim info to send the current step and the next ones
_Infos->sendAnimationStepsFrom(_Eid, _Next, this);
}
void nextStep()
{
_Next++;
}
private:
TCameraAnimInfo* _Infos;
int _Next;
NLMISC::CEntityId _Eid;
};
};
typedef std::map<std::string, TCameraAnimInfo> TCameraAnimationContainer;
/// Variable that contains the animations
TCameraAnimationContainer Animations;
};
#endif /* RY_CAMERAANIMATIONMANAGER_H */

@ -0,0 +1,62 @@
// 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/camera_animation_modifier_factory.h"
std::vector<std::pair<std::string, ICameraAnimationModifierFactory*> >* ICameraAnimationModifierFactory::Entries;
ICameraAnimationModifier* ICameraAnimationModifierFactory::parseModifier(const NLLIGO::IPrimitive* prim, const std::string& filename, const std::string& modifierType)
{
// We search the correct modifier type in our entries
for (uint i = 0; i < Entries->size(); i++)
{
if (modifierType == (*Entries)[i].first)
{
ICameraAnimationModifier * ret = (*Entries)[i].second->instanciate();
if (!ret)
{
nlerror("BUG IN CAMERA ANIMATION MODIFIER FACTORY : BAD INIT CODE");
return NULL;
}
// We parse the modifier
if (!ret->parseModifier(prim, filename))
{
nlerror("building camera animation modifier failed");
delete ret;
return NULL;
}
return ret;
}
}
return NULL;
}
void ICameraAnimationModifierFactory::init()
{
if (!Entries)
Entries = new std::vector<std::pair<std::string, ICameraAnimationModifierFactory*> >;
}
void ICameraAnimationModifier::sendCameraFullModifier(NLMISC::CBitMemStream& bms)
{
// We first add the name of the modifier
std::string name = getModifierName();
bms.serial(const_cast<std::string&>(name));
// We ask the modifier to add its information to the message
sendCameraModifier(bms);
}

@ -0,0 +1,94 @@
// 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_CAMERAANIMATIONMODIFIERFACTORY_H
#define RY_CAMERAANIMATIONMODIFIERFACTORY_H
#include "nel/ligo/primitive.h"
#include <string>
/************************************************************************/
/* Interface for camera animation modifiers.
* For simplicity, sounds triggers and considered like modifiers too.
* It has to be able to parse it's parameters from the primitive.
* And also to generate a small script to send to the client
*/
/************************************************************************/
class ICameraAnimationModifier
{
public:
/// This function is called when it's time to parse the primitive to load the camera animation modifier
virtual bool parseModifier(const NLLIGO::IPrimitive* prim, const std::string& filename) = 0;
/// Function called to send the modifier to the client
virtual void sendCameraModifier(NLMISC::CBitMemStream& bms) = 0;
/// Function to get the name of the modifier
virtual std::string getModifierName() const = 0;
/// Function called to send the modifier to the client (including its name)
void sendCameraFullModifier(NLMISC::CBitMemStream& bms);
};
/************************************************************************/
/* Factory class that can instanciate the correct camera animation modifier handler.
*
* \author Fabien Henon
* \date 2012
*/
/************************************************************************/
class ICameraAnimationModifierFactory
{
public:
/// Function that will instanciate the correct camera animation step
static ICameraAnimationModifier* parseModifier(const NLLIGO::IPrimitive* prim, const std::string& filename, const std::string& modifierType);
protected:
/// Functions used to be able to create the camera animation modifiers
static void init();
virtual ICameraAnimationModifier * instanciate() = 0;
static std::vector<std::pair<std::string, ICameraAnimationModifierFactory*> >* Entries;
};
// Define used to register the different types of camera animation modifiers
#define CAMERA_ANIMATION_REGISTER_MODIFIER(_class_,_name_) \
class _class_##CameraAnimationModifierFactory : public ICameraAnimationModifierFactory \
{\
public:\
_class_##CameraAnimationModifierFactory()\
{\
init();\
std::string str = std::string(_name_); \
for (uint i = 0; i < (*Entries).size(); i++ ) \
{\
if ( (*Entries)[i].first == str || (*Entries)[i].second == this )nlstop;\
}\
(*Entries).push_back( std::make_pair( str, this ) );\
}\
ICameraAnimationModifier * instanciate()\
{ \
return new _class_;\
} \
};\
static _class_##CameraAnimationModifierFactory* _class_##CameraAnimationModifierFactoryInstance = new _class_##CameraAnimationModifierFactory;
#define CAMERA_ANIMATION_MODIFIER_NAME(name) \
std::string getModifierName() const \
{ \
return name; \
}
#endif /* RY_CAMERAANIMATIONMODIFIERFACTORY_H */

@ -0,0 +1,125 @@
// 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/camera_animation_modifier_factory.h"
#include "game_share/position_or_entity_type.h"
#include "nel/misc/sheet_id.h"
#include "camera_animation_manager/position_or_entity_type_helper.h"
/////////////////////////////////////////////////////////////////////////////
/// This animation modifier shakes the camera. The parameter is
/// - strength
class CCameraAnimationModifierShake : public ICameraAnimationModifier
{
protected:
float Strength;
public:
CCameraAnimationModifierShake()
{
Strength = 0.f;
}
virtual bool parseModifier(const NLLIGO::IPrimitive* prim, const std::string& filename)
{
std::string value;
// We get the strength
if (!prim->getPropertyByName("strength", value))
{
nlwarning("<CCameraAnimationModifierShake parseModifier> impossible to get the strength property of the basic modifier in primitive : %s", filename.c_str());
return false;
}
if (!NLMISC::fromString(value, Strength))
{
nlwarning("<CCameraAnimationModifierShake parseModifier> impossible to convert the string : %s, in float in the basic modifier in primitive : %s", value.c_str(), filename.c_str());
return false;
}
return true;
}
virtual void sendCameraModifier(NLMISC::CBitMemStream& bms)
{
bms.serial(const_cast<float&>(Strength));
}
CAMERA_ANIMATION_MODIFIER_NAME("camera_modifier_shake");
};
CAMERA_ANIMATION_REGISTER_MODIFIER(CCameraAnimationModifierShake, "camera_modifier_shake");
/////////////////////////////////////////////////////////////////////////////
/// This animation modifier plays a sound. The parameters are
/// - sound_name
/// - sound_position
class CCameraAnimationModifierSoundTrigger : public ICameraAnimationModifier
{
protected:
std::string SoundPos;
NLMISC::CSheetId SoundId;
public:
CCameraAnimationModifierSoundTrigger()
{
SoundPos = "";
SoundId = NLMISC::CSheetId::Unknown;
}
virtual bool parseModifier(const NLLIGO::IPrimitive* prim, const std::string& filename)
{
std::string value;
// We get the sound name
if (!prim->getPropertyByName("sound_name", value))
{
nlwarning("<CCameraAnimationModifierSoundTrigger parseModifier> impossible to get the sound_name property of the basic modifier in primitive : %s", filename.c_str());
return false;
}
SoundId = NLMISC::CSheetId(value);
if (SoundId == NLMISC::CSheetId::Unknown)
{
nlwarning("<CCameraAnimationModifierSoundTrigger parseModifier> sheetid not found for sound name %s in the basic modifier in primitive : %s", value.c_str(), filename.c_str());
return false;
}
// We get the sound position
if (!prim->getPropertyByName("sound_position", value))
{
nlwarning("<CCameraAnimationModifierSoundTrigger parseModifier> impossible to get the sound_position property of the basic modifier in primitive : %s", filename.c_str());
return false;
}
SoundPos = value;
return true;
}
virtual void sendCameraModifier(NLMISC::CBitMemStream& bms)
{
CPositionOrEntityHelper pos = CPositionOrEntityHelper::fromString(SoundPos);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationModifierSoundTrigger parseModifier> invalid soundpos %s", SoundPos.c_str());
}
bms.serial(const_cast<CPositionOrEntityHelper&>(pos));
bms.serial(const_cast<NLMISC::CSheetId&>(SoundId));
}
CAMERA_ANIMATION_MODIFIER_NAME("sound_trigger");
};
CAMERA_ANIMATION_REGISTER_MODIFIER(CCameraAnimationModifierSoundTrigger, "sound_trigger");

@ -0,0 +1,104 @@
// 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/camera_animation_step_factory.h"
std::vector<std::pair<std::string, ICameraAnimationStepFactory*> >* ICameraAnimationStepFactory::Entries;
ICameraAnimationStep* ICameraAnimationStepFactory::parseStep(const NLLIGO::IPrimitive* prim, const std::string& filename, const std::string& stepType)
{
// We search the correct step type in our entries
for (uint i = 0; i < Entries->size(); i++)
{
if (stepType == (*Entries)[i].first)
{
ICameraAnimationStep * ret = (*Entries)[i].second->instanciate();
if (!ret)
{
nlerror("BUG IN CAMERA ANIMATION STEP FACTORY : BAD INIT CODE");
return NULL;
}
// We parse the step
if (!ret->parseStep(prim, filename))
{
nlerror("building camera animation step failed");
delete ret;
return NULL;
}
// We look for children (modifiers or sound triggers)
for (uint i = 0; i < prim->getNumChildren(); i++)
{
const NLLIGO::IPrimitive* child;
prim->getChild(child, i);
// We tell the factory to load the modifier in function of its type
std::string modifierType;
if (!child->getPropertyByName("class", modifierType))
{
nlwarning("<ICameraAnimationStepFactory parseStep> Error while getting the class of a camera animation modifier in primitive number '%s'", filename.c_str());
continue;
}
ICameraAnimationModifier* modifier = ICameraAnimationModifierFactory::parseModifier(child, filename, modifierType);
// We add the modifier to the list
if (modifier)
{
ret->addModifier(modifier);
}
}
return ret;
}
}
return NULL;
}
void ICameraAnimationStepFactory::init()
{
if (!Entries)
Entries = new std::vector<std::pair<std::string, ICameraAnimationStepFactory*> >;
}
void ICameraAnimationStep::addModifier(ICameraAnimationModifier* modifier)
{
Modifiers.push_back(modifier);
}
void ICameraAnimationStep::sendAnimationFullStep(NLMISC::CBitMemStream& bms)
{
/*// We first add the name of the step
std::string name = getStepName();
bms.serial(const_cast<std::string&>(name));*/
// We ask the step to add its information to the message
sendAnimationStep(bms);
// We finally send the modifiers instructions
// We add a header to tell the number of modifiers
uint8 nbModifiers = (uint8)Modifiers.size();
bms.serial(const_cast<uint8&>(nbModifiers));
// We loop through the modifiers to add them
std::vector<ICameraAnimationModifier*>::iterator it;
for (it = Modifiers.begin(); it != Modifiers.end(); ++it)
{
ICameraAnimationModifier* modifier = *it;
modifier->sendCameraFullModifier(bms);
}
}

@ -0,0 +1,104 @@
// 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_CAMERAANIMATIONSTEPFACTORY_H
#define RY_CAMERAANIMATIONSTEPFACTORY_H
#include "nel/ligo/primitive.h"
#include <string>
#include <vector>
#include "camera_animation_manager/camera_animation_modifier_factory.h"
/************************************************************************/
/* Interface for camera animation steps.
* It has to be able to parse the step from the primitive.
* And also to generate a small script to send to the client
*/
/************************************************************************/
class ICameraAnimationStep
{
public:
/// This function is called when it's time to parse the primitive to load the camera animation step
virtual bool parseStep(const NLLIGO::IPrimitive* prim, const std::string& filename) = 0;
/// Function that adds a camera animation modifier to this step
void addModifier(ICameraAnimationModifier* modifier);
/// Function that returns the duration of the step (in seconds)
virtual float getDuration() const = 0;
/// Function that returns the name of the step
virtual std::string getStepName() const = 0;
/// Function that sends the animation step the to client
virtual void sendAnimationStep(NLMISC::CBitMemStream& bms) = 0;
/// Function that send all information about a step to the client (this includes modifiers)
void sendAnimationFullStep(NLMISC::CBitMemStream& bms);
protected:
// The list of modifiers
std::vector<ICameraAnimationModifier*> Modifiers;
};
/************************************************************************/
/* Factory class that can instanciate the correct camera animation step handler.
*
* \author Fabien Henon
* \date 2012
*/
/************************************************************************/
class ICameraAnimationStepFactory
{
public:
/// Function that will instanciate the correct camera animation step
static ICameraAnimationStep* parseStep(const NLLIGO::IPrimitive* prim, const std::string& filename, const std::string& stepType);
protected:
/// Functions used to be able to create the camera animation steps
static void init();
virtual ICameraAnimationStep * instanciate() = 0;
static std::vector<std::pair<std::string, ICameraAnimationStepFactory*> >* Entries;
};
// Define used to register the different types of camera animation steps
#define CAMERA_ANIMATION_REGISTER_STEP(_class_,_name_) \
class _class_##CameraAnimationStepFactory : public ICameraAnimationStepFactory \
{\
public:\
_class_##CameraAnimationStepFactory()\
{\
init();\
std::string str = std::string(_name_); \
for (uint i = 0; i < (*Entries).size(); i++ ) \
{\
if ( (*Entries)[i].first == str || (*Entries)[i].second == this )nlstop;\
}\
(*Entries).push_back( std::make_pair( str, this ) );\
}\
ICameraAnimationStep * instanciate()\
{ \
return new _class_;\
} \
};\
static _class_##CameraAnimationStepFactory* _class_##CameraAnimationStepFactoryInstance = new _class_##CameraAnimationStepFactory;
#define CAMERA_ANIMATION_STEP_NAME(name) \
std::string getStepName() const \
{ \
return name; \
}
#endif /* RY_CAMERAANIMATIONSTEPFACTORY_H */

@ -0,0 +1,197 @@
// 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/camera_animation_step_factory.h"
#include "game_share/position_or_entity_type.h"
#include "camera_animation_manager/position_or_entity_type_helper.h"
#include "game_share/camera_anim_type_parser.h"
/// Basic camera animation step that has generic values
class CCameraAnimationStep : public ICameraAnimationStep
{
protected:
std::string LookAtTarget;
float DirectionTransitionTime;
std::string PositionTarget;
float PositionTransitionTime;
float DistanceTo;
bool HasTurnAround;
float TurnAroundSpeed;
std::string Text;
float Duration;
public:
CCameraAnimationStep()
{
LookAtTarget = "";
DirectionTransitionTime = 0.f;
PositionTarget = "";
PositionTransitionTime = 0.f;
DistanceTo = 0.f;
HasTurnAround = false;
TurnAroundSpeed = 0.f;
Text = "";
Duration = 0.f;
}
virtual bool parseStep(const NLLIGO::IPrimitive* prim, const std::string& filename)
{
std::string value;
// We get the look at target
if (!prim->getPropertyByName("look_at_target", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the look_at_target property of the basic step in primitive : %s", filename.c_str());
return false;
}
LookAtTarget = value;
// We get the direction_transition_time
if (!prim->getPropertyByName("direction_transition_time", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the direction_transition_time property of the basic step in primitive : %s", filename.c_str());
return false;
}
if (!NLMISC::fromString(value, DirectionTransitionTime))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to convert the string : %s, in float in the basic step in primitive : %s", value.c_str(), filename.c_str());
return false;
}
// We get the position_target
if (!prim->getPropertyByName("position_target", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the position_target property of the basic step in primitive : %s", filename.c_str());
return false;
}
PositionTarget = value;
// We get the position_transition_time
if (!prim->getPropertyByName("position_transition_time", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the position_transition_time property of the basic step in primitive : %s", filename.c_str());
return false;
}
if (!NLMISC::fromString(value, PositionTransitionTime))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to convert the string : %s, in float in the basic step in primitive : %s", value.c_str(), filename.c_str());
return false;
}
// We get the distance_to
if (!prim->getPropertyByName("distance_to", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the distance_to property of the basic step in primitive : %s", filename.c_str());
return false;
}
if (!NLMISC::fromString(value, DistanceTo))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to convert the string : %s, in float in the basic step in primitive : %s", value.c_str(), filename.c_str());
return false;
}
// We get the has_turn_around
if (!prim->getPropertyByName("has_turn_around", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the has_turn_around property of the basic step in primitive : %s", filename.c_str());
return false;
}
if (!NLMISC::fromString(value, HasTurnAround))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to convert the string : %s, in bool in the basic step in primitive : %s", value.c_str(), filename.c_str());
return false;
}
// We get the turn_around_speed
if (!prim->getPropertyByName("turn_around_speed", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the turn_around_speed property of the basic step in primitive : %s", filename.c_str());
return false;
}
if (!NLMISC::fromString(value, TurnAroundSpeed))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to convert the string : %s, in float in the basic step in primitive : %s", value.c_str(), filename.c_str());
return false;
}
// We get the text
if (!prim->getPropertyByName("text", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the text property of the basic step in primitive : %s", filename.c_str());
return false;
}
Text = value;
// We get the duration
if (!prim->getPropertyByName("duration", value))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the duration property of the basic step in primitive : %s", filename.c_str());
return false;
}
if (!NLMISC::fromString(value, Duration))
{
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to convert the string : %s, in float in the basic step in primitive : %s", value.c_str(), filename.c_str());
return false;
}
return true;
}
virtual void sendAnimationStep(NLMISC::CBitMemStream& bms)
{
CPositionOrEntityHelper posLookAtTarget = CPositionOrEntityHelper::fromString(LookAtTarget);
if (posLookAtTarget == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationStepBasic parseStep> invalid LookAtTarget %s", LookAtTarget.c_str());
}
bms.serial(const_cast<CPositionOrEntityHelper&>(posLookAtTarget));
if (!posLookAtTarget.isPreviousPos())
{
NLMISC::serialDuration(bms, DirectionTransitionTime);
}
CPositionOrEntityHelper posPosTarget = CPositionOrEntityHelper::fromString(PositionTarget);
if (posPosTarget == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationStepBasic parseStep> invalid PositionTarget %s", PositionTarget.c_str());
}
bms.serial(const_cast<CPositionOrEntityHelper&>(posPosTarget));
if (!posPosTarget.isPreviousPos())
{
NLMISC::serialDistance(bms, DistanceTo);
NLMISC::serialDuration(bms, PositionTransitionTime);
bms.serialBit(const_cast<bool&>(HasTurnAround));
if (HasTurnAround)
{
NLMISC::serialSpeed(bms, TurnAroundSpeed);
}
}
}
virtual float getDuration() const
{
return Duration;
}
CAMERA_ANIMATION_STEP_NAME("camera_animation_step");
};
CAMERA_ANIMATION_REGISTER_STEP(CCameraAnimationStep, "camera_animation_step");

@ -0,0 +1,127 @@
// 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_type_helper.h"
#include "game_share/mirror.h"
#include "game_share/mirrored_data_set.h"
#include "game_share/base_types.h"
#include "mission_manager/ai_alias_translator.h"
#include "mission_manager/mission_parser.h"
#include "egs_mirror.h"
#define POS_OR_ENTITY_PREVIOUS_POS_VALUE "_PreviousPos_"
#define POS_OR_ENTITY_RETURN_POS_VALUE "_ReturnPos_"
const CPositionOrEntityHelper CPositionOrEntityHelper::Invalid = CPositionOrEntityHelper();
CPositionOrEntityHelper CPositionOrEntityHelper::fromString(const std::string& s)
{
// If the string is empty it's a previous pos
if (s.empty())
{
return CPositionOrEntityHelper(CPositionOrEntity::EPreviousPos);
}
std::string str = s;
CMissionParser::removeBlanks(str);
// We already check if it's a special position or entity object
if (NLMISC::toLower(str) == POS_OR_ENTITY_PREVIOUS_POS_VALUE)
{
return CPositionOrEntityHelper(CPositionOrEntity::EPreviousPos);
}
else if (NLMISC::toLower(str) == POS_OR_ENTITY_RETURN_POS_VALUE)
{
return CPositionOrEntityHelper(CPositionOrEntity::EReturnPos);
}
std::vector<std::string> resS;
NLMISC::splitString(str, ";", resS);
// If we don't have 3 components, it's an entity
if (resS.size() != 3)
{
std::vector<TAIAlias> res;
CAIAliasTranslator::getInstance()->getNPCAliasesFromName(str, res);
if (res.size() != 1)
{
nlerror("TPositionOrentityHelper : no alias for entity name %s", str.c_str());
return CPositionOrEntityHelper();
}
TAIAlias alias = res[0];
if (alias == CAIAliasTranslator::Invalid)
{
nlerror("TPositionOrentityHelper : invalid alias for entity name %s", str.c_str());
return CPositionOrEntityHelper();
}
NLMISC::CEntityId eid = CAIAliasTranslator::getInstance()->getEntityId(alias);
if (eid == NLMISC::CEntityId::Unknown)
{
nlerror("TPositionOrentityHelper : invalid entity id from alias %d", alias);
return CPositionOrEntityHelper();
}
TDataSetIndex compressedId = TheDataset.getDataSetRow(eid).getCompressedIndex();
return CPositionOrEntityHelper(compressedId);
}
else
{
// It's a position
std::string xStr = resS[0];
std::string yStr = resS[1];
std::string zStr = resS[2];
CMissionParser::removeBlanks(xStr);
CMissionParser::removeBlanks(yStr);
CMissionParser::removeBlanks(zStr);
float x = 0.f;
float y = 0.f;
float z = 0.f;
if (!NLMISC::fromString(xStr, x))
{
nlerror("TPositionOrentityHelper : invalid x component from string %s", xStr.c_str());
return CPositionOrEntityHelper();
}
if (!NLMISC::fromString(yStr, y))
{
nlerror("TPositionOrentityHelper : invalid y component from string %s", yStr.c_str());
return CPositionOrEntityHelper();
}
if (!NLMISC::fromString(yStr, x))
{
nlerror("TPositionOrentityHelper : invalid z component from string %s", zStr.c_str());
return CPositionOrEntityHelper();
}
return CPositionOrEntityHelper(NLMISC::CVector(x, y, z));
}
return CPositionOrEntityHelper();
}
/*NLMISC::CVector CPositionOrEntityHelper::getDiffPos(const NLMISC::CVector& targetPos) const
{
return Position;
}
NLMISC::CVector CPositionOrEntityHelper::setPositionFromDiffPos(const NLMISC::CVector& diffPos)
{
return Position;
}*/

@ -0,0 +1,70 @@
// 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_POSITIONORENTITYTYPEHELPER_H
#define RY_POSITIONORENTITYTYPEHELPER_H
#include "game_share/position_or_entity_type.h"
//////////////////////////////////////////////////////////////////////////
/************************************************************************/
/* Class that can contain either an entity id or a position */
/************************************************************************/
class CPositionOrEntityHelper: public CPositionOrEntity
{
public:
CPositionOrEntityHelper(): CPositionOrEntity()
{
}
CPositionOrEntityHelper(const NLMISC::CVector& position): CPositionOrEntity(position)
{
}
CPositionOrEntityHelper(const TDataSetIndex& eid): CPositionOrEntity(eid)
{
}
CPositionOrEntityHelper(PositionOrEntityType type): CPositionOrEntity(type)
{
}
CPositionOrEntityHelper(const CPositionOrEntity& c): CPositionOrEntity(c)
{
}
/************************************************************************/
/* Creates a PositionOrEntity instance from a string */
/************************************************************************/
static CPositionOrEntityHelper fromString(const std::string& s);
static const CPositionOrEntityHelper Invalid;
// Declares abstract methods
/// This function returns the difference between the player's position and the specified position
/*NLMISC::CVector getDiffPos(const NLMISC::CVector& targetPos) const;
/// This function returns the target position given the difference between the player's position and this target position
NLMISC::CVector setPositionFromDiffPos(const NLMISC::CVector& diffPos);*/
};
#endif /* RY_POSITIONORENTITYTYPEHELPER_H */

@ -21,6 +21,10 @@
/////////////
// INCLUDE //
/////////////
/////////////
#include "camera_animation_manager/camera_animation_manager.h"
// misc
#include "nel/misc/bit_mem_stream.h"
#include "nel/misc/path.h"
@ -1521,6 +1525,8 @@ nlassert(nodeLeaf->getType() == ICDBStructNode::TEXT);
if (!packingSheets) CNamedItems::getInstance();
if (!packingSheets) CBuildingManager::init();
// Init camera animations
if (!packingSheets) CCameraAnimationManager::init();
if (!packingSheets) CMissionManager::init();
if (!packingSheets) CMissionQueueManager::getInstance()->init();
@ -1872,6 +1878,8 @@ void CPlayerService::release()
CActionDistanceChecker::release();
if (!packingSheets) CMissionManager::release();
if (!packingSheets) CCameraAnimationManager::release();
CEffectManager::release();
if (!packingSheets) CZoneManager::getInstance().release();

@ -56,6 +56,10 @@
#include "shop_type/named_items.h"
#include "server_share/log_item_gen.h"
#include "server_share/log_character_gen.h"
#include "camera_animation_manager/camera_animation_manager.h"
#include "game_share/position_or_entity_type.h"
#include "camera_animation_manager/position_or_entity_type_helper.h"
using namespace std;
using namespace NLMISC;
@ -130,6 +134,9 @@ Implementation of all mission instructions
-set_guild_civ : set civilization of guild of character made the mission
-set_guild_cult : set cult of guild of characters made the mission
-if_no_trial : jump to an instruction if character made the mission are not a trial account
-sound_trigger : play a sound
-camera_animation : play a camera animation
@ -5386,3 +5393,106 @@ class CMissionActionHandleRelease : public IMissionAction
};
MISSION_REGISTER_ACTION(CMissionActionHandleRelease, "handle_release");
*/
/// camera animation
// ----------------------------------------------------------------------------
class CMissionActionCameraAnimation : public IMissionAction
{
bool buildAction( uint32 line, const std::vector< std::string > & script, CMissionGlobalParsingData & globalData, CMissionSpecificParsingData & missionData)
{
bool ret = true;
_SourceLine = line;
if (script.size() != 2)
{
MISLOGSYNTAXERROR("<animation_name>");
return false;
}
_AnimationName = script[1];
CMissionParser::removeBlanks(_AnimationName);
return ret;
}
void launch(CMission* instance, std::list< CMissionEvent * > & eventList)
{
LOGMISSIONACTION("camera_animation");
// We tell the client to play the animation by sending him the animation steps
std::vector<TDataSetRow> entities;
instance->getEntities(entities);
// For all entities that do this mission
for (uint i = 0; i < entities.size(); i++)
{
// We send the message
CEntityId eid = TheDataset.getEntityId(entities[i]);
CCameraAnimationManager::getInstance()->sendAnimation(eid, _AnimationName);
}
};
std::string _AnimationName;
MISSION_ACTION_GETNEWPTR(CMissionActionCameraAnimation)
};
MISSION_REGISTER_ACTION(CMissionActionCameraAnimation, "camera_animation");
/// sound trigger
// ----------------------------------------------------------------------------
class CMissionActionSoundTrigger : public IMissionAction
{
bool buildAction( uint32 line, const std::vector< std::string > & script, CMissionGlobalParsingData & globalData, CMissionSpecificParsingData & missionData)
{
bool ret = true;
_SourceLine = line;
if (script.size() != 3)
{
MISLOGSYNTAXERROR("<sound_name> : <sound_position>");
return false;
}
std::string SoundName = script[1];
CMissionParser::removeBlanks(SoundName);
if (script.size() >= 3)
_SoundPosition = script[2];
else
_SoundPosition = "";
_SoundId = NLMISC::CSheetId(SoundName);
if (_SoundId == NLMISC::CSheetId::Unknown)
{
MISLOGSYNTAXERROR("sound_trigger action: sheetid not found");
return false;
}
return ret;
}
void launch(CMission* instance, std::list< CMissionEvent * > & eventList)
{
LOGMISSIONACTION("sound_trigger");
// We tell the client to play the sound
std::vector<TDataSetRow> entities;
instance->getEntities(entities);
// We get the position or entity
CPositionOrEntityHelper pos = CPositionOrEntityHelper::fromString(_SoundPosition);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<sound_trigger mission_action launch> invalid position or entity from %s", _SoundPosition.c_str());
}
// For all entities that do this mission
for (uint i = 0; i < entities.size(); i++)
{
// We send the message
CEntityId eid = TheDataset.getEntityId(entities[i]);
PlayerManager.sendImpulseToClient(eid, "SOUND_TRIGGER", _SoundId, pos);
}
};
std::string _SoundPosition;
NLMISC::CSheetId _SoundId;
MISSION_ACTION_GETNEWPTR(CMissionActionSoundTrigger)
};
MISSION_REGISTER_ACTION(CMissionActionSoundTrigger, "sound_trigger");

@ -732,6 +732,30 @@ bool CMissionCompiler::installCompiledMission(NLLIGO::CLigoConfig &ligoConfig, c
for (uint i=0; i<_CompiledMission.size(); ++i)
{
CMissionData &mission = *(_CompiledMission[i]);
// Before adding the script to the giver npc, we first check if the referenced camera animations exist in the current primitive
TLoadedPrimitive &currLoadedPrim = loadedPrimitives[toLower(primFileName)];
CPrimitives *currPrimDoc = currLoadedPrim.PrimDoc;
CPrimitiveContext::instance().CurrentPrimitive = currPrimDoc;
std::vector<std::string> cameraAnimationNames = mission.getCameraAnimationNames();
for (std::vector<std::string>::iterator it = cameraAnimationNames.begin(); it != cameraAnimationNames.end(); ++it)
{
std::string animName = *it;
TPrimitiveSet camAnims;
CPrimitiveSet<TPrimitiveClassAndNamePredicate> filter;
TPrimitiveClassAndNamePredicate pred("camera_animation_tree", animName);
filter.buildSet(currPrimDoc->RootNode, pred, camAnims);
if (camAnims.empty())
{
// Error, we cannot find the camera animation !
string err = toString("Can't find camera animation '%s' in primitive '%s' !",
animName.c_str(),
primFileName.c_str());
throw EParseException(NULL, err.c_str());
}
}
string fileName = mission.getGiverPrimitive();
if (fileName.empty())
{
@ -2184,6 +2208,16 @@ bool CMissionData::isThereAJumpTo(const std::string &stepName)
return false;
}
void CMissionData::addCameraAnimationName( const std::string& name )
{
_CameraAnimations.push_back(name);
}
std::vector<std::string> CMissionData::getCameraAnimationNames()
{
return _CameraAnimations;
}
void TCompilerVarName::init(const std::string &defaultName, STRING_MANAGER::TParamType type, CMissionData &md, NLLIGO::IPrimitive *prim, const std::string propName)
{
_DefaultName = defaultName;

@ -315,6 +315,8 @@ public:
std::string getProperty(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail);
std::vector<std::string> getPropertyArray(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail);
void addCameraAnimationName(const std::string& name);
std::vector<std::string> getCameraAnimationNames();
bool isThereAJumpTo(const std::string &stepName);
@ -407,6 +409,8 @@ private:
std::set<TJumpInfo> _JumpPoints;
std::vector<std::string> _CameraAnimations;
};
typedef NLMISC::CSmartPtr<CMissionData> TMissionDataPtr;

@ -3464,3 +3464,77 @@ public:
};
REGISTER_STEP_CONTENT(CContentRingScenario, "ring_scenario");
// ---------------------------------------------------------------------------
class CActionSoundTrigger : public IStepContent
{
string _SoundName;
string _SoundPos;
void getPredefParam(uint32 &numEntry, CPhrase::TPredefParams &predef)
{
numEntry = 0;
}
public:
void init(CMissionData &md, IPrimitive *prim)
{
IStepContent::init(md, prim);
_SoundName = md.getProperty(prim, "sound_name", true, false);
_SoundPos = md.getProperty(prim, "sound_position", true, false);
// We assert everything is ok
if (_SoundPos.empty())
{
string err = toString("primitive(%s): 'sound_position' must not be empty.", prim->getName().c_str());
throw EParseException(prim, err.c_str());
}
if (_SoundName.empty())
{
string err = toString("primitive(%s): 'sound_name' must not be empty.", prim->getName().c_str());
throw EParseException(prim, err.c_str());
}
}
string genCode(CMissionData &md)
{
string ret;
ret = "sound_trigger : "+_SoundName + " : " + _SoundPos + NL;
return ret;
}
};
REGISTER_STEP_CONTENT(CActionSoundTrigger, "sound_trigger");
// ---------------------------------------------------------------------------
class CActionCameraAnimation : public IStepContent
{
string _Name;
void getPredefParam(uint32 &numEntry, CPhrase::TPredefParams &predef)
{
numEntry = 0;
}
public:
void init(CMissionData &md, IPrimitive *prim)
{
IStepContent::init(md, prim);
_Name = md.getProperty(prim, "animation_name", true, false);
// We assert everything is ok
if (_Name.empty())
{
string err = toString("primitive(%s): 'animation_name' must not be empty.", prim->getName().c_str());
throw EParseException(prim, err.c_str());
}
// We add the animation name to the list, so that we can check later if the animation exists
md.addCameraAnimationName(_Name);
}
string genCode(CMissionData &md)
{
string ret;
ret = "camera_animation : " + _Name + NL;
return ret;
}
};
REGISTER_STEP_CONTENT(CActionCameraAnimation, "camera_animation");

Loading…
Cancel
Save