Changeset 10527
- Timestamp:
- 08/06/09 14:40:06 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 5 modified
-
include/osgAnimation/Bone (modified) (2 diffs)
-
include/osgAnimation/Channel (modified) (5 diffs)
-
include/osgAnimation/Interpolator (modified) (4 diffs)
-
include/osgAnimation/Sampler (modified) (4 diffs)
-
src/osgAnimation/UpdateCallback.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgAnimation/Bone
r10518 r10527 11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 * OpenSceneGraph Public License for more details. 13 */ 13 * 14 * Authors: 15 * Cedric Pinson <cedric.pinson@plopbyte.net> 16 * Michael Platings <mplatings@pixelpower.com> 17 */ 14 18 15 19 #ifndef OSGANIMATION_BONE_H … … 130 134 if (channel->getName().find("quaternion") != std::string::npos) 131 135 { 132 osgAnimation::QuatSphericalLinearChannel* qc = dynamic_cast<osgAnimation::QuatSphericalLinearChannel*>(channel); 133 if (qc) 134 { 135 qc->setTarget(_quaternion.get()); 136 return true; 137 } 136 return channel->setTarget(_quaternion.get()); 138 137 } 139 138 else if (channel->getName().find("position") != std::string::npos) 140 139 { 141 osgAnimation::Vec3LinearChannel* vc = dynamic_cast<osgAnimation::Vec3LinearChannel*>(channel); 142 if (vc) 143 { 144 vc->setTarget(_position.get()); 145 return true; 146 } 140 return channel->setTarget(_position.get()); 147 141 } 148 142 else if (channel->getName().find("scale") != std::string::npos) 149 143 { 150 osgAnimation::Vec3LinearChannel* vc = dynamic_cast<osgAnimation::Vec3LinearChannel*>(channel); 151 if (vc) 152 { 153 vc->setTarget(_scale.get()); 154 return true; 155 } 144 return channel->setTarget(_scale.get()); 156 145 } 157 146 else -
OpenSceneGraph/trunk/include/osgAnimation/Channel
r10386 r10527 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 … … 11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 * OpenSceneGraph Public License for more details. 13 */ 13 * 14 * Authors: 15 * Cedric Pinson <cedric.pinson@plopbyte.net> 16 * Michael Platings <mplatings@pixelpower.com> 17 */ 14 18 15 19 #ifndef OSGANIMATION_CHANNEL_H … … 37 41 virtual void reset() = 0; 38 42 virtual Target* getTarget() = 0; 43 virtual bool setTarget(Target*) = 0; 39 44 40 45 const std::string& getName() const; … … 99 104 virtual void reset() { _target->reset(); } 100 105 virtual Target* getTarget() { return _target.get();} 106 virtual bool setTarget(Target* target) 107 { 108 _target = dynamic_cast<TargetType*>(target); 109 return _target.get() == target; 110 } 101 111 102 SamplerType* getOrCreateSampler() 112 SamplerType* getOrCreateSampler() 103 113 { 104 114 if (!_sampler.valid()) … … 127 137 128 138 typedef std::vector<osg::ref_ptr<osgAnimation::Channel> > ChannelList; 139 140 typedef TemplateChannel<DoubleStepSampler> DoubleStepChannel; 141 typedef TemplateChannel<FloatStepSampler> FloatStepChannel; 142 typedef TemplateChannel<Vec2StepSampler> Vec2StepChannel; 143 typedef TemplateChannel<Vec3StepSampler> Vec3StepChannel; 144 typedef TemplateChannel<Vec4StepSampler> Vec4StepChannel; 145 typedef TemplateChannel<QuatStepSampler> QuatStepChannel; 146 129 147 typedef TemplateChannel<DoubleLinearSampler> DoubleLinearChannel; 130 148 typedef TemplateChannel<FloatLinearSampler> FloatLinearChannel; 131 132 149 typedef TemplateChannel<Vec2LinearSampler> Vec2LinearChannel; 133 150 typedef TemplateChannel<Vec3LinearSampler> Vec3LinearChannel; -
OpenSceneGraph/trunk/include/osgAnimation/Interpolator
r9531 r10527 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 … … 11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 * OpenSceneGraph Public License for more details. 13 */ 13 * 14 * Authors: 15 * Cedric Pinson <cedric.pinson@plopbyte.net> 16 * Michael Platings <mplatings@pixelpower.com> 17 */ 14 18 15 19 #ifndef OSGANIMATION_INTERPOLATOR_H … … 63 67 64 68 template <class TYPE, class KEY=TYPE> 69 class TemplateStepInterpolator : public TemplateInterpolatorBase<TYPE,KEY> 70 { 71 public: 72 73 TemplateStepInterpolator() {} 74 void getValue(const TemplateKeyframeContainer<KEY>& keyframes, float time, TYPE& result) const 75 { 76 77 if (time >= keyframes.back().getTime()) 78 { 79 result = keyframes.back().getValue(); 80 return; 81 } 82 else if (time <= keyframes.front().getTime()) 83 { 84 result = keyframes.front().getValue(); 85 return; 86 } 87 88 int i = getKeyIndexFromTime(keyframes,time); 89 return keyframes[i].getValue(); 90 } 91 }; 92 93 94 template <class TYPE, class KEY=TYPE> 65 95 class TemplateLinearInterpolator : public TemplateInterpolatorBase<TYPE,KEY> 66 96 { … … 184 214 } 185 215 }; 216 217 typedef TemplateStepInterpolator<double, double> DoubleStepInterpolator; 218 typedef TemplateStepInterpolator<float, float> FloatStepInterpolator; 219 typedef TemplateStepInterpolator<osg::Vec2, osg::Vec2> Vec2StepInterpolator; 220 typedef TemplateStepInterpolator<osg::Vec3, osg::Vec3> Vec3StepInterpolator; 221 typedef TemplateStepInterpolator<osg::Vec3, Vec3Packed> Vec3PackedStepInterpolator; 222 typedef TemplateStepInterpolator<osg::Vec4, osg::Vec4> Vec4StepInterpolator; 223 typedef TemplateStepInterpolator<osg::Quat, osg::Quat> QuatStepInterpolator; 186 224 187 225 typedef TemplateLinearInterpolator<double, double> DoubleLinearInterpolator; -
OpenSceneGraph/trunk/include/osgAnimation/Sampler
r9531 r10527 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 … … 11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 * OpenSceneGraph Public License for more details. 13 */ 13 * 14 * Authors: 15 * Cedric Pinson <cedric.pinson@plopbyte.net> 16 * Michael Platings <mplatings@pixelpower.com> 17 */ 14 18 15 19 #ifndef OSGANIMATION_SAMPLER_H … … 109 113 110 114 115 typedef TemplateSampler<DoubleStepInterpolator> DoubleStepSampler; 116 typedef TemplateSampler<FloatStepInterpolator> FloatStepSampler; 117 typedef TemplateSampler<Vec2StepInterpolator> Vec2StepSampler; 118 typedef TemplateSampler<Vec3StepInterpolator> Vec3StepSampler; 119 typedef TemplateSampler<Vec4StepInterpolator> Vec4StepSampler; 120 typedef TemplateSampler<QuatStepInterpolator> QuatStepSampler; 121 111 122 typedef TemplateSampler<DoubleLinearInterpolator> DoubleLinearSampler; 112 123 typedef TemplateSampler<FloatLinearInterpolator> FloatLinearSampler; … … 115 126 typedef TemplateSampler<Vec4LinearInterpolator> Vec4LinearSampler; 116 127 typedef TemplateSampler<QuatSphericalLinearInterpolator> QuatSphericalLinearSampler; 128 117 129 typedef TemplateSampler<FloatCubicBezierInterpolator> FloatCubicBezierSampler; 118 130 typedef TemplateSampler<DoubleCubicBezierInterpolator> DoubleCubicBezierSampler; -
OpenSceneGraph/trunk/src/osgAnimation/UpdateCallback.cpp
r10518 r10527 11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 * OpenSceneGraph Public License for more details. 13 */ 13 * 14 * Authors: 15 * Cedric Pinson <cedric.pinson@plopbyte.net> 16 * Michael Platings <mplatings@pixelpower.com> 17 */ 14 18 15 19 #include <osgAnimation/UpdateCallback> … … 96 100 if (channel->getName().find("euler") != std::string::npos) 97 101 { 98 osgAnimation::Vec3LinearChannel* qc = dynamic_cast<osgAnimation::Vec3LinearChannel*>(channel); 99 if (qc) 100 { 101 qc->setTarget(_euler.get()); 102 return true; 103 } 102 return channel->setTarget(_euler.get()); 104 103 } 105 104 else if (channel->getName().find("position") != std::string::npos) 106 105 { 107 osgAnimation::Vec3LinearChannel* vc = dynamic_cast<osgAnimation::Vec3LinearChannel*>(channel); 108 if (vc) 109 { 110 vc->setTarget(_position.get()); 111 return true; 112 } 106 return channel->setTarget(_position.get()); 113 107 } 114 108 else if (channel->getName().find("scale") != std::string::npos) 115 109 { 116 osgAnimation::Vec3LinearChannel* vc = dynamic_cast<osgAnimation::Vec3LinearChannel*>(channel); 117 if (vc) 118 { 119 vc->setTarget(_scale.get()); 120 return true; 121 } 110 return channel->setTarget(_scale.get()); 122 111 } 123 112 else … … 172 161 if (channel->getName().find("diffuse") != std::string::npos) 173 162 { 174 osgAnimation::Vec4LinearChannel* d = dynamic_cast<osgAnimation::Vec4LinearChannel*>(channel); 175 if (d) 176 { 177 d->setTarget(_diffuse.get()); 178 return true; 179 } 163 return channel->setTarget(_diffuse.get()); 180 164 } 181 165 else
