set defaut implementation at creation
This commit is contained in:
parent
0c9a624026
commit
059fc70337
@ -61,25 +61,25 @@ namespace osgAnimation
|
||||
virtual const char* className() const { return "MorphGeometry"; }
|
||||
|
||||
// set implementation of rig method
|
||||
void setMorphTransformImplementation(MorphTransform*);
|
||||
MorphTransform* getMorphTransformImplementation();
|
||||
const MorphTransform* getMorphTransformImplementation() const { return _rigTransformImplementation.get(); }
|
||||
inline void setMorphTransformImplementation(MorphTransform*mt) { _morphTransformImplementation=mt; }
|
||||
inline MorphTransform* getMorphTransformImplementation() { return _morphTransformImplementation.get(); }
|
||||
inline const MorphTransform* getMorphTransformImplementation() const { return _morphTransformImplementation.get(); }
|
||||
|
||||
/** Set the morphing method. */
|
||||
void setMethod(Method method) { _method = method; }
|
||||
inline void setMethod(Method method) { _method = method; }
|
||||
/** Get the morphing method. */
|
||||
inline Method getMethod() const { return _method; }
|
||||
|
||||
/** Set flag for morphing normals. */
|
||||
void setMorphNormals(bool morphNormals) { _morphNormals = morphNormals; }
|
||||
inline void setMorphNormals(bool morphNormals) { _morphNormals = morphNormals; }
|
||||
/** Get the flag for morphing normals. */
|
||||
inline bool getMorphNormals() const { return _morphNormals; }
|
||||
|
||||
/** Get the list of MorphTargets.*/
|
||||
const MorphTargetList& getMorphTargetList() const { return _morphTargets; }
|
||||
inline const MorphTargetList& getMorphTargetList() const { return _morphTargets; }
|
||||
|
||||
/** Get the list of MorphTargets. Warning if you modify this array you will have to call dirty() */
|
||||
MorphTargetList& getMorphTargetList() { return _morphTargets; }
|
||||
inline MorphTargetList& getMorphTargetList() { return _morphTargets; }
|
||||
|
||||
/** Return the \c MorphTarget at position \c i.*/
|
||||
inline const MorphTarget& getMorphTarget( unsigned int i ) const { return _morphTargets[i]; }
|
||||
@ -130,7 +130,7 @@ namespace osgAnimation
|
||||
}
|
||||
|
||||
/** update a morph target at index setting its current weight to morphWeight */
|
||||
void setWeight(unsigned int index, float morphWeight)
|
||||
inline void setWeight(unsigned int index, float morphWeight)
|
||||
{
|
||||
if (index < _morphTargets.size())
|
||||
{
|
||||
@ -144,10 +144,10 @@ namespace osgAnimation
|
||||
inline bool isDirty()const { return _dirty; }
|
||||
|
||||
/** for retrocompatibility */
|
||||
virtual void transformSoftwareMethod(){ if (!_rigTransformImplementation.valid())_rigTransformImplementation = new MorphTransformSoftware();(*_rigTransformImplementation.get())(*this);}
|
||||
virtual void transformSoftwareMethod(){(*_morphTransformImplementation.get())(*this);}
|
||||
|
||||
protected:
|
||||
osg::ref_ptr<MorphTransform> _rigTransformImplementation;
|
||||
osg::ref_ptr<MorphTransform> _morphTransformImplementation;
|
||||
/// Do we need to recalculate the morphed geometry?
|
||||
bool _dirty;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
* Copyright (C) 2017 Julien Valentin <mp3butcher@hotmail.com>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
|
@ -145,10 +145,6 @@ namespace osgAnimation
|
||||
}
|
||||
geom->setSkeleton(finder._root.get());
|
||||
|
||||
if(!geom->getRigTransformImplementation())
|
||||
{
|
||||
geom->setRigTransformImplementation(new RigTransformSoftware);
|
||||
}
|
||||
geom->getRigTransformImplementation()->prepareData(*geom);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ MorphGeometry::MorphGeometry() :
|
||||
setUseDisplayList(false);
|
||||
setUpdateCallback(new UpdateMorphGeometry);
|
||||
setUseVertexBufferObjects(true);
|
||||
_morphTransformImplementation = new MorphTransformSoftware();
|
||||
}
|
||||
|
||||
MorphGeometry::MorphGeometry(const osg::Geometry& g) :
|
||||
@ -41,10 +42,12 @@ MorphGeometry::MorphGeometry(const osg::Geometry& g) :
|
||||
setUseDisplayList(false);
|
||||
setUpdateCallback(new UpdateMorphGeometry);
|
||||
setUseVertexBufferObjects(true);
|
||||
_morphTransformImplementation = new MorphTransformSoftware();
|
||||
}
|
||||
|
||||
MorphGeometry::MorphGeometry(const MorphGeometry& b, const osg::CopyOp& copyop) :
|
||||
osg::Geometry(b,copyop),
|
||||
_morphTransformImplementation((MorphTransform*)copyop(b._morphTransformImplementation)),
|
||||
_dirty(b._dirty),
|
||||
_method(b._method),
|
||||
_morphTargets(b._morphTargets),
|
||||
@ -56,9 +59,6 @@ MorphGeometry::MorphGeometry(const MorphGeometry& b, const osg::CopyOp& copyop)
|
||||
setUseVertexBufferObjects(true);
|
||||
}
|
||||
|
||||
MorphTransform* MorphGeometry::getMorphTransformImplementation() { return _rigTransformImplementation.get(); }
|
||||
void MorphGeometry::setMorphTransformImplementation(MorphTransform* rig) { _rigTransformImplementation = rig; }
|
||||
|
||||
UpdateMorph::UpdateMorph(const UpdateMorph& apc,const osg::CopyOp& copyop) :
|
||||
osg::Object(apc, copyop),
|
||||
osg::Callback(apc, copyop),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*-c++-*-
|
||||
* Copyleft 2016 Valentin Julien
|
||||
* Copyright (C) 2017 Julien Valentin <mp3butcher@hotmail.com>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
|
@ -59,6 +59,7 @@ RigGeometry::RigGeometry()
|
||||
_matrixFromSkeletonToGeometry = _invMatrixFromSkeletonToGeometry = osg::Matrix::identity();
|
||||
// disable the computation of boundingbox for the rig mesh
|
||||
setComputeBoundingBoxCallback(new RigComputeBoundingBoxCallback());
|
||||
_rigTransformImplementation = new osgAnimation::RigTransformSoftware;
|
||||
|
||||
}
|
||||
|
||||
@ -66,6 +67,7 @@ RigGeometry::RigGeometry()
|
||||
RigGeometry::RigGeometry(const RigGeometry& b, const osg::CopyOp& copyop) :
|
||||
osg::Geometry(b,copyop),
|
||||
_geometry(b._geometry),
|
||||
_rigTransformImplementation((RigTransform*)copyop(b._rigTransformImplementation)),
|
||||
_vertexInfluenceMap(b._vertexInfluenceMap),
|
||||
_needToComputeMatrix(b._needToComputeMatrix)
|
||||
{
|
||||
@ -100,7 +102,7 @@ void RigGeometry::computeMatrixFromRootSkeleton()
|
||||
|
||||
void RigGeometry::update()
|
||||
{
|
||||
RigTransform& implementation = *getRigTransformImplementation();
|
||||
RigTransform& implementation = *_rigTransformImplementation;
|
||||
(implementation)(*this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user