Changeset 13041 for OpenSceneGraph/trunk/include/osgAnimation/MorphGeometry
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgAnimation/MorphGeometry
r12139 r13041 1 /* -*-c++-*- 1 /* -*-c++-*- 2 2 * Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net> 3 3 * 4 * This library is open source and may be redistributed and/or modified under 5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 4 * This library is open source and may be redistributed and/or modified under 5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 6 6 * (at your option) any later version. The full license is in LICENSE file 7 7 * included with this distribution, and on the openscenegraph.org website. 8 * 8 * 9 9 * This library is distributed in the hope that it will be useful, 10 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 * OpenSceneGraph Public License for more details. 13 13 */ … … 20 20 #include <osg/Geometry> 21 21 22 namespace osgAnimation 22 namespace osgAnimation 23 23 { 24 24 25 25 class OSGANIMATION_EXPORT MorphGeometry : public osg::Geometry 26 26 { 27 27 28 28 public: 29 29 30 30 enum Method { 31 31 NORMALIZED, 32 32 RELATIVE 33 33 }; 34 34 35 35 class MorphTarget 36 36 { … … 72 72 73 73 virtual void transformSoftwareMethod(); 74 74 75 75 /** Set the morphing method. */ 76 76 void setMethod(Method method) { _method = method; } 77 77 /** Get the morphing method. */ 78 78 inline Method getMethod() const { return _method; } 79 79 80 80 /** Set flag for morphing normals. */ 81 81 void setMorphNormals(bool morphNormals) { _morphNormals = morphNormals; } 82 82 /** Get the flag for morphing normals. */ 83 83 inline bool getMorphNormals() const { return _morphNormals; } 84 84 85 85 /** Add a \c MorphTarget to the \c MorphGeometry. 86 86 * If \c MorphTarget is not \c NULL and is not contained in the \c MorphGeometry … … 93 93 */ 94 94 virtual void addMorphTarget( osg::Geometry *morphTarget, float weight = 1.0 ) { _morphTargets.push_back(MorphTarget(morphTarget, weight)); _dirty = true; } 95 95 96 96 void setWeight(unsigned int index, float morphWeight) 97 { 98 if (index < _morphTargets.size()) 99 { 97 { 98 if (index < _morphTargets.size()) 99 { 100 100 _morphTargets[index].setWeight(morphWeight); 101 101 dirty(); … … 105 105 /** Set the MorphGeometry dirty.*/ 106 106 void dirty() { _dirty = true; } 107 107 108 108 /** Get the list of MorphTargets.*/ 109 109 const MorphTargetList& getMorphTargetList() const { return _morphTargets; } … … 111 111 /** Get the list of MorphTargets. Warning if you modify this array you will have to call dirty() */ 112 112 MorphTargetList& getMorphTargetList() { return _morphTargets; } 113 113 114 114 /** Return the \c MorphTarget at position \c i.*/ 115 115 inline const MorphTarget& getMorphTarget( unsigned int i ) const { return _morphTargets[i]; } … … 124 124 Method _method; 125 125 MorphTargetList _morphTargets; 126 126 127 127 std::vector<osg::Vec3> _positionSource; 128 128 std::vector<osg::Vec3> _normalSource; 129 129 130 130 /// Do we also morph between normals? 131 131 bool _morphNormals; 132 132 }; 133 133 134 134 class OSGANIMATION_EXPORT UpdateMorph : public AnimationUpdateCallback<osg::NodeCallback> 135 135 { 136 136 protected: 137 137 std::map<int, osg::ref_ptr<osgAnimation::FloatTarget> > _weightTargets; 138 138 139 139 public: 140 140
