#include <channel_mixer.h>
Inheritance diagram for NL3D::CChannelMixer:
Animation are referenced in an animation slot (CSlot).
Each slot have an IAnimation pointer, a weight for this animation between [0.f ~ 1.f] and a time for this animation.
Each CChannel have a weight on each animation slot between [0.f ~ 1.f].
Blending is normalized internaly so, weight sum have not to be == 1.f.
Nevrax France
Definition at line 64 of file channel_mixer.h.
Slots acces | |
void | applySkeletonWeight (uint slot, uint skeleton, bool invert=false) |
void | emptySlot (uint slot) |
const CAnimation * | getSlotAnimation (uint slot) const |
Get the animation used by a given slot. | |
void | resetEvalDetailDate () |
reset to -1 the evalDetailDate. Hence next eval(true,..) will be forced to compute | |
void | resetSkeletonWeight (uint slot) |
void | resetSlots () |
void | setSlotAnimation (uint slot, uint animation) |
void | setSlotTime (uint slot, TAnimationTime time) |
void | setSlotWeight (uint slot, float weight) |
void | cleanAll () |
Clean the mixer. | |
void | dirtAll () |
Dirt all slots. | |
void | evalSingleChannel (CChannel &chan, uint numActiveSlots, uint activeSlot[NumAnimationSlot]) |
void | refreshList () |
Reshresh channel list. | |
void | refreshListToEval () |
Reshresh animate list. | |
const CAnimationSet * | _AnimationSet |
std::map< uint, CChannel > | _Channels |
std::vector< CChannel * > | _DetailListToEval |
bool | _Dirt |
CChannel * | _FirstChannelDetail |
CChannel * | _FirstChannelGlobal |
std::vector< CChannel * > | _GlobalListToEval |
sint64 | _LastEvalDetailDate |
bool | _ListToEvalDirt |
CSlot | _SlotArray [NumAnimationSlot] |
Public Types | |
Const values | |
enum | { NumAnimationSlot = 8 } |
Public Member Functions | |
const sint & | getRefCount () const |
Channel access | |
sint | addChannel (const std::string &channelName, IAnimatable *animatable, IAnimatedValue *value, ITrack *defaultValue, uint32 valueId, uint32 ownerValueId, bool detail) |
void | enableChannel (uint channelId, bool enable) |
bool | isChannelEnabled (uint channelId) const |
bool | isChannelLodEnabled (uint channelId) const |
void | lodEnableChannel (uint channelId, bool enable) |
void | resetChannels () |
Reset the channel list if the mixer. All channels are removed from the mixer. | |
Internal classes | |
CChannelMixer () | |
Constructor. The default constructor resets the slots and the channels. | |
Setup the mixer | |
void | eval (bool detail, uint64 evalDetailDate=0) |
void | evalChannels (sint *channelIdArray, uint numID) |
void | evalSingleChannel (sint channelId) |
const CAnimationSet * | getAnimationSet () const |
void | setAnimationSet (const CAnimationSet *animationSet) |
Data Fields | |
sint | crefs |
CPtrInfo * | pinfo |
Static Public Attributes | |
CPtrInfo | NullPtrInfo |
Friends | |
struct | CPtrInfo |
|
Definition at line 70 of file channel_mixer.h.
00071 { 00073 NumAnimationSlot=8 00074 }; |
|
Constructor. The default constructor resets the slots and the channels.
Definition at line 44 of file channel_mixer.cpp. References _FirstChannelDetail, _FirstChannelGlobal, _LastEvalDetailDate, and _ListToEvalDirt.
00045 { 00046 // No channel in the list 00047 _FirstChannelGlobal=NULL; 00048 _FirstChannelDetail=NULL; 00049 00050 // No animation set 00051 _AnimationSet=NULL; 00052 00053 // Mixer no dirty 00054 _Dirt=false; 00055 _ListToEvalDirt= false; 00056 00057 // never evaluated. 00058 _LastEvalDetailDate= -1; 00059 } |
|
Add a channel for a specific value of an IAnimatable object. Warning: this method will assign the default value in the animated value.
Definition at line 306 of file channel_mixer.cpp. References NL3D::CChannelMixer::CChannel::_ChannelName, _Channels, NL3D::CChannelMixer::CChannel::_DefaultTracks, NL3D::CChannelMixer::CChannel::_Detail, NL3D::CChannelMixer::CChannel::_IsQuat, NL3D::CChannelMixer::CChannel::_Object, NL3D::CChannelMixer::CChannel::_OwnerValueId, NL3D::CChannelMixer::CChannel::_Tracks, NL3D::CChannelMixer::CChannel::_Value, NL3D::CChannelMixer::CChannel::_ValueId, NL3D::CChannelMixer::CChannel::_Weights, dirtAll(), NL3D::CAnimationSet::getChannelIdByName(), nlassert, NumAnimationSlot, s, sint, uint, uint32, and value. Referenced by NL3D::IAnimatable::addValue(), and NL3D::CScene::setAutomaticAnimationSet().
00307 { 00308 // Check the animationSet has been set 00309 nlassert (_AnimationSet); 00310 00311 // Check args 00312 nlassert (animatable); 00313 nlassert (value); 00314 nlassert (defaultValue); 00315 00316 // Get the channel Id having the same name than the tracks in this animation set. 00317 uint iDInAnimationSet=_AnimationSet->getChannelIdByName (channelName); 00318 00319 // Tracks exist in this animation set? 00320 if (iDInAnimationSet!=CAnimationSet::NotFound) 00321 { 00322 // The channel entry 00323 CChannel entry; 00324 00325 // Set the channel name 00326 entry._ChannelName=channelName; 00327 00328 // Set the object pointer 00329 entry._Object=animatable; 00330 00331 // Set the pointer on the value in the object 00332 entry._Value=value; 00333 00334 // Is this a CQuat animated value??? 00335 entry._IsQuat= (typeid (*(entry._Value))==typeid (CAnimatedValueBlendable<NLMISC::CQuat>))!=0; 00336 00337 00338 // Set the default track pointer 00339 entry._DefaultTracks=defaultValue; 00340 00341 // Set the value ID in the object 00342 entry._ValueId=valueId; 00343 00344 // Set the First value ID in the object 00345 entry._OwnerValueId=ownerValueId; 00346 00347 // in what mode is the channel? 00348 entry._Detail= detail; 00349 00350 // All weights default to 1. All Tracks default to defaultTrack. 00351 for(sint s=0;s<NumAnimationSlot;s++) 00352 { 00353 entry._Weights[s]= 1.0f; 00354 entry._Tracks[s]= entry._DefaultTracks; 00355 } 00356 00357 // add (if not already done) the entry in the map. 00358 _Channels[iDInAnimationSet]= entry; 00359 00360 // Dirt all the slots 00361 dirtAll (); 00362 00363 // Affect the default value in the animated value 00364 entry._Value->affect (entry._DefaultTracks->getValue()); 00365 00366 // Touch the animated value and its owner to recompute them later. 00367 entry._Object->touch (entry._ValueId, entry._OwnerValueId); 00368 00369 // return the id. 00370 return iDInAnimationSet; 00371 } 00372 else 00373 { 00374 // return Not found. 00375 return -1; 00376 } 00377 } |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 516 of file channel_mixer.cpp. References _Channels, NL3D::CChannelMixer::CSlot::_InvertedSkeletonWeight, NL3D::CChannelMixer::CSlot::_SkeletonWeight, _SlotArray, NL3D::CAnimationSet::getChannelIdByName(), NL3D::CSkeletonWeight::getNodeName(), NL3D::CSkeletonWeight::getNodeWeight(), NL3D::CSkeletonWeight::getNumNode(), NL3D::CAnimationSet::getSkeletonWeight(), nlassert, NumAnimationSlot, and uint. Referenced by NL3D::CAnimationPlaylist::setupMixer().
00517 { 00518 // Check alot arg 00519 nlassert (slot<NumAnimationSlot); 00520 00521 // Check the animationSet has been set 00522 nlassert (_AnimationSet); 00523 00524 // Get the skeleton weight 00525 const CSkeletonWeight *pSkeleton=_AnimationSet->getSkeletonWeight (skeleton); 00526 00527 // Something to change ? 00528 if ((pSkeleton!=_SlotArray[slot]._SkeletonWeight)||(invert!=_SlotArray[slot]._InvertedSkeletonWeight)) 00529 { 00530 // Set the current skeleton 00531 _SlotArray[slot]._SkeletonWeight=pSkeleton; 00532 _SlotArray[slot]._InvertedSkeletonWeight=invert; 00533 00534 // Get number of node in the skeleton weight 00535 uint sizeSkel=pSkeleton->getNumNode (); 00536 00537 // For each entry of the skeleton weight 00538 for (uint n=0; n<sizeSkel; n++) 00539 { 00540 // Get the name of the channel for this node 00541 const string& channelName=pSkeleton->getNodeName (n); 00542 00543 // Get the channel Id having the same name than the tracks in this animation set. 00544 uint channelId=_AnimationSet->getChannelIdByName (channelName); 00545 00546 // Tracks exist in this animation set? 00547 if (channelId!=CAnimationSet::NotFound) 00548 { 00549 // Get the weight of the channel for this node 00550 float weight=pSkeleton->getNodeWeight (n); 00551 00552 // Set the weight of this channel for this slot (only if channel setuped!!) 00553 std::map<uint, CChannel>::iterator ite=_Channels.find(channelId); 00554 if (ite!=_Channels.end()) 00555 ite->second._Weights[slot]=invert?1.f-weight:weight; 00556 } 00557 } 00558 } 00559 } |
|
Clean the mixer.
Definition at line 587 of file channel_mixer.cpp. References NL3D::CChannelMixer::CSlot::_Dirt, _SlotArray, NumAnimationSlot, s, and uint. Referenced by eval(), and evalChannels().
00588 { 00589 // For each slot 00590 for (uint s=0; s<NumAnimationSlot; s++) 00591 { 00592 // Clean it 00593 _SlotArray[s]._Dirt=false; 00594 } 00595 00596 // Clean the mixer 00597 _Dirt=false; 00598 } |
|
Dirt all slots.
Definition at line 602 of file channel_mixer.cpp. References NL3D::CChannelMixer::CSlot::_Dirt, _SlotArray, NL3D::CChannelMixer::CSlot::isEmpty(), NumAnimationSlot, s, and uint. Referenced by addChannel(), and resetChannels().
00603 { 00604 // For each slot 00605 for (uint s=0; s<NumAnimationSlot; s++) 00606 { 00607 // Dirt 00608 if (!_SlotArray[s].isEmpty()) 00609 { 00610 // Dirt it 00611 _SlotArray[s]._Dirt=true; 00612 00613 // Dirt the mixer 00614 _Dirt=true; 00615 } 00616 } 00617 } |
|
Empty a slot. Calling this method will dirt the mixer, ie, all the mixer's channels will be visited to check if they are used by the old animation. If they are, they will be linked in the internal CChannel list. Warning: this method will assign the default value in the animated value that are removed from the active channel queue.
Definition at line 485 of file channel_mixer.cpp. References NL3D::CChannelMixer::CSlot::_Dirt, _SlotArray, NL3D::CChannelMixer::CSlot::empty(), NL3D::CChannelMixer::CSlot::isEmpty(), nlassert, NumAnimationSlot, and uint. Referenced by resetSlots(), and NL3D::CAnimationPlaylist::setupMixer().
00486 { 00487 // Check alot arg 00488 nlassert (slot<NumAnimationSlot); 00489 00490 // Does this animation already empty ? 00491 if (!_SlotArray[slot].isEmpty ()) 00492 { 00493 // Change it 00494 _SlotArray[slot].empty (); 00495 00496 // Dirt it 00497 _SlotArray[slot]._Dirt=true; 00498 00499 // Dirt the mixer 00500 _Dirt=true; 00501 } 00502 } |
|
disabling a channel means it is no more modified during animation. Default is enabled. NB: this channel must have been added (via addChannel()....).
Definition at line 389 of file channel_mixer.cpp. References _Channels, _ListToEvalDirt, and uint. Referenced by NL3D::CPlayListUser::enableChannel().
00390 { 00391 std::map<uint, CChannel>::iterator it= _Channels.find(channelId); 00392 if(it!=_Channels.end()) 00393 { 00394 it->second._EnableFlags &= ~CChannel::EnableUserFlag; 00395 if(enable) 00396 it->second._EnableFlags |= CChannel::EnableUserFlag; 00397 00398 // Must recompute the channels to animate. 00399 _ListToEvalDirt= true; 00400 } 00401 } |
|
Launch evaluation of all channels. This is the main method. It evals animations selected in the slots for listed channels. Only the channels that are animated by animations selected in the slots are evaluated. They are stored in a linked list managed by the channel array. Others are initialized with the default channel value.
Definition at line 154 of file channel_mixer.cpp. References _DetailListToEval, _GlobalListToEval, _LastEvalDetailDate, _ListToEvalDirt, NL3D::CChannelMixer::CChannel::_Object, NL3D::CChannelMixer::CChannel::_OwnerValueId, _SlotArray, NL3D::CChannelMixer::CSlot::_Time, NL3D::CChannelMixer::CChannel::_Tracks, NL3D::CChannelMixer::CChannel::_Value, NL3D::CChannelMixer::CChannel::_ValueId, NL3D::CChannelMixer::CSlot::_Weight, NL3D::CChannelMixer::CChannel::_Weights, NL3D::IAnimatedValue::affect(), cleanAll(), evalSingleChannel(), NL3D::ITrack::getValue(), NL3D::CChannelMixer::CSlot::isEmpty(), nlassert, NumAnimationSlot, refreshList(), refreshListToEval(), s, sint64, NL3D::TAnimationTime, NL3D::IAnimatable::touch(), uint, and uint64. Referenced by NL3D::CLodCharacterBuilder::addAnim(), NL3D::CSkeletonModel::computeCurrentBBox(), NL3D::CPlayListUser::evalPlayList(), NL3D::CTransform::traverseAnimDetailWithoutUpdateWorldMatrix(), and NL3D::CMeshBaseInstance::traverseHrc().
00155 { 00156 // eval the detail animation only one time per scene traversal. 00157 if(detail) 00158 { 00159 if((sint64)evalDetailDate== _LastEvalDetailDate) 00160 return; 00161 _LastEvalDetailDate= evalDetailDate; 00162 } 00163 00164 // clean list according to anim setup 00165 if(_Dirt) 00166 { 00167 refreshList(); 00168 cleanAll(); 00169 } 00170 00171 // clean eval list, according to channels enabled. 00172 if(_ListToEvalDirt) 00173 { 00174 refreshListToEval(); 00175 nlassert(!_ListToEvalDirt); 00176 } 00177 00178 // If the number of channels to draw is 0, quick quit. 00179 CChannel **channelArrayPtr; 00180 uint numChans; 00181 if(detail) 00182 { 00183 numChans= _DetailListToEval.size(); 00184 if(numChans) 00185 channelArrayPtr= &_DetailListToEval[0]; 00186 else 00187 return; 00188 } 00189 else 00190 { 00191 numChans= _GlobalListToEval.size(); 00192 if(numChans) 00193 channelArrayPtr= &_GlobalListToEval[0]; 00194 else 00195 return; 00196 } 00197 00198 // Setup an array of animation that are not empty and stay. HTimer: 0.0% (because CLod skeletons not parsed here) 00199 uint numActive=0; 00200 uint activeSlot[NumAnimationSlot]; 00201 for (uint s=0; s<NumAnimationSlot; s++) 00202 { 00203 // Dirt, not empty and has an influence? (add) 00204 if (!_SlotArray[s].isEmpty() && _SlotArray[s]._Weight>0) 00205 // Add a dirt slot 00206 activeSlot[numActive++]=s; 00207 } 00208 00209 // no slot enabled at all?? skip 00210 if(numActive==0) 00211 return; 00212 00213 // For each selected channel 00214 // fast 'just one slot Activated' version 00215 if(numActive==1) 00216 { 00217 // Slot number 00218 uint slot=activeSlot[0]; 00219 // Slot time 00220 TAnimationTime slotTime= _SlotArray[slot]._Time; 00221 00222 // For all channels 00223 for(;numChans>0; numChans--, channelArrayPtr++) 00224 { 00225 CChannel &chan= **channelArrayPtr; 00226 00227 // if Current blend factor is not 0 00228 if(chan._Weights[slot]!=0.0f) 00229 { 00230 // Eval the track at this time. HTimer: 0.7% 00231 ((ITrack*)chan._Tracks[slot])->eval (slotTime); 00232 00233 // Copy the interpolated value. HTimer: 0.7% 00234 chan._Value->affect (chan._Tracks[slot]->getValue()); 00235 00236 // Touch the animated value and its owner to recompute them later. HTimer: 0.6% 00237 chan._Object->touch (chan._ValueId, chan._OwnerValueId); 00238 } 00239 } 00240 } 00241 // little bit slower Blend version 00242 else 00243 { 00244 // For all channels 00245 for(;numChans>0; numChans--, channelArrayPtr++) 00246 { 00247 CChannel *pChannel= *channelArrayPtr; 00248 evalSingleChannel(**channelArrayPtr, numActive, activeSlot); 00249 } 00250 } 00251 } |
|
Launch evaluation of some channels.
Definition at line 255 of file channel_mixer.cpp. References _Channels, _ListToEvalDirt, _SlotArray, NL3D::CChannelMixer::CSlot::_Weight, cleanAll(), evalSingleChannel(), NL3D::CChannelMixer::CSlot::isEmpty(), nlassert, NumAnimationSlot, refreshList(), refreshListToEval(), s, sint, and uint. Referenced by evalSingleChannel(), and NL3D::CBone::forceAnimate().
00256 { 00257 if (!channelIdArray) return; 00258 if (numID == 0) return; 00259 00260 // Setup an array of animation that are not empty and stay 00261 uint numActive=0; 00262 uint activeSlot[NumAnimationSlot]; 00263 00264 // clean list according to anim setup 00265 if(_Dirt) 00266 { 00267 refreshList(); 00268 cleanAll(); 00269 } 00270 00271 // clean eval list, according to channels enabled. 00272 if(_ListToEvalDirt) 00273 { 00274 refreshListToEval(); 00275 nlassert(!_ListToEvalDirt); 00276 } 00277 00278 // Setup it up 00279 for (uint s=0; s<NumAnimationSlot; s++) 00280 { 00281 // Dirt, not empty and has an influence? (add) 00282 if (!_SlotArray[s].isEmpty() && _SlotArray[s]._Weight>0) 00283 // Add a dirt slot 00284 activeSlot[numActive++]=s; 00285 } 00286 00287 // no slot enabled at all?? skip 00288 if(numActive==0) 00289 return; 00290 00291 for(uint k = 0; k < numID; ++k) 00292 { 00293 std::map<uint, CChannel>::iterator it = _Channels.find(channelIdArray[k]); 00294 if (it != _Channels.end()) 00295 { 00296 evalSingleChannel(it->second, numActive, activeSlot); 00297 } 00298 } 00299 } |
|
Force evaluation of a single channel
Definition at line 83 of file channel_mixer.cpp. References NL3D::CChannelMixer::CChannel::_IsQuat, NL3D::CChannelMixer::CChannel::_Object, NL3D::CChannelMixer::CChannel::_OwnerValueId, _SlotArray, NL3D::CChannelMixer::CChannel::_Tracks, NL3D::CChannelMixer::CChannel::_Value, NL3D::CChannelMixer::CChannel::_ValueId, NL3D::CChannelMixer::CSlot::_Weight, NL3D::CChannelMixer::CChannel::_Weights, NL3D::IAnimatedValue::affect(), NL3D::IAnimatedValue::blend(), NL3D::ITrack::getValue(), NL3D::IAnimatable::touch(), uint, and NL3D::CAnimatedValueBlendable< T >::Value.
00084 { 00085 // For Quat animated value only. 00086 CQuat firstQuat; 00087 00088 // First slot found 00089 bool bFirst=true; 00090 00091 // Last blend factor 00092 float lastBlend=0.0; 00093 00094 // Eval each slot 00095 for (uint a=0; a<numActive; a++) 00096 { 00097 // Slot number 00098 uint slot=activeSlot[a]; 00099 00100 // Current blend factor 00101 float blend=chan._Weights[slot]*_SlotArray[slot]._Weight; 00102 00103 if(blend!=0.0f) 00104 { 00105 // Eval the track at this time 00106 ((ITrack*)chan._Tracks[slot])->eval (_SlotArray[slot]._Time); 00107 00108 // First track to be eval ? 00109 if (bFirst) 00110 { 00111 // If channel is a Quaternion animated Value, must store the first Quat. 00112 if (chan._IsQuat) 00113 { 00114 CAnimatedValueBlendable<NLMISC::CQuat> *pQuatValue=(CAnimatedValueBlendable<NLMISC::CQuat>*)&chan._Tracks[slot]->getValue(); 00115 firstQuat=pQuatValue->Value; 00116 } 00117 00118 // Copy the interpolated value 00119 chan._Value->affect (chan._Tracks[slot]->getValue()); 00120 00121 // First blend factor 00122 lastBlend=blend; 00123 00124 // Not first anymore 00125 bFirst=false; 00126 } 00127 else 00128 { 00129 // If channel is a Quaternion animated Value, must makeClosest the ith result of the track, from firstQuat. 00130 if (chan._IsQuat) 00131 { 00132 CAnimatedValueBlendable<NLMISC::CQuat> *pQuatValue=(CAnimatedValueBlendable<NLMISC::CQuat>*)&chan._Tracks[slot]->getValue(); 00133 pQuatValue->Value.makeClosest (firstQuat); 00134 } 00135 00136 // Blend with this value and the previous sum 00137 chan._Value->blend (chan._Tracks[slot]->getValue(), lastBlend/(lastBlend+blend)); 00138 00139 // last blend update 00140 lastBlend+=blend; 00141 } 00142 } 00143 00144 // NB: if all weights are 0, the AnimatedValue is not modified... 00145 } 00146 00147 // Touch the animated value and its owner to recompute them later. 00148 chan._Object->touch (chan._ValueId, chan._OwnerValueId); 00149 } |
|
Force evaluation of a single channel Definition at line 481 of file channel_mixer.h. References evalChannels(), and sint. Referenced by eval(), and evalChannels().
00482 { 00483 evalChannels(&channelId, 1); 00484 } |
|
Get the animation set used by this channel mixer. The pointer is hold by the channel mixer until it changes. Return NULL if no animationSet defined. Definition at line 74 of file channel_mixer.cpp. Referenced by NL3D::CAnimationPlaylist::setupMixer().
00075 { 00076 // Return the animationSet Pointer 00077 return _AnimationSet; 00078 } |
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 { 00072 return crefs; 00073 } |
|
Get the animation used by a given slot.
Definition at line 476 of file channel_mixer.cpp. References NL3D::CChannelMixer::CSlot::_Animation, _SlotArray, nlassert, NumAnimationSlot, and uint. Referenced by NL3D::CMeshBaseInstance::traverseHrc().
00477 { 00478 nlassert(slot < NumAnimationSlot); 00479 return _SlotArray[slot]._Animation; 00480 } |
|
see enableChannel(). return false if channel do not exist...
Definition at line 405 of file channel_mixer.cpp. References _Channels, and uint. Referenced by NL3D::CPlayListUser::isChannelEnabled().
|
|
see enableChannel(). return false if channel do not exist...
Definition at line 434 of file channel_mixer.cpp. References _Channels, and uint.
|
|
Same as enableChannel but for Animation Lod system. The channel is animated only if both enableChannel() and lodEnableChannel() are true. Default is enabled. NB: this channel must have been added (via addChannel()....).
Definition at line 418 of file channel_mixer.cpp. References _Channels, _ListToEvalDirt, and uint. Referenced by NL3D::CBone::lodEnableChannels().
00419 { 00420 std::map<uint, CChannel>::iterator it= _Channels.find(channelId); 00421 if(it!=_Channels.end()) 00422 { 00423 it->second._EnableFlags &= ~CChannel::EnableLodFlag; 00424 if(enable) 00425 it->second._EnableFlags |= CChannel::EnableLodFlag; 00426 00427 // Must recompute the channels to animate. 00428 _ListToEvalDirt= true; 00429 } 00430 } |
|
Reshresh channel list.
Definition at line 621 of file channel_mixer.cpp. References NL3D::CChannelMixer::CSlot::_Animation, NL3D::CChannelMixer::CChannel::_ChannelName, _Channels, NL3D::CChannelMixer::CChannel::_DefaultTracks, NL3D::CChannelMixer::CChannel::_Detail, NL3D::CChannelMixer::CSlot::_Dirt, _FirstChannelDetail, _FirstChannelGlobal, NL3D::CChannelMixer::CChannel::_InTheList, _ListToEvalDirt, NL3D::CChannelMixer::CChannel::_Next, NL3D::CChannelMixer::CChannel::_Object, NL3D::CChannelMixer::CChannel::_OwnerValueId, _SlotArray, NL3D::CChannelMixer::CChannel::_Tracks, NL3D::CChannelMixer::CChannel::_Value, NL3D::CChannelMixer::CChannel::_ValueId, NL3D::IAnimatedValue::affect(), NL3D::CAnimation::getIdTrackByName(), NL3D::ITrack::getValue(), NL3D::CChannelMixer::CSlot::isEmpty(), NumAnimationSlot, s, NL3D::IAnimatable::touch(), and uint. Referenced by eval(), and evalChannels().
00622 { 00623 // Setup an array of animation to add 00624 uint numAdd=0; 00625 uint addSlot[NumAnimationSlot]; 00626 00627 // Setup an array of animation that are not empty and stay 00628 uint numStay=0; 00629 uint staySlot[NumAnimationSlot]; 00630 00631 // Setup it up 00632 uint s; 00633 for (s=0; s<NumAnimationSlot; s++) 00634 { 00635 // Dirt and not empty ? (add) 00636 if ((_SlotArray[s]._Dirt)&&(!_SlotArray[s].isEmpty())) 00637 // Add a dirt slot 00638 addSlot[numAdd++]=s; 00639 00640 // Not empty and not dirt ? (stay) 00641 if ((!_SlotArray[s]._Dirt)&&(!_SlotArray[s].isEmpty())) 00642 // Add a dirt slot 00643 staySlot[numStay++]=s; 00644 } 00645 00646 // Last channel pointer 00647 CChannel **lastPointerGlobal=&_FirstChannelGlobal; 00648 CChannel **lastPointerDetail=&_FirstChannelDetail; 00649 00650 00651 // Now scan each channel 00652 map<uint, CChannel>::iterator itChannel; 00653 for(itChannel= _Channels.begin(); itChannel!=_Channels.end();itChannel++) 00654 { 00655 CChannel &channel= (*itChannel).second; 00656 00657 // Add this channel to the list if true 00658 bool add=false; 00659 00660 // For each slot to add 00661 for (s=0; s<numAdd; s++) 00662 { 00663 // Find the index of the channel track in the animation set 00664 uint iDTrack=_SlotArray[addSlot[s]]._Animation->getIdTrackByName (channel._ChannelName); 00665 00666 // If this track exist 00667 if (iDTrack!=CAnimation::NotFound) 00668 { 00669 // Set the track 00670 channel._Tracks[addSlot[s]]=_SlotArray[addSlot[s]]._Animation->getTrack (iDTrack); 00671 00672 // Add this channel to the list 00673 add=true; 00674 } 00675 else 00676 { 00677 // Set the default track 00678 channel._Tracks[addSlot[s]]=channel._DefaultTracks; 00679 } 00680 } 00681 00682 // Add this channel to the list ? 00683 if (!add) 00684 { 00685 // Was it in the list ? 00686 if (channel._InTheList) 00687 { 00688 // Check if this channel is still in use 00689 00690 // For each slot in the stay list 00691 for (s=0; s<numStay; s++) 00692 { 00693 // Use anything interesting ? 00694 if (channel._Tracks[staySlot[s]]!=channel._DefaultTracks) 00695 { 00696 // Ok, add it to the list 00697 add=true; 00698 00699 // Stop 00700 break; 00701 } 00702 } 00703 00704 // Still in use? 00705 if (!add) 00706 { 00707 // Set it's value to default and touch it's object 00708 channel._Value->affect (channel._DefaultTracks->getValue()); 00709 channel._Object->touch (channel._ValueId, channel._OwnerValueId); 00710 } 00711 } 00712 } 00713 00714 // Do i have to add the channel to the list 00715 if (add) 00716 { 00717 // It is in the list 00718 channel._InTheList=true; 00719 00720 if(channel._Detail) 00721 { 00722 // Set the last pointer value 00723 *lastPointerDetail=&channel; 00724 // Change last pointer 00725 lastPointerDetail=&channel._Next; 00726 } 00727 else 00728 { 00729 // Set the last pointer value 00730 *lastPointerGlobal=&channel; 00731 // Change last pointer 00732 lastPointerGlobal=&channel._Next; 00733 } 00734 00735 } 00736 else 00737 { 00738 // It is not in the list 00739 channel._InTheList=false; 00740 } 00741 } 00742 00743 // End of the list 00744 *lastPointerGlobal=NULL; 00745 *lastPointerDetail=NULL; 00746 00747 // Must recompute the channels to animate. 00748 _ListToEvalDirt= true; 00749 } |
|
Reshresh animate list.
Definition at line 753 of file channel_mixer.cpp. References _Channels, _DetailListToEval, NL3D::CChannelMixer::CChannel::_EnableFlags, _FirstChannelDetail, _FirstChannelGlobal, _GlobalListToEval, _ListToEvalDirt, and NL3D::CChannelMixer::CChannel::_Next. Referenced by eval(), and evalChannels().
00754 { 00755 CChannel* pChannel; 00756 00757 /* NB: this save if(), especially when Used with Skeleton, and CLod mode 00758 */ 00759 00760 // Global list. 00761 _GlobalListToEval.clear(); 00762 _GlobalListToEval.reserve(_Channels.size()); 00763 pChannel=_FirstChannelGlobal; 00764 while(pChannel) 00765 { 00766 // if the channel is enabled (both user and lod), must eval all active slot. 00767 if(pChannel->_EnableFlags == CChannel::EnableAllFlag) 00768 _GlobalListToEval.push_back(pChannel); 00769 // next 00770 pChannel= pChannel->_Next; 00771 } 00772 00773 // Global list. 00774 _DetailListToEval.clear(); 00775 _DetailListToEval.reserve(_Channels.size()); 00776 pChannel=_FirstChannelDetail; 00777 while(pChannel) 00778 { 00779 // if the channel is enabled (both user and lod), must eval all active slot. 00780 if(pChannel->_EnableFlags == CChannel::EnableAllFlag) 00781 _DetailListToEval.push_back(pChannel); 00782 // next 00783 pChannel= pChannel->_Next; 00784 } 00785 00786 // done 00787 _ListToEvalDirt= false; 00788 } |
|
Reset the channel list if the mixer. All channels are removed from the mixer.
Definition at line 381 of file channel_mixer.cpp. References _Channels, and dirtAll(). Referenced by NL3D::CPlayListUser::resetAllChannels(), and setAnimationSet().
|
|
reset to -1 the evalDetailDate. Hence next eval(true,..) will be forced to compute
Definition at line 791 of file channel_mixer.cpp. References _LastEvalDetailDate. Referenced by NL3D::CSkeletonModel::computeCurrentBBox().
00792 { 00793 _LastEvalDetailDate= -1; 00794 } |
|
Reset the skeleton weight for a specific slot. This method apply set each channel's slot weight to 1.f.
Definition at line 563 of file channel_mixer.cpp. References _Channels, NL3D::CChannelMixer::CSlot::_InvertedSkeletonWeight, NL3D::CChannelMixer::CSlot::_SkeletonWeight, _SlotArray, nlassert, NumAnimationSlot, and uint. Referenced by NL3D::CAnimationPlaylist::setupMixer().
00564 { 00565 // Check alot arg 00566 nlassert (slot<NumAnimationSlot); 00567 00568 // Something to change ? 00569 if (_SlotArray[slot]._SkeletonWeight!=NULL) 00570 { 00571 // Set skeleton 00572 _SlotArray[slot]._SkeletonWeight=NULL; 00573 _SlotArray[slot]._InvertedSkeletonWeight=false; 00574 00575 // For each channels 00576 map<uint, CChannel>::iterator itChannel; 00577 for(itChannel= _Channels.begin(); itChannel!=_Channels.end();itChannel++) 00578 { 00579 // Reset 00580 (*itChannel).second._Weights[slot]=1.f; 00581 } 00582 } 00583 } |
|
Reset the slot of the mixer. All slot will be empty. Calling this method will dirt the mixer, ie, all the mixer's channels will be visited to check if they are used by the old animation. If they are, they will be linked in the internal CChannel list. Definition at line 506 of file channel_mixer.cpp. References emptySlot(), NumAnimationSlot, s, and uint.
|
|
Set the animation set used by this channel mixer. The pointer is hold by the channel mixer until it changes. Definition at line 63 of file channel_mixer.cpp. References resetChannels(). Referenced by NL3D::CLodCharacterBuilder::addAnim(), NL3D::CPlayListUser::CPlayListUser(), NL3D::CScene::createInstance(), and NL3D::CScene::setAutomaticAnimationSet().
00064 { 00065 // Set the animationSet Pointer 00066 _AnimationSet=animationSet; 00067 00068 // clear the channels. 00069 resetChannels(); 00070 } |
|
Set slot animation. You must set an animationSet in the channel mixer before calling this. Calling this method will dirt the mixer, ie, all the mixer's channels will be visited to check if they are used by the new animation. If they are, they will be linked in the internal CChannel list.
Definition at line 449 of file channel_mixer.cpp. References NL3D::CChannelMixer::CSlot::_Animation, NL3D::CChannelMixer::CSlot::_Dirt, _SlotArray, NL3D::CAnimationSet::getAnimation(), nlassert, NumAnimationSlot, and uint. Referenced by NL3D::CLodCharacterBuilder::addAnim(), NL3D::CScene::createInstance(), and NL3D::CAnimationPlaylist::setupMixer().
00450 { 00451 // Check alot arg 00452 nlassert (slot<NumAnimationSlot); 00453 00454 // Check an animationSet as been set. 00455 nlassert (_AnimationSet); 00456 00457 // Find the animation pointer for this animation 00458 const CAnimation* pAnimation=_AnimationSet->getAnimation (animation); 00459 00460 // Does this animation change ? 00461 if (_SlotArray[slot]._Animation!=pAnimation) 00462 { 00463 // Change it 00464 _SlotArray[slot]._Animation=pAnimation; 00465 00466 // Dirt it 00467 _SlotArray[slot]._Dirt=true; 00468 00469 // Dirt the mixer 00470 _Dirt=true; 00471 } 00472 } |
|
Set time of a slot. This time will be used to eval the animation set in this slot. Each slot can have different time. Calling this method won't dirt the mixer.
Definition at line 345 of file channel_mixer.h. References _SlotArray, NL3D::CChannelMixer::CSlot::_Time, nlassert, NumAnimationSlot, NL3D::TAnimationTime, and uint. Referenced by NL3D::CLodCharacterBuilder::addAnim(), NL3D::CAnimationPlaylist::setupMixer(), and NL3D::CMeshBaseInstance::traverseHrc().
00346 { 00347 // Check alot arg 00348 nlassert (slot<NumAnimationSlot); 00349 00350 // Set the time 00351 _SlotArray[slot]._Time=time; 00352 } |
|
Set slot weight. This weight will be used to eval the animation set in this slot. Each slot can have different weight. Calling this method won't dirt the mixer. By default the weight of the slot is 1.0f.
Definition at line 366 of file channel_mixer.h. References _SlotArray, NL3D::CChannelMixer::CSlot::_Weight, nlassert, NumAnimationSlot, and uint. Referenced by NL3D::CAnimationPlaylist::setupMixer().
00367 { 00368 // Check alot arg 00369 nlassert (slot<NumAnimationSlot); 00370 00371 // Set the time 00372 _SlotArray[slot]._Weight=weight; 00373 } |
|
Definition at line 67 of file smart_ptr.h. |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 439 of file channel_mixer.h. |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 442 of file channel_mixer.h. Referenced by addChannel(), applySkeletonWeight(), enableChannel(), evalChannels(), isChannelEnabled(), isChannelLodEnabled(), lodEnableChannel(), refreshList(), refreshListToEval(), resetChannels(), and resetSkeletonWeight(). |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 461 of file channel_mixer.h. Referenced by eval(), and refreshListToEval(). |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 454 of file channel_mixer.h. |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 448 of file channel_mixer.h. Referenced by CChannelMixer(), refreshList(), and refreshListToEval(). |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 445 of file channel_mixer.h. Referenced by CChannelMixer(), refreshList(), and refreshListToEval(). |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 460 of file channel_mixer.h. Referenced by eval(), and refreshListToEval(). |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 451 of file channel_mixer.h. Referenced by CChannelMixer(), eval(), and resetEvalDetailDate(). |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 457 of file channel_mixer.h. Referenced by CChannelMixer(), enableChannel(), eval(), evalChannels(), lodEnableChannel(), refreshList(), and refreshListToEval(). |
|
Apply a skeleton template weight on a specific slot. This method apply the weight of each node contains in skelWeight to the channel's slot weight.
Definition at line 436 of file channel_mixer.h. Referenced by applySkeletonWeight(), cleanAll(), dirtAll(), emptySlot(), eval(), evalChannels(), evalSingleChannel(), getSlotAnimation(), refreshList(), resetSkeletonWeight(), setSlotAnimation(), setSlotTime(), and setSlotWeight(). |
|
Definition at line 79 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
Referenced by NLMISC::CRefCount::CRefCount(). |
|
Definition at line 80 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount(). |