KX_BlenderScalarInterpolator.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program 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. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. /** \file gameengine/Converter/KX_BlenderScalarInterpolator.cpp
  28. * \ingroup bgeconv
  29. */
  30. #include "KX_BlenderScalarInterpolator.h"
  31. #include <cstring>
  32. extern "C" {
  33. #include "DNA_action_types.h"
  34. #include "DNA_anim_types.h"
  35. #include "BKE_fcurve.h"
  36. }
  37. float BL_ScalarInterpolator::GetValue(float currentTime) const
  38. {
  39. // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime);
  40. return evaluate_fcurve(m_fcu, currentTime);
  41. }
  42. BL_InterpolatorList::BL_InterpolatorList(bAction *action)
  43. {
  44. if (action==NULL)
  45. return;
  46. for (FCurve *fcu = (FCurve *)action->curves.first; fcu; fcu = fcu->next) {
  47. if (fcu->rna_path) {
  48. BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu);
  49. //assert(new_ipo);
  50. push_back(new_ipo);
  51. }
  52. }
  53. }
  54. BL_InterpolatorList::~BL_InterpolatorList()
  55. {
  56. BL_InterpolatorList::iterator i;
  57. for (i = begin(); !(i == end()); ++i) {
  58. delete *i;
  59. }
  60. }
  61. KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index)
  62. {
  63. for (BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ )
  64. {
  65. FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve();
  66. if (array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0)
  67. return *i;
  68. }
  69. return NULL;
  70. }