Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

SkeletalModel.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. ////////////////////////////////////////////////////////////
  23. // Constructors
  24. ////////////////////////////////////////////////////////////
  25. SkeletalModel::SkeletalModel()
  26. {
  27. model = 0x0;
  28. flags = 0;
  29. mBoneFrame = 0;
  30. mAnimationFrame = 0;
  31. mIdleAnimation = 0;
  32. }
  33. SkeletalModel::~SkeletalModel()
  34. {
  35. if (model)
  36. {
  37. for (model->animation.start();
  38. model->animation.forward();
  39. model->animation.next())
  40. {
  41. animation_frame_t *af = model->animation.current();
  42. if (!af)
  43. continue;
  44. for (af->frame.start(); af->frame.forward(); af->frame.next())
  45. {
  46. bone_frame_t *bf = af->frame.current();
  47. if (!bf)
  48. continue;
  49. bf->tag.erase();
  50. //for (bf->tag.start(); bf->tag.forward(); bf->tag.next())
  51. //{
  52. // if (bf->tag.current())
  53. // delete bf->tag.current();
  54. //}
  55. delete bf;
  56. }
  57. af->frame.clear();
  58. delete af;
  59. }
  60. model->animation.clear();
  61. delete model;
  62. }
  63. }
  64. ////////////////////////////////////////////////////////////
  65. // Public Accessors
  66. ////////////////////////////////////////////////////////////
  67. int SkeletalModel::getAnimation()
  68. {
  69. return mAnimationFrame;
  70. }
  71. int SkeletalModel::getFrame()
  72. {
  73. return mBoneFrame;
  74. }
  75. int SkeletalModel::getIdleAnimation()
  76. {
  77. return mIdleAnimation;
  78. }
  79. ////////////////////////////////////////////////////////////
  80. // Public Mutators
  81. ////////////////////////////////////////////////////////////
  82. void SkeletalModel::setModel(skeletal_model_t *mdl)
  83. {
  84. if (mdl)
  85. model = mdl;
  86. }
  87. void SkeletalModel::setAnimation(int index)
  88. {
  89. if (!model) // index > (int)model->animation.size())
  90. return;
  91. animation_frame_t *a = model->animation[index];
  92. if (a)
  93. {
  94. mAnimationFrame = index;
  95. mBoneFrame = 0;
  96. rate = a->rate;
  97. }
  98. }
  99. void SkeletalModel::setFrame(int index)
  100. {
  101. if (!model)
  102. return;
  103. animation_frame_t *a = model->animation[mAnimationFrame];
  104. if (a) // index > (int)a->frame.size())
  105. {
  106. bone_frame_t *b = a->frame[index];
  107. if (b)
  108. {
  109. mBoneFrame = index;
  110. }
  111. }
  112. }
  113. void SkeletalModel::setIdleAnimation(int index)
  114. {
  115. if (!model)
  116. return;
  117. animation_frame_t *a = model->animation[index];
  118. if (a)
  119. {
  120. mIdleAnimation = index;
  121. }
  122. }
  123. ////////////////////////////////////////////////////////////
  124. // Private Accessors
  125. ////////////////////////////////////////////////////////////
  126. ////////////////////////////////////////////////////////////
  127. // Private Mutators
  128. ////////////////////////////////////////////////////////////