# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CChannelMixer Class Reference

A channel mixer. More...

#include <channel_mixer.h>

Inheritance diagram for NL3D::CChannelMixer:

NLMISC::CRefCount List of all members.

Public Types

enum  { NumAnimationSlot = 8 }

Public Methods

 CChannelMixer ()
 Constructor. The default constructor resets the slots and the channels. More...

void setAnimationSet (const CAnimationSet *animationSet)
 Set the animation set used by this channel mixer. More...

const CAnimationSetgetAnimationSet () const
 Get the animation set used by this channel mixer. More...

void eval (bool detail, uint64 evalDetailDate=0)
 Launch evaluation of channels. More...

sint addChannel (const std::string &channelName, IAnimatable *animatable, IAnimatedValue *value, ITrack *defaultValue, uint32 valueId, uint32 ownerValueId, bool detail)
 Add a channel for a specific value of an IAnimatable object. More...

void resetChannels ()
 Reset the channel list if the mixer. All channels are removed from the mixer. More...

void enableChannel (uint channelId, bool enable)
 disabling a channel means it is no more modified during animation. More...

bool isChannelEnabled (uint channelId) const
 see enableChannel(). More...

void lodEnableChannel (uint channelId, bool enable)
 Same as enableChannel but for Animation Lod system. More...

bool isChannelLodEnabled (uint channelId) const
 see enableChannel(). More...

void setSlotAnimation (uint slot, uint animation)
 Set slot animation. More...

const CAnimationgetSlotAnimation (uint slot) const
 Get the animation used by a given slot. More...

void setSlotTime (uint slot, TAnimationTime time)
 Set time of a slot. More...

void setSlotWeight (uint slot, float weight)
 Set slot weight. More...

void emptySlot (uint slot)
 Empty a slot. More...

void resetSlots ()
 Reset the slot of the mixer. More...

void applySkeletonWeight (uint slot, uint skeleton, bool invert=false)
 Apply a skeleton template weight on a specific slot. More...

void resetSkeletonWeight (uint slot)
 Reset the skeleton weight for a specific slot. More...

void resetEvalDetailDate ()
 reset to -1 the evalDetailDate. Hence next eval(true,..) will be forced to compute. More...


Private Methods

void cleanAll ()
 Clean the mixer. More...

void dirtAll ()
 Dirt all slots. More...

void refreshList ()
 Reshresh channel list. More...

void refreshListToEval ()
 Reshresh animate list. More...


Private Attributes

CSlot _SlotArray [NumAnimationSlot]
const CAnimationSet_AnimationSet
std::map< uint, CChannel_Channels
CChannel_FirstChannelGlobal
CChannel_FirstChannelDetail
sint64 _LastEvalDetailDate
bool _Dirt
bool _ListToEvalDirt
std::vector< CChannel * > _GlobalListToEval
std::vector< CChannel * > _DetailListToEval

Detailed Description

A channel mixer.

Animated value are registred in it. Each animated value create a channel in the mixer. Then, mixer animates all those channels with 1 to CChannelMixer::NumAnimationSlot animations.

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.

Author:
Cyril 'Hulud' Corvazier , Nevrax France
Date:
2001

Definition at line 64 of file channel_mixer.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
NumAnimationSlot  Number of animation slot in the CChannelMixer.

Definition at line 70 of file channel_mixer.h.


Constructor & Destructor Documentation

NL3D::CChannelMixer::CChannelMixer  
 

Constructor. The default constructor resets the slots and the channels.

Definition at line 43 of file channel_mixer.cpp.

References _AnimationSet, _Dirt, _FirstChannelDetail, _FirstChannelGlobal, _LastEvalDetailDate, and _ListToEvalDirt.


Member Function Documentation

sint NL3D::CChannelMixer::addChannel const std::string &    channelName,
IAnimatable   animatable,
IAnimatedValue   value,
ITrack   defaultValue,
uint32    valueId,
uint32    ownerValueId,
bool    detail
 

Add a channel for a specific value of an IAnimatable object.

Warning: this method will assign the default value in the animated value.

Parameters:
channelName  is the name of the channel.
animatable  is a pointer on the IAnimatable object in which the value is stored. It will be kept by the CChannelMixer until it is removed from the channel.
value  is a pointer on the value the channel works with. It will be kept by the CChannelMixer until it is removed from the channel.
defaultValue  is a track used by default if a track is not presents in the animation for this channel. It will be kept by the CChannelMixer until it is removed from the channel.
valueId  is the value ID in the IAnimatable object.
ownerId  is the owner Bit of the animated vlaue, in the IAnimatable object. touched when the animatedvalue is touched.
detail  true if this channel must be evaluated in detail mode (see eval()).
Returns:
-1 if the track was not found in the animationSet, else it return the channelId as if returned by CAnimationSet::getChannelIdByName(channelName).

void NL3D::CChannelMixer::applySkeletonWeight uint    slot,
uint    skeleton,
bool    invert = false
 

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.

Parameters:
slot  is the slot number to empty. Must be >= 0 and < NumAnimationSlot.
skeleton  is the index of a skeleton in the animationSet.
invert  is true if the weights to attach to the channels are the weights of the skeleton template. false if the weights to attach to the channels are the 1.f-weights of the skeleton template.

Definition at line 419 of file channel_mixer.cpp.

References _AnimationSet, _Channels, NL3D::CChannelMixer::CSlot::_InvertedSkeletonWeight, NL3D::CChannelMixer::CSlot::_SkeletonWeight, _SlotArray, nlassert, and NumAnimationSlot.

void NL3D::CChannelMixer::cleanAll   [private]
 

Clean the mixer.

Definition at line 490 of file channel_mixer.cpp.

References _Dirt, _SlotArray, NumAnimationSlot, and s.

Referenced by eval.

void NL3D::CChannelMixer::dirtAll   [private]
 

Dirt all slots.

Definition at line 505 of file channel_mixer.cpp.

References _Dirt, _SlotArray, NumAnimationSlot, and s.

Referenced by resetChannels.

void NL3D::CChannelMixer::emptySlot uint    slot
 

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.

Parameters:
slot  is the slot number to empty. Must be >= 0 and < NumAnimationSlot.

Definition at line 388 of file channel_mixer.cpp.

References _Dirt, NL3D::CChannelMixer::CSlot::_Dirt, _SlotArray, NL3D::CChannelMixer::CSlot::empty, NL3D::CChannelMixer::CSlot::isEmpty, nlassert, and NumAnimationSlot.

Referenced by resetSlots.

void NL3D::CChannelMixer::enableChannel uint    channelId,
bool    enable
 

disabling a channel means it is no more modified during animation.

Default is enabled. NB: this channel must have been added (via addChannel()....).

Parameters:
channelId  channelId get from CAnimationSet::getChannelIdByName() or addChannel()

Definition at line 292 of file channel_mixer.cpp.

References _Channels, and _ListToEvalDirt.

void NL3D::CChannelMixer::eval bool    detail,
uint64    evalDetailDate = 0
 

Launch evaluation of 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.

Parameters:
detail  true if eval the detail part of animation. (done after clipping).
evalDetailDate  chann mixer store the last date of anim detail evaluated. if same, do nothing, else if < or >, compute the anim. ingored if detail is false.

Definition at line 81 of file channel_mixer.cpp.

References _DetailListToEval, _GlobalListToEval, _LastEvalDetailDate, _ListToEvalDirt, _SlotArray, NL3D::CChannelMixer::CSlot::_Weight, NLMISC::blend, cleanAll, nlassert, NumAnimationSlot, refreshList, refreshListToEval, and s.

const CAnimationSet * NL3D::CChannelMixer::getAnimationSet   const
 

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 73 of file channel_mixer.cpp.

References _AnimationSet.

const CAnimation * NL3D::CChannelMixer::getSlotAnimation uint    slot const
 

Get the animation used by a given slot.

Definition at line 379 of file channel_mixer.cpp.

References NL3D::CChannelMixer::CSlot::_Animation, _SlotArray, nlassert, and NumAnimationSlot.

bool NL3D::CChannelMixer::isChannelEnabled uint    channelId const
 

see enableChannel().

return false if channel do not exist...

Parameters:
channelId  channelId get from CAnimationSet::getChannelIdByName() or addChannel()

Definition at line 308 of file channel_mixer.cpp.

References _Channels.

bool NL3D::CChannelMixer::isChannelLodEnabled uint    channelId const
 

see enableChannel().

return false if channel do not exist...

Parameters:
channelId  channelId get from CAnimationSet::getChannelIdByName() or addChannel()

Definition at line 337 of file channel_mixer.cpp.

References _Channels.

void NL3D::CChannelMixer::lodEnableChannel uint    channelId,
bool    enable
 

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()....).

Parameters:
channelId  channelId get from CAnimationSet::getChannelIdByName() or addChannel()

Definition at line 321 of file channel_mixer.cpp.

References _Channels, and _ListToEvalDirt.

void NL3D::CChannelMixer::refreshList   [private]
 

Reshresh channel list.

Definition at line 524 of file channel_mixer.cpp.

References _Channels, _FirstChannelDetail, _FirstChannelGlobal, _ListToEvalDirt, _SlotArray, NumAnimationSlot, and s.

Referenced by eval.

void NL3D::CChannelMixer::refreshListToEval   [private]
 

Reshresh animate list.

Definition at line 656 of file channel_mixer.cpp.

References _Channels, _DetailListToEval, _FirstChannelDetail, _FirstChannelGlobal, _GlobalListToEval, and _ListToEvalDirt.

Referenced by eval.

void NL3D::CChannelMixer::resetChannels  
 

Reset the channel list if the mixer. All channels are removed from the mixer.

Definition at line 284 of file channel_mixer.cpp.

References _Channels, and dirtAll.

Referenced by setAnimationSet.

void NL3D::CChannelMixer::resetEvalDetailDate  
 

reset to -1 the evalDetailDate. Hence next eval(true,..) will be forced to compute.

Definition at line 694 of file channel_mixer.cpp.

References _LastEvalDetailDate.

void NL3D::CChannelMixer::resetSkeletonWeight uint    slot
 

Reset the skeleton weight for a specific slot.

This method apply set each channel's slot weight to 1.f.

Parameters:
slot  is the slot number to empty. Must be >= 0 and < NumAnimationSlot.

Definition at line 466 of file channel_mixer.cpp.

References _Channels, NL3D::CChannelMixer::CSlot::_InvertedSkeletonWeight, NL3D::CChannelMixer::CSlot::_SkeletonWeight, _SlotArray, nlassert, and NumAnimationSlot.

void NL3D::CChannelMixer::resetSlots  
 

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 409 of file channel_mixer.cpp.

References emptySlot, NumAnimationSlot, and s.

void NL3D::CChannelMixer::setAnimationSet const CAnimationSet   animationSet
 

Set the animation set used by this channel mixer.

The pointer is hold by the channel mixer until it changes.

Definition at line 62 of file channel_mixer.cpp.

References _AnimationSet, and resetChannels.

void NL3D::CChannelMixer::setSlotAnimation uint    slot,
uint    animation
 

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.

Parameters:
slot  is the slot number to change the animation. Must be >= 0 and < NumAnimationSlot.
animation  is the new animation index in the animationSet use by this slot.
See also:
CAnimationSet, CAnimation

Definition at line 352 of file channel_mixer.cpp.

References NL3D::CChannelMixer::CSlot::_Animation, _AnimationSet, _Dirt, NL3D::CChannelMixer::CSlot::_Dirt, _SlotArray, nlassert, and NumAnimationSlot.

void NL3D::CChannelMixer::setSlotTime uint    slot,
TAnimationTime    time
[inline]
 

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.

Parameters:
slot  is the slot number to change the time. Must be >= 0 and < NumAnimationSlot.
time  is the new time to use in the slot.
See also:
TAnimationTime

Definition at line 331 of file channel_mixer.h.

References _SlotArray, NL3D::CChannelMixer::CSlot::_Time, nlassert, NumAnimationSlot, and NL3D::TAnimationTime.

void NL3D::CChannelMixer::setSlotWeight uint    slot,
float    weight
[inline]
 

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.

Parameters:
slot  is the slot number to change the weight.
weight  is the new weight to use in the slot. No range for this weight. If the weight == 0.f, the slot have no effect on the final mix.

Definition at line 352 of file channel_mixer.h.

References _SlotArray, NL3D::CChannelMixer::CSlot::_Weight, nlassert, and NumAnimationSlot.


Member Data Documentation

const CAnimationSet* NL3D::CChannelMixer::_AnimationSet [private]
 

Definition at line 425 of file channel_mixer.h.

Referenced by applySkeletonWeight, CChannelMixer, getAnimationSet, setAnimationSet, and setSlotAnimation.

std::map<uint, CChannel> NL3D::CChannelMixer::_Channels [private]
 

Definition at line 428 of file channel_mixer.h.

Referenced by applySkeletonWeight, enableChannel, isChannelEnabled, isChannelLodEnabled, lodEnableChannel, refreshList, refreshListToEval, resetChannels, and resetSkeletonWeight.

std::vector<CChannel*> NL3D::CChannelMixer::_DetailListToEval [private]
 

Definition at line 447 of file channel_mixer.h.

Referenced by eval, and refreshListToEval.

bool NL3D::CChannelMixer::_Dirt [private]
 

Definition at line 440 of file channel_mixer.h.

Referenced by CChannelMixer, cleanAll, dirtAll, emptySlot, and setSlotAnimation.

CChannel* NL3D::CChannelMixer::_FirstChannelDetail [private]
 

Definition at line 434 of file channel_mixer.h.

Referenced by CChannelMixer, refreshList, and refreshListToEval.

CChannel* NL3D::CChannelMixer::_FirstChannelGlobal [private]
 

Definition at line 431 of file channel_mixer.h.

Referenced by CChannelMixer, refreshList, and refreshListToEval.

std::vector<CChannel*> NL3D::CChannelMixer::_GlobalListToEval [private]
 

Definition at line 446 of file channel_mixer.h.

Referenced by eval, and refreshListToEval.

sint64 NL3D::CChannelMixer::_LastEvalDetailDate [private]
 

Definition at line 437 of file channel_mixer.h.

Referenced by CChannelMixer, eval, and resetEvalDetailDate.

bool NL3D::CChannelMixer::_ListToEvalDirt [private]
 

Definition at line 443 of file channel_mixer.h.

Referenced by CChannelMixer, enableChannel, eval, lodEnableChannel, refreshList, and refreshListToEval.

CSlot NL3D::CChannelMixer::_SlotArray[NumAnimationSlot] [private]
 

Definition at line 422 of file channel_mixer.h.

Referenced by applySkeletonWeight, cleanAll, dirtAll, emptySlot, eval, getSlotAnimation, refreshList, resetSkeletonWeight, setSlotAnimation, setSlotTime, and setSlotWeight.


The documentation for this class was generated from the following files: