1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "nel/3d/play_list_user.h"
20 #include "nel/3d/animation_set_user.h"
21 #include "nel/3d/u_transform.h"
22 #include "nel/3d/transform.h"
24 #include "nel/misc/hierarchical_timer.h"
25 #include "nel/misc/debug.h"
27 using namespace NLMISC
;
36 H_AUTO_DECL( NL3D_UI_PlayList
)
38 #define NL3D_HAUTO_UI_PLAY_LIST H_AUTO_USE( NL3D_UI_PlayList )
41 // ***************************************************************************
43 TAnimationTime
CPlayListUser::getLocalTime (uint8 slot
, TGlobalAnimationTime globalTime
, const UAnimationSet
& animSet
) const
45 NL3D_HAUTO_UI_PLAY_LIST
;
48 const CAnimationSetUser
*cAnimSetUser
=safe_cast
<const CAnimationSetUser
*>(&animSet
);
50 // Get the animationset pointer
51 const CAnimationSet
* cAnimSet
=cAnimSetUser
->getAnimationSet ();
54 return _PlayList
.getLocalTime (slot
, globalTime
, *cAnimSet
);
57 // ***************************************************************************
59 float CPlayListUser::getLocalWeight (uint8 slot
, TGlobalAnimationTime globalTime
) const
61 NL3D_HAUTO_UI_PLAY_LIST
;
63 return _PlayList
.getLocalWeight (slot
, globalTime
);
66 // ***************************************************************************
68 void CPlayListUser::registerTransform(UTransform object
, const char* prefix
)
70 NL3D_HAUTO_UI_PLAY_LIST
;
72 CTransform
*obj
= object
.getObjectPtr();
75 // Register the transform to the channel mixer.
76 obj
->registerToChannelMixer(&_ChannelMixer
, prefix
);
78 void CPlayListUser::resetAllChannels()
80 NL3D_HAUTO_UI_PLAY_LIST
;
82 _ChannelMixer
.resetChannels();
85 // ***************************************************************************
87 void CPlayListUser::emptyPlayList ()
89 NL3D_HAUTO_UI_PLAY_LIST
;
91 _PlayList
.emptyPlayList ();
94 void CPlayListUser::setAnimation (uint8 slot
, uint animation
)
96 NL3D_HAUTO_UI_PLAY_LIST
;
98 _PlayList
.setAnimation (slot
, animation
);
101 uint
CPlayListUser::getAnimation (uint8 slot
) const
103 NL3D_HAUTO_UI_PLAY_LIST
;
105 return _PlayList
.getAnimation (slot
);
108 // ***************************************************************************
110 void CPlayListUser::setTimeOrigin (uint8 slot
, TGlobalAnimationTime timeOrigin
)
112 NL3D_HAUTO_UI_PLAY_LIST
;
114 _PlayList
.setTimeOrigin (slot
, timeOrigin
);
117 TGlobalAnimationTime
CPlayListUser::getTimeOrigin (uint8 slot
) const
119 NL3D_HAUTO_UI_PLAY_LIST
;
121 return _PlayList
.getTimeOrigin (slot
);
124 void CPlayListUser::setSpeedFactor (uint8 slot
, float speedFactor
)
126 NL3D_HAUTO_UI_PLAY_LIST
;
128 _PlayList
.setSpeedFactor (slot
, speedFactor
);
131 float CPlayListUser::getSpeedFactor (uint8 slot
) const
133 NL3D_HAUTO_UI_PLAY_LIST
;
135 return _PlayList
.getSpeedFactor (slot
);
138 void CPlayListUser::setWrapMode (uint8 slot
, TWrapMode wrapMode
)
140 NL3D_HAUTO_UI_PLAY_LIST
;
142 _PlayList
.setWrapMode (slot
, (CAnimationPlaylist::TWrapMode
)(uint
)wrapMode
);
145 UPlayList::TWrapMode
CPlayListUser::getWrapMode (uint8 slot
) const
147 NL3D_HAUTO_UI_PLAY_LIST
;
149 return (UPlayList::TWrapMode
)(uint
)_PlayList
.getWrapMode (slot
);
152 // ***************************************************************************
154 void CPlayListUser::setStartWeight (uint8 slot
, float startWeight
, TGlobalAnimationTime time
)
156 NL3D_HAUTO_UI_PLAY_LIST
;
158 _PlayList
.setStartWeight (slot
, startWeight
, time
);
161 float CPlayListUser::getStartWeight (uint8 slot
, TGlobalAnimationTime
& time
) const
163 NL3D_HAUTO_UI_PLAY_LIST
;
165 return _PlayList
.getStartWeight(slot
, time
);
168 void CPlayListUser::setEndWeight (uint8 slot
, float endWeight
, TGlobalAnimationTime time
)
170 NL3D_HAUTO_UI_PLAY_LIST
;
172 _PlayList
.setEndWeight (slot
, endWeight
, time
);
175 float CPlayListUser::getEndWeight (uint8 slot
, TGlobalAnimationTime
& time
) const
177 NL3D_HAUTO_UI_PLAY_LIST
;
179 return _PlayList
.getEndWeight (slot
, time
);
182 void CPlayListUser::setWeightSmoothness (uint8 slot
, float smoothness
)
184 NL3D_HAUTO_UI_PLAY_LIST
;
186 _PlayList
.setWeightSmoothness (slot
, smoothness
);
189 float CPlayListUser::getWeightSmoothness (uint8 slot
) const
191 NL3D_HAUTO_UI_PLAY_LIST
;
193 return _PlayList
.getWeightSmoothness (slot
);
196 void CPlayListUser::setWeight (uint8 slot
, float weight
)
198 NL3D_HAUTO_UI_PLAY_LIST
;
200 _PlayList
.setStartWeight (slot
, weight
, 0);
201 _PlayList
.setEndWeight (slot
, weight
, 0);
204 // ***************************************************************************
206 void CPlayListUser::setSkeletonWeight (uint8 slot
, uint skeletonId
, bool inverted
)
208 NL3D_HAUTO_UI_PLAY_LIST
;
210 _PlayList
.setSkeletonWeight (slot
, skeletonId
, inverted
);
213 uint
CPlayListUser::getSkeletonWeight (uint8 slot
, bool &inverted
) const
215 NL3D_HAUTO_UI_PLAY_LIST
;
217 return _PlayList
.getSkeletonWeight (slot
, inverted
);
220 // ***************************************************************************
222 void CPlayListUser::enableChannel (uint channelId
, bool enable
)
224 NL3D_HAUTO_UI_PLAY_LIST
;
226 _ChannelMixer
.enableChannel(channelId
, enable
);
229 bool CPlayListUser::isChannelEnabled (uint channelId
) const
231 NL3D_HAUTO_UI_PLAY_LIST
;
233 return _ChannelMixer
.isChannelEnabled (channelId
) ;
237 // ***************************************************************************
238 void CPlayListUser::evalPlayList(double playTime
)
240 _PlayList
.setupMixer(_ChannelMixer
, playTime
);
241 _ChannelMixer
.eval(false);