NL3D::IAnimatable Class Reference

#include <animatable.h>

Inheritance diagram for NL3D::IAnimatable:

NL3D::CAnimatedLightmap NL3D::CAnimatedMaterial NL3D::CAnimatedMorph NL3D::ITransformable NL3D::CBone NL3D::CTransform NL3D::CCamera NL3D::CCluster NL3D::CLandscapeModel NL3D::CPointLightModel NL3D::CQuadGridClipManager NL3D::CRootModel NL3D::CTransformShape NL3D::CVegetableBlendLayerModel

Detailed Description

An animatable object.

This object can have a set of animated values. At Max 32 animated values can be set (because of bit and touch mgt) Animated values are animated by a CChannelMixer object. Each value have a name and a default track.

An IAnimatable may have IAnimatable sons (list of bones, list of materails etc...). The value count and valueId of the IAnimatable DO NOT count those sons, but register() should register his sons too. A father propagated touch system (setFather()) is implemented. When a son is touched, he touchs his fathers, his grandfather and so on.

When a class derives from IAnimatable, it must implement all the interface's methods:

extend TAnimValues enum, beginning to BaseClass::AnimValueLast, and add a bit OwnerBit. ctor(): just type "IAnimatable::resize (AnimValueLast);" virtual IAnimatedValue* getValue (uint valueId); virtual const char *getValueName (uint valueId) const; virtual ITrack* getDefaultTrack (uint valueId);

virtual register(CChannelMixer *, const string &prefix);

Watch NL3D::ITransformable and NL3D::CTransform for a good example.

Author:
Cyril 'Hulud' Corvazier

Nevrax France

Date:
2001

Definition at line 73 of file animatable.h.

Interface

enum  TAnimValues { AnimValueLast = 0 }
virtual ITrackgetDefaultTrack (uint valueId)=0
virtual IAnimatedValuegetValue (uint valueId)=0
virtual const char * getValueName (uint valueId) const=0
virtual void registerToChannelMixer (CChannelMixer *chanMixer, const std::string &prefix=std::string())=0

Public Types


Public Member Functions

 IAnimatable ()
virtual ~IAnimatable ()

Protected Member Functions

sint addValue (CChannelMixer *chanMixer, uint valueId, uint ownerValueId, const std::string &prefix, bool detail)
void clearFlag (uint valueId)
 This method clear a bit in the bitset.

void setFlag (uint valueId)
 This method set a bit in the bitset.


Private Member Functions

void propagateTouch ()

Private Attributes

uint32 _BitSet
IAnimatable_Father
uint _FatherOwnerBit

Friends

class IAnimatedValue


Member Enumeration Documentation

enum NL3D::IAnimatable::TAnimValues
 

The enum of animated values. (same system in CMOT). Deriver should extend this enum, beginning with OwnerBit= BaseClass::AnimValueLast. The number of values MUST NOT EXCEED 32, for fast touch() system. "OwnerBit" system: each deriver of IAnimatable should had an entry "OwnerBit" in this TAnimValues. This bit will be set when an IAnimatedValue of this deriver part is touched, or if one of his IAnimatable sons is touched (see setFather()).

Enumeration values:
AnimValueLast 

Reimplemented in NL3D::CAnimatedLightmap, NL3D::CAnimatedMaterial, NL3D::CAnimatedMorph, NL3D::CCamera, NL3D::CMeshBaseInstance, NL3D::CParticleSystemModel, NL3D::CSegRemanence, NL3D::CSkeletonModel, and NL3D::ITransformable.

Definition at line 98 of file animatable.h.

00099         {
00100                 AnimValueLast=0,
00101         };


Constructor & Destructor Documentation

NL3D::IAnimatable::IAnimatable  )  [inline]
 

Default Constructor. Set number of value to 0. Deriver: should just write: IAnimatable::resize (getValueCount());

Definition at line 83 of file animatable.h.

References _BitSet, and _Father.

00084         {
00085                 _Father= NULL;
00086                 _BitSet= 0;
00087         }

virtual NL3D::IAnimatable::~IAnimatable  )  [inline, virtual]
 

Definition at line 89 of file animatable.h.

00089 {}


Member Function Documentation

sint NL3D::IAnimatable::addValue CChannelMixer chanMixer,
uint  valueId,
uint  ownerValueId,
const std::string &  prefix,
bool  detail
[protected]
 

This is a tool function which add a given value to a channel.

Returns:
-1 if the track was not found in the animationSet, else it return the channelId as if returned by CAnimationSet::getChannelIdByName(channelName).

Definition at line 37 of file animatable.cpp.

References NL3D::CChannelMixer::addChannel(), getDefaultTrack(), getValue(), getValueName(), nlassert, sint, and uint.

Referenced by NL3D::CTransform::registerToChannelMixer(), NL3D::CParticleSystemModel::registerToChannelMixer(), NL3D::CCamera::registerToChannelMixer(), NL3D::CBone::registerToChannelMixer(), NL3D::CAnimatedMorph::registerToChannelMixer(), NL3D::CAnimatedMaterial::registerToChannelMixer(), and NL3D::CAnimatedLightmap::registerToChannelMixer().

00038 {
00039         nlassert(chanMixer);
00040         return chanMixer->addChannel(prefix+getValueName(valueId), this, getValue(valueId), getDefaultTrack(valueId), valueId, ownerValueId, detail);
00041 }

void NL3D::IAnimatable::clearFlag uint  valueId  )  [inline, protected]
 

This method clear a bit in the bitset.

Definition at line 233 of file animatable.h.

References _BitSet, and uint.

Referenced by NL3D::ITransformable::clearTransformFlags(), NL3D::CParticleSystemModel::doAnimate(), and NL3D::CAnimatedMaterial::update().

00234         {
00235                 _BitSet&= ~(1<<valueId);
00236         }

virtual ITrack* NL3D::IAnimatable::getDefaultTrack uint  valueId  )  [pure virtual]
 

Get default track pointer.

Parameters:
valueId is the animated value ID in the object we want the default track. IGNORING IANIMATABLE SONS (eg: bones, materials...).
Returns:
The pointer on the default track of the value.

Implemented in NL3D::CAnimatedLightmap, NL3D::CAnimatedMaterial, NL3D::CAnimatedMorph, NL3D::CBone, NL3D::CCamera, NL3D::CMeshBaseInstance, NL3D::CParticleSystemModel, NL3D::CSegRemanence, NL3D::CTransform, NL3D::ITransformable, NL3D::CWaterModel, and NL3D::CWaveMakerModel.

Referenced by addValue().

virtual IAnimatedValue* NL3D::IAnimatable::getValue uint  valueId  )  [pure virtual]
 

Get a value pointer.

Parameters:
valueId is the animated value ID in the object. IGNORING IANIMATABLE SONS (eg: bones, materials...).
Returns:
The pointer on the animated value.

Implemented in NL3D::CAnimatedLightmap, NL3D::CAnimatedMaterial, NL3D::CAnimatedMorph, NL3D::CCamera, NL3D::CParticleSystemModel, and NL3D::ITransformable.

Referenced by addValue().

virtual const char* NL3D::IAnimatable::getValueName uint  valueId  )  const [pure virtual]
 

Get animated value name.

Parameters:
valueId is the animated value ID in the object we want the name. IGNORING IANIMATABLE SONS (eg: bones, materials...).
Returns:
the name of the animated value.

Implemented in NL3D::CAnimatedLightmap, NL3D::CAnimatedMaterial, NL3D::CAnimatedMorph, NL3D::CCamera, NL3D::CParticleSystemModel, and NL3D::ITransformable.

Referenced by addValue().

uint32 NL3D::IAnimatable::isTouched uint  valueId  )  const [inline]
 

Return non 0 int if the value as been touched else 0.

Parameters:
valueId is the animated value ID in the object we want to test the touch flag. or it may be an OwnerBit.

Definition at line 184 of file animatable.h.

References _BitSet, uint, and uint32.

Referenced by NL3D::CParticleSystemModel::doAnimate(), NL3D::ITransformable::needCompute(), propagateTouch(), and NL3D::CAnimatedMaterial::update().

00185         {
00186                 return _BitSet&(1<<valueId);
00187         }

void NL3D::IAnimatable::propagateTouch  )  [inline, private]
 

Definition at line 212 of file animatable.h.

References _Father, _FatherOwnerBit, isTouched(), and setFlag().

Referenced by setFather(), and touch().

00213         {
00214                 IAnimatable             *pCur= this;
00215                 // Stop when no father, or when father is already touched (and so the grandfather...!!!).
00216                 while(pCur->_Father && !pCur->_Father->isTouched(_FatherOwnerBit))
00217                 {
00218                         // The Owner bit is the "something is touched" flag. touch it.
00219                         pCur->_Father->setFlag(pCur->_FatherOwnerBit);
00220                         pCur= pCur->_Father;
00221                 }
00222         }

virtual void NL3D::IAnimatable::registerToChannelMixer CChannelMixer chanMixer,
const std::string &  prefix = std::string()
[pure virtual]
 

register the Aniamtable to a channelMixer (using CChannelMixer::addChannel()). You MUST use this method to register Animatable. This method should:

  • call is BaseClass method.
  • register local AnimatableValues, with channel name: prefix+getValueName().
  • register local sons!!. eg: matlist[0]->registerToChannelMixer(chanMixer, prefix+"mat0.").

Parameters:
chanMixer is the channel mixer. Should not be NULL. for anim detail purpose , the IAnimatable may store a RefPtr on this channel mixer.
prefix prefix to be append to valueNames

Implemented in NL3D::CAnimatedLightmap, NL3D::CAnimatedMaterial, NL3D::CAnimatedMorph, NL3D::CBone, NL3D::CCamera, NL3D::CMeshBaseInstance, NL3D::CParticleSystemModel, NL3D::CSegRemanence, NL3D::CSkeletonModel, NL3D::CTransform, and NL3D::ITransformable.

void NL3D::IAnimatable::resize uint  count  )  [inline]
 

Change value count, bit are set to 0

Parameters:
count is the new value count.

Definition at line 195 of file animatable.h.

References count, nlassert, and uint.

00196         {
00197                 // with the "uint32 _BitSet" implementation, juste check the size is correct
00198                 nlassert(count<=32);
00199         }

void NL3D::IAnimatable::setFather IAnimatable father,
uint  fatherOwnerBit
[inline]
 

Say which (if any) IAnimatable owns this one. This is important for Touch propagation. By this system, Fathers and ancestors know if they must check their sons (isTouched() return true).

Parameters:
father the father we must inform of our update.
fatherOwnerBit What bit of father we must set when we are updated

Definition at line 153 of file animatable.h.

References _Father, _FatherOwnerBit, propagateTouch(), and uint.

Referenced by NL3D::CMeshBase::instanciateMeshBase(), and NL3D::CSegRemanence::setAnimatedMaterial().

00154         {
00155                 _Father= father; _FatherOwnerBit= fatherOwnerBit;
00156 
00157                 // propagate the touch to the fathers.
00158                 propagateTouch();
00159         }

void NL3D::IAnimatable::setFlag uint  valueId  )  [inline, protected]
 

This method set a bit in the bitset.

Definition at line 239 of file animatable.h.

References _BitSet, and uint.

Referenced by propagateTouch(), and touch().

00240         {
00241                 _BitSet|= (1<<valueId);
00242         }

void NL3D::IAnimatable::touch uint  valueId,
uint  ownerValueId
[inline]
 

Touch a value because it has been modified.

Parameters:
valueId is the animated value ID in the object we want to touch.
ownerValueId is the bit of the IAnimatable part which owns this animated value.

Definition at line 168 of file animatable.h.

References propagateTouch(), setFlag(), and uint.

Referenced by NL3D::CChannelMixer::eval(), NL3D::CChannelMixer::evalSingleChannel(), NL3D::CParticleSystemModel::reallocRsc(), NL3D::CChannelMixer::refreshList(), NL3D::CCamera::setFov(), NL3D::ITransformable::setPivot(), NL3D::ITransformable::setPos(), NL3D::CCamera::setRoll(), NL3D::ITransformable::setRotEuler(), NL3D::ITransformable::setRotQuat(), NL3D::ITransformable::setScale(), NL3D::CCamera::setTargetPos(), NL3D::ITransformable::setTransformMode(), and NL3D::CParticleSystemInstanceUser::setUserParam().

00169         {
00170                 // Set the bit
00171                 setFlag(valueId);
00172                 // Set the owner bit
00173                 setFlag(ownerValueId);
00174 
00175                 // propagate the touch to the fathers.
00176                 propagateTouch();
00177         }


Friends And Related Function Documentation

friend class IAnimatedValue [friend]
 

Definition at line 75 of file animatable.h.


Field Documentation

uint32 NL3D::IAnimatable::_BitSet [private]
 

Definition at line 206 of file animatable.h.

Referenced by clearFlag(), IAnimatable(), isTouched(), and setFlag().

IAnimatable* NL3D::IAnimatable::_Father [private]
 

Definition at line 208 of file animatable.h.

Referenced by IAnimatable(), propagateTouch(), and setFather().

uint NL3D::IAnimatable::_FatherOwnerBit [private]
 

Definition at line 210 of file animatable.h.

Referenced by propagateTouch(), and setFather().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 08:37:13 2004 for NeL by doxygen 1.3.6