ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

emianim_component.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "common/foreach.h"
00024 
00025 #include "engines/grim/debug.h"
00026 #include "engines/grim/emi/costume/emianim_component.h"
00027 #include "engines/grim/emi/costume/emiskel_component.h"
00028 #include "engines/grim/resource.h"
00029 #include "engines/grim/costume.h"
00030 #include "engines/grim/emi/costumeemi.h"
00031 #include "engines/grim/emi/modelemi.h"
00032 #include "engines/grim/emi/skeleton.h"
00033 #include "engines/grim/emi/animationemi.h"
00034 
00035 namespace Grim {
00036 
00037 EMIAnimComponent::EMIAnimComponent(Component *p, int parentID, const char *filename, Component *prevComponent, tag32 t) :
00038         Component(p, parentID, filename, t), _animState(nullptr) {
00039 }
00040 
00041 EMIAnimComponent::~EMIAnimComponent() {
00042     delete _animState;
00043 }
00044 
00045 void EMIAnimComponent::init() {
00046     _visible = true;
00047     _animState = new AnimationStateEmi(_name);
00048 }
00049 
00050 int EMIAnimComponent::update(uint time) {
00051     EMISkelComponent *skel = ((EMICostume *)_cost)->_emiSkel;
00052     if (skel) {
00053         _animState->setSkeleton(skel->_obj);
00054         _animState->update(time);
00055     }
00056     return 0;
00057 }
00058 
00059 void EMIAnimComponent::setKey(int f) {
00060     switch (f) {
00061     case 0: // Stop
00062         _animState->stop();
00063         break;
00064     case 1: // Play
00065         _animState->play();
00066         break;
00067     case 2: // Pause
00068         _animState->setPaused(true);
00069         break;
00070     case 3: // Loop
00071         _animState->setLooping(true);
00072         _animState->play();
00073         break;
00074     case 4: // No loop
00075         _animState->setLooping(false);
00076         break;
00077     case 5: // Fade in 1
00078         _animState->fade(Animation::FadeIn, 1000);
00079         break;
00080     case 6: // Fade in 3/4
00081         _animState->fade(Animation::FadeIn, 750);
00082         break;
00083     case 7: // Fade in 1/2
00084         _animState->fade(Animation::FadeIn, 500);
00085         break;
00086     case 8: // Fade in 1/4
00087         _animState->fade(Animation::FadeIn, 250);
00088         break;
00089     case 9: // Fade in 1/8
00090         _animState->fade(Animation::FadeIn, 125);
00091         break;
00092     case 10: // Fade out 1
00093         _animState->fade(Animation::FadeOut, 1000);
00094         break;
00095     case 11: // Fade out 3/4
00096         _animState->fade(Animation::FadeOut, 750);
00097         break;
00098     case 12: // Fade out 1/2
00099         _animState->fade(Animation::FadeOut, 500);
00100         break;
00101     case 13: // Fade out 1/4
00102         _animState->fade(Animation::FadeOut, 250);
00103         break;
00104     case 14: // Fade out 1/8
00105         _animState->fade(Animation::FadeOut, 125);
00106         break;
00107     default:
00108         Debug::warning(Debug::Costumes, "Unknown key %d for component %s", f, _name.c_str());
00109         break;
00110     }
00111 }
00112 
00113 void EMIAnimComponent::reset() {
00114     _visible = true;
00115     _animState->stop();
00116 }
00117 
00118 void EMIAnimComponent::fade(Animation::FadeMode mode, int fadeLength) {
00119     _animState->fade(mode, fadeLength);
00120 }
00121 
00122 void EMIAnimComponent::advance(uint msecs) {
00123     _animState->advance(msecs);
00124 }
00125 
00126 void EMIAnimComponent::setPaused(bool paused) {
00127     _animState->setPaused(paused);
00128 }
00129 
00130 void EMIAnimComponent::draw() {
00131 }
00132 
00133 void EMIAnimComponent::saveState(SaveGame *state) {
00134     _animState->saveState(state);
00135 }
00136 
00137 void EMIAnimComponent::restoreState(SaveGame *state) {
00138     _animState->restoreState(state);
00139 }
00140 
00141 } // end of namespace Grim


Generated on Sat Aug 24 2019 05:00:54 for ResidualVM by doxygen 1.7.1
curved edge   curved edge