/****************************************************************************** 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 "DataStream.h" #include "Model.h" #include "UtilTypes.h" namespace Libx42 { generic< typename T > void DataStream< T >::CopyToBuffer( int index, int count, IntPtr dest, int stride, int padBytes ) { if( index < 0 || count < 0 || index + count > this->count || stride < 0 || padBytes < 0 ) throw gcnew ArgumentOutOfRangeException(); x42memStream_t src; src.pStreamZero = (Byte*)pBase + this->stride * index; src.stride = this->stride; src.scratchBytes = this->padBytes; x42memStream_t dst; dst.pStreamZero = dest.ToPointer(); dst.stride = (size_t)stride; dst.scratchBytes = (size_t)padBytes; if( !x42_CopyStreamToStream( &dst, &src, sizeof( T ), count, owner->Opts->opts ) ) throw gcnew Exception( "Failed to copy stream data." ); } }