3 * Copyright (c) 2007-2010 SlimDX Group
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 #include "../stack_array.h"
28 #include "../ComObject.h"
29 #include "../DataStream.h"
31 #include "../Math/Vector3.h"
35 #include "ProgressiveMesh.h"
36 #include "PatchMesh.h"
38 #include "AnimationFrame.h"
39 #include "CompressedAnimationSet.h"
40 #include "Direct3D9Exception.h"
42 using namespace System;
48 CompressedAnimationSet::CompressedAnimationSet( String^ name, double ticksPerSecond,
49 SlimDX::Direct3D9::PlaybackType playbackType, DataStream^ compressedData,
50 array<CallbackKey>^ callbackKeys )
52 LPD3DXCOMPRESSEDANIMATIONSET pointer;
53 array<unsigned char>^ nameBytes = System::Text::ASCIIEncoding::ASCII->GetBytes( name );
54 pin_ptr<unsigned char> pinnedName = &nameBytes[0];
55 int count = callbackKeys->Length;
57 stack_array<D3DXKEY_CALLBACK> keys = stackalloc( D3DXKEY_CALLBACK, count );
58 for( int i = 0; i < count; i++ )
60 keys[i].Time = callbackKeys[i].Time;
61 keys[i].pCallbackData = callbackKeys[i].Data.ToPointer();
64 HRESULT hr = D3DXCreateCompressedAnimationSet( reinterpret_cast<LPCSTR>( pinnedName ), ticksPerSecond,
65 static_cast<D3DXPLAYBACK_TYPE>( playbackType ), compressedData->GetD3DBuffer(), count,
68 if( RECORD_D3D9( hr ).IsFailure )
69 throw gcnew Direct3D9Exception( Result::Last );
74 array<CallbackKey>^ CompressedAnimationSet::GetCallbackKeys()
76 int count = CallbackKeyCount;
77 stack_array<D3DXKEY_CALLBACK> keys = stackalloc( D3DXKEY_CALLBACK, count );
79 HRESULT hr = InternalPointer->GetCallbackKeys( &keys[0] );
81 if( RECORD_D3D9( hr ).IsFailure )
84 array<CallbackKey>^ results = gcnew array<CallbackKey>( count );
85 for( int i = 0; i < count; i++ )
86 results[i] = CallbackKey( keys[i] );
91 DataStream^ CompressedAnimationSet::GetCompressedData()
95 HRESULT hr = InternalPointer->GetCompressedData( &buffer );
97 if( RECORD_D3D9( hr ).IsFailure )
100 return gcnew DataStream( buffer );
103 int CompressedAnimationSet::CallbackKeyCount::get()
105 return InternalPointer->GetNumCallbackKeys();
108 SlimDX::Direct3D9::PlaybackType CompressedAnimationSet::PlaybackType::get()
110 return static_cast<SlimDX::Direct3D9::PlaybackType>( InternalPointer->GetPlaybackType() );
113 double CompressedAnimationSet::SourceTicksPerSecond::get()
115 return InternalPointer->GetSourceTicksPerSecond();