/* -*- Objc -*- */ /* * $Id: MdlAnimatedModelForViewer.m,v 1.1 2003/08/18 10:56:13 ano Exp $ * * Copyright (C) 2003 Free Software Foundation, Inc. * * This file is part of GNU Hégémonie. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "MdlAnimatedModelForViewer.h" #include "Model/MdlAnimation.h" #include "Model/MdlModel.h" #include "Model/MdlAnimatedModel.h" @implementation MdlAnimatedModelForViewer - (id) initWithModel: (MdlModel *)model animation: (NSString *)currentAnimation mode: (int)mode { self = [super initWithModel: model animation: currentAnimation]; _mode = mode; return self; } - (void) dealloc { [super dealloc]; } - (void) setCurrentTime { MdlAnimation *animation = [_model animation: _currentAnimation]; double time = - [_date timeIntervalSinceNow]; int frame = [animation startFrame]; _time = ((time - _lastTime)* [animation framePerSecond]); switch(_mode) { case RETOUR_RAP: _time *= 2; frame = (_currentFrame + [animation nbFrames] - 1 - [animation startFrame]) % [animation nbFrames] + [animation startFrame]; break; case AVANCE_RAP: _time *= 2; frame = (_currentFrame + 1 - [animation startFrame] ) % [animation nbFrames] + [animation startFrame]; break; case DEBUT: _time = 0; frame = [animation startFrame]; break; case FIN: _time = 0; frame = [animation startFrame] + [animation nbFrames] - 1; break; case LECTURE: frame = (_currentFrame + 1 - [animation startFrame] ) % [animation nbFrames] + [animation startFrame]; break; case PAUSE: _time = 0; frame = _currentFrame; break; case STOP: _time = 0; frame = [animation startFrame]; break; case RALENTI: _time /= [animation framePerSecond]; frame = (_currentFrame + 1 - [animation startFrame] ) % [animation nbFrames] + [animation startFrame]; break; default: printf("loossse"); frame = 0; break; } if (_time >= 1.0 ) { _currentFrame = frame; _lastTime = time; _time -= (int)_time ; } } - (void) setModeA: (int)mode { _mode = mode; } @end /* MdlAnimatedModelForViewer*/