Changeset 10656
- Timestamp:
- 10/21/09 17:45:13 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 11 modified
-
include/osgAnimation/AnimationManagerBase (modified) (2 diffs)
-
include/osgAnimation/Channel (modified) (2 diffs)
-
include/osgAnimation/Skeleton (modified) (1 diff)
-
include/osgAnimation/Skinning (modified) (2 diffs)
-
include/osgAnimation/VertexInfluence (modified) (2 diffs)
-
src/osgAnimation/Animation.cpp (modified) (1 diff)
-
src/osgAnimation/AnimationManagerBase.cpp (modified) (5 diffs)
-
src/osgAnimation/Bone.cpp (modified) (2 diffs)
-
src/osgAnimation/StatsHandler.cpp (modified) (2 diffs)
-
src/osgAnimation/Timeline.cpp (modified) (1 diff)
-
src/osgAnimation/VertexInfluence.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgAnimation/AnimationManagerBase
r10576 r10656 45 45 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); 46 46 47 /// Operation that must be done each frame 47 /** Reset the value of targets 48 this Operation must be done each frame */ 48 49 void clearTargets(); 50 49 51 50 52 LinkVisitor* getOrCreateLinkVisitor(); 51 53 void setLinkVisitor(LinkVisitor*); 54 55 /// set a flag to define the behaviour 56 void setAutomaticLink(bool); 57 bool isAutomaticLink() const; 58 59 void dirty(); 52 60 53 61 protected: … … 57 65 TargetSet _targets; 58 66 bool _needToLink; 67 bool _automaticLink; 59 68 }; 60 69 } -
OpenSceneGraph/trunk/include/osgAnimation/Channel
r10581 r10656 78 78 79 79 TemplateChannel (const TemplateChannel& channel) : 80 Channel(channel), 81 _target(new TargetType(*channel.getTargetTyped())), 82 _sampler(channel._sampler.get()) 80 Channel(channel) 83 81 { 82 if (channel.getTargetTyped()) 83 _target = new TargetType(*channel.getTargetTyped()); 84 85 if (channel.getSamplerTyped()) 86 _sampler = new SamplerType(*channel.getSamplerTyped()); 84 87 } 85 88 … … 103 106 typename KeyframeContainerType::KeyType key(0, _target->getValue()); 104 107 // recreate the keyframe container 105 _sampler = 0;108 getOrCreateSampler()->setKeyframeContainer(0); 106 109 getOrCreateSampler()->getOrCreateKeyframeContainer(); 107 110 // add the key -
OpenSceneGraph/trunk/include/osgAnimation/Skeleton
r10558 r10656 33 33 META_Object(osgAnimation, UpdateSkeleton); 34 34 UpdateSkeleton() : _needValidate(true) {} 35 UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop) { }35 UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop) { _needValidate = true;} 36 36 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); 37 37 -
OpenSceneGraph/trunk/include/osgAnimation/Skinning
r9531 r10656 47 47 public: 48 48 BoneWeight(BoneType* bone, float weight) : _bone(bone), _weight(weight) {} 49 const BoneType* getBone() const { return &(*_bone); }49 const BoneType* getBone() const { return _bone.get(); } 50 50 float getWeight() const { return _weight; } 51 51 void setWeight(float w) { _weight = w; } 52 52 protected: 53 osg:: ref_ptr<BoneType> _bone;53 osg::observer_ptr<BoneType> _bone; 54 54 float _weight; 55 55 }; … … 192 192 const VertexList& vertexes = uniq.getVertexes(); 193 193 int vertexSize = vertexes.size(); 194 for (int j = 0; j < vertexSize; j++) 194 for (int j = 0; j < vertexSize; j++) 195 195 { 196 196 int idx = vertexes[j]; -
OpenSceneGraph/trunk/include/osgAnimation/VertexInfluence
r10026 r10656 1 1 /* -*-c++-*- 2 * Copyright (C) 2008 Cedric Pinson < mornifle@plopbyte.net>2 * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net> 3 3 * 4 4 * This library is open source and may be redistributed and/or modified under … … 97 97 _uniqVertexSetToBoneSet.clear(); 98 98 } 99 100 const VertexIndexToBoneWeightMap& getVertexToBoneList() const; 99 101 protected: 100 102 BoneToVertexList _bone2Vertexes; -
OpenSceneGraph/trunk/src/osgAnimation/Animation.cpp
r10556 r10656 134 134 } 135 135 136 // std::cout << "t " << t << " / " << _duration << std::endl;137 138 136 ChannelList::const_iterator chan; 139 137 for( chan=_channels.begin(); chan!=_channels.end(); ++chan) -
OpenSceneGraph/trunk/src/osgAnimation/AnimationManagerBase.cpp
r10576 r10656 24 24 { 25 25 _needToLink = false; 26 _automaticLink = true; 26 27 } 27 28 … … 31 32 (*it).get()->reset(); 32 33 } 34 35 void AnimationManagerBase::dirty() 36 { 37 _needToLink = true; 38 } 39 40 void AnimationManagerBase::setAutomaticLink(bool state) { _automaticLink = state; } 41 bool AnimationManagerBase::isAutomaticLink() const { return _automaticLink; } 33 42 34 43 void AnimationManagerBase::operator()(osg::Node* node, osg::NodeVisitor* nv) … … 65 74 } 66 75 _needToLink = true; 76 _automaticLink = b._automaticLink; 67 77 buildTargetReference(); 68 78 } … … 71 81 { 72 82 _targets.clear(); 73 for( AnimationList::iterator iterAnim = _animations.begin(); iterAnim != _animations.end(); ++iterAnim ) 83 for( AnimationList::iterator iterAnim = _animations.begin(); iterAnim != _animations.end(); ++iterAnim ) 74 84 { 75 85 Animation* anim = (*iterAnim).get(); … … 99 109 } 100 110 101 bool AnimationManagerBase::needToLink() const { return _needToLink ; }111 bool AnimationManagerBase::needToLink() const { return _needToLink && isAutomaticLink(); } 102 112 103 113 -
OpenSceneGraph/trunk/src/osgAnimation/Bone.cpp
r10561 r10656 70 70 } 71 71 72 if (!_manager.valid())73 {74 FindParentAnimationManagerVisitor finder;75 76 if (b->getParents().size() > 1)77 {78 osg::notify(osg::WARN) << "A Bone should not have multi parent ( " << b->getName() << " ) has parents ";79 osg::notify(osg::WARN) << "( " << b->getParents()[0]->getName();80 for (int i = 1; i < (int)b->getParents().size(); i++)81 osg::notify(osg::WARN) << ", " << b->getParents()[i]->getName();82 osg::notify(osg::WARN) << ")" << std::endl;83 return;84 }85 b->getParents()[0]->accept(finder);86 87 if (!finder.getAnimationManager())88 {89 osg::notify(osg::WARN) << "Warning can't update Bone, path to parent AnimationManagerBase not found" << std::endl;90 return;91 }92 93 _manager = finder.getAnimationManager();94 }95 96 updateLink();97 72 update(*b); 98 73 … … 118 93 _boneInSkeletonSpace(b._boneInSkeletonSpace) 119 94 { 120 #if 0121 osg::ref_ptr<osg::NodeCallback> updatecallback = getUpdateCallback();122 setUpdateCallback(0);123 while (updatecallback.valid()) {124 osg::NodeCallback* ucb = dynamic_cast<osg::NodeCallback*>(updatecallback->clone(copyop));125 ucb->setNestedCallback(0);126 addUpdateCallback(ucb);127 updatecallback = updatecallback->getNestedCallback();128 }129 #endif130 95 } 131 96 -
OpenSceneGraph/trunk/src/osgAnimation/StatsHandler.cpp
r10432 r10656 564 564 565 565 for (int i = 0; i < (int)finder._timelines.size(); i++) 566 statsList.push_back(finder._timelines[ 0]->getStats());566 statsList.push_back(finder._timelines[i]->getStats()); 567 567 568 568 for(int i = statsList[0]->getEarliestFrameNumber(); i<= statsList[0]->getLatestFrameNumber()-1; ++i) … … 654 654 osg::MatrixTransform* m = s->createStatsForTimeline(finder._timelines[i].get()); 655 655 m->setUpdateCallback(s); 656 m->setMatrix(osg::Matrix::translate(0, -i * 100, 0)); 656 657 _group->addChild(m); 657 658 } -
OpenSceneGraph/trunk/src/osgAnimation/Timeline.cpp
r10561 r10656 202 202 { 203 203 _actions[priority].insert(_actions[priority].begin(), ftl); 204 // _actions[priority].push_back(ftl); 205 } 206 207 #if 0 208 void osgAnimation::Timeline::evaluateCallback(unsigned int frame) 209 { 210 // update from high priority to low priority 211 for( ActionLayers::reverse_iterator iterAnim = _actions.rbegin(); iterAnim != _actions.rend(); ++iterAnim ) 212 { 213 // update all animation 214 ActionList& list = iterAnim->second; 215 for (unsigned int i = 0; i < list.size(); i++) 216 { 217 unsigned int firstFrame = list[i].first; 218 Action* action = list[i].second.get(); 219 // check if current frame of timeline hit an action interval 220 if (frame >= firstFrame && 221 frame < (firstFrame + action->getNumFrames()) ) 222 action->evaluateCallback(frame - firstFrame); 223 } 224 } 225 processPendingOperation(); 226 } 227 #endif 204 } 228 205 229 206 bool osgAnimation::Timeline::isActive(Action* activeAction) -
OpenSceneGraph/trunk/src/osgAnimation/VertexInfluence.cpp
r9093 r10656 14 14 15 15 #include <osgAnimation/VertexInfluence> 16 #include <osg/Notify> 16 17 #include <iostream> 17 18 #include <algorithm> … … 19 20 using namespace osgAnimation; 20 21 22 const osgAnimation::VertexInfluenceSet::VertexIndexToBoneWeightMap& osgAnimation::VertexInfluenceSet::getVertexToBoneList() const { return _vertex2Bones;} 21 23 // this class manage VertexInfluence database by mesh 22 24 // reference bones per vertex ... … … 34 36 float weight = viw.second; 35 37 if (vi.getName().empty()) 36 std::cout<< "osgAnimation::VertexInfluenceSet::buildVertex2BoneList warning vertex " << index << " is not assigned to a bone" << std::endl;38 osg::notify(osg::WARN) << "osgAnimation::VertexInfluenceSet::buildVertex2BoneList warning vertex " << index << " is not assigned to a bone" << std::endl; 37 39 _vertex2Bones[index].push_back(BoneWeight(vi.getName(), weight)); 38 40 } … … 40 42 41 43 // normalize weight per vertex 42 for (VertexIndexToBoneWeightMap::iterator it = _vertex2Bones.begin(); it != _vertex2Bones.end(); it++) 44 for (VertexIndexToBoneWeightMap::iterator it = _vertex2Bones.begin(); it != _vertex2Bones.end(); it++) 43 45 { 44 46 BoneWeightList& bones = it->second; … … 49 51 if (sum < 1e-4) 50 52 { 51 std::cerr<< "VertexInfluenceSet::buildVertex2BoneList warning the vertex " << it->first << " seems to have 0 weight, skip normalize for this vertex" << std::endl;53 osg::notify(osg::WARN) << "VertexInfluenceSet::buildVertex2BoneList warning the vertex " << it->first << " seems to have 0 weight, skip normalize for this vertex" << std::endl; 52 54 } 53 55 else
