VertexInfluence
Go to the documentation of this file.
/* -*-c++-*-
* Copyright (C) 2008 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
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGANIMATION_VERTEX_INFLUENCE
#define OSGANIMATION_VERTEX_INFLUENCE 1
#include <osg/Object>
#include <osgAnimation/Export>
#include <map>
#include <vector>
#include <string>
namespace osgAnimation
{
class Skeleton;
// first is bonename, and second the weight
typedef std::pair<std::string, float> BoneWeight;
// first is vertex index, and second the weight
typedef std::pair<unsigned int, float> VertexIndexWeight;
// list of IndexWeight
typedef std::vector<VertexIndexWeight> IndexWeightList;
// list of IndexWeight
typedef std::vector<BoneWeight> BoneWeightList;
// list of Index
typedef std::vector<unsigned int> IndexList;
//Bone influence list
class OSGANIMATION_EXPORT VertexInfluence : public IndexWeightList
{
public:
const std::string& getName() const { return _name; }
void setName(const std::string& name) { _name = name; }
protected:
// the name is the bone to link to
std::string _name;
};
class VertexInfluenceMap : public std::map<std::string, VertexInfluence>, public osg::Object
{
public:
META_Object(osgAnimation, VertexInfluenceMap);
VertexInfluenceMap() {}
VertexInfluenceMap(const osgAnimation::VertexInfluenceMap& org, const osg::CopyOp& copyop):
std::map<std::string, VertexInfluence>(org),
osg::Object(org, copyop) {}
void normalize(unsigned int numvert);
void cullInfluenceCountPerVertex(unsigned int maxnumbonepervertex, float minweight=0, bool renormalize=true);
//compute PerVertexInfluenceList
void computePerVertexInfluenceList(std::vector<BoneWeightList>& perVertexInfluenceList, unsigned int numvert) const;
class VertexGroup: public std::pair<BoneWeightList, IndexList>
{
public:
inline const BoneWeightList& getBoneWeights() const { return first; }
inline void setBoneWeights( BoneWeightList& o ) { first=o; }
inline IndexList& vertIDs() { return second; }
};
void computeMinimalVertexGroupList(std::vector<VertexGroup>&uniqVertexGroupList, unsigned int numvert) const;
//Experimental removal of unexpressed bone from the skeleton
void removeUnexpressedBones(Skeleton &skel) const;
};
}
#endif
Object
osgAnimation::Skeleton
Definition Skeleton:26
osgAnimation::VertexInfluenceMap::VertexGroup
map a set of boneinfluence to a list of vertex indices sharing this set
Definition VertexInfluence:72
osgAnimation::VertexInfluenceMap::VertexGroup::vertIDs
IndexList & vertIDs()
Definition VertexInfluence:76
osgAnimation::VertexInfluenceMap::VertexGroup::getBoneWeights
const BoneWeightList & getBoneWeights() const
Definition VertexInfluence:74
osgAnimation::VertexInfluenceMap::VertexGroup::setBoneWeights
void setBoneWeights(BoneWeightList &o)
Definition VertexInfluence:75
osgAnimation::VertexInfluenceMap
Definition VertexInfluence:52
osgAnimation::VertexInfluenceMap::cullInfluenceCountPerVertex
void cullInfluenceCountPerVertex(unsigned int maxnumbonepervertex, float minweight=0, bool renormalize=true)
remove weakest influences in order to fit targeted numbonepervertex
osgAnimation::VertexInfluenceMap::VertexInfluenceMap
VertexInfluenceMap()
Definition VertexInfluence:56
osgAnimation::VertexInfluenceMap::VertexInfluenceMap
VertexInfluenceMap(const osgAnimation::VertexInfluenceMap &org, const osg::CopyOp &copyop)
Definition VertexInfluence:57
osgAnimation::VertexInfluenceMap::removeUnexpressedBones
void removeUnexpressedBones(Skeleton &skel) const
osgAnimation::VertexInfluenceMap::computeMinimalVertexGroupList
void computeMinimalVertexGroupList(std::vector< VertexGroup > &uniqVertexGroupList, unsigned int numvert) const
compute the minimal VertexGroup Set in which vertices shares the same influence set
osgAnimation::VertexInfluenceMap::normalize
void normalize(unsigned int numvert)
normalize per vertex weights given numvert of the attached mesh
osgAnimation::VertexInfluenceMap::META_Object
META_Object(osgAnimation, VertexInfluenceMap)
osgAnimation::VertexInfluenceMap::computePerVertexInfluenceList
void computePerVertexInfluenceList(std::vector< BoneWeightList > &perVertexInfluenceList, unsigned int numvert) const
osgAnimation::VertexInfluence
Definition VertexInfluence:42
osgAnimation::VertexInfluence::_name
std::string _name
Definition VertexInfluence:48
osgAnimation::VertexInfluence::getName
const std::string & getName() const
Definition VertexInfluence:44
osgAnimation::VertexInfluence::setName
void setName(const std::string &name)
Definition VertexInfluence:45
osg::CopyOp
Definition CopyOp:41
osg::Object
Definition Object:61
osg::Object::Object
Object()
Definition Object:69
osgAnimation
Definition Action:34
osgAnimation::IndexWeightList
std::vector< VertexIndexWeight > IndexWeightList
Definition VertexInfluence:34
osgAnimation::BoneWeightList
std::vector< BoneWeight > BoneWeightList
Definition VertexInfluence:36
osgAnimation::BoneWeight
std::pair< std::string, float > BoneWeight
Definition VertexInfluence:30
osgAnimation::VertexIndexWeight
std::pair< unsigned int, float > VertexIndexWeight
Definition VertexInfluence:32
osgAnimation::IndexList
std::vector< unsigned int > IndexList
Definition VertexInfluence:38
osg
Definition AlphaFunc:19
Export
OSGANIMATION_EXPORT
#define OSGANIMATION_EXPORT
Definition osgAnimation/Export:40