/****************************************************************************** libx42.net - skinned vertex animation library (.NET API) Copyright (C) 2007 HermitWorks Entertainment Corporation 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. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. ******************************************************************************/ #include "Stdafx.h" #include "AnimationData.h" #include "Model.h" namespace Libx42 { bool KeyStreamEntry::Equals( KeyStreamEntry ke ) { return Bone == ke.Bone && Type == ke.Type && Frame == ke.Frame && Value == ke.Value; } bool KeyStreamEntry::Equals( Object^ obj ) { if( !obj ) return false; try { KeyStreamEntry ke = safe_cast< KeyStreamEntry >( obj ); return Equals( ke ); } catch( InvalidCastException^ ) { return false; } } KeyStream::KeyStream( Model ^owner ) : owner( owner ), DataStream< KeyStreamEntry >( owner, owner->m->keyStream, sizeof( x42keyStreamEntry_t ), 0, owner->m->header.keyStreamLength ) { } AnimationClip::AnimationClip( Model ^owner, int index ) : owner( owner ), index( index ) { } const x42animation_t& AnimationClip::RawAnimationClip::get( void ) { return owner->m->animations[index]; } String^ AnimationClip::Name::get( void ) { return owner->GetModelString( RawAnimationClip.name ); } AnimationClipCollection::AnimationClipCollection( Model ^owner ) : ModelItemCollection< AnimationClip^ >( owner ) { items = gcnew array< AnimationClip^ >( owner->m->header.numAnims ); for( int i = 0; i < items->Length; i++ ) items[i] = gcnew AnimationClip( owner, i ); } AnimationData::AnimationData( Model ^owner ) : owner( owner ) { keyStream = gcnew Libx42::KeyStream( owner ); posValues = gcnew DataStream< Libx42::Math::Vector3 >( owner, owner->m->posValues, sizeof( vec3_t ), 0, owner->m->header.numPosValues ); rotValues = gcnew DataStream< Libx42::Math::Quaternion >( owner, owner->m->rotValues, sizeof( quat_t ), 0, owner->m->header.numRotValues ); scaleValues = gcnew DataStream< Libx42::Math::Vector3 >( owner, owner->m->scaleValues, sizeof( vec3_t ), 0, owner->m->header.numScaleValues ); animations = gcnew AnimationClipCollection( owner ); } };