OSDN Git Service

作業部屋#50802 画面キャプチャができなくなっていた問題を暫定対応(F12キー固定で対応中)
[dtxmaniaxg-verk/dtxmaniaxg-verk-git.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d9 / CompressedAnimationSet.cpp
1 #include "stdafx.h"
2 /*
3 * Copyright (c) 2007-2010 SlimDX Group
4
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:
11
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14
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
21 * THE SOFTWARE.
22 */
23 #include <d3d9.h>
24 #include <d3dx9.h>
25 #include <vcclr.h>
26
27 #include "../stack_array.h"
28 #include "../ComObject.h"
29 #include "../DataStream.h"
30
31 #include "../Math/Vector3.h"
32
33 #include "Device.h"
34 #include "Mesh.h"
35 #include "ProgressiveMesh.h"
36 #include "PatchMesh.h"
37 #include "SkinInfo.h"
38 #include "AnimationFrame.h"
39 #include "CompressedAnimationSet.h"
40 #include "Direct3D9Exception.h"
41
42 using namespace System;
43
44 namespace SlimDX
45 {
46 namespace Direct3D9
47 {
48         CompressedAnimationSet::CompressedAnimationSet( String^ name, double ticksPerSecond,
49                 SlimDX::Direct3D9::PlaybackType playbackType, DataStream^ compressedData,
50                 array<CallbackKey>^ callbackKeys )
51         {
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;
56
57                 stack_array<D3DXKEY_CALLBACK> keys = stackalloc( D3DXKEY_CALLBACK, count );
58                 for( int i = 0; i < count; i++ )
59                 {
60                         keys[i].Time = callbackKeys[i].Time;
61                         keys[i].pCallbackData = callbackKeys[i].Data.ToPointer();
62                 }
63
64                 HRESULT hr = D3DXCreateCompressedAnimationSet( reinterpret_cast<LPCSTR>( pinnedName ), ticksPerSecond,
65                         static_cast<D3DXPLAYBACK_TYPE>( playbackType ), compressedData->GetD3DBuffer(), count,
66                         &keys[0], &pointer );
67
68                 if( RECORD_D3D9( hr ).IsFailure )
69                         throw gcnew Direct3D9Exception( Result::Last );
70
71                 Construct(pointer);
72         }
73
74         array<CallbackKey>^ CompressedAnimationSet::GetCallbackKeys()
75         {
76                 int count = CallbackKeyCount;
77                 stack_array<D3DXKEY_CALLBACK> keys = stackalloc( D3DXKEY_CALLBACK, count );
78
79                 HRESULT hr = InternalPointer->GetCallbackKeys( &keys[0] );
80                 
81                 if( RECORD_D3D9( hr ).IsFailure )
82                         return nullptr;
83
84                 array<CallbackKey>^ results = gcnew array<CallbackKey>( count );
85                 for( int i = 0; i < count; i++ )
86                         results[i] = CallbackKey( keys[i] );
87
88                 return results;
89         }
90
91         DataStream^ CompressedAnimationSet::GetCompressedData()
92         {
93                 LPD3DXBUFFER buffer;
94
95                 HRESULT hr = InternalPointer->GetCompressedData( &buffer );
96                 
97                 if( RECORD_D3D9( hr ).IsFailure )
98                         return nullptr;
99
100                 return gcnew DataStream( buffer );
101         }
102
103         int CompressedAnimationSet::CallbackKeyCount::get()
104         {
105                 return InternalPointer->GetNumCallbackKeys();
106         }
107
108         SlimDX::Direct3D9::PlaybackType CompressedAnimationSet::PlaybackType::get()
109         {
110                 return static_cast<SlimDX::Direct3D9::PlaybackType>( InternalPointer->GetPlaybackType() );
111         }
112
113         double CompressedAnimationSet::SourceTicksPerSecond::get()
114         {
115                 return InternalPointer->GetSourceTicksPerSecond();
116         }
117 }
118 }