replace VertexInfluence to BoneInfluenceList

and VertexIndexWeight to IndexWeight

fix in example
This commit is contained in:
Julien Valentin 2017-08-27 02:14:12 +02:00
parent 4f0256bcc3
commit ca224c81dd
8 changed files with 25 additions and 25 deletions

View File

@ -145,7 +145,7 @@ struct SetupRigGeometry : public osg::NodeVisitor
if (_hardware) { if (_hardware) {
osgAnimation::RigGeometry* rig = dynamic_cast<osgAnimation::RigGeometry*>(&geom); osgAnimation::RigGeometry* rig = dynamic_cast<osgAnimation::RigGeometry*>(&geom);
if (rig) if (rig)
rig->setRigTransformImplementation(new MyRigTransformHardware); rig->setRigTransformImplementation(new osgAnimation::RigTransformHardware);
} }
#if 0 #if 0

View File

@ -146,11 +146,11 @@ void initVertexMap(osgAnimation::Bone* b0,
float val = (*array)[i][0]; float val = (*array)[i][0];
std::cout << val << std::endl; std::cout << val << std::endl;
if (val >= -1.0f && val <= 0.0f) if (val >= -1.0f && val <= 0.0f)
(*vim)[b0->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); (*vim)[b0->getName()].push_back(osgAnimation::IndexWeight(i,1.0f));
else if ( val > 0.0f && val <= 1.0f) else if ( val > 0.0f && val <= 1.0f)
(*vim)[b1->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); (*vim)[b1->getName()].push_back(osgAnimation::IndexWeight(i,1.0f));
else if ( val > 1.0f) else if ( val > 1.0f)
(*vim)[b2->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); (*vim)[b2->getName()].push_back(osgAnimation::IndexWeight(i,1.0f));
} }
geom->setInfluenceMap(vim); geom->setInfluenceMap(vim);

View File

@ -25,9 +25,9 @@ namespace osgAnimation
{ {
// first is vertex index, and second the weight, the // first is vertex index, and second the weight, the
typedef std::pair<unsigned int, float> VertexIndexWeight; typedef std::pair<unsigned int, float> IndexWeight;
typedef std::vector<VertexIndexWeight> VertexList; typedef std::vector<IndexWeight> VertexList;
class OSGANIMATION_EXPORT VertexInfluence : public VertexList class OSGANIMATION_EXPORT BoneInfluenceList : public VertexList
{ {
public: public:
const std::string& getName() const { return _name;} const std::string& getName() const { return _name;}
@ -38,14 +38,14 @@ namespace osgAnimation
std::string _name; std::string _name;
}; };
class VertexInfluenceMap : public std::map<std::string, VertexInfluence> , public osg::Object class VertexInfluenceMap : public std::map<std::string, BoneInfluenceList> , public osg::Object
{ {
public: public:
META_Object(osgAnimation, VertexInfluenceMap); META_Object(osgAnimation, VertexInfluenceMap);
VertexInfluenceMap() {} VertexInfluenceMap() {}
VertexInfluenceMap(const osgAnimation::VertexInfluenceMap& org, const osg::CopyOp& copyop): VertexInfluenceMap(const osgAnimation::VertexInfluenceMap& org, const osg::CopyOp& copyop):
std::map<std::string, VertexInfluence>(org), std::map<std::string, BoneInfluenceList>(org),
osg::Object(org, copyop) osg::Object(org, copyop)
{} {}
}; };
@ -56,7 +56,7 @@ namespace osgAnimation
class OSGANIMATION_EXPORT VertexInfluenceSet class OSGANIMATION_EXPORT VertexInfluenceSet
{ {
public: public:
typedef std::vector<VertexInfluence> BoneToVertexList; typedef std::vector<BoneInfluenceList> BoneToVertexList;
class BoneWeight class BoneWeight
{ {
@ -95,7 +95,7 @@ namespace osgAnimation
void buildUniqVertexGroupList(); void buildUniqVertexGroupList();
/** return a list of unique VertexGroups and their influences**/ /** return a list of unique VertexGroups and their influences**/
const UniqVertexGroupList& getUniqVertexGroupList() const { return _uniqVertexSetToBoneSet;} const UniqVertexGroupList& getUniqVertexGroupList() const { return _uniqVertexSetToBoneSet;}
void addVertexInfluence(const VertexInfluence& v); void addVertexInfluence(const BoneInfluenceList& v);
void buildVertex2BoneList(unsigned int numvertices); void buildVertex2BoneList(unsigned int numvertices);
void clear(); void clear();

View File

@ -20,7 +20,7 @@
using namespace osgAnimation; using namespace osgAnimation;
void VertexInfluenceSet::addVertexInfluence(const VertexInfluence& v) { _bone2Vertexes.push_back(v); } void VertexInfluenceSet::addVertexInfluence(const BoneInfluenceList& v) { _bone2Vertexes.push_back(v); }
const VertexInfluenceSet::VertIDToBoneWeightList& VertexInfluenceSet::getVertexToBoneList() const { return _vertex2Bones;} const VertexInfluenceSet::VertIDToBoneWeightList& VertexInfluenceSet::getVertexToBoneList() const { return _vertex2Bones;}
// this class manage VertexInfluence database by mesh // this class manage VertexInfluence database by mesh
// reference bones per vertex ... // reference bones per vertex ...
@ -33,11 +33,11 @@ void VertexInfluenceSet::buildVertex2BoneList(unsigned int numvertices)
for (BoneToVertexList::const_iterator it = _bone2Vertexes.begin(); it != _bone2Vertexes.end(); ++it) for (BoneToVertexList::const_iterator it = _bone2Vertexes.begin(); it != _bone2Vertexes.end(); ++it)
{ {
const VertexInfluence& vi = (*it); const BoneInfluenceList& vi = (*it);
int size = vi.size(); int size = vi.size();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
VertexIndexWeight viw = vi[i]; IndexWeight viw = vi[i];
int index = viw.first; int index = viw.first;
float weight = viw.second; float weight = viw.second;
if (vi.getName().empty()){ if (vi.getName().empty()){

View File

@ -51,7 +51,7 @@ void ComputeAABBOnBoneVisitor::computeBoundingBoxOnBones() {
osg::Vec3Array *vertices = dynamic_cast<osg::Vec3Array*>(rigGeometry->getVertexArray()); osg::Vec3Array *vertices = dynamic_cast<osg::Vec3Array*>(rigGeometry->getVertexArray());
if(!vertices) continue; if(!vertices) continue;
osgAnimation::VertexInfluence vxtInf = (*itMap).second; osgAnimation::BoneInfluenceList vxtInf = (*itMap).second;
//Expand the boundingBox with each vertex //Expand the boundingBox with each vertex
for(unsigned int j = 0; j < vxtInf.size(); j++) { for(unsigned int j = 0; j < vxtInf.size(); j++) {

View File

@ -200,9 +200,9 @@ protected:
BoneNameBoneMap::iterator bone_it = boneMap.find(vertexInfluencePair->first); BoneNameBoneMap::iterator bone_it = boneMap.find(vertexInfluencePair->first);
if(bone_it == boneMap.end()) continue; if(bone_it == boneMap.end()) continue;
osg::ref_ptr<osgAnimation::Bone> bone = bone_it->second; osg::ref_ptr<osgAnimation::Bone> bone = bone_it->second;
const osgAnimation::VertexInfluence& vertexInfluence = (*vertexInfluencePair).second; const osgAnimation::BoneInfluenceList& vertexInfluence = (*vertexInfluencePair).second;
for(osgAnimation::VertexInfluence::const_iterator vertexIndexWeight = vertexInfluence.begin(); vertexIndexWeight != vertexInfluence.end(); ++vertexIndexWeight) { for(osgAnimation::BoneInfluenceList::const_iterator vertexIndexWeight = vertexInfluence.begin(); vertexIndexWeight != vertexInfluence.end(); ++vertexIndexWeight) {
rigGeometryInfluenceByBoneMap[bone.get()][*rigGeometry].addWeight((*vertexIndexWeight).second); rigGeometryInfluenceByBoneMap[bone.get()][*rigGeometry].addWeight((*vertexIndexWeight).second);
} }
} }

View File

@ -813,7 +813,7 @@ bool RigGeometry_readLocalData(Object& obj, Input& fr)
iteratorAdvanced = true; iteratorAdvanced = true;
} }
osgAnimation::VertexInfluence vi; osgAnimation::BoneInfluenceList vi;
vi.setName(name); vi.setName(name);
vi.reserve(nbVertexes); vi.reserve(nbVertexes);
for (int j = 0; j < nbVertexes; j++) for (int j = 0; j < nbVertexes; j++)
@ -827,7 +827,7 @@ bool RigGeometry_readLocalData(Object& obj, Input& fr)
fr += 2; fr += 2;
iteratorAdvanced = true; iteratorAdvanced = true;
} }
vi.push_back(osgAnimation::VertexIndexWeight(index, weight)); vi.push_back(osgAnimation::IndexWeight(index, weight));
} }
if (fr.matchSequence("}")) if (fr.matchSequence("}"))
{ {
@ -863,8 +863,8 @@ bool RigGeometry_writeLocalData(const Object& obj, Output& fw)
name = "Empty"; name = "Empty";
fw.indent() << "osgAnimation::VertexInfluence \"" << name << "\" " << it->second.size() << " {" << std::endl; fw.indent() << "osgAnimation::VertexInfluence \"" << name << "\" " << it->second.size() << " {" << std::endl;
fw.moveIn(); fw.moveIn();
const osgAnimation::VertexInfluence& vi = it->second; const osgAnimation::BoneInfluenceList& vi = it->second;
for (osgAnimation::VertexInfluence::const_iterator itv = vi.begin(); itv != vi.end(); itv++) for (osgAnimation::BoneInfluenceList::const_iterator itv = vi.begin(); itv != vi.end(); itv++)
{ {
fw.indent() << itv->first << " " << itv->second << std::endl; fw.indent() << itv->first << " " << itv->second << std::endl;
} }

View File

@ -20,7 +20,7 @@ static bool readInfluenceMap( osgDB::InputStream& is, osgAnimation::RigGeometry&
is.readWrappedString(name); is.readWrappedString(name);
viSize = is.readSize(); is >> is.BEGIN_BRACKET; viSize = is.readSize(); is >> is.BEGIN_BRACKET;
osgAnimation::VertexInfluence vi; osgAnimation::BoneInfluenceList vi;
vi.setName( name ); vi.setName( name );
vi.reserve( viSize ); vi.reserve( viSize );
for ( unsigned int j=0; j<viSize; ++j ) for ( unsigned int j=0; j<viSize; ++j )
@ -28,7 +28,7 @@ static bool readInfluenceMap( osgDB::InputStream& is, osgAnimation::RigGeometry&
int index = 0; int index = 0;
float weight = 0.0f; float weight = 0.0f;
is >> index >> weight; is >> index >> weight;
vi.push_back( osgAnimation::VertexIndexWeight(index, weight) ); vi.push_back( osgAnimation::IndexWeight(index, weight) );
} }
(*map)[name] = vi; (*map)[name] = vi;
is >> is.END_BRACKET; is >> is.END_BRACKET;
@ -47,14 +47,14 @@ static bool writeInfluenceMap( osgDB::OutputStream& os, const osgAnimation::RigG
itr!=map->end(); ++itr ) itr!=map->end(); ++itr )
{ {
std::string name = itr->first; std::string name = itr->first;
const osgAnimation::VertexInfluence& vi = itr->second; const osgAnimation::BoneInfluenceList& vi = itr->second;
if ( name.empty() ) name = "Empty"; if ( name.empty() ) name = "Empty";
os << os.PROPERTY("VertexInfluence"); os << os.PROPERTY("VertexInfluence");
os.writeWrappedString(name); os.writeWrappedString(name);
os.writeSize(vi.size()) ; os << os.BEGIN_BRACKET << std::endl; os.writeSize(vi.size()) ; os << os.BEGIN_BRACKET << std::endl;
for ( osgAnimation::VertexInfluence::const_iterator vitr=vi.begin(); for ( osgAnimation::BoneInfluenceList::const_iterator vitr=vi.begin();
vitr != vi.end(); ++vitr ) vitr != vi.end(); ++vitr )
{ {
os << vitr->first << vitr->second << std::endl; os << vitr->first << vitr->second << std::endl;