MorphTransformHardware 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* -*-c++-*-
  2. * Copyright (C) 2017 Julien Valentin <mp3butcher@hotmail.com>
  3. *
  4. * This library is open source and may be redistributed and/or modified under
  5. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  6. * (at your option) any later version. The full license is in LICENSE file
  7. * included with this distribution, and on the openscenegraph.org website.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * OpenSceneGraph Public License for more details.
  13. */
  14. #ifndef OSGANIMATION_MORPH_TRANSFORM_HARDWARE
  15. #define OSGANIMATION_MORPH_TRANSFORM_HARDWARE 1
  16. #include <osgAnimation/Export>
  17. #include <osgAnimation/RigTransform>
  18. #include <osgAnimation/VertexInfluence>
  19. #include <osgAnimation/Bone>
  20. #include <osg/Matrix>
  21. #include <osg/Array>
  22. ///texture unit reserved for morphtarget TBO
  23. #define MORPHTRANSHW_DEFAULTMORPHTEXTUREUNIT 7
  24. namespace osgAnimation
  25. {
  26. class MorphGeometry;
  27. /// This class manage format for hardware morphing
  28. class OSGANIMATION_EXPORT MorphTransformHardware : public MorphTransform
  29. {
  30. public:
  31. MorphTransformHardware();
  32. MorphTransformHardware(const MorphTransformHardware& rth, const osg::CopyOp& copyop);
  33. META_Object(osgAnimation,MorphTransformHardware);
  34. virtual void operator()(MorphGeometry&);
  35. inline void setShader( osg::Shader*s ) { _shader=s; }
  36. inline const osg::Shader * getShader() const { return _shader.get(); }
  37. inline osg::Shader * getShader() { return _shader.get(); }
  38. ///texture unit reserved for morphtarget TBO default is 7
  39. void setReservedTextureUnit(unsigned int t) { _reservedTextureUnit=t; }
  40. unsigned int getReservedTextureUnit() const { return _reservedTextureUnit; }
  41. protected:
  42. bool init(MorphGeometry&);
  43. osg::ref_ptr<osg::Uniform> _uniformTargetsWeight;
  44. osg::ref_ptr<osg::Shader> _shader;
  45. bool _needInit;
  46. unsigned int _reservedTextureUnit;
  47. };
  48. }
  49. #endif