RigTransformHardware
Go to the documentation of this file.
/* -*-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
* (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_RIG_TRANSFORM_HARDWARE
#define OSGANIMATION_RIG_TRANSFORM_HARDWARE 1
#include <osgAnimation/Export>
#include <osgAnimation/RigTransform>
#include <osgAnimation/VertexInfluence>
#include <osgAnimation/Bone>
#include <osg/Matrix>
#include <osg/Array>
#define RIGTRANSHW_DEFAULT_FIRST_VERTATTRIB_TARGETTED 11
namespace osgAnimation
{
class RigGeometry;
class OSGANIMATION_EXPORT RigTransformHardware : public RigTransform
{
public:
RigTransformHardware();
RigTransformHardware(const RigTransformHardware& rth, const osg::CopyOp& copyop);
META_Object(osgAnimation,RigTransformHardware);
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;
void setFirstVertexAttributeTarget(unsigned int i) { _minAttribIndex=i; }
unsigned int getFirstVertexAttributeTarget()const { return _minAttribIndex; }
void setShader(osg::Shader* shader) { _shader = shader; }
const osg::Shader* getShader() const { return _shader.get(); }
osg::Shader* getShader() { return _shader.get(); }
osg::Vec4Array* getVertexAttrib(unsigned int index);
unsigned int getNumVertexAttrib() const { return _boneWeightAttribArrays.size(); }
const unsigned int &getNumBonesPerVertex() const { return _bonesPerVertex; }
const unsigned int &getNumVertexes() const { return _nbVertices; }
const BoneNamePaletteIndex& getBoneNameToPalette() { return _boneNameToPalette; }
const BonePalette& getBonePalette() { return _bonePalette; }
osg::Uniform* getMatrixPaletteUniform() { return _uniformMatrixPalette.get(); }
void computeMatrixPaletteUniform(const osg::Matrix& transformFromSkeletonToGeometry, const osg::Matrix& invTransformFromSkeletonToGeometry);
// update rig if needed
virtual void operator()(RigGeometry&);
// init/reset animations data
virtual bool prepareData(RigGeometry& );
protected:
unsigned int _bonesPerVertex;
unsigned int _nbVertices;
BonePalette _bonePalette;
BoneNamePaletteIndex _boneNameToPalette;
BoneWeightAttribList _boneWeightAttribArrays;
osg::ref_ptr<osg::Uniform> _uniformMatrixPalette;
osg::ref_ptr<osg::Shader> _shader;
bool _needInit;
unsigned int _minAttribIndex;
bool buildPalette(const BoneMap& boneMap,const RigGeometry& rig);
//on first update
virtual bool init(RigGeometry& );
std::vector<IndexWeightList> _perVertexInfluences;
};
}
#endif
Array
Bone
Matrix
RigTransform
VertexInfluence
osgAnimation::RigGeometry
Definition RigGeometry:50
osgAnimation::RigTransformHardware::_shader
osg::ref_ptr< osg::Shader > _shader
Definition RigTransformHardware:83
osgAnimation::RigTransformHardware::getNumVertexes
const unsigned int & getNumVertexes() const
Definition RigTransformHardware:60
osgAnimation::RigTransformHardware::prepareData
virtual bool prepareData(RigGeometry &)
osgAnimation::RigTransformHardware::getFirstVertexAttributeTarget
unsigned int getFirstVertexAttributeTarget() const
Definition RigTransformHardware:50
osgAnimation::RigTransformHardware::META_Object
META_Object(osgAnimation, RigTransformHardware)
osgAnimation::RigTransformHardware::_uniformMatrixPalette
osg::ref_ptr< osg::Uniform > _uniformMatrixPalette
Definition RigTransformHardware:82
osgAnimation::RigTransformHardware::BonePalette
std::vector< osg::ref_ptr< Bone > > BonePalette
Definition RigTransformHardware:44
osgAnimation::RigTransformHardware::getMatrixPaletteUniform
osg::Uniform * getMatrixPaletteUniform()
Definition RigTransformHardware:64
osgAnimation::RigTransformHardware::operator()
virtual void operator()(RigGeometry &)
osgAnimation::RigTransformHardware::computeMatrixPaletteUniform
void computeMatrixPaletteUniform(const osg::Matrix &transformFromSkeletonToGeometry, const osg::Matrix &invTransformFromSkeletonToGeometry)
osgAnimation::RigTransformHardware::getNumBonesPerVertex
const unsigned int & getNumBonesPerVertex() const
Definition RigTransformHardware:59
osgAnimation::RigTransformHardware::getBonePalette
const BonePalette & getBonePalette()
Definition RigTransformHardware:63
osgAnimation::RigTransformHardware::_nbVertices
unsigned int _nbVertices
Definition RigTransformHardware:77
osgAnimation::RigTransformHardware::RigTransformHardware
RigTransformHardware()
osgAnimation::RigTransformHardware::setShader
void setShader(osg::Shader *shader)
Definition RigTransformHardware:52
osgAnimation::RigTransformHardware::buildPalette
bool buildPalette(const BoneMap &boneMap, const RigGeometry &rig)
osgAnimation::RigTransformHardware::RigTransformHardware
RigTransformHardware(const RigTransformHardware &rth, const osg::CopyOp &copyop)
osgAnimation::RigTransformHardware::getVertexAttrib
osg::Vec4Array * getVertexAttrib(unsigned int index)
osgAnimation::RigTransformHardware::MatrixPalette
std::vector< osg::Matrix > MatrixPalette
Definition RigTransformHardware:46
osgAnimation::RigTransformHardware::init
virtual bool init(RigGeometry &)
osgAnimation::RigTransformHardware::getShader
osg::Shader * getShader()
Definition RigTransformHardware:54
osgAnimation::RigTransformHardware::_needInit
bool _needInit
Definition RigTransformHardware:85
osgAnimation::RigTransformHardware::_boneWeightAttribArrays
BoneWeightAttribList _boneWeightAttribArrays
Definition RigTransformHardware:81
osgAnimation::RigTransformHardware::getNumVertexAttrib
unsigned int getNumVertexAttrib() const
Definition RigTransformHardware:57
osgAnimation::RigTransformHardware::getBoneNameToPalette
const BoneNamePaletteIndex & getBoneNameToPalette()
Definition RigTransformHardware:62
osgAnimation::RigTransformHardware::_minAttribIndex
unsigned int _minAttribIndex
Definition RigTransformHardware:86
osgAnimation::RigTransformHardware::_bonesPerVertex
unsigned int _bonesPerVertex
Definition RigTransformHardware:76
osgAnimation::RigTransformHardware::setFirstVertexAttributeTarget
void setFirstVertexAttributeTarget(unsigned int i)
set the first Vertex Attribute Array index of the rig generated by this technic (default:11)
Definition RigTransformHardware:49
osgAnimation::RigTransformHardware::_boneNameToPalette
BoneNamePaletteIndex _boneNameToPalette
Definition RigTransformHardware:80
osgAnimation::RigTransformHardware::BoneWeightAttribList
std::vector< osg::ref_ptr< osg::Vec4Array > > BoneWeightAttribList
Definition RigTransformHardware:43
osgAnimation::RigTransformHardware::_perVertexInfluences
std::vector< IndexWeightList > _perVertexInfluences
Definition RigTransformHardware:92
osgAnimation::RigTransformHardware::getShader
const osg::Shader * getShader() const
Definition RigTransformHardware:53
osgAnimation::RigTransformHardware::_bonePalette
BonePalette _bonePalette
Definition RigTransformHardware:79
osgAnimation::RigTransformHardware::BoneNamePaletteIndex
std::map< std::string, unsigned int > BoneNamePaletteIndex
Definition RigTransformHardware:45
osgAnimation::RigTransform::RigTransform
RigTransform()
Definition RigTransform:28
osg::CopyOp
Definition CopyOp:41
osg::Shader
Definition Shader:89
osg::Uniform
Definition Uniform:414
osg::ref_ptr
Definition ref_ptr:32
osgAnimation
Definition Action:34
osgAnimation::BoneMap
std::map< std::string, osg::ref_ptr< Bone > > BoneMap
Definition Bone:59
osg::Vec4Array
TemplateArray< Vec4, Array::Vec4ArrayType, 4, GL_FLOAT > Vec4Array
Definition Array:450
osg::Matrix
Matrixd Matrix
Definition Matrix:27
Export
OSGANIMATION_EXPORT
#define OSGANIMATION_EXPORT
Definition osgAnimation/Export:40