123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- /*!
- * \file src/SkeletalModel.cpp
- * \brief This is the factored out skeletal model class
- *
- * \author Mongoose
- */
-
- #include "SkeletalModel.h"
-
- ////////////////////////////////////////////////////////////
- // Constructors
- ////////////////////////////////////////////////////////////
-
- SkeletalModel::SkeletalModel()
- {
- model = 0x0;
- flags = 0;
- mBoneFrame = 0;
- mAnimationFrame = 0;
- mIdleAnimation = 0;
- time = 0.0f;
- lastTime = 0.0f;
- rate = 0.0f;
- }
-
-
- SkeletalModel::~SkeletalModel()
- {
- if (model)
- {
- for (model->animation.start();
- model->animation.forward();
- model->animation.next())
- {
- animation_frame_t *af = model->animation.current();
-
- if (!af)
- continue;
-
- for (af->frame.start(); af->frame.forward(); af->frame.next())
- {
- bone_frame_t *bf = af->frame.current();
-
- if (!bf)
- continue;
-
- bf->tag.erase();
-
- //for (bf->tag.start(); bf->tag.forward(); bf->tag.next())
- //{
- // if (bf->tag.current())
- // delete bf->tag.current();
- //}
-
- delete bf;
- }
-
- af->frame.clear();
-
- delete af;
- }
-
- model->animation.clear();
-
- delete model;
- }
- }
-
-
- ////////////////////////////////////////////////////////////
- // Public Accessors
- ////////////////////////////////////////////////////////////
-
- int SkeletalModel::getAnimation()
- {
- return mAnimationFrame;
- }
-
-
- int SkeletalModel::getFrame()
- {
- return mBoneFrame;
- }
-
-
- int SkeletalModel::getIdleAnimation()
- {
- return mIdleAnimation;
- }
-
-
- ////////////////////////////////////////////////////////////
- // Public Mutators
- ////////////////////////////////////////////////////////////
-
- void SkeletalModel::setModel(skeletal_model_t *mdl)
- {
- if (mdl)
- model = mdl;
- }
-
-
- void SkeletalModel::setAnimation(int index)
- {
- if (!model) // index > (int)model->animation.size())
- return;
-
- animation_frame_t *a = model->animation[index];
-
- if (a)
- {
- mAnimationFrame = index;
- mBoneFrame = 0;
- rate = a->rate;
- }
- }
-
-
- void SkeletalModel::setFrame(int index)
- {
- if (!model)
- return;
-
- animation_frame_t *a = model->animation[mAnimationFrame];
-
- if (a) // index > (int)a->frame.size())
- {
- bone_frame_t *b = a->frame[index];
-
- if (b)
- {
- mBoneFrame = index;
- }
- }
- }
-
-
- void SkeletalModel::setIdleAnimation(int index)
- {
- if (!model)
- return;
-
- animation_frame_t *a = model->animation[index];
-
- if (a)
- {
- mIdleAnimation = index;
- }
- }
-
-
- ////////////////////////////////////////////////////////////
- // Private Accessors
- ////////////////////////////////////////////////////////////
-
-
- ////////////////////////////////////////////////////////////
- // Private Mutators
- ////////////////////////////////////////////////////////////
|