OSDN Git Service

フォーラム[#56172] SlimDX(改)のフォルダ内容が不完全だったので再UP。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d9 / MatrixStack.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
6 * of this software and associated documentation files (the "Software"), to deal\r
7 * in the Software without restriction, including without limitation the rights\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
9 * copies of the Software, and to permit persons to whom the Software is\r
10 * furnished to do so, subject to the following conditions:\r
11\r
12 * The above copyright notice and this permission notice shall be included in\r
13 * all copies or substantial portions of the Software.\r
14\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
21 * THE SOFTWARE.\r
22 */\r
23 #include <d3d9.h>\r
24 #include <d3dx9.h>\r
25 \r
26 #include "../ComObject.h"\r
27 \r
28 #include "../math/Matrix.h"\r
29 #include "../math/Vector3.h"\r
30 \r
31 #include "Direct3D9Exception.h"\r
32 \r
33 #include "MatrixStack.h"\r
34 \r
35 using namespace System;\r
36 \r
37 namespace SlimDX\r
38 {\r
39 namespace Direct3D9\r
40 {\r
41         MatrixStack::MatrixStack()\r
42         {\r
43                 ID3DXMatrixStack* matrixStack;\r
44                 HRESULT hr = D3DXCreateMatrixStack( 0, &matrixStack );\r
45                 if( RECORD_D3D9( hr ).IsFailure )\r
46                         throw gcnew Direct3D9Exception( "Failed to create MatrixStack." );\r
47 \r
48                 Construct(matrixStack);\r
49         }\r
50 \r
51         Result MatrixStack::Push()\r
52         {\r
53                 HRESULT hr = InternalPointer->Push();\r
54                 return RECORD_D3D9( hr );\r
55         }\r
56 \r
57         Result MatrixStack::Pop()\r
58         {\r
59                 HRESULT hr = InternalPointer->Pop();\r
60                 return RECORD_D3D9( hr );\r
61         }\r
62 \r
63         Result MatrixStack::LoadIdentity()\r
64         {\r
65                 HRESULT hr = InternalPointer->LoadIdentity();\r
66                 return RECORD_D3D9( hr );\r
67         }\r
68 \r
69         Result MatrixStack::LoadMatrix( Matrix matrix )\r
70         {\r
71                 HRESULT hr = InternalPointer->LoadMatrix( reinterpret_cast<D3DXMATRIX*>( &matrix ) );\r
72                 return RECORD_D3D9( hr );\r
73         }\r
74 \r
75         Result MatrixStack::MultiplyMatrix( Matrix matrix )\r
76         {\r
77                 HRESULT hr = InternalPointer->MultMatrix( reinterpret_cast<D3DXMATRIX*>( &matrix ) );\r
78                 return RECORD_D3D9( hr );\r
79         }\r
80 \r
81         Result MatrixStack::MultiplyMatrixLocal( Matrix matrix )\r
82         {\r
83                 HRESULT hr = InternalPointer->MultMatrixLocal( reinterpret_cast<D3DXMATRIX*>( &matrix ) );\r
84                 return RECORD_D3D9( hr );\r
85         }\r
86 \r
87         Result MatrixStack::RotateAxis( Vector3 axis, float angle )\r
88         {\r
89                 HRESULT hr = InternalPointer->RotateAxis( reinterpret_cast<D3DXVECTOR3*>( &axis ), angle );\r
90                 return RECORD_D3D9( hr );\r
91         }\r
92 \r
93         Result MatrixStack::RotateAxisLocal( Vector3 axis, float angle )\r
94         {\r
95                 HRESULT hr = InternalPointer->RotateAxisLocal( reinterpret_cast<D3DXVECTOR3*>( &axis ), angle );\r
96                 return RECORD_D3D9( hr );\r
97         }\r
98 \r
99         Result MatrixStack::RotateYawPitchRoll( float yaw, float pitch, float roll )\r
100         {\r
101                 HRESULT hr = InternalPointer->RotateYawPitchRoll( yaw, pitch, roll );\r
102                 return RECORD_D3D9( hr );\r
103         }\r
104 \r
105         Result MatrixStack::RotateYawPitchRollLocal( float yaw, float pitch, float roll )\r
106         {\r
107                 HRESULT hr = InternalPointer->RotateYawPitchRollLocal( yaw, pitch, roll );\r
108                 return RECORD_D3D9( hr );\r
109         }\r
110 \r
111         Result MatrixStack::Scale( float x, float y, float z )\r
112         {\r
113                 HRESULT hr = InternalPointer->Scale( x, y, z );\r
114                 return RECORD_D3D9( hr );\r
115         }\r
116 \r
117         Result MatrixStack::ScaleLocal( float x, float y, float z )\r
118         {\r
119                 HRESULT hr = InternalPointer->ScaleLocal( x, y, z );\r
120                 return RECORD_D3D9( hr );\r
121         }\r
122 \r
123         Result MatrixStack::Translate( float x, float y, float z )\r
124         {\r
125                 HRESULT hr = InternalPointer->Translate( x, y, z );\r
126                 return RECORD_D3D9( hr );\r
127         }\r
128 \r
129         Result MatrixStack::TranslateLocal( float x, float y, float z )\r
130         {\r
131                 HRESULT hr = InternalPointer->TranslateLocal( x, y, z );\r
132                 return RECORD_D3D9( hr );\r
133         }\r
134 \r
135         Matrix MatrixStack::Top::get()\r
136         {\r
137                 D3DXMATRIX* top = InternalPointer->GetTop();\r
138                 Matrix result;\r
139                 *reinterpret_cast<D3DXMATRIX*>( &result ) = *top;\r
140 \r
141                 return result;\r
142         }\r
143 }\r
144 }\r