Changeset 13041 for OpenSceneGraph/trunk/src/osg/AnimationPath.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/AnimationPath.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/AnimationPath.cpp
r8347 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 28 28 { 29 29 if (_timeControlPointMap.empty()) return false; 30 30 31 31 switch(_loopMode) 32 32 { … … 36 36 double fraction_part = modulated_time - floor(modulated_time); 37 37 if (fraction_part>0.5) fraction_part = 1.0-fraction_part; 38 38 39 39 time = getFirstTime()+(fraction_part*2.0) * getPeriod(); 40 40 break; … … 51 51 break; 52 52 } 53 54 53 54 55 55 56 56 TimeControlPointMap::const_iterator second = _timeControlPointMap.lower_bound(time); … … 62 62 { 63 63 TimeControlPointMap::const_iterator first = second; 64 --first; 65 64 --first; 65 66 66 // we have both a lower bound and the next item. 67 67 … … 76 76 first->second, 77 77 second->second); 78 } 78 } 79 79 } 80 80 else // (second==_timeControlPointMap.end()) … … 139 139 double time3 = osg::PI*1.5/angularVelocity; 140 140 double time4 = osg::PI*2.0/angularVelocity; 141 141 142 142 osg::Quat rotation0(0.0, axis); 143 143 osg::Quat rotation1(osg::PI*0.5, axis); 144 144 osg::Quat rotation2(osg::PI*1.0, axis); 145 145 osg::Quat rotation3(osg::PI*1.5, axis); 146 147 146 147 148 148 _animationPath->insert(time0,osg::AnimationPath::ControlPoint(pivot,rotation0)); 149 149 _animationPath->insert(time1,osg::AnimationPath::ControlPoint(pivot,rotation1)); … … 169 169 else 170 170 _cp.getMatrix(matrix); 171 171 172 172 camera.setViewMatrix(osg::Matrix::translate(-_pivotPoint)*matrix); 173 173 } 174 174 175 175 176 176 virtual void apply(CameraView& cv) … … 183 183 cv.setAttitude(_cp.getRotation().inverse()); 184 184 cv.setFocalLength(1.0f/_cp.getScale().x()); 185 185 186 186 } 187 187 else … … 200 200 else 201 201 _cp.getMatrix(matrix); 202 202 203 203 mt.setMatrix(osg::Matrix::translate(-_pivotPoint)*matrix); 204 204 } 205 205 206 206 virtual void apply(PositionAttitudeTransform& pat) 207 207 { … … 214 214 pat.setScale(osg::Vec3(1.0f/_cp.getScale().x(),1.0f/_cp.getScale().y(),1.0f/_cp.getScale().z())); 215 215 pat.setPivotPoint(_pivotPoint); 216 216 217 217 } 218 218 else … … 224 224 } 225 225 } 226 226 227 227 AnimationPath::ControlPoint _cp; 228 228 osg::Vec3d _pivotPoint; 229 bool _useInverseMatrix; 229 bool _useInverseMatrix; 230 230 }; 231 231 232 232 void AnimationPathCallback::operator()(Node* node, NodeVisitor* nv) 233 233 { 234 if (_animationPath.valid() && 235 nv->getVisitorType()==NodeVisitor::UPDATE_VISITOR && 234 if (_animationPath.valid() && 235 nv->getVisitorType()==NodeVisitor::UPDATE_VISITOR && 236 236 nv->getFrameStamp()) 237 237 { … … 246 246 } 247 247 } 248 248 249 249 // must call any nested node callbacks and continue subgraph traversal. 250 250 NodeCallback::traverse(node,nv); … … 284 284 return; 285 285 } 286 286 287 287 _pause = pause; 288 288
