2 * Mathematical operations specific to D3DX9.
4 * Copyright (C) 2008 Philip Nilsson
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
29 /*************************************************************************
30 * D3DXPlaneTransformArray
32 D3DXPLANE
* WINAPI
D3DXPlaneTransformArray(
33 D3DXPLANE
* out
, UINT outstride
, CONST D3DXPLANE
* in
, UINT instride
,
34 CONST D3DXMATRIX
* matrix
, UINT elements
)
38 for (i
= 0; i
< elements
; ++i
) {
40 (D3DXPLANE
*)((char*)out
+ outstride
* i
),
41 (CONST D3DXPLANE
*)((const char*)in
+ instride
* i
),
47 /*************************************************************************
48 * D3DXVec2TransformArray
50 * Transform an array of vectors by a matrix.
52 D3DXVECTOR4
* WINAPI
D3DXVec2TransformArray(
53 D3DXVECTOR4
* out
, UINT outstride
, CONST D3DXVECTOR2
* in
, UINT instride
,
54 CONST D3DXMATRIX
* matrix
, UINT elements
)
58 for (i
= 0; i
< elements
; ++i
) {
60 (D3DXVECTOR4
*)((char*)out
+ outstride
* i
),
61 (CONST D3DXVECTOR2
*)((const char*)in
+ instride
* i
),
67 /*************************************************************************
68 * D3DXVec2TransformCoordArray
70 D3DXVECTOR2
* WINAPI
D3DXVec2TransformCoordArray(
71 D3DXVECTOR2
* out
, UINT outstride
, CONST D3DXVECTOR2
* in
, UINT instride
,
72 CONST D3DXMATRIX
* matrix
, UINT elements
)
76 for (i
= 0; i
< elements
; ++i
) {
77 D3DXVec2TransformCoord(
78 (D3DXVECTOR2
*)((char*)out
+ outstride
* i
),
79 (CONST D3DXVECTOR2
*)((const char*)in
+ instride
* i
),
85 /*************************************************************************
86 * D3DXVec2TransformNormalArray
88 D3DXVECTOR2
* WINAPI
D3DXVec2TransformNormalArray(
89 D3DXVECTOR2
* out
, UINT outstride
, CONST D3DXVECTOR2
*in
, UINT instride
,
90 CONST D3DXMATRIX
*matrix
, UINT elements
)
94 for (i
= 0; i
< elements
; ++i
) {
95 D3DXVec2TransformNormal(
96 (D3DXVECTOR2
*)((char*)out
+ outstride
* i
),
97 (CONST D3DXVECTOR2
*)((const char*)in
+ instride
* i
),
103 /*************************************************************************
104 * D3DXVec3ProjectArray
106 * Projects an array of vectors to the screen.
108 D3DXVECTOR3
* WINAPI
D3DXVec3ProjectArray(
109 D3DXVECTOR3
* out
, UINT outstride
, CONST D3DXVECTOR3
* in
, UINT instride
,
110 CONST D3DVIEWPORT9
* viewport
, CONST D3DXMATRIX
* projection
,
111 CONST D3DXMATRIX
* view
, CONST D3DXMATRIX
* world
, UINT elements
)
115 for (i
= 0; i
< elements
; ++i
) {
117 (D3DXVECTOR3
*)((char*)out
+ outstride
* i
),
118 (CONST D3DXVECTOR3
*)((const char*)in
+ instride
* i
),
119 viewport
, projection
, view
, world
);
124 /*************************************************************************
125 * D3DXVec3TransformArray
127 D3DXVECTOR4
* WINAPI
D3DXVec3TransformArray(
128 D3DXVECTOR4
* out
, UINT outstride
, CONST D3DXVECTOR3
* in
, UINT instride
,
129 CONST D3DXMATRIX
* matrix
, UINT elements
)
133 for (i
= 0; i
< elements
; ++i
) {
135 (D3DXVECTOR4
*)((char*)out
+ outstride
* i
),
136 (CONST D3DXVECTOR3
*)((const char*)in
+ instride
* i
),
142 /*************************************************************************
143 * D3DXVec3TransformCoordArray
145 D3DXVECTOR3
* WINAPI
D3DXVec3TransformCoordArray(
146 D3DXVECTOR3
* out
, UINT outstride
, CONST D3DXVECTOR3
* in
, UINT instride
,
147 CONST D3DXMATRIX
* matrix
, UINT elements
)
151 for (i
= 0; i
< elements
; ++i
) {
152 D3DXVec3TransformCoord(
153 (D3DXVECTOR3
*)((char*)out
+ outstride
* i
),
154 (CONST D3DXVECTOR3
*)((const char*)in
+ instride
* i
),
160 /*************************************************************************
161 * D3DXVec3TransformNormalArray
163 D3DXVECTOR3
* WINAPI
D3DXVec3TransformNormalArray(
164 D3DXVECTOR3
* out
, UINT outstride
, CONST D3DXVECTOR3
* in
, UINT instride
,
165 CONST D3DXMATRIX
* matrix
, UINT elements
)
169 for (i
= 0; i
< elements
; ++i
) {
170 D3DXVec3TransformNormal(
171 (D3DXVECTOR3
*)((char*)out
+ outstride
* i
),
172 (CONST D3DXVECTOR3
*)((const char*)in
+ instride
* i
),
178 /*************************************************************************
179 * D3DXVec3UnprojectArray
181 D3DXVECTOR3
* WINAPI
D3DXVec3UnprojectArray(
182 D3DXVECTOR3
* out
, UINT outstride
, CONST D3DXVECTOR3
* in
, UINT instride
,
183 CONST D3DVIEWPORT9
* viewport
, CONST D3DXMATRIX
* projection
,
184 CONST D3DXMATRIX
* view
, CONST D3DXMATRIX
* world
, UINT elements
)
188 for (i
= 0; i
< elements
; ++i
) {
190 (D3DXVECTOR3
*)((char*)out
+ outstride
* i
),
191 (CONST D3DXVECTOR3
*)((const char*)in
+ instride
* i
),
192 viewport
, projection
, view
, world
);
197 /*************************************************************************
198 * D3DXVec4TransformArray
200 D3DXVECTOR4
* WINAPI
D3DXVec4TransformArray(
201 D3DXVECTOR4
* out
, UINT outstride
, CONST D3DXVECTOR4
* in
, UINT instride
,
202 CONST D3DXMATRIX
* matrix
, UINT elements
)
206 for (i
= 0; i
< elements
; ++i
) {
208 (D3DXVECTOR4
*)((char*)out
+ outstride
* i
),
209 (CONST D3DXVECTOR4
*)((const char*)in
+ instride
* i
),