OpenSceneGraph 3.6.5
RigTransformHardware
Go to the documentation of this file.
1/* -*-c++-*-
2 * Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
3 * Copyright (C) 2017 Julien Valentin <mp3butcher@hotmail.com>
4 *
5 * This library is open source and may be redistributed and/or modified under
6 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
7 * (at your option) any later version. The full license is in LICENSE file
8 * included with this distribution, and on the openscenegraph.org website.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * OpenSceneGraph Public License for more details.
14 */
15
16#ifndef OSGANIMATION_RIG_TRANSFORM_HARDWARE
17#define OSGANIMATION_RIG_TRANSFORM_HARDWARE 1
18
19#include <osgAnimation/Export>
22#include <osgAnimation/Bone>
23#include <osg/Matrix>
24#include <osg/Array>
25
26#define RIGTRANSHW_DEFAULT_FIRST_VERTATTRIB_TARGETTED 11
27
28namespace osgAnimation
29{
30 class RigGeometry;
31
34 {
35 public:
36
38
40
42
43 typedef std::vector<osg::ref_ptr<osg::Vec4Array> > BoneWeightAttribList;
44 typedef std::vector<osg::ref_ptr<Bone> > BonePalette;
45 typedef std::map<std::string, unsigned int> BoneNamePaletteIndex;
46 typedef std::vector<osg::Matrix> MatrixPalette;
47
50 unsigned int getFirstVertexAttributeTarget()const { return _minAttribIndex; }
51
52 void setShader(osg::Shader* shader) { _shader = shader; }
53 const osg::Shader* getShader() const { return _shader.get(); }
54 osg::Shader* getShader() { return _shader.get(); }
55
56 osg::Vec4Array* getVertexAttrib(unsigned int index);
57 unsigned int getNumVertexAttrib() const { return _boneWeightAttribArrays.size(); }
58
59 const unsigned int &getNumBonesPerVertex() const { return _bonesPerVertex; }
60 const unsigned int &getNumVertexes() const { return _nbVertices; }
61
65
66 void computeMatrixPaletteUniform(const osg::Matrix& transformFromSkeletonToGeometry, const osg::Matrix& invTransformFromSkeletonToGeometry);
67
68 // update rig if needed
69 virtual void operator()(RigGeometry&);
70
71 // init/reset animations data
72 virtual bool prepareData(RigGeometry& );
73
74 protected:
75
76 unsigned int _bonesPerVertex;
77 unsigned int _nbVertices;
78
84
86 unsigned int _minAttribIndex;
87 bool buildPalette(const BoneMap& boneMap,const RigGeometry& rig);
88
89 //on first update
90 virtual bool init(RigGeometry& );
91
92 std::vector<IndexWeightList> _perVertexInfluences;
93 };
94}
95
96#endif
TemplateArray< Vec4, Array::Vec4ArrayType, 4, GL_FLOAT > Vec4Array
Definition Array:450
Matrixd Matrix
Definition Matrix:27
The osgAnimation library provides general purpose utility classes for animation.
Definition Action:34
std::map< std::string, osg::ref_ptr< Bone > > BoneMap
Definition Bone:59
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
osg::Shader is an application-level abstraction of an OpenGL glShader.
Definition Shader:89
Uniform encapsulates glUniform values.
Definition Uniform:414
Definition RigGeometry:50
RigTransform()
Definition RigTransform:28
osg::ref_ptr< osg::Shader > _shader
Definition RigTransformHardware:83
const unsigned int & getNumVertexes() const
Definition RigTransformHardware:60
virtual bool prepareData(RigGeometry &)
to call manually when a skeleton is reacheable from the rig in order to prepare technic data before r...
unsigned int getFirstVertexAttributeTarget() const
Definition RigTransformHardware:50
META_Object(osgAnimation, RigTransformHardware)
osg::ref_ptr< osg::Uniform > _uniformMatrixPalette
Definition RigTransformHardware:82
std::vector< osg::ref_ptr< Bone > > BonePalette
Definition RigTransformHardware:44
osg::Uniform * getMatrixPaletteUniform()
Definition RigTransformHardware:64
virtual void operator()(RigGeometry &)
void computeMatrixPaletteUniform(const osg::Matrix &transformFromSkeletonToGeometry, const osg::Matrix &invTransformFromSkeletonToGeometry)
const unsigned int & getNumBonesPerVertex() const
Definition RigTransformHardware:59
const BonePalette & getBonePalette()
Definition RigTransformHardware:63
unsigned int _nbVertices
Definition RigTransformHardware:77
void setShader(osg::Shader *shader)
Definition RigTransformHardware:52
bool buildPalette(const BoneMap &boneMap, const RigGeometry &rig)
RigTransformHardware(const RigTransformHardware &rth, const osg::CopyOp &copyop)
osg::Vec4Array * getVertexAttrib(unsigned int index)
std::vector< osg::Matrix > MatrixPalette
Definition RigTransformHardware:46
virtual bool init(RigGeometry &)
osg::Shader * getShader()
Definition RigTransformHardware:54
bool _needInit
Definition RigTransformHardware:85
BoneWeightAttribList _boneWeightAttribArrays
Definition RigTransformHardware:81
unsigned int getNumVertexAttrib() const
Definition RigTransformHardware:57
const BoneNamePaletteIndex & getBoneNameToPalette()
Definition RigTransformHardware:62
unsigned int _minAttribIndex
Definition RigTransformHardware:86
unsigned int _bonesPerVertex
Definition RigTransformHardware:76
void setFirstVertexAttributeTarget(unsigned int i)
set the first Vertex Attribute Array index of the rig generated by this technic (default:11)
Definition RigTransformHardware:49
BoneNamePaletteIndex _boneNameToPalette
Definition RigTransformHardware:80
std::vector< osg::ref_ptr< osg::Vec4Array > > BoneWeightAttribList
Definition RigTransformHardware:43
std::vector< IndexWeightList > _perVertexInfluences
Definition RigTransformHardware:92
const osg::Shader * getShader() const
Definition RigTransformHardware:53
BonePalette _bonePalette
Definition RigTransformHardware:79
std::map< std::string, unsigned int > BoneNamePaletteIndex
Definition RigTransformHardware:45
#define OSGANIMATION_EXPORT
Definition Export:40

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.