Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SkeletalModel.cpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : OpenRaider
  5. * Author : Terry 'Mongoose' Hendrix II
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : SkeletalModel
  9. * License : No use w/o permission (C) 2003 Mongoose
  10. * Comments: This is the factored out skeletal model class
  11. *
  12. *
  13. * This file was generated using Mongoose's C++
  14. * template generator script. <stu7440@westga.edu>
  15. *
  16. *-- History -------------------------------------------------
  17. *
  18. * 2003.05.19:
  19. * Mongoose - Created
  20. =================================================================*/
  21. #include <SkeletalModel.h>
  22. #ifdef MEMORY_TEST
  23. #include <memory_test.h>
  24. #endif
  25. ////////////////////////////////////////////////////////////
  26. // Constructors
  27. ////////////////////////////////////////////////////////////
  28. SkeletalModel::SkeletalModel()
  29. {
  30. model = 0x0;
  31. flags = 0;
  32. mBoneFrame = 0;
  33. mAnimationFrame = 0;
  34. mIdleAnimation = 0;
  35. }
  36. SkeletalModel::~SkeletalModel()
  37. {
  38. if (model)
  39. {
  40. for (model->animation.start();
  41. model->animation.forward();
  42. model->animation.next())
  43. {
  44. animation_frame_t *af = model->animation.current();
  45. if (!af)
  46. continue;
  47. for (af->frame.start(); af->frame.forward(); af->frame.next())
  48. {
  49. bone_frame_t *bf = af->frame.current();
  50. if (!bf)
  51. continue;
  52. bf->tag.erase();
  53. //for (bf->tag.start(); bf->tag.forward(); bf->tag.next())
  54. //{
  55. // if (bf->tag.current())
  56. // delete bf->tag.current();
  57. //}
  58. delete bf;
  59. }
  60. af->frame.clear();
  61. delete af;
  62. }
  63. model->animation.clear();
  64. delete model;
  65. }
  66. }
  67. ////////////////////////////////////////////////////////////
  68. // Public Accessors
  69. ////////////////////////////////////////////////////////////
  70. int SkeletalModel::getAnimation()
  71. {
  72. return mAnimationFrame;
  73. }
  74. int SkeletalModel::getFrame()
  75. {
  76. return mBoneFrame;
  77. }
  78. int SkeletalModel::getIdleAnimation()
  79. {
  80. return mIdleAnimation;
  81. }
  82. ////////////////////////////////////////////////////////////
  83. // Public Mutators
  84. ////////////////////////////////////////////////////////////
  85. void SkeletalModel::setModel(skeletal_model_t *mdl)
  86. {
  87. if (mdl)
  88. model = mdl;
  89. }
  90. void SkeletalModel::setAnimation(int index)
  91. {
  92. if (!model) // index > (int)model->animation.size())
  93. return;
  94. animation_frame_t *a = model->animation[index];
  95. if (a)
  96. {
  97. mAnimationFrame = index;
  98. mBoneFrame = 0;
  99. rate = a->rate;
  100. }
  101. }
  102. void SkeletalModel::setFrame(int index)
  103. {
  104. if (!model)
  105. return;
  106. animation_frame_t *a = model->animation[mAnimationFrame];
  107. if (a) // index > (int)a->frame.size())
  108. {
  109. bone_frame_t *b = a->frame[index];
  110. if (b)
  111. {
  112. mBoneFrame = index;
  113. }
  114. }
  115. }
  116. void SkeletalModel::setIdleAnimation(int index)
  117. {
  118. if (!model)
  119. return;
  120. animation_frame_t *a = model->animation[index];
  121. if (a)
  122. {
  123. mIdleAnimation = index;
  124. }
  125. }
  126. ////////////////////////////////////////////////////////////
  127. // Private Accessors
  128. ////////////////////////////////////////////////////////////
  129. ////////////////////////////////////////////////////////////
  130. // Private Mutators
  131. ////////////////////////////////////////////////////////////