3 * Copyright (c) 2007-2010 SlimDX Group
\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
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\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
26 #include "../ComObject.h"
\r
28 #include "../math/Matrix.h"
\r
29 #include "../math/Vector3.h"
\r
31 #include "Direct3D9Exception.h"
\r
33 #include "MatrixStack.h"
\r
35 using namespace System;
\r
41 MatrixStack::MatrixStack()
\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
48 Construct(matrixStack);
\r
51 Result MatrixStack::Push()
\r
53 HRESULT hr = InternalPointer->Push();
\r
54 return RECORD_D3D9( hr );
\r
57 Result MatrixStack::Pop()
\r
59 HRESULT hr = InternalPointer->Pop();
\r
60 return RECORD_D3D9( hr );
\r
63 Result MatrixStack::LoadIdentity()
\r
65 HRESULT hr = InternalPointer->LoadIdentity();
\r
66 return RECORD_D3D9( hr );
\r
69 Result MatrixStack::LoadMatrix( Matrix matrix )
\r
71 HRESULT hr = InternalPointer->LoadMatrix( reinterpret_cast<D3DXMATRIX*>( &matrix ) );
\r
72 return RECORD_D3D9( hr );
\r
75 Result MatrixStack::MultiplyMatrix( Matrix matrix )
\r
77 HRESULT hr = InternalPointer->MultMatrix( reinterpret_cast<D3DXMATRIX*>( &matrix ) );
\r
78 return RECORD_D3D9( hr );
\r
81 Result MatrixStack::MultiplyMatrixLocal( Matrix matrix )
\r
83 HRESULT hr = InternalPointer->MultMatrixLocal( reinterpret_cast<D3DXMATRIX*>( &matrix ) );
\r
84 return RECORD_D3D9( hr );
\r
87 Result MatrixStack::RotateAxis( Vector3 axis, float angle )
\r
89 HRESULT hr = InternalPointer->RotateAxis( reinterpret_cast<D3DXVECTOR3*>( &axis ), angle );
\r
90 return RECORD_D3D9( hr );
\r
93 Result MatrixStack::RotateAxisLocal( Vector3 axis, float angle )
\r
95 HRESULT hr = InternalPointer->RotateAxisLocal( reinterpret_cast<D3DXVECTOR3*>( &axis ), angle );
\r
96 return RECORD_D3D9( hr );
\r
99 Result MatrixStack::RotateYawPitchRoll( float yaw, float pitch, float roll )
\r
101 HRESULT hr = InternalPointer->RotateYawPitchRoll( yaw, pitch, roll );
\r
102 return RECORD_D3D9( hr );
\r
105 Result MatrixStack::RotateYawPitchRollLocal( float yaw, float pitch, float roll )
\r
107 HRESULT hr = InternalPointer->RotateYawPitchRollLocal( yaw, pitch, roll );
\r
108 return RECORD_D3D9( hr );
\r
111 Result MatrixStack::Scale( float x, float y, float z )
\r
113 HRESULT hr = InternalPointer->Scale( x, y, z );
\r
114 return RECORD_D3D9( hr );
\r
117 Result MatrixStack::ScaleLocal( float x, float y, float z )
\r
119 HRESULT hr = InternalPointer->ScaleLocal( x, y, z );
\r
120 return RECORD_D3D9( hr );
\r
123 Result MatrixStack::Translate( float x, float y, float z )
\r
125 HRESULT hr = InternalPointer->Translate( x, y, z );
\r
126 return RECORD_D3D9( hr );
\r
129 Result MatrixStack::TranslateLocal( float x, float y, float z )
\r
131 HRESULT hr = InternalPointer->TranslateLocal( x, y, z );
\r
132 return RECORD_D3D9( hr );
\r
135 Matrix MatrixStack::Top::get()
\r
137 D3DXMATRIX* top = InternalPointer->GetTop();
\r
139 *reinterpret_cast<D3DXMATRIX*>( &result ) = *top;
\r