Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SkeletonT.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 //-----------------------------------------------------------------------------
51 //
52 // CLASS SkeletonT - IMPLEMENTATION
53 //
54 //-----------------------------------------------------------------------------
55 
56 #define SKELETON_C
57 
58 //== INCLUDES =================================================================
59 
60 #include <iostream>
61 #include <algorithm>
62 #include <utility>
63 
64 #include "SkeletonT.hh"
65 
66 #include "Animation/FrameAnimationT.hh"
67 
68 
69 //-----------------------------------------------------------------------------
70 // ITERATOR - IMPLEMENTATION
71 //-----------------------------------------------------------------------------
72 
78 template<typename PointT>
80 {
81  pCurrent_ = 0;
82 }
83 
84 //-----------------------------------------------------------------------------
85 
91 template<typename PointT>
93 {
94  pCurrent_ = _root;
95 }
96 
97 //-----------------------------------------------------------------------------
98 
105 template<typename PointT>
107 {
108  pCurrent_ = other.pCurrent_;
109  stJoints_ = other.stJoints_;
110 }
111 
112 //-----------------------------------------------------------------------------
113 
118 template<typename PointT>
120 {
121 }
122 
123 //-----------------------------------------------------------------------------
124 
131 template<typename PointT>
133 {
134  pCurrent_ = other.pCurrent_;
135  stJoints_ = other.stJoints_;
136  return *this;
137 }
138 
139 //-----------------------------------------------------------------------------
140 
146 template<typename PointT>
148 {
149  if(pCurrent_ == 0)
150  return *this;
151 
152  // try to make this iterator point to the first child
153  if(pCurrent_->size() > 0)
154  {
155  // there are children, so add the current joint to the stack and choose the first child as new current position
156  stJoints_.push(pCurrent_);
157  pCurrent_ = pCurrent_->child(0);
158  }else{
159 
160  if ( pCurrent_->isRoot() ){
161  //root without children -> return invalid iterator
162  pCurrent_ = 0;
163 
164  } else {
165  // there are no children left, so try to get the next sibling
166  Joint *pSibling = nextSibling(stJoints_.top(), pCurrent_);
167 
168  while(pSibling == 0 && !stJoints_.empty())
169  {
170  // there is no sibling, so try the parents sibling and so on
171  Joint *pParent = stJoints_.top();
172  stJoints_.pop();
173  if(!stJoints_.empty())
174  pSibling = nextSibling(stJoints_.top(), pParent);
175  }
176 
177  // did we fail to find a next node?
178  // if so pSibling is 0 now and will invalidate the iterator
179  pCurrent_ = pSibling;
180  }
181  }
182  return *this;
183 }
184 
185 //-----------------------------------------------------------------------------
186 
192 template<typename PointT>
194 {
195  return pCurrent_ != other.pCurrent_;
196 }
197 
198 //-----------------------------------------------------------------------------
199 
205 template<typename PointT>
207 {
208  return pCurrent_ == other.pCurrent_;
209 }
210 
211 //-----------------------------------------------------------------------------
212 
216 template<typename PointT>
218 {
219  return pCurrent_;
220 }
221 
222 //-----------------------------------------------------------------------------
223 
234 template<typename PointT>
236 {
237  return pCurrent_;
238 }
239 
240 //-----------------------------------------------------------------------------
241 
248 template<typename PointT>
250 {
251  return pCurrent_ != 0;
252 }
253 
254 //-----------------------------------------------------------------------------
255 
263 template<typename PointT>
265 {
266  // first find the current node in the parents list of children
267  typename Joint::ChildIter it;
268  for(it = _pParent->begin(); it != _pParent->end(); ++it)
269  {
270  if(*it == _pJoint)
271  {
272  // found it. If there is another child it is the wanted sibling
273  ++it;
274  if(it == _pParent->end())
275  return 0; // oh no, we ran out of siblings
276 
277  return *it;
278  }
279  }
280 
281  return 0;
282 }
283 
284 //-----------------------------------------------------------------------------
285 // AnimationIterator - IMPLEMENTATION
286 //-----------------------------------------------------------------------------
287 
293 template<typename PointT>
294 SkeletonT<PointT>::AnimationIterator::AnimationIterator(std::vector<Animation*>& _animations ) :
295  animations_(_animations)
296 {
297  currentIndex_ = 0;
298 
299  // Increment, until we are at the end or we found a valid animation which is not deleted ( == 0 )
300  while ( currentIndex_ < animations_.size() && animations_[currentIndex_] == 0) {
301  currentIndex_++;
302  }
303 
304 }
305 
310 template<typename PointT>
311 SkeletonT<PointT>::AnimationIterator::AnimationIterator(std::vector<Animation*>& _animations, unsigned int _animationIndex ) :
312 animations_(_animations)
313 {
314  currentIndex_ = _animationIndex;
315 
316  // Increment, until we are at the end or we found a valid animation which is not deleted ( == 0 )
317  while ( currentIndex_ < animations_.size() && animations_[currentIndex_] == 0) {
318  currentIndex_++;
319  }
320 }
321 
327 template<typename PointT>
329  currentIndex_++;
330 
331  // Increment, until we are at the end or we found a valid animation which is not deleted ( == 0 )
332  while ( currentIndex_ < animations_.size() && animations_[currentIndex_] == 0) {
333  currentIndex_++;
334  }
335 
336  return *this;
337 }
338 
343 template<typename PointT>
345  currentIndex_ = other.currentIndex_;
346  animations_ = other.animations_;
347  return *this;
348 }
349 
355 template<typename PointT>
357  return ( currentIndex_ < animations_.size() );
358 }
359 
364 template<typename PointT>
366  return AnimationHandle(currentIndex_);
367 }
368 
369 //-----------------------------------------------------------------------------
370 // SKELETONT - IMPLEMENTATION
371 //-----------------------------------------------------------------------------
372 
376 template<typename PointT>
378 {
379 }
380 
381 //-----------------------------------------------------------------------------
382 
388 template<typename PointT>
390  Properties(),
391  referencePose_(this)
392 {
393  // create a copy of the joints, not yet linked because they refer to each other using pointers
394  for(typename std::vector<Joint*>::const_iterator it = _other.joints_.begin(); it != _other.joints_.end(); ++it)
395  {
396  joints_.push_back(new Joint(**it));
397  insert_property_at( (*it)->id() );
398  }
399 
400  // construct the links
401  for(typename std::vector<Joint*>::const_iterator it = _other.joints_.begin(); it != _other.joints_.end(); ++it)
402  {
403  Joint *pJoint = *it;
404 
405  if(pJoint->parent() != 0)
406  joint(pJoint->id())->parent_ = joint(pJoint->parent()->id());
407  else
408  joint(pJoint->id())->parent_ = 0;
409  for(typename Joint::ChildIter it_ch = pJoint->begin(); it_ch != pJoint->end(); ++it_ch)
410  joint(pJoint->id())->children_.push_back( joint((*it_ch)->id()) );
411  }
412 
413  names_.insert(_other.names_.begin(), _other.names_.end());
414 
415  for(typename std::vector<Animation*>::const_iterator it = _other.animations_.begin(); it != _other.animations_.end(); ++it)
416  if (*it) {
417  animations_.push_back((**it).copy());
418  }
419 
421 }
422 
423 //-----------------------------------------------------------------------------
424 
430 template<typename PointT>
432 
433  if (this != &_other){ // protect against invalid self-assignment
434 
435  // clear the current skeleton
436  clear();
437 
438  // create a copy of the joints, not yet linked because they refer to each other using pointers
439  for(typename std::vector<Joint*>::const_iterator it = _other.joints_.begin(); it != _other.joints_.end(); ++it){
440  joints_.push_back(new Joint(**it));
441  insert_property_at( (*it)->id() );
442  }
443 
444  // construct the links
445  for(typename std::vector<Joint*>::const_iterator it = _other.joints_.begin(); it != _other.joints_.end(); ++it){
446  Joint *pJoint = *it;
447 
448  if(pJoint->parent() != 0)
449  joint(pJoint->id())->parent_ = joint(pJoint->parent()->id());
450  else
451  joint(pJoint->id())->parent_ = 0;
452 
453  for(typename Joint::ChildIter it_ch = pJoint->begin(); it_ch != pJoint->end(); ++it_ch)
454  joint(pJoint->id())->children_.push_back( joint((*it_ch)->id()) );
455  }
456 
457  names_.insert(_other.names_.begin(), _other.names_.end());
458 
459  for(typename std::vector<Animation*>::const_iterator it = _other.animations_.begin(); it != _other.animations_.end(); ++it)
460  if (*it)
461  animations_.push_back((**it).copy());
462 
463  referencePose_ = _other.referencePose_;
464  }
465 
466  return *this;
467 }
468 
469 //-----------------------------------------------------------------------------
470 
475 template<typename PointT>
477 {
478  // clear the joints and animations
479  clear();
480 }
481 
482 //-----------------------------------------------------------------------------
483 
493 template<typename PointT>
495 {
496  unsigned int newJointID;
497 
498  if(_pParent == 0)
499  {
500  clear();
501  clean_properties();
502 
503  _pJoint->setId(0);
504  joints_.push_back(_pJoint);
505 
506  newJointID = 0;
507  }else{
508  _pParent->children_.push_back(_pJoint); // tell the parent about the new child
509  _pJoint->setId(joints_.size()); // set its id
510  joints_.push_back(_pJoint); // add it to the skeleton vector
511 
512  newJointID = joints_.size() - 1;
513  }
514 
515  //onAddJoint
516  insert_property_at(newJointID);
517 
518  referencePose_.insertJointAt(newJointID);
519  for(typename std::vector<Animation*>::iterator it = animations_.begin(); it != animations_.end(); ++it)
520  if (*it)
521  (*it)->insertJointAt(newJointID);
522 
523  referencePose_.updateFromGlobal(0, true);
524 }
525 
526 //-----------------------------------------------------------------------------
527 
537 template<typename PointT>
539 {
540 
541  if (joints_.size() == 1){
542  std::cerr << "Cannot delete last joint. Delete the skeleton instead." << std::endl;
543  return;
544  }
545 
546  remove_property_at(_pJoint->id());
547  referencePose_.removeJointAt(_pJoint->id());
548 
549  for(typename std::vector<Animation*>::iterator it = animations_.begin(); it != animations_.end(); ++it)
550  if (*it) (*it)->removeJointAt(_pJoint->id());
551 
552  // Reattach the deleted joint's children to the joint's parent
553  typename SkeletonT<PointT>::Joint::ChildIter c_it = _pJoint->begin();
554 
555  if( _pJoint->parent() == 0 ){
556  //root removal
557  typename SkeletonT<PointT>::Joint* newRoot = *c_it; //first child is new root
558  newRoot->parent_ = 0;
559  ++c_it;
560 
561  for ( ; c_it!=_pJoint->end(); ++c_it) {
562  (*c_it)->parent_ = newRoot;
563  newRoot->children_.push_back(*c_it);
564  }
565 
566  } else {
567 
568  for ( ; c_it!=_pJoint->end(); ++c_it) {
569  (*c_it)->parent_ = _pJoint->parent_;
570  _pJoint->parent_->children_.push_back(*c_it);
571  }
572 
573  if(std::remove(_pJoint->parent_->children_.begin(), _pJoint->parent_->children_.end(), _pJoint) != _pJoint->parent_->children_.end()) // remove the joint from its parent
574  _pJoint->parent_->children_.resize(_pJoint->parent_->children_.size() - 1);
575  }
576 
577  typename std::vector<Joint*>::iterator it = joints_.begin() + _pJoint->id(); // iterator pointing to the element that has to be erased
578  it = joints_.erase(it); // erase the element
579  for(; it != joints_.end(); ++it) // for all following elements
580  (*it)->setId((*it)->id() - 1); // reduce their index by one (since they have been moved there)
581 
582  referencePose_.updateFromGlobal(0, true);
583  for (typename std::vector<Animation*>::iterator a_it = animations_.begin(); a_it != animations_.end(); ++a_it) {
584  if (*a_it)
585  (*a_it)->updateFromGlobal(0);
586  }
587 }
588 
589 //-----------------------------------------------------------------------------
590 
598 template<typename PointT>
600 {
601  // no joints, so no animation either
602  clean_properties();
603  clearAnimations();
604 
605  // clear the joints
606  typename std::vector<Joint*>::iterator it;
607  for(it = joints_.begin(); it != joints_.end(); ++it)
608  delete *it;
609 
610  joints_.clear();
611  names_.clear();
612 }
613 
614 //-----------------------------------------------------------------------------
615 
623 template<typename PointT>
625 {
626  if(joints_.empty())
627  return 0;
628  return joints_[0];
629 }
630 
631 //-----------------------------------------------------------------------------
632 
641 template<typename PointT>
642 inline typename SkeletonT<PointT>::Joint *SkeletonT<PointT>::joint(const unsigned int& _index)
643 {
644  if(_index >= joints_.size())
645  return 0;
646  return joints_[_index];
647 }
648 
649 //-----------------------------------------------------------------------------
650 
657 template<typename PointT>
658 int SkeletonT<PointT>::parent(unsigned int _joint)
659 {
660  if(joints_[_joint]->parent() == 0)
661  return -1;
662  return joints_[_joint]->parent()->id();
663 }
664 
665 //-----------------------------------------------------------------------------
666 
670 template<typename PointT>
671 unsigned int SkeletonT<PointT>::childCount(unsigned int _joint)
672 {
673  if ( _joint >= joints_.size() ){
674  std::cerr << "SkeletonT : childCount() called with non-existing joint " << _joint << std::endl;
675  return 0;
676  }
677 
678  return joints_[_joint]->size();
679 }
680 
681 //-----------------------------------------------------------------------------
682 
689 template<typename PointT>
690 unsigned int SkeletonT<PointT>::child(unsigned int _joint, unsigned int _child)
691 {
692  return joints_[_joint]->child(_child)->id();
693 }
694 
695 //-----------------------------------------------------------------------------
696 
700 template<typename PointT>
702 {
703  return joints_.size();
704 }
705 
706 //-----------------------------------------------------------------------------
707 
713 template<typename PointT>
715 {
716  return Iterator(root());
717 }
718 
719 //-----------------------------------------------------------------------------
720 
724 template<typename PointT>
726 {
727  // why return Iterator(0)? operator= will compare the current pointer, and 0 is used once the iterator
728  // passed the last joint
729  return Iterator(0);
730 }
731 
732 
733 //-----------------------------------------------------------------------------
734 
740 template<typename PointT>
742 {
743  if(_hAni.isValid() && _hAni.animationIndex() < animations_.size() && animations_[_hAni.animationIndex()] != NULL)
744  return animations_[_hAni.animationIndex()]->pose(_hAni.frame());
745  else
746  return &referencePose_;
747 }
748 
749 //-----------------------------------------------------------------------------
750 
760 template<typename PointT>
762 {
763  return &referencePose_;
764 }
765 
766 //-----------------------------------------------------------------------------
767 
774 template<typename PointT>
776 {
777  // try to find an unused animation slot first
778  typename std::vector<Animation*>::iterator f;
779  for(f = animations_.begin(); f != animations_.end(); ++f)
780  if(*f == 0)
781  break;
782 
783  if(f == animations_.end())
784  {
785  // all in use, append
786  names_.insert( std::pair<std::string, unsigned int>(_name, animations_.size()) );
787  animations_.push_back(_animation);
788  }else{
789  // found an empty one, use it
790  names_.insert( std::pair<std::string, unsigned int>(_name, f - animations_.begin()) );
791  *f = _animation;
792  }
793 
794  if (_animation)
795  _animation->setName(_name);
796 
797  return AnimationHandle(names_[_name]);
798 }
799 
800 //-----------------------------------------------------------------------------
801 
808 template<typename PointT>
810 {
811  // try to find an unused animation slot first
812  typename std::vector<Animation*>::iterator f;
813  for(f = animations_.begin(); f != animations_.end(); ++f)
814  if(*f == 0)
815  break;
816 
817  if(f == animations_.end())
818  {
819  // all in use, append
820  names_.insert( std::pair<std::string, unsigned int>(_name, animations_.size()) );
821  if(animation(_hAni) != 0)
822  animations_.push_back((*animation(_hAni)).copy());
823  else
824  animations_.push_back(new FrameAnimationT<Point>(referencePose_));
825  }else{
826  // found an empty one, use it
827  names_.insert( std::pair<std::string, unsigned int>(_name, f - animations_.begin()) );
828  if(animation(_hAni) != 0)
829  *f = (*animation(_hAni)).copy();
830  else
831  *f = new FrameAnimationT<Point>(referencePose_);
832  }
833 
834  return AnimationHandle(names_[_name]);
835 }
836 
837 //-----------------------------------------------------------------------------
838 
842 template<typename PointT>
844 {
845  std::map<std::string, unsigned int>::iterator f = names_.find(_name);
846  if(f == names_.end())
847  return AnimationHandle();
848 
849  return AnimationHandle(f->second);
850 }
851 
852 //-----------------------------------------------------------------------------
853 
857 template<typename PointT>
859 {
860  std::map<std::string, unsigned int>::iterator f = names_.find(_name);
861  if(f == names_.end())
862  return 0;
863 
864  return animations_[f->second];
865 }
866 
867 //-----------------------------------------------------------------------------
868 
872 template<typename PointT>
874 {
875  if(!_hAni.isValid())
876  return 0;
877  return animations_[_hAni.animationIndex()];
878 }
879 
880 //-----------------------------------------------------------------------------
881 
885 template<typename PointT>
886 void SkeletonT<PointT>::removeAnimation(std::string _name)
887 {
888  // get an iterator for the animation
889  std::map<std::string, unsigned int>::iterator f = names_.find(_name);
890  if(f == names_.end())
891  return;
892 
893  // delete the animation
894  delete animations_[f->second];
895  animations_[f->second] = 0;
896  // remove the name entry
897  names_.erase(f);
898 }
899 
900 //-----------------------------------------------------------------------------
901 
905 template<typename PointT>
907 {
908  // delete the animation
909  delete animations_[_hAni.animationIndex()];
910  animations_[_hAni.animationIndex()] = 0;
911 
912  // remove the name entry
913  for(typename std::map<std::string, unsigned int>::iterator it = names_.begin(); it != names_.end(); ++it)
914  {
915  if(it->second == _hAni.animationIndex())
916  {
917  names_.erase(it);
918  break;
919  }
920  }
921 }
922 
923 //-----------------------------------------------------------------------------
924 
928 template<typename PointT>
930 {
931  names_.clear();
932 
933  for(typename std::vector<Animation*>::iterator it = animations_.begin(); it != animations_.end(); ++it)
934  delete *it;
935  animations_.clear();
936 }
937 
938 //-----------------------------------------------------------------------------
939 
944 template<typename PointT>
946 {
947  return AnimationIterator(animations_);
948 }
949 
950 //-----------------------------------------------------------------------------
951 
955 template<typename PointT>
957 {
958 
959  return AnimationIterator(animations_.size());
960 }
961 
962 
963 //-----------------------------------------------------------------------------
964 
970 template<typename PointT>
972 {
973  return names_.size();
974 }
975 
976 //-----------------------------------------------------------------------------
977 
983 template<typename PointT>
984 const std::string &SkeletonT<PointT>::animationName(unsigned int _index)
985 {
986  unsigned int i = 0;
987  std::map<std::string, unsigned int>::iterator pos = names_.begin();
988 
989  while(pos->second != _index && pos != names_.end())
990  {
991  ++i;
992  ++pos;
993  }
994 
995  return pos->first;
996 }
997 
998 //-----------------------------------------------------------------------------
999 
1005 template<typename PointT>
1006 void SkeletonT<PointT>::updateFromGlobal(unsigned int _idJoint)
1007 {
1008  referencePose_.updateFromGlobal(_idJoint);
1009  for(typename std::vector<Animation*>::iterator it = animations_.begin(); it != animations_.end(); ++it) {
1010  if (*it)
1011  (*it)->updateFromGlobal(_idJoint);
1012  }
1013 }
1014 
1015 //-----------------------------------------------------------------------------
1016 
1023 template<typename PointT>
1025 {
1026  if (!_pChild || !_pChild->parent() || !_pInsert)
1027  return;
1028 
1029  Joint* parent = _pChild->parent();
1030 
1031  //update IDs of our joints
1032  unsigned int childID = _pChild->id();
1033  for(typename std::vector<Joint*>::iterator it = joints_.begin() + childID; it != joints_.end(); ++it)
1034  (*it)->setId((*it)->id() + 1);
1035 
1036  //insert our new joint into this skeleton
1037  joints_.insert(joints_.begin() + childID, _pInsert);
1038  _pInsert->setId(childID);
1039 
1040  //update the parents
1041  //note: pChild will be automatically erased in parent->children_
1042  _pInsert->setParent(parent, *this);
1043  _pChild->setParent(_pInsert, *this);
1044 
1045  insert_property_at(childID);
1046 
1047  referencePose_.insertJointAt(childID);
1048  for(typename std::vector<Animation*>::iterator it = animations_.begin(); it != animations_.end(); ++it)
1049  if (*it)
1050  (*it)->insertJointAt(childID);
1051 
1052  referencePose_.updateFromGlobal(0, true);
1053 }
1054 
1055 //-----------------------------------------------------------------------------
1056 
unsigned int child(unsigned int _joint, unsigned int _child)
Returns the child with the given index.
Definition: SkeletonT.cc:690
bool isValid() const
Returns true if the handle is valid.
unsigned int childCount(unsigned int _joint)
Returns the number of children of the given node.
Definition: SkeletonT.cc:671
AnimationIterator(std::vector< Animation * > &_animations)
Default constructor.
Definition: SkeletonT.cc:294
ChildIter begin()
Returns an iterator on the joints children.
Definition: JointT.cc:181
std::vector< Joint * > joints_
Joints of the skeleton.
Definition: SkeletonT.hh:221
int parent(unsigned int _joint)
Returns the parents id of the given node.
Definition: SkeletonT.cc:658
Iterator class for the animations attached to a skeleton.
Definition: SkeletonT.hh:120
void addJoint(typename SkeletonT< PointT >::Joint *_pParent, typename SkeletonT< PointT >::Joint *_pJoint)
Adds a joint as child of a given parent joint.
Definition: SkeletonT.cc:494
void clearAnimations()
Removes all animations.
Definition: SkeletonT.cc:929
bool operator==(const Iterator &other) const
Compares the iterators.
Definition: SkeletonT.cc:206
Pose referencePose_
The skeletons reference pose.
Definition: SkeletonT.hh:229
~Iterator()
Destructor.
Definition: SkeletonT.cc:119
The properties storage class.
Definition: Properties.hh:100
Pose * pose(const AnimationHandle &_hAni)
Returns a pointer to the pose with the given animation handle.
Definition: SkeletonT.cc:741
Joint * root()
Returns the root joint.
Definition: SkeletonT.cc:624
AnimationIterator animationsEnd()
Returns an iterator pointing behind the last animation.
Definition: SkeletonT.cc:956
Pose * referencePose()
Returns a pointer to the reference pose.
Definition: SkeletonT.cc:761
Joint * child(size_t _index)
Returns the child joint with the given index.
Definition: JointT.cc:217
Joint * nextSibling(Joint *_pParent, Joint *_pJoint)
Given a parent and one of its child nodes this method finds and returns the next sibling.
Definition: SkeletonT.cc:264
std::vector< Joint * > children_
The joints children, use the JointT::getChild method to access them.
Definition: JointT.hh:129
Animation * animation(std::string _name)
Returns a pointer to the animation to the given name.
Definition: SkeletonT.cc:858
void insert_property_at(int _index)
Inserts a property for a new object at the given index.
Definition: Properties.cc:113
Iterator & operator=(const Iterator &other)
Assignment Operator.
Definition: SkeletonT.cc:132
ChildIter end()
Returns the end iterator for the joints children.
Definition: JointT.cc:192
void removeAnimation(std::string _name)
Removes an animation from the list.
Definition: SkeletonT.cc:886
~SkeletonT()
Destructor.
Definition: SkeletonT.cc:476
A general pose, used to store the frames of the animation.
Definition: PoseT.hh:68
unsigned int jointCount()
Returns the number of joints.
Definition: SkeletonT.cc:701
unsigned int animationIndex() const
Returns the animation index (zero based)
Iterator end()
Compare an iterator with the return value of this method to test if it is done.
Definition: SkeletonT.cc:725
Iterator class for the skeleton.
Definition: SkeletonT.hh:88
Iterator()
Default constructor.
Definition: SkeletonT.cc:79
Joint * joint(const unsigned int &_index)
Returns the joint with the given index.
Definition: SkeletonT.cc:642
void removeJoint(typename SkeletonT< PointT >::Joint *_pJoint)
Remove the given joint from the tree.
Definition: SkeletonT.cc:538
AnimationHandle animationHandle(std::string _name)
Get an AnimationHandle to the animation with the given name.
Definition: SkeletonT.cc:843
AnimationHandle cloneAnimation(std::string _name, const AnimationHandle &_hAni)
Creates a new animation by cloning an existing one.
Definition: SkeletonT.cc:809
AnimationIterator & operator=(const AnimationIterator &other)
Operator =.
Definition: SkeletonT.cc:344
Iterator begin()
Iterator over joints of the skeletal tree in TOP-DOWN order (from root to leafs)
Definition: SkeletonT.cc:714
AnimationIterator & operator++()
Increase the iterator.
Definition: SkeletonT.cc:328
Joint * parent_
The parent joint; this joint is in its parents JointT::children_ vector. It's 0 for the root node...
Definition: JointT.hh:127
std::map< std::string, unsigned int > names_
Binds a name to each animation.
Definition: SkeletonT.hh:224
Joint * parent()
Returns the parent joint.
Definition: JointT.cc:162
unsigned int animationCount()
Returns the number of animations stored in this skeleton.
Definition: SkeletonT.cc:971
Joint * operator->() const
Returns a pointer to the current joint.
Definition: SkeletonT.cc:235
void updateFromGlobal(unsigned int _idJoint)
update the structure when parent changes for a joint
Definition: SkeletonT.cc:1006
unsigned int frame() const
Returns the selected frame (zero based)
bool operator!=(const Iterator &other) const
Compares the iterators.
Definition: SkeletonT.cc:193
void insertJoint(typename SkeletonT< PointT >::Joint *_pChild, typename SkeletonT< PointT >::Joint *_pInsert)
insert a Joint given its future child joint
Definition: SkeletonT.cc:1024
Iterator & operator++()
Increase the iterator.
Definition: SkeletonT.cc:147
AnimationHandle operator*() const
Get an animation handle for the current animation.
Definition: SkeletonT.cc:365
unsigned int id()
returns the joint id
Definition: JointT.cc:103
A handle used to refer to an animation or to a specific frame in an animation.
SkeletonT & operator=(const SkeletonT< PointT > &_other)
Assignment operator.
Definition: SkeletonT.cc:431
Stores a single animation.
Definition: AnimationT.hh:67
Joint * operator*() const
Returns a pointer to the current joint.
Definition: SkeletonT.cc:217
const std::string & animationName(unsigned int _index)
Returns the name of the animation with the given index.
Definition: SkeletonT.cc:984
AnimationHandle addAnimation(std::string _name, Animation *_animation)
Adds a new animation to the list.
Definition: SkeletonT.cc:775
Represents a single joint in the skeleton.
Definition: JointT.hh:66
void setParent(Joint *_newParent, SkeletonT< PointT > &_skeleton)
access parent of the joint
Definition: JointT.cc:128
std::vector< Animation * > animations_
Animations defined on the skeleton.
Definition: SkeletonT.hh:226
AnimationIterator animationsBegin()
Iterator over the animations.
Definition: SkeletonT.cc:945
void clear()
Removes all joints from the skeleton.
Definition: SkeletonT.cc:599
SkeletonT()
Default constructor.
Definition: SkeletonT.cc:377