15#ifndef OSGANIMATION_MORPHGEOMETRY_H
16#define OSGANIMATION_MORPHGEOMETRY_H
61 virtual const char*
libraryName()
const {
return "osgAnimation"; }
62 virtual const char*
className()
const {
return "MorphGeometry"; }
114 _morphTargets.push_back(
MorphTarget(morphTarget, weight));
120 for(MorphTargetList::iterator iterator = _morphTargets.begin() ; iterator != _morphTargets.end() ; ++ iterator)
122 if(iterator->getGeometry() == morphTarget)
124 _morphTargets.erase(iterator);
132 for(MorphTargetList::iterator iterator = _morphTargets.begin() ; iterator != _morphTargets.end() ; ++ iterator)
134 if(iterator->getGeometry() && iterator->getGeometry()->getName() == name)
136 _morphTargets.erase(iterator);
144 inline void setWeight(
unsigned int index,
float morphWeight)
146 if (index < _morphTargets.size())
148 _morphTargets[index].setWeight(morphWeight);
154 inline void dirty(
bool b=
true) { _dirty = b; }
155 inline bool isDirty()
const {
return _dirty; }
179 typedef std::map< int, osg::ref_ptr<osgAnimation::FloatTarget> >
WeightTargets;
186 void addTarget(
const std::string& name) { _targetNames.push_back(name); }
188 const std::string&
getTargetName(
unsigned int index) {
return _targetNames[index]; }
191 TargetNames::iterator found = std::find(_targetNames.begin(), _targetNames.end(), name);
192 if(found != _targetNames.end())
193 _targetNames.erase(found);
236 (implementation)(*geom);
Definition AnimationUpdateCallback:36
Definition MorphGeometry:39
void setGeometry(osg::Geometry *geom)
Definition MorphGeometry:49
osg::Geometry * getGeometry()
Definition MorphGeometry:47
const osg::Geometry * getGeometry() const
Definition MorphGeometry:48
float getWeight() const
Definition MorphGeometry:46
MorphTarget(osg::Geometry *geom, float w=1.0)
Definition MorphGeometry:44
float _weight
Definition MorphGeometry:42
void setWeight(float weight)
Definition MorphGeometry:45
osg::ref_ptr< osg::Geometry > _geom
Definition MorphGeometry:41
Definition MorphGeometry:28
MorphTarget & getMorphTarget(unsigned int i)
Definition MorphGeometry:89
MorphTransform * getMorphTransformImplementation()
Definition MorphGeometry:66
osg::ref_ptr< MorphTransform > _morphTransformImplementation
Definition MorphGeometry:161
osg::Vec3Array * getNormalSource() const
Definition MorphGeometry:101
Method
Definition MorphGeometry:33
@ NORMALIZED
Definition MorphGeometry:34
virtual osg::Object * cloneType() const
Definition MorphGeometry:58
MorphGeometry(const MorphGeometry &b, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY)
osg::ref_ptr< osg::Vec3Array > _normalSource
Definition MorphGeometry:169
osg::ref_ptr< osg::Vec3Array > _positionSource
Definition MorphGeometry:168
Method getMethod() const
Definition MorphGeometry:72
MorphGeometry(const osg::Geometry &b)
const MorphTarget & getMorphTarget(unsigned int i) const
Definition MorphGeometry:86
virtual bool isSameKindAs(const osg::Object *obj) const
Definition MorphGeometry:60
void setMethod(Method method)
Definition MorphGeometry:70
std::vector< MorphTarget > MorphTargetList
Definition MorphGeometry:52
virtual void removeMorphTarget(osg::Geometry *morphTarget)
Definition MorphGeometry:118
bool _dirty
Do we need to recalculate the morphed geometry?
Definition MorphGeometry:163
osg::Vec3Array * getVertexSource() const
Definition MorphGeometry:95
const MorphTransform * getMorphTransformImplementation() const
Definition MorphGeometry:67
void setMorphNormals(bool morphNormals)
Definition MorphGeometry:75
void transformSoftwareMethod()
Definition MorphGeometry:158
MorphTargetList _morphTargets
Definition MorphGeometry:166
virtual void removeMorphTarget(const std::string &name)
Definition MorphGeometry:130
virtual const char * libraryName() const
Definition MorphGeometry:61
const MorphTargetList & getMorphTargetList() const
Definition MorphGeometry:80
void setNormalSource(osg::Vec3Array *n)
Definition MorphGeometry:98
Method _method
Definition MorphGeometry:165
void setWeight(unsigned int index, float morphWeight)
Definition MorphGeometry:144
void setMorphTransformImplementation(MorphTransform *mt)
Definition MorphGeometry:65
MorphTargetList & getMorphTargetList()
Definition MorphGeometry:83
virtual const char * className() const
Definition MorphGeometry:62
virtual osg::Object * clone(const osg::CopyOp ©op) const
Definition MorphGeometry:59
virtual void addMorphTarget(osg::Geometry *morphTarget, float weight=1.0)
Definition MorphGeometry:112
bool _morphNormals
Do we also morph between normals?
Definition MorphGeometry:172
void dirty(bool b=true)
Definition MorphGeometry:154
bool getMorphNormals() const
Definition MorphGeometry:77
void setVertexSource(osg::Vec3Array *v)
Definition MorphGeometry:92
bool isDirty() const
Definition MorphGeometry:155
Definition MorphGeometry:176
TargetNames _targetNames
Definition MorphGeometry:210
const std::string & getTargetName(unsigned int index)
Definition MorphGeometry:188
int link(Animation *animation)
META_Object(osgAnimation, UpdateMorph)
void removeTarget(const std::string &name)
Definition MorphGeometry:189
void setTargetNames(const TargetNames &targetNames)
Definition MorphGeometry:200
WeightTargets _weightTargets
Definition MorphGeometry:209
bool link(osgAnimation::Channel *channel)
unsigned int getNumTarget() const
Definition MorphGeometry:187
UpdateMorph(const UpdateMorph &apc, const osg::CopyOp ©op)
const std::vector< std::string > & getTargetNames() const
Definition MorphGeometry:197
void addTarget(const std::string &name)
Definition MorphGeometry:186
std::vector< std::string > & getTargetNames()
Definition MorphGeometry:198
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
UpdateMorph(const std::string &name="")
std::map< int, osg::ref_ptr< osgAnimation::FloatTarget > > WeightTargets
Definition MorphGeometry:179
std::vector< std::string > TargetNames
Definition MorphGeometry:178
Callback()
Definition Callback:38
@ SHALLOW_COPY
Definition CopyOp:47
DrawableUpdateCallback()
Definition Callback:300
Definition NodeVisitor:82
Object()
Definition Object:69
A concrete array holding elements of type T.
Definition Array:243
T * get() const
Definition ref_ptr:117
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSGANIMATION_EXPORT
Definition osgAnimation/Export:40
#define NULL
Definition osg/Export:55
Definition MorphGeometry:214
virtual void update(osg::NodeVisitor *, osg::Drawable *drw)
Definition MorphGeometry:224
UpdateMorphGeometry()
Definition MorphGeometry:215
UpdateMorphGeometry(const UpdateMorphGeometry &org, const osg::CopyOp ©op)
Definition MorphGeometry:217
META_Object(osgAnimation, UpdateMorphGeometry)