NL3D::CBone Class Reference

#include <bone.h>

Inheritance diagram for NL3D::CBone:

NL3D::ITransformable NL3D::IAnimatable

Detailed Description

This is a bone, for skeleton animation, with information for result WorldMatrix.
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 96 of file bone.h.

Herited from IAnimatable

enum  TAnimValues {
  OwnerBit = IAnimatable::AnimValueLast, PosValue, RotEulerValue, RotQuatValue,
  ScaleValue, PivotValue, AnimValueLast
}
 Added values. More...

virtual IAnimatedValuegetValue (uint valueId)
 From IAnimatable.

virtual const char * getValueName (uint valueId) const
 From IAnimatable.


Public Types

enum  TTransformMode { DirectMatrix = 0, RotEuler, RotQuat, TransformModeCount }

Public Member Functions

 CBone (CBoneBase *boneBase)
bool compareMatrixDate (uint64 callerDate) const
void compute (CBone *parent, const CMatrix &rootMatrix, CSkeletonModel *skeletonForAnimCtrl)
void forceAnimate (CChannelMixer &chanMixer)
CBoneBasegetBoneBase () const
 retrieve the boneBase

const std::string & getBoneName () const
 retrieve the boneName from BoneBase.

const CMatrixgetBoneSkinMatrix () const
 retrieve the BoneSkinMatrix computed in compute().

sint32 getFatherId () const
 retrieve the fatherId from BoneBase.

const CMatrixgetLocalSkeletonMatrix () const
 retrieve the matrix local to the skeleton, computed in compute().

const CMatrixgetMatrix () const
 Get the matrix, compute her if necessary (work in all modes).

uint64 getMatrixDate () const
const CMatrixgetWorldMatrix () const
 retrieve the WorldMatrix computed in compute().

void interpolateBoneSkinMatrix (const CMatrix &otherMatrix, float interp)
void lodEnableChannels (CChannelMixer *chanMixer, bool enable)
 enable the channels (lodEnable) associated to this bone in the channelMixer.

Herited from ITransformable
virtual ITrackgetDefaultTrack (uint valueId)
 retrive the default trak from skeleton shape.

virtual void registerToChannelMixer (CChannelMixer *chanMixer, const std::string &prefix)
 register the ITransformable channels as detailled channels.


Static Public Member Functions

const char * getPivotValueName ()
const char * getPosValueName ()
const char * getRotEulerValueName ()
const char * getRotQuatValueName ()
const char * getScaleValueName ()

Data Fields

IAnimCtrl_AnimCtrl
NLMISC::CBSphere _MaxSphere

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 Attributes

NLMISC::CRefPtr< CBoneBase_BoneBase
CMatrix _BoneSkinMatrix
CMatrix _LocalSkeletonMatrix
sint _PivotChannelId
sint _PosChannelId
sint _RotEulerChannelId
sint _RotQuatChannelId
sint _ScaleChannelId
CMatrix _WorldMatrix


Member Enumeration Documentation

enum NL3D::ITransformable::TAnimValues [inherited]
 

Added values.

Enumeration values:
OwnerBit 
PosValue 
RotEulerValue 
RotQuatValue 
ScaleValue 
PivotValue 
AnimValueLast 

Reimplemented from NL3D::IAnimatable.

Reimplemented in NL3D::CCamera, NL3D::CMeshBaseInstance, NL3D::CParticleSystemModel, NL3D::CSegRemanence, and NL3D::CSkeletonModel.

Definition at line 280 of file transformable.h.

00281         {
00282                 OwnerBit= IAnimatable::AnimValueLast,
00283                 PosValue,
00284                 RotEulerValue,
00285                 RotQuatValue,
00286                 ScaleValue,
00287                 PivotValue,
00288                 AnimValueLast
00289         };

enum NL3D::ITransformable::TTransformMode [inherited]
 

Enumeration values:
DirectMatrix 
RotEuler 
RotQuat 
TransformModeCount 

Definition at line 58 of file transformable.h.

Referenced by NL3D::ITransformable::getTransformMode().

00059         {
00060                 DirectMatrix=0,         // DirectMatrixMode.
00061                 RotEuler,                       // Matrix is computed from sperated composantes, with euler rotation.
00062                 RotQuat,                        // Matrix is computed from sperated composantes, with quat rotation (default).
00063 
00064                 TransformModeCount
00065         };


Constructor & Destructor Documentation

NL3D::CBone::CBone CBoneBase boneBase  ) 
 

Constructor. build a bone from a CBoneBase*. By defautl, a bone is in RotQuat transform mode. This ctor:

  • store a RefPtr on the bonebase (for getDefaultTracks() method). the refptr is just for nlassert.
  • copy the bonebase default track value into Animated Values Pos/Rot etc....

Definition at line 93 of file bone.cpp.

References _AnimCtrl, _BoneBase, _PivotChannelId, _PosChannelId, _RotEulerChannelId, _RotQuatChannelId, _ScaleChannelId, NL3D::CAnimatedValueQuat, NL3D::CAnimatedValueVector, and nlassert.

00094 {
00095         nlassert(boneBase);
00096         _BoneBase= boneBase;
00097 
00098         // IAnimatable.
00099         IAnimatable::resize(AnimValueLast);
00100 
00101         ITransformable::setTransformMode(ITransformable::RotQuat);
00102         ITransformable::setPos( ((CAnimatedValueVector&)_BoneBase->DefaultPos.getValue()).Value  );
00103         ITransformable::setRotQuat( ((CAnimatedValueQuat&)_BoneBase->DefaultRotQuat.getValue()).Value  );
00104         ITransformable::setScale( ((CAnimatedValueVector&)_BoneBase->DefaultScale.getValue()).Value  );
00105         ITransformable::setPivot( ((CAnimatedValueVector&)_BoneBase->DefaultPivot.getValue()).Value  );
00106 
00107         // By default, the bone is not binded to a channelMixer.
00108         _PosChannelId= -1;
00109         _RotEulerChannelId= -1;
00110         _RotQuatChannelId= -1;
00111         _ScaleChannelId= -1;
00112         _PivotChannelId= -1;
00113 
00114         // No animCtrl by default
00115         _AnimCtrl= NULL;
00116 }


Member Function Documentation

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

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(), NL3D::IAnimatable::getDefaultTrack(), NL3D::IAnimatable::getValue(), NL3D::IAnimatable::getValueName(), nlassert, sint, and uint.

Referenced by NL3D::CTransform::registerToChannelMixer(), NL3D::CParticleSystemModel::registerToChannelMixer(), NL3D::CCamera::registerToChannelMixer(), 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, inherited]
 

This method clear a bit in the bitset.

Definition at line 233 of file animatable.h.

References NL3D::IAnimatable::_BitSet, and uint.

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

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

bool NL3D::ITransformable::compareMatrixDate uint64  callerDate  )  const [inline, inherited]
 

Tells if the LocalMatrix is newer than what caller except. This return true either if the matrix components (pos/rot etc...) are touched, or if matrix is newer than caller date.

Definition at line 82 of file transformable.h.

References NL3D::ITransformable::_LocalMatrixDate, NL3D::ITransformable::needCompute(), and uint64.

Referenced by NL3D::CWaterModel::updateDiffuseMapMatrix().

00083         {
00084                 return callerDate<_LocalMatrixDate || needCompute();
00085         }

void NL3D::CBone::compute CBone parent,
const CMatrix rootMatrix,
CSkeletonModel skeletonForAnimCtrl
 

Compute the LocalSkeletonMatrix, the WorldMatrix, and the BoneSkinMatrix (for skinning). NB: the result localSkeletonMatrix depends on BoneBase::UnheritScale.
NB: the result worldMatrix depends on BoneBase::UnheritScale.
NB: the result boneSkinMatrix depends on BoneBase::InvBindPos.

Parameters:
parent the parent of this bone (maybe NULL if root). his WorldMatrix is used, so it should be computed before.
rootMatrix is used as father worldmatrix if parent==NULL. Usefull for computing WorldMatrix.
skeletonForAnimCtrl if NULL, no AnimCtrl is performed, else skeletonForAnimCtrl->getWorldMAtrix() should be == to rootMatrix

Definition at line 155 of file bone.cpp.

References _AnimCtrl, _BoneBase, _BoneSkinMatrix, _LocalSkeletonMatrix, _WorldMatrix, NL3D::IAnimCtrl::execute(), NL3D::ITransformable::getMatrix(), NLMISC::CMatrix::getPos(), NL3D::ITransformable::getScale(), nlassert, NLMISC::CMatrix::setMulMatrixNoProj(), NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setScale(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NL3D::CTargetAnimCtrl::execute(), NL3D::CSkeletonModel::forceComputeBone(), and NL3D::CSkeletonModel::traverseAnimDetail().

00156 {
00157         // compute is called typically 800 time per frame.
00158 #ifdef NL_DEBUG
00159         nlassert(_BoneBase);
00160 #endif
00161 
00162         // get/compute our local matrix
00163         const CMatrix   &localMatrix= getMatrix();
00164         
00165         // Compute LocalSkeletonMatrix.
00166         // Root case?
00167         if(!parent)
00168         {
00169                 _LocalSkeletonMatrix= localMatrix;
00170         }
00171         // Else, son case, take world matrix from parent.
00172         else
00173         {
00174                 // UnheritScale case.
00175                 if(_BoneBase->UnheritScale)
00176                 {
00177                         CMatrix         invScaleComp;
00178                         CVector         fatherScale;
00179                         CVector         trans;
00180 
00181                         /* Optim note:
00182                                 the scale is rarely ==1, so don't optimize case where it may be.
00183                         */
00184 
00185                         // retrieve our translation
00186                         localMatrix.getPos(trans);
00187                         // retrieve scale from our father.
00188                         parent->getScale(fatherScale);
00189                         // inverse this scale.
00190                         fatherScale.x= 1.0f / fatherScale.x;
00191                         fatherScale.y= 1.0f / fatherScale.y;
00192                         fatherScale.z= 1.0f / fatherScale.z;
00193 
00194                         // Compute InverseScale compensation:
00195                         // with UnheritScale, formula per bone should be  T*Sf-1*P*R*S*P-1.
00196                         // But getMatrix() return T*P*R*S*P-1.
00197                         // So we must compute T*Sf-1*T-1, in order to get wanted result.
00198                         invScaleComp.setScale(fatherScale);
00199                         // Faster compute of the translation part: just "trans + fatherScale MUL -trans" where MUL is comp mul
00200                         trans.x-= fatherScale.x * trans.x;
00201                         trans.y-= fatherScale.y * trans.y;
00202                         trans.z-= fatherScale.z * trans.z;
00203                         invScaleComp.setPos(trans);
00204 
00205 
00206                         // And finally, we got ParentWM * T*Sf-1*P*R*S*P-1.
00207                         // Do: _LocalSkeletonMatrix= parent->_LocalSkeletonMatrix * invScaleComp * localMatrix
00208                         static  CMatrix tmp;
00209                         tmp.setMulMatrixNoProj( parent->_LocalSkeletonMatrix, invScaleComp );
00210                         _LocalSkeletonMatrix.setMulMatrixNoProj( tmp, localMatrix );
00211                 }
00212                 // Normal case.
00213                 else
00214                 {
00215                         // Do: _LocalSkeletonMatrix= parent->_LocalSkeletonMatrix * localMatrix
00216                         _LocalSkeletonMatrix.setMulMatrixNoProj( parent->_LocalSkeletonMatrix, localMatrix );
00217                 }
00218         }
00219 
00220         // Compute WorldMatrix. Do: _WorldMatrix= rootMatrix * _LocalSkeletonMatrix
00221         _WorldMatrix.setMulMatrixNoProj( rootMatrix, _LocalSkeletonMatrix );
00222 
00223         // Compute BoneSkinMatrix. Do: _BoneSkinMatrix= _LocalSkeletonMatrix * _BoneBase->InvBindPos
00224         _BoneSkinMatrix.setMulMatrixNoProj( _LocalSkeletonMatrix, _BoneBase->InvBindPos );
00225         
00226         // When compute is done, do extra user ctrl?
00227         if(_AnimCtrl && skeletonForAnimCtrl)
00228                 _AnimCtrl->execute(skeletonForAnimCtrl, this);
00229 }

void NL3D::CBone::forceAnimate CChannelMixer chanMixer  )  [inline]
 

Force to eval the animation of that bone Useful when a bone position is needed, and if the father skeleton has been clipped (and thus not detail-animated)

Parameters:
chanMixer the channel mixer to which that bone has been registered

Definition at line 194 of file bone.h.

References _PivotChannelId, _PosChannelId, _RotEulerChannelId, _RotQuatChannelId, _ScaleChannelId, NL3D::CChannelMixer::evalChannels(), and sint.

00195 {
00196         sint ids[] = 
00197         {
00198                 _PosChannelId,
00199                 _RotEulerChannelId,
00200                 _RotQuatChannelId,
00201                 _ScaleChannelId,
00202                 _PivotChannelId
00203         };
00204         chanMixer.evalChannels(ids, sizeof(ids) / sizeof(ids[0]));
00205 }

CBoneBase& NL3D::CBone::getBoneBase  )  const [inline]
 

retrieve the boneBase

Definition at line 114 of file bone.h.

References _BoneBase, and nlassert.

Referenced by NL3D::CTargetAnimCtrl::execute(), and NL3D::CTargetAnimCtrl::getCurrentLSRotationFromBone().

00114 {nlassert(_BoneBase); return *_BoneBase;}

const std::string& NL3D::CBone::getBoneName  )  const [inline]
 

retrieve the boneName from BoneBase.

Definition at line 110 of file bone.h.

References _BoneBase, and nlassert.

00110 {nlassert(_BoneBase); return _BoneBase->Name;}

const CMatrix& NL3D::CBone::getBoneSkinMatrix  )  const [inline]
 

retrieve the BoneSkinMatrix computed in compute().

Definition at line 150 of file bone.h.

References _BoneSkinMatrix.

Referenced by NL3D::CSkeletonModel::traverseAnimDetail().

00150 {return _BoneSkinMatrix;}

ITrack * NL3D::CBone::getDefaultTrack uint  valueId  )  [virtual]
 

retrive the default trak from skeleton shape.

Implements NL3D::ITransformable.

Definition at line 119 of file bone.cpp.

References _BoneBase, nlassert, nlstop, and uint.

00120 {
00121         nlassert(_BoneBase);
00122         
00123         // what value ?
00124         switch (valueId)
00125         {
00126         case PosValue:                  return &_BoneBase->DefaultPos;
00127         case RotEulerValue:             return &_BoneBase->DefaultRotEuler;
00128         case RotQuatValue:              return &_BoneBase->DefaultRotQuat;
00129         case ScaleValue:                return &_BoneBase->DefaultScale;
00130         case PivotValue:                return &_BoneBase->DefaultPivot;
00131         }
00132 
00133         // No, only ITrnasformable values!
00134         nlstop;
00135         // Deriver note: else call BaseClass::getDefaultTrack(valueId);
00136 
00137         return NULL;
00138 }

sint32 NL3D::CBone::getFatherId  )  const [inline]
 

retrieve the fatherId from BoneBase.

Definition at line 112 of file bone.h.

References _BoneBase, nlassert, and sint32.

Referenced by NL3D::CTargetAnimCtrl::execute(), and NL3D::CSkeletonModel::forceComputeBone().

00112 {nlassert(_BoneBase); return _BoneBase->FatherId;}

const CMatrix& NL3D::CBone::getLocalSkeletonMatrix  )  const [inline]
 

retrieve the matrix local to the skeleton, computed in compute().

Definition at line 144 of file bone.h.

References _LocalSkeletonMatrix.

Referenced by NL3D::CTargetAnimCtrl::execute(), and NL3D::CTargetAnimCtrl::getCurrentLSRotationFromBone().

00144 {return _LocalSkeletonMatrix;}

const CMatrix& NL3D::ITransformable::getMatrix  )  const [inline, inherited]
 

Get the matrix, compute her if necessary (work in all modes).

Definition at line 76 of file transformable.h.

References NL3D::ITransformable::updateMatrix().

Referenced by NL3D::CInstanceGroup::addToSceneWhenAllShapesLoaded(), NL3D::CCamera::buildCameraPyramid(), compute(), NL3D::CWaterShape::createInstance(), NL3D::CWaterModel::getAttenuatedHeight(), NL3D::CTransformableUser::getMatrix(), NL3D::CCloudScape::render(), NL3D::CMeshMultiLod::renderCoarseMesh(), and NL3D::CTransform::update().

00076 {updateMatrix(); return _LocalMatrix;}

uint64 NL3D::ITransformable::getMatrixDate  )  const [inline, inherited]
 

return the last date of computed matrix. updateMatrix() if necessary.

Definition at line 90 of file transformable.h.

References NL3D::ITransformable::_LocalMatrixDate, uint64, and NL3D::ITransformable::updateMatrix().

Referenced by NL3D::CWaterModel::updateDiffuseMapMatrix().

00091         {
00092                 updateMatrix();
00093                 return _LocalMatrixDate;
00094         }

CVector NL3D::ITransformable::getPivot  )  [inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 255 of file transformable.h.

References NL3D::ITransformable::_Pivot, nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

00256         {
00257                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00258                 return _Pivot.Value;
00259         }

void NL3D::ITransformable::getPivot CVector pivot  )  [inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 224 of file transformable.h.

References NL3D::ITransformable::_Pivot, nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CTransformableUser::getPivot().

00225         {
00226                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00227                 pivot= _Pivot.Value;
00228         }

const char * NL3D::ITransformable::getPivotValueName  )  [static, inherited]
 

Definition at line 117 of file transformable.cpp.

Referenced by NL3D::ITransformable::getValueName().

00118 {
00119         return "pivot";
00120 }

CVector NL3D::ITransformable::getPos void   )  [inline, inherited]
 

Work only in Rot* mode(nlassert).

Definition at line 231 of file transformable.h.

References nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CSkeletonModel::generateShadowMap(), NL3D::CWaterModel::getHeight(), NL3D::CSkeletonModel::renderIntoSkeletonShadowMap(), NL3D::CMeshInstance::renderIntoSkeletonShadowMap(), and NL3D::CPointLightModel::traverseLight().

00232         {
00233                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00234                 return _Pos.Value;
00235         }

void NL3D::ITransformable::getPos CVector pos  )  [inline, inherited]
 

Work only in Rot* mode(nlassert).

Definition at line 200 of file transformable.h.

References nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CTransformableUser::getPos(), NL3D::CInstanceGroup::getPos(), and NL3D::CPSLight::step().

00201         {
00202                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00203                 pos= _Pos.Value;
00204         }

const char * NL3D::ITransformable::getPosValueName  )  [static, inherited]
 

Definition at line 97 of file transformable.cpp.

Referenced by NL3D::ITransformable::getValueName().

00098 {
00099         return "pos";
00100 }

CVector NL3D::ITransformable::getRotEuler  )  [inline, inherited]
 

Work only in RotEuler mode(nlassert).

Definition at line 237 of file transformable.h.

References NL3D::ITransformable::_RotEuler, nlassert, NL3D::ITransformable::RotEuler, and NL3D::CAnimatedValueBlendable< T >::Value.

00238         {
00239                 nlassert(_Mode==RotEuler);
00240                 return _RotEuler.Value;
00241         }

void NL3D::ITransformable::getRotEuler CVector rot  )  [inline, inherited]
 

Work only in RotEuler mode(nlassert).

Definition at line 206 of file transformable.h.

References NL3D::ITransformable::_RotEuler, nlassert, NL3D::ITransformable::RotEuler, and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CTransformableUser::getRotEuler().

00207         {
00208                 nlassert(_Mode==RotEuler);
00209                 rot= _RotEuler.Value;
00210         }

const char * NL3D::ITransformable::getRotEulerValueName  )  [static, inherited]
 

Definition at line 102 of file transformable.cpp.

Referenced by NL3D::ITransformable::getValueName().

00103 {
00104         return "roteuler";
00105 }

CMatrix::TRotOrder NL3D::ITransformable::getRotOrder  )  [inline, inherited]
 

get the current rotorder (information vlaid only when RotEuler mode).

Definition at line 194 of file transformable.h.

References NL3D::ITransformable::_RotOrder.

Referenced by NL3D::CTransformableUser::getRotOrder().

00195         {
00196                 return _RotOrder;
00197         }

CQuat NL3D::ITransformable::getRotQuat  )  [inline, inherited]
 

Work only in RotQuat mode (nlassert).

Definition at line 243 of file transformable.h.

References NL3D::ITransformable::_RotQuat, nlassert, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

00244         {
00245                 nlassert(_Mode==RotQuat);
00246                 return _RotQuat.Value;
00247         }

void NL3D::ITransformable::getRotQuat CQuat quat  )  [inline, inherited]
 

Work only in RotQuat mode (nlassert).

Definition at line 212 of file transformable.h.

References NL3D::ITransformable::_RotQuat, nlassert, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CTransformableUser::getRotQuat(), and NL3D::CInstanceGroup::getRotQuat().

00213         {
00214                 nlassert(_Mode==RotQuat);
00215                 quat= _RotQuat.Value;
00216         }

const char * NL3D::ITransformable::getRotQuatValueName  )  [static, inherited]
 

Definition at line 107 of file transformable.cpp.

Referenced by NL3D::ITransformable::getValueName().

00108 {
00109         return "rotquat";
00110 }

CVector NL3D::ITransformable::getScale void   )  [inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 249 of file transformable.h.

References nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

00250         {
00251                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00252                 return _Scale.Value;
00253         }

void NL3D::ITransformable::getScale CVector scale  )  [inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 218 of file transformable.h.

References nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by compute(), and NL3D::CTransformableUser::getScale().

00219         {
00220                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00221                 scale= _Scale.Value;
00222         }

const char * NL3D::ITransformable::getScaleValueName  )  [static, inherited]
 

Definition at line 112 of file transformable.cpp.

Referenced by NL3D::ITransformable::getValueName().

00113 {
00114         return "scale";
00115 }

TTransformMode NL3D::ITransformable::getTransformMode  )  [inline, inherited]
 

get the current transform mode.

Definition at line 189 of file transformable.h.

References NL3D::ITransformable::TTransformMode.

Referenced by NL3D::CTargetAnimCtrl::execute(), and NL3D::CTransformableUser::getTransformMode().

00190         {
00191                 return _Mode;
00192         }

IAnimatedValue * NL3D::ITransformable::getValue uint  valueId  )  [virtual, inherited]
 

From IAnimatable.

Implements NL3D::IAnimatable.

Reimplemented in NL3D::CCamera, and NL3D::CParticleSystemModel.

Definition at line 58 of file transformable.cpp.

References NL3D::ITransformable::_Pivot, NL3D::ITransformable::_RotEuler, NL3D::ITransformable::_RotQuat, nlstop, NL3D::ITransformable::PivotValue, NL3D::ITransformable::PosValue, NL3D::ITransformable::RotEulerValue, NL3D::ITransformable::RotQuatValue, NL3D::ITransformable::ScaleValue, and uint.

00059 {
00060         // what value ?
00061         switch (valueId)
00062         {
00063         case PosValue:                  return &_Pos;
00064         case RotEulerValue:             return &_RotEuler;
00065         case RotQuatValue:              return &_RotQuat;
00066         case ScaleValue:                return &_Scale;
00067         case PivotValue:                return &_Pivot;
00068         }
00069 
00070         // No, only ITrnasformable values!
00071         nlstop;
00072         // Deriver note: else call BaseClass::getValue(valueId);
00073 
00074         return NULL;
00075 }

const char * NL3D::ITransformable::getValueName uint  valueId  )  const [virtual, inherited]
 

From IAnimatable.

Implements NL3D::IAnimatable.

Reimplemented in NL3D::CCamera, and NL3D::CParticleSystemModel.

Definition at line 77 of file transformable.cpp.

References NL3D::ITransformable::getPivotValueName(), NL3D::ITransformable::getPosValueName(), NL3D::ITransformable::getRotEulerValueName(), NL3D::ITransformable::getRotQuatValueName(), NL3D::ITransformable::getScaleValueName(), nlstop, NL3D::ITransformable::PivotValue, NL3D::ITransformable::PosValue, NL3D::ITransformable::RotEulerValue, NL3D::ITransformable::RotQuatValue, NL3D::ITransformable::ScaleValue, and uint.

00078 {
00079         // what value ?
00080         switch (valueId)
00081         {
00082         case PosValue:                  return getPosValueName ();
00083         case RotEulerValue:             return getRotEulerValueName();
00084         case RotQuatValue:              return getRotQuatValueName();
00085         case ScaleValue:                return getScaleValueName();
00086         case PivotValue:                return getPivotValueName();
00087         }
00088 
00089         // No, only ITrnasformable values!
00090         nlstop;
00091         // Deriver note: else call BaseClass::getValueName(valueId);
00092 
00093         return "";
00094 }

const CMatrix& NL3D::CBone::getWorldMatrix  )  const [inline]
 

retrieve the WorldMatrix computed in compute().

Definition at line 147 of file bone.h.

References _WorldMatrix.

Referenced by NL3D::CSkeletonModel::computeWorldBBoxForShadow(), NL3D::CTargetAnimCtrl::execute(), and NL3D::CSkeletonModel::forceComputeBone().

00147 {return _WorldMatrix;}

void NL3D::CBone::interpolateBoneSkinMatrix const CMatrix otherMatrix,
float  interp
 

Interpolate the current result of _BoneSkinMatrix fith otherMatrix. when interp==0.f, _BoneSkinMatrix= otherMatrix. NB: the interpolation is made on per-vector basis => bad matrix interpolation.

Definition at line 233 of file bone.cpp.

References _BoneSkinMatrix, NLMISC::CMatrix::getI(), NLMISC::CMatrix::getJ(), NLMISC::CMatrix::getK(), NLMISC::CMatrix::getPos(), NLMISC::CMatrix::setPos(), and NLMISC::CMatrix::setRot().

Referenced by NL3D::CSkeletonModel::traverseAnimDetail().

00234 {
00235         CMatrix         &curMatrix= _BoneSkinMatrix;
00236 
00237         // interpolate rot/scale. Just interpolate basis vectors
00238         CVector         fatherI= otherMatrix.getI();
00239         CVector         curI= curMatrix.getI();
00240         curI= fatherI*(1-interp) + curI*interp;
00241         CVector         fatherJ= otherMatrix.getJ();
00242         CVector         curJ= curMatrix.getJ();
00243         curJ= fatherJ*(1-interp) + curJ*interp;
00244         CVector         fatherK= otherMatrix.getK();
00245         CVector         curK= curMatrix.getK();
00246         curK= fatherK*(1-interp) + curK*interp;
00247         // replace rotation
00248         curMatrix.setRot(curI, curJ, curK);
00249 
00250         // interpolate pos
00251         CVector         fatherPos= otherMatrix.getPos();
00252         CVector         curPos= curMatrix.getPos();
00253         curPos= fatherPos*(1-interp) + curPos*interp;
00254         curMatrix.setPos(curPos);
00255 }

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

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 NL3D::IAnimatable::_BitSet, uint, and uint32.

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

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

void NL3D::CBone::lodEnableChannels CChannelMixer chanMixer,
bool  enable
 

enable the channels (lodEnable) associated to this bone in the channelMixer.

Definition at line 259 of file bone.cpp.

References _PivotChannelId, _PosChannelId, _RotEulerChannelId, _RotQuatChannelId, _ScaleChannelId, NL3D::CChannelMixer::lodEnableChannel(), and nlassert.

00260 {
00261         nlassert(chanMixer);
00262 
00263         // Lod Enable channels if they are correclty registered to the channelMixer.
00264         if( _PosChannelId>=0 )
00265                 chanMixer->lodEnableChannel(_PosChannelId, enable);
00266         if( _RotEulerChannelId>=0 )
00267                 chanMixer->lodEnableChannel(_RotEulerChannelId, enable);
00268         if( _RotQuatChannelId>=0 )
00269                 chanMixer->lodEnableChannel(_RotQuatChannelId, enable);
00270         if( _ScaleChannelId>=0 )
00271                 chanMixer->lodEnableChannel(_ScaleChannelId, enable);
00272         if( _PivotChannelId>=0 )
00273                 chanMixer->lodEnableChannel(_PivotChannelId, enable);
00274 
00275 }

void NL3D::ITransformable::lookAt const CVector eye,
const CVector target,
float  roll = 0.f
[inherited]
 

Setup Matrix by the lookAt method. Work only in DirectMatrix mode and RotQuat mode (not euler...).

Parameters:
eye is the coordinate of the object.
target is the point the object look at.
roll is the roll angle in radian along the object's Y axis.

Definition at line 169 of file transformable.cpp.

References NL3D::ITransformable::DirectMatrix, NLMISC::CMatrix::getPos(), NLMISC::CMatrix::getRot(), NLMISC::CMatrix::identity(), nlassert, NLMISC::CVector::normalize(), NLMISC::CMatrix::rotateY(), NL3D::ITransformable::RotQuat, NL3D::ITransformable::setMatrix(), NL3D::ITransformable::setPivot(), NL3D::ITransformable::setPos(), NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), NL3D::ITransformable::setRotQuat(), and NL3D::ITransformable::setScale().

Referenced by NL3D::CTransformableUser::lookAt(), and NL3D::CCamera::update().

00170 {
00171         nlassert(_Mode==RotQuat || _Mode==DirectMatrix);
00172 
00173         // Roll matrix
00174         CMatrix rollMT;
00175         rollMT.identity();
00176         if (roll!=0.f)
00177                 rollMT.rotateY (roll);
00178 
00179         // Make the target base
00180         CVector j=target;
00181         j-=eye;
00182         j.normalize();
00183         CVector i=j^CVector (0,0,1.f);
00184         CVector k=i^j;
00185         k.normalize();
00186         i=j^k;
00187         i.normalize();
00188 
00189         // Make the target matrix
00190         CMatrix targetMT;
00191         targetMT.identity();
00192         targetMT.setRot (i, j, k);
00193         targetMT.setPos (eye);
00194 
00195         // Compose matrix
00196         targetMT*=rollMT;
00197 
00198         // Set the matrix
00199         if(_Mode==DirectMatrix)
00200                 setMatrix (targetMT);
00201         else
00202         {
00203                 // transfrom to quaternion mode.
00204                 setScale(CVector(1,1,1));
00205                 setPivot(CVector::Null);
00206                 setPos(targetMT.getPos());
00207                 setRotQuat(targetMT.getRot());
00208         }
00209 }

void NL3D::CBone::registerToChannelMixer CChannelMixer chanMixer,
const std::string &  prefix
[virtual]
 

register the ITransformable channels as detailled channels.

Implements NL3D::ITransformable.

Definition at line 141 of file bone.cpp.

References _PivotChannelId, _PosChannelId, _RotEulerChannelId, _RotQuatChannelId, _ScaleChannelId, and NL3D::IAnimatable::addValue().

00142 {
00143         // For CBone, channels are detailled.
00144         // Bkup each channelId (for disable).
00145         _PosChannelId= addValue(chanMixer, PosValue, OwnerBit, prefix, true);
00146         _RotEulerChannelId= addValue(chanMixer, RotEulerValue, OwnerBit, prefix, true);
00147         _RotQuatChannelId= addValue(chanMixer, RotQuatValue, OwnerBit, prefix, true);
00148         _ScaleChannelId= addValue(chanMixer, ScaleValue, OwnerBit, prefix, true);
00149         _PivotChannelId= addValue(chanMixer, PivotValue, OwnerBit, prefix, true);
00150 
00151         // Deriver note: if necessary, call     BaseClass::registerToChannelMixer(chanMixer, prefix);
00152 }

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

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, inherited]
 

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 NL3D::IAnimatable::_Father, NL3D::IAnimatable::_FatherOwnerBit, NL3D::IAnimatable::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, inherited]
 

This method set a bit in the bitset.

Definition at line 239 of file animatable.h.

References NL3D::IAnimatable::_BitSet, and uint.

Referenced by NL3D::IAnimatable::propagateTouch(), and NL3D::IAnimatable::touch().

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

void NL3D::ITransformable::setMatrix const CMatrix mat  )  [inline, inherited]
 

Work only in DirecTMatrix mode (nlassert).

Definition at line 174 of file transformable.h.

References NL3D::ITransformable::_LocalMatrixDate, NL3D::ITransformable::DirectMatrix, and nlassert.

Referenced by NL3D::ITransformable::lookAt(), and NL3D::CTransformableUser::setMatrix().

00175         {
00176                 nlassert(_Mode==DirectMatrix);
00177                 _LocalMatrix= mat;
00178                 // The matrix has changed.
00179                 _LocalMatrixDate++;
00180         }

void NL3D::ITransformable::setPivot float  x,
float  y,
float  z
[inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 169 of file transformable.h.

References NL3D::ITransformable::setPivot(), x, y, and z.

00170         {
00171                 setPivot(CVector(x, y, z));
00172         }

void NL3D::ITransformable::setPivot const CVector pivot  )  [inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 162 of file transformable.h.

References NL3D::ITransformable::_Pivot, nlassert, NL3D::ITransformable::PivotValue, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, NL3D::IAnimatable::touch(), and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::ITransformable::lookAt(), NL3D::CTransformableUser::setPivot(), and NL3D::ITransformable::setPivot().

00163         {
00164                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00165                 _Pivot.Value= pivot;
00166                 touch(PivotValue, OwnerBit);
00167         }

void NL3D::ITransformable::setPos float  x,
float  y,
float  z
[inline, inherited]
 

Work only in Rot* mode(nlassert).

Definition at line 121 of file transformable.h.

References NL3D::ITransformable::setPos(), x, y, and z.

00122         {
00123                 setPos(CVector(x,y,z));
00124         }

void NL3D::ITransformable::setPos const CVector pos  )  [inline, inherited]
 

Work only in Rot* mode(nlassert).

Definition at line 114 of file transformable.h.

References nlassert, NL3D::ITransformable::PosValue, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, NL3D::IAnimatable::touch(), and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CCamera::build(), NL3D::ITransformable::lookAt(), NL3D::CTransformableUser::setPos(), NL3D::ITransformable::setPos(), NL3D::CInstanceGroup::setPos(), and NL3D::CPSLight::step().

00115         {
00116                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00117                 _Pos.Value= pos;
00118                 touch(PosValue, OwnerBit);
00119         }

void NL3D::ITransformable::setRotEuler float  rotX,
float  rotY,
float  rotZ
[inline, inherited]
 

Work only in RotEuler mode(nlassert).

Definition at line 133 of file transformable.h.

References NL3D::ITransformable::setRotEuler().

00134         {
00135                 setRotEuler(CVector(rotX, rotY, rotZ));
00136         }

void NL3D::ITransformable::setRotEuler const CVector rot  )  [inline, inherited]
 

Work only in RotEuler mode(nlassert).

Definition at line 126 of file transformable.h.

References NL3D::ITransformable::_RotEuler, nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotEulerValue, NL3D::IAnimatable::touch(), and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CTransformableUser::setRotEuler(), and NL3D::ITransformable::setRotEuler().

00127         {
00128                 nlassert(_Mode==RotEuler);
00129                 _RotEuler.Value= rot;
00130                 touch(RotEulerValue, OwnerBit);
00131         }

void NL3D::ITransformable::setRotQuat const CQuat quat  )  [inline, inherited]
 

Work only in RotQuat mode (nlassert).

Definition at line 138 of file transformable.h.

References NL3D::ITransformable::_RotQuat, nlassert, NL3D::ITransformable::RotQuat, NL3D::ITransformable::RotQuatValue, NL3D::IAnimatable::touch(), and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::CTargetAnimCtrl::execute(), NL3D::ITransformable::lookAt(), NL3D::CTransformableUser::setRotQuat(), and NL3D::CInstanceGroup::setRotQuat().

00139         {
00140                 nlassert(_Mode==RotQuat);
00141                 _RotQuat.Value= quat;
00142                 touch(RotQuatValue, OwnerBit);
00143         }

void NL3D::ITransformable::setScale float  scale  )  [inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 157 of file transformable.h.

References NL3D::ITransformable::setScale().

00158         {
00159                 setScale(CVector(scale, scale, scale));
00160         }

void NL3D::ITransformable::setScale float  scaleX,
float  scaleY,
float  scaleZ
[inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 152 of file transformable.h.

References NL3D::ITransformable::setScale().

00153         {
00154                 setScale(CVector(scaleX, scaleY, scaleZ));
00155         }

void NL3D::ITransformable::setScale const CVector scale  )  [inline, inherited]
 

Work only in Rot* mode (nlassert).

Definition at line 145 of file transformable.h.

References nlassert, NL3D::ITransformable::RotEuler, NL3D::ITransformable::RotQuat, NL3D::ITransformable::ScaleValue, NL3D::IAnimatable::touch(), and NL3D::CAnimatedValueBlendable< T >::Value.

Referenced by NL3D::ITransformable::lookAt(), NL3D::CTransformableUser::setScale(), and NL3D::ITransformable::setScale().

00146         {
00147                 nlassert(_Mode==RotEuler || _Mode==RotQuat);
00148                 _Scale.Value= scale;
00149                 touch(ScaleValue, OwnerBit);
00150         }

void NL3D::ITransformable::setTransformMode TTransformMode  mode,
CMatrix::TRotOrder  ro = CMatrix::ZXY
[inline, inherited]
 

Change the transform mode. Components or matrix are not reseted.

Definition at line 100 of file transformable.h.

References NL3D::ITransformable::_RotOrder, NL3D::ITransformable::PosValue, and NL3D::IAnimatable::touch().

Referenced by NL3D::CCamera::build(), NL3D::CCamera::enableTargetAnimation(), NL3D::CPSMesh::newElement(), NL3D::CTransformableUser::setTransformMode(), and NL3D::CPSMesh::updatePos().

00101         {
00102                 _Mode= mode;
00103                 _RotOrder= ro;
00104                 // just for information.
00105                 touch(PosValue, OwnerBit);
00106         }

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

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 NL3D::IAnimatable::propagateTouch(), NL3D::IAnimatable::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         }


Field Documentation

IAnimCtrl* NL3D::CBone::_AnimCtrl
 

Definition at line 166 of file bone.h.

Referenced by CBone(), compute(), and NL3D::CSkeletonModel::setBoneAnimCtrl().

NLMISC::CRefPtr<CBoneBase> NL3D::CBone::_BoneBase [private]
 

Definition at line 173 of file bone.h.

Referenced by CBone(), compute(), getBoneBase(), getBoneName(), getDefaultTrack(), and getFatherId().

CMatrix NL3D::CBone::_BoneSkinMatrix [private]
 

Definition at line 180 of file bone.h.

Referenced by compute(), getBoneSkinMatrix(), and interpolateBoneSkinMatrix().

CMatrix NL3D::CBone::_LocalSkeletonMatrix [private]
 

Definition at line 176 of file bone.h.

Referenced by compute(), and getLocalSkeletonMatrix().

NLMISC::CBSphere NL3D::CBone::_MaxSphere
 

Definition at line 169 of file bone.h.

Referenced by NL3D::CSkeletonModel::computeWorldBBoxForShadow().

sint NL3D::CBone::_PivotChannelId [private]
 

Definition at line 187 of file bone.h.

Referenced by CBone(), forceAnimate(), lodEnableChannels(), and registerToChannelMixer().

sint NL3D::CBone::_PosChannelId [private]
 

Definition at line 183 of file bone.h.

Referenced by CBone(), forceAnimate(), lodEnableChannels(), and registerToChannelMixer().

sint NL3D::CBone::_RotEulerChannelId [private]
 

Definition at line 184 of file bone.h.

Referenced by CBone(), forceAnimate(), lodEnableChannels(), and registerToChannelMixer().

sint NL3D::CBone::_RotQuatChannelId [private]
 

Definition at line 185 of file bone.h.

Referenced by CBone(), forceAnimate(), lodEnableChannels(), and registerToChannelMixer().

sint NL3D::CBone::_ScaleChannelId [private]
 

Definition at line 186 of file bone.h.

Referenced by CBone(), forceAnimate(), lodEnableChannels(), and registerToChannelMixer().

CMatrix NL3D::CBone::_WorldMatrix [private]
 

Definition at line 178 of file bone.h.

Referenced by compute(), and getWorldMatrix().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:44:38 2004 for NeL by doxygen 1.3.6