#include <animation_set.h>
Inheritance diagram for NL3D::CAnimationSet:
Nevrax France
Definition at line 54 of file animation_set.h.
Public Types | |
enum | { NotFound = 0xffffffff } |
Public Member Functions | |
uint | addAnimation (const char *name, CAnimation *animation) |
uint | addSkeletonWeight (const char *name, CSkeletonWeight *skeletonWeight) |
void | build () |
CAnimation * | getAnimation (uint animationId) |
const CAnimation * | getAnimation (uint animationId) const |
uint | getAnimationIdByName (const std::string &name) const |
const std::string & | getAnimationName (uint animationId) const |
uint | getChannelIdByName (const std::string &name) const |
uint | getNumAnimation () const |
uint | getNumChannelId () const |
uint | getNumSkeletonWeight () const |
const sint & | getRefCount () const |
CSkeletonWeight * | getSkeletonWeight (uint skeletonId) |
const CSkeletonWeight * | getSkeletonWeight (uint skeletonId) const |
uint | getSkeletonWeightIdByName (const std::string &name) const |
const std::string & | getSkeletonWeightName (uint skeletonId) const |
bool | loadFromFiles (const std::string &path, bool recurse=true, const char *ext="anim", bool wantWarningMessage=true) |
void | reset () |
void | serial (NLMISC::IStream &f) |
Serial the template. | |
~CAnimationSet () | |
Data Fields | |
sint | crefs |
CPtrInfo * | pinfo |
Static Public Attributes | |
CPtrInfo | NullPtrInfo |
Private Attributes | |
std::vector< CAnimation * > | _Animation |
std::map< std::string, uint32 > | _AnimationIdByName |
std::vector< std::string > | _AnimationName |
std::map< std::string, uint32 > | _ChannelIdByName |
std::vector< CSkeletonWeight * > | _SkeletonWeight |
std::map< std::string, uint32 > | _SkeletonWeightIdByName |
std::vector< std::string > | _SkeletonWeightName |
Friends | |
struct | CPtrInfo |
|
Definition at line 58 of file animation_set.h.
00058 { NotFound=0xffffffff }; |
|
Definition at line 43 of file animation_set.cpp. References _Animation, s, and uint.
00044 { 00045 // Erase all animations. 00046 for (uint a=0; a<_Animation.size(); a++) 00047 delete _Animation[a]; 00048 for (uint s=0; s<_SkeletonWeight.size(); s++) 00049 delete _SkeletonWeight[s]; 00050 } |
|
Add an animation to the set. The pointer of the animation must be allocated with new. It is then handled by the animation set.
Definition at line 61 of file animation_set.cpp. References _Animation, _AnimationIdByName, _AnimationName, and uint. Referenced by NL3D::CLodCharacterBuilder::addAnim(), and loadFromFiles().
00062 { 00063 // Add an animation 00064 _Animation.push_back (animation); 00065 _AnimationName.push_back (name); 00066 00067 // Add an entry name / animation 00068 _AnimationIdByName.insert (std::map <std::string, uint32>::value_type (name, _Animation.size()-1)); 00069 00070 // Return animation id 00071 return _Animation.size()-1; 00072 } |
|
Add a skeleton weight to the set. The pointer of the skeletonWeight must be allocated with new. It is then handled by the animation set.
Definition at line 76 of file animation_set.cpp. References _SkeletonWeightIdByName, _SkeletonWeightName, and uint.
00077 { 00078 // Add an animation 00079 _SkeletonWeight.push_back (skeletonWeight); 00080 _SkeletonWeightName.push_back (name); 00081 00082 // Add an entry name / animation 00083 _SkeletonWeightIdByName.insert (std::map <std::string, uint32>::value_type (name, _SkeletonWeight.size()-1)); 00084 00085 // Return animation id 00086 return _SkeletonWeight.size()-1; 00087 } |
|
Final build of the animation set. First, for each animation you want to add to the set, you must add the animation in the set. When all animations are built, call this method to finlize the set. Definition at line 104 of file animation_set.cpp. References _Animation, _ChannelIdByName, getAnimation(), NL3D::CAnimation::getTrackNames(), and uint. Referenced by NL3D::CLodCharacterBuilder::addAnim(), and loadFromFiles().
00105 { 00106 // Clear the channel map 00107 _ChannelIdByName.clear (); 00108 00109 // Set of names 00110 std::set<std::string> channelNames; 00111 00112 // For each animation in the set 00113 for (uint a=0; a<_Animation.size(); a++) 00114 { 00115 // Fill the set of channel names 00116 getAnimation (a)->getTrackNames (channelNames); 00117 } 00118 00119 // Add this name in the map with there iD 00120 uint id=0; 00121 std::set<std::string>::iterator ite=channelNames.begin (); 00122 while (ite!=channelNames.end ()) 00123 { 00124 // Insert an entry 00125 _ChannelIdByName.insert (std::map <std::string, uint32>::value_type (*ite, id++)); 00126 00127 // Next entry 00128 ite++; 00129 } 00130 } |
|
Get a writable animation pointer. Definition at line 120 of file animation_set.h. References _Animation, and uint.
00121 { 00122 return _Animation[animationId]; 00123 } |
|
Get a read only animation pointer. Definition at line 112 of file animation_set.h. References _Animation, and uint. Referenced by build(), NL3D::CAnimationPlaylist::getLocalTime(), NL3D::CChannelMixer::setSlotAnimation(), and NL3D::CAnimationPlaylist::setupMixer().
00113 { 00114 return _Animation[animationId]; 00115 } |
|
Get a animation ID by name. If no channel is found, method returns NotFound. Definition at line 83 of file animation_set.h. References _AnimationIdByName, and uint. Referenced by NL3D::CLodCharacterBuilder::addAnim().
00084 { 00085 // Look for an id with this name 00086 std::map <std::string, uint32>::const_iterator ite=_AnimationIdByName.find (name); 00087 if (ite!=_AnimationIdByName.end ()) 00088 return ite->second; 00089 else 00090 return NotFound; 00091 } |
|
Get animation name. Definition at line 104 of file animation_set.h. References _AnimationName, and uint.
00105 { 00106 return _AnimationName[animationId]; 00107 } |
|
Get a channel ID with its name. If no channel is found, method returns NotFound. Definition at line 70 of file animation_set.h. References _ChannelIdByName, and uint. Referenced by NL3D::CChannelMixer::addChannel(), and NL3D::CChannelMixer::applySkeletonWeight().
00071 { 00072 // Look for an id with this name 00073 std::map <std::string, uint32>::const_iterator ite=_ChannelIdByName.find (name); 00074 if (ite!=_ChannelIdByName.end ()) 00075 return ite->second; 00076 else 00077 return NotFound; 00078 } |
|
Get animations count. Definition at line 96 of file animation_set.h. References _Animation, and uint.
00097 { 00098 return _Animation.size(); 00099 } |
|
Get channel ID count. This number is the count of different track name in the animation set. Definition at line 54 of file animation_set.cpp. References _ChannelIdByName, and uint.
00055 { 00056 return _ChannelIdByName.size (); 00057 } |
|
Get skeleton weight count. Definition at line 128 of file animation_set.h. References uint.
00129 { 00130 return _SkeletonWeight.size(); 00131 } |
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 { 00072 return crefs; 00073 } |
|
Get a writable skeleton weight pointer. Definition at line 165 of file animation_set.h. References uint.
00166 { 00167 return _SkeletonWeight[skeletonId]; 00168 } |
|
Get a read only skeleton weight pointer. Definition at line 157 of file animation_set.h. References uint. Referenced by NL3D::CChannelMixer::applySkeletonWeight().
00158 { 00159 return _SkeletonWeight[skeletonId]; 00160 } |
|
Get a skeleton weight ID by name. If no skeleton weight is found, method returns NotFound. Definition at line 136 of file animation_set.h. References _SkeletonWeightIdByName, and uint.
00137 { 00138 // Look for an id with this name 00139 std::map <std::string, uint32>::const_iterator ite=_SkeletonWeightIdByName.find (name); 00140 if (ite!=_SkeletonWeightIdByName.end ()) 00141 return ite->second; 00142 else 00143 return NotFound; 00144 } |
|
Get skeleton template name. Definition at line 149 of file animation_set.h. References _SkeletonWeightName, and uint.
00150 { 00151 return _SkeletonWeightName[skeletonId]; 00152 } |
|
Helper method. Load an animation set from animation files in a directory, then call build().
Definition at line 155 of file animation_set.cpp. References addAnimation(), build(), NLMISC::CIFile::close(), NLMISC::CFile::getExtension(), NLMISC::CPath::getPathContent(), nlinfo, NLMISC::CIFile::open(), and uint.
00156 { 00157 bool everythingOk = true; 00158 std::vector<std::string> anims; 00159 NLMISC::CPath::getPathContent(path, recurse, false, true, anims); 00160 for (uint k = 0; k < anims.size(); ++k) 00161 { 00162 std::string fileExt = NLMISC::CFile::getExtension(anims[k]); 00163 if (fileExt == ext) // an animation file ? 00164 { 00165 try 00166 { 00167 NLMISC::CIFile iFile; 00168 iFile.open(anims[k]); 00169 std::auto_ptr<CAnimation> anim(new CAnimation); 00170 anim->serial(iFile); 00171 addAnimation(NLMISC::CFile::getFilenameWithoutExtension(anims[k]).c_str(), anim.release()); 00172 iFile.close(); 00173 00174 } 00175 catch (NLMISC::EStream &e) 00176 { 00177 if (wantWarningMessage) 00178 { 00179 nlinfo("Unable to load an automatic animation : %s", e.what()); 00180 } 00181 everythingOk = false; 00182 } 00183 } 00184 } 00185 build(); 00186 return everythingOk; 00187 } |
|
Reset the animation set. Definition at line 91 of file animation_set.cpp. References _Animation, _AnimationIdByName, _AnimationName, _ChannelIdByName, _SkeletonWeightIdByName, and _SkeletonWeightName.
00092 { 00093 _Animation.clear(); 00094 _SkeletonWeight.clear(); 00095 _AnimationName.clear(); 00096 _SkeletonWeightName.clear(); 00097 _ChannelIdByName.clear(); 00098 _AnimationIdByName.clear(); 00099 _SkeletonWeightIdByName.clear(); 00100 } |
|
Serial the template.
Definition at line 134 of file animation_set.cpp. References _Animation, _AnimationIdByName, _AnimationName, _ChannelIdByName, _SkeletonWeightIdByName, _SkeletonWeightName, NLMISC::IStream::serialCheck(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialContPtr(), NLMISC::IStream::serialVersion(), and uint32.
00135 { 00136 // Serial an header 00137 f.serialCheck ((uint32)'_LEN'); 00138 f.serialCheck ((uint32)'MINA'); 00139 f.serialCheck ((uint32)'TES_'); 00140 00141 // Serial a version 00142 (void)f.serialVersion (0); 00143 00144 // Serial the class 00145 f.serialContPtr (_Animation); 00146 f.serialContPtr (_SkeletonWeight); 00147 f.serialCont (_AnimationName); 00148 f.serialCont (_SkeletonWeightName); 00149 f.serialCont(_ChannelIdByName); 00150 f.serialCont(_AnimationIdByName); 00151 f.serialCont(_SkeletonWeightIdByName); 00152 } |
|
Definition at line 67 of file smart_ptr.h. |
|
Definition at line 223 of file animation_set.h. Referenced by addAnimation(), build(), getAnimation(), getNumAnimation(), reset(), serial(), and ~CAnimationSet(). |
|
Definition at line 228 of file animation_set.h. Referenced by addAnimation(), getAnimationIdByName(), reset(), and serial(). |
|
Definition at line 225 of file animation_set.h. Referenced by addAnimation(), getAnimationName(), reset(), and serial(). |
|
Definition at line 227 of file animation_set.h. Referenced by build(), getChannelIdByName(), getNumChannelId(), reset(), and serial(). |
|
Definition at line 224 of file animation_set.h. |
|
Definition at line 229 of file animation_set.h. Referenced by addSkeletonWeight(), getSkeletonWeightIdByName(), reset(), and serial(). |
|
Definition at line 226 of file animation_set.h. Referenced by addSkeletonWeight(), getSkeletonWeightName(), reset(), and serial(). |
|
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(). |