This commit is contained in:
Julien Valentin
2017-08-30 13:21:32 +02:00
parent 985d766f05
commit fd9b8f103e
5 changed files with 67 additions and 101 deletions

View File

@@ -17,7 +17,7 @@
#include <osgAnimation/Export>
#include <osgAnimation/Skeleton>
#include <osgAnimation/RigTransformSoftware>
#include <osgAnimation/RigTransform>
#include <osgAnimation/VertexInfluence>
#include <osg/Geometry>

View File

@@ -38,36 +38,32 @@ namespace osgAnimation
META_Object(osgAnimation,RigTransformHardware);
typedef osg::Matrix MatrixType;
typedef std::vector<osg::ref_ptr<osg::Vec4Array> > BoneWeightAttribList;
typedef std::vector<osg::ref_ptr<Bone> > BonePalette;
typedef std::map<std::string, unsigned int> BoneNamePaletteIndex;
typedef std::vector<osg::Matrix> MatrixPalette;
osg::Vec4Array* getVertexAttrib(unsigned int index);
unsigned int getNumVertexAttrib();
unsigned int getNumVertexAttrib() const {return _boneWeightAttribArrays.size();}
void setShader(osg::Shader* shader) { _shader = shader; }
osg::Shader* getShader() const { return _shader; }
const unsigned int &getNumBonesPerVertex() const{ return _bonesPerVertex; }
const unsigned int &getNumVertexes() const { return _nbVertexes; }
const BoneNamePaletteIndex& getBoneNameToPalette(){ return _boneNameToPalette; }
const BonePalette& getBonePalette() { return _bonePalette; }
osg::Uniform* getMatrixPaletteUniform() { return _uniformMatrixPalette; }
osg::Uniform* getMatrixPaletteUniform();
void computeMatrixPaletteUniform(const osg::Matrix& transformFromSkeletonToGeometry, const osg::Matrix& invTransformFromSkeletonToGeometry);
unsigned int getNumBonesPerVertex() const;
unsigned int getNumVertexes() const;
virtual void operator()(RigGeometry&);
virtual bool prepareData(RigGeometry& );
void setShader(osg::Shader*);
const BoneNamePaletteIndex& getBoneNameToPalette() {
return _boneNameToPalette;
}
protected:
osg::Uniform* createVertexUniform();
unsigned int _bonesPerVertex;
unsigned int _nbVertexes;
@@ -79,7 +75,7 @@ namespace osgAnimation
bool _needInit;
bool buildPalette(BoneMap&boneMap ,RigGeometry&rig);
bool buildPalette(const BoneMap& boneMap ,const RigGeometry& rig);
};
}

View File

@@ -129,7 +129,7 @@ namespace osgAnimation
inline void compute(const osg::Matrix& transform, const osg::Matrix& invTransform, const V* src, V* dst)
{
// the result of matrix mult should be cached to be used for vertexes transform and normal transform and maybe other computation
for(VertexGroupList::iterator itvg=_uniqInfluenceSet2VertIDList.begin(); itvg!=_uniqInfluenceSet2VertIDList.end(); ++itvg)
for(VertexGroupList::iterator itvg=_uniqVertexGroupList.begin(); itvg!=_uniqVertexGroupList.end(); ++itvg)
{
VertexGroup& uniq = *itvg;
uniq.computeMatrixForVertexSet();
@@ -148,7 +148,7 @@ namespace osgAnimation
template <class V>
inline void computeNormal(const osg::Matrix& transform, const osg::Matrix& invTransform, const V* src, V* dst)
{
for(VertexGroupList::iterator itvg=_uniqInfluenceSet2VertIDList.begin(); itvg!=_uniqInfluenceSet2VertIDList.end(); ++itvg)
for(VertexGroupList::iterator itvg=_uniqVertexGroupList.begin(); itvg!=_uniqVertexGroupList.end(); ++itvg)
{
VertexGroup& uniq = *itvg;
uniq.computeMatrixForVertexSet();
@@ -170,7 +170,7 @@ namespace osgAnimation
typedef std::vector<VertexGroup> VertexGroupList;
VertexGroupList _uniqInfluenceSet2VertIDList;
VertexGroupList _uniqVertexGroupList;
void buildMinimumUpdateSet(const BoneMap&boneMap,const RigGeometry&rig );
};