00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Teddy/Behaviour/ModelAnimator.h"
00026 #include "Teddy/Behaviour/ModelController.h"
00027 using namespace Teddy::Maths;
00028 using namespace Teddy::Models;
00029
00030
00031 namespace Teddy {
00032 namespace Behaviour {
00033
00034
00036 ModelAnimator::ModelAnimator(
00037 Model *m,
00038 DoubleVector tick_translation,
00039 double up,
00040 double right,
00041 double view
00042 )
00043 :
00044 model ( m ),
00045 controller ( NULL ),
00046 tick_translation ( tick_translation ),
00047 tick_rotation_up ( up ),
00048 tick_rotation_right( right ),
00049 tick_rotation_view ( view )
00050 {
00051 }
00052
00053
00054 ModelAnimator::~ModelAnimator(){
00055 if( controller!=NULL ){
00056 controller->setAnimator( NULL );
00057 }
00058 }
00059
00060
00061 void ModelAnimator::setController( ModelController *controller ){
00062 this->controller = controller;
00063 }
00064
00065
00066 ModelController *ModelAnimator::getController(){
00067 return this->controller;
00068 }
00069
00070
00071 void ModelAnimator::setTickTranslation( DoubleVector tick_translation ){
00072 this->tick_translation = tick_translation;
00073 }
00074
00075
00076 float ModelAnimator::getSpeed(){
00077 return tick_translation.magnitude();
00078 }
00079
00080
00081 void ModelAnimator::setTickRotation( double up, double right, double view ){
00082 tick_rotation_up = up;
00083 tick_rotation_right = right;
00084 tick_rotation_view = view;
00085 }
00086
00087
00088 void ModelAnimator::tick(){
00089 if( controller != NULL ){
00090 controller->tick();
00091 }
00092 if( model != NULL ){
00093 model->translate( tick_translation );
00094 model->heading ( tick_rotation_up );
00095 model->pitch ( tick_rotation_right );
00096 model->roll ( tick_rotation_view );
00097 }
00098 }
00099
00100
00101 Model *ModelAnimator::getModel(){
00102 return this->model;
00103 }
00104
00105
00106 void ModelAnimator::setModel( Model *model ){
00107 this->model = model;
00108 }
00109
00110
00111 };
00112 };
00113