Changeset 13041 for OpenSceneGraph/trunk/src/osg/AutoTransform.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/AutoTransform.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/AutoTransform.cpp
r12321 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 */ … … 59 59 _side(pat._side) 60 60 { 61 // setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); 61 // setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); 62 62 } 63 63 64 64 void AutoTransform::setAutoRotateMode(AutoRotateMode mode) 65 { 66 _autoRotateMode = mode; 67 _firstTimeToInitEyePoint = true; 65 { 66 _autoRotateMode = mode; 67 _firstTimeToInitEyePoint = true; 68 68 _cachedMode = CACHE_DIRTY; 69 69 updateCache(); … … 94 94 } 95 95 else _cachedMode = _autoRotateMode; 96 96 97 97 _side = _axis^_normal; 98 _side.normalize(); 98 _side.normalize(); 99 99 } 100 100 101 101 void AutoTransform::setScale(const Vec3d& scale) 102 102 { 103 _scale = scale; 103 _scale = scale; 104 104 if (_scale.x()<_minimumScale) _scale.x() = _minimumScale; 105 105 if (_scale.y()<_minimumScale) _scale.y() = _minimumScale; 106 106 if (_scale.z()<_minimumScale) _scale.z() = _minimumScale; 107 107 108 108 if (_scale.x()>_maximumScale) _scale.x() = _maximumScale; 109 109 if (_scale.y()>_maximumScale) _scale.y() = _maximumScale; 110 110 if (_scale.z()>_maximumScale) _scale.z() = _maximumScale; 111 112 _matrixDirty=true; 111 112 _matrixDirty=true; 113 113 dirtyBound(); 114 114 } … … 118 118 { 119 119 if (_matrixDirty) computeMatrix(); 120 120 121 121 if (_referenceFrame==RELATIVE_RF) 122 122 { … … 156 156 { 157 157 if (!_matrixDirty) return; 158 158 159 159 _cachedMatrix.makeRotate(_rotation); 160 160 _cachedMatrix.postMultTranslate(_position); 161 161 _cachedMatrix.preMultScale(_scale); 162 162 _cachedMatrix.preMultTranslate(-_pivotPoint); 163 163 164 164 _matrixDirty = false; 165 165 } … … 167 167 void AutoTransform::accept(NodeVisitor& nv) 168 168 { 169 if (nv.validNodeMask(*this)) 169 if (nv.validNodeMask(*this)) 170 170 { 171 171 // if app traversal update the frame count. … … 191 191 } 192 192 193 osg::Vec3d eyePoint = cs->getEyeLocal(); 194 osg::Vec3d localUp = cs->getUpLocal(); 193 osg::Vec3d eyePoint = cs->getEyeLocal(); 194 osg::Vec3d localUp = cs->getUpLocal(); 195 195 osg::Vec3d position = getPosition(); 196 196 … … 216 216 doUpdate = true; 217 217 } 218 else if (projection != _previousProjection) 219 { 220 doUpdate = true; 221 } 222 else if (position != _previousPosition) 223 { 224 doUpdate = true; 225 } 218 else if (projection != _previousProjection) 219 { 220 doUpdate = true; 221 } 222 else if (position != _previousPosition) 223 { 224 doUpdate = true; 225 } 226 226 } 227 227 _firstTimeToInitEyePoint = false; 228 228 229 229 if (doUpdate) 230 { 230 { 231 231 232 232 if (getAutoScaleToScreen()) … … 235 235 236 236 if (_autoScaleTransitionWidthRatio>0.0) 237 { 237 { 238 238 if (_minimumScale>0.0) 239 239 { 240 240 double j = _minimumScale; 241 double i = (_maximumScale<DBL_MAX) ? 241 double i = (_maximumScale<DBL_MAX) ? 242 242 _minimumScale+(_maximumScale-_minimumScale)*_autoScaleTransitionWidthRatio : 243 243 _minimumScale*(1.0+_autoScaleTransitionWidthRatio); … … 264 264 if (size>p) size = _maximumScale; 265 265 else if (size>m) size = a + b*size + c*(size*size); 266 } 266 } 267 267 } 268 268 269 269 setScale(size); 270 270 } … … 276 276 osg::Vec3d scale; 277 277 osg::Quat so; 278 278 279 279 cs->getModelViewMatrix()->decompose( translation, rotation, scale, so ); 280 280 … … 351 351 break; 352 352 } 353 case(ROTATE_TO_AXIS): // need to implement 353 case(ROTATE_TO_AXIS): // need to implement 354 354 { 355 355 float ev_side = ev*_side;
