27 origin[0] = (1.f-e->backlerp) * e->origin[0] + e->backlerp * e->oldorigin[0];
28 origin[1] = (1.f-e->backlerp) * e->origin[1] + e->backlerp * e->oldorigin[1];
29 origin[2] = (1.f-e->backlerp) * e->origin[2] + e->backlerp * e->oldorigin[2];
31 AnglesToAxis(e->angles, axis);
33 float scale = (e->scale > 0.f) ? e->scale : 1.f;
35 vec3_t scales = { scale, scale, scale };
36 if ((e->flags & RF_LEFTHAND) && enable_left_hand)
41 matrix[0] = axis[0][0] * scales[0];
42 matrix[4] = axis[1][0] * scales[1];
43 matrix[8] = axis[2][0] * scales[2];
46 matrix[1] = axis[0][1] * scales[0];
47 matrix[5] = axis[1][1] * scales[1];
48 matrix[9] = axis[2][1] * scales[2];
51 matrix[2] = axis[0][2] * scales[0];
52 matrix[6] = axis[1][2] * scales[1];
53 matrix[10] = axis[2][2] * scales[2];
65 float xmin, xmax, ymin, ymax;
68 ymax = znear * tan(fov_y * M_PI / 360.0);
71 xmax = znear * tan(fov_x * M_PI / 360.0);
78 matrix[0] = 2 * znear /
width;
80 matrix[8] = (xmax + xmin) /
width;
84 matrix[5] = -2 * znear /
height;
85 matrix[9] = (ymax + ymin) /
height;
90 matrix[10] = (zfar + znear) / depth;
91 matrix[14] = 2 * zfar * znear / depth;
101 float ymin,
float ymax,
float znear,
float zfar)
107 depth = zfar - znear;
109 matrix[0] = 2 /
width;
112 matrix[12] = -(xmax + xmin) /
width;
117 matrix[13] = -(ymax + ymin) /
height;
121 matrix[10] = 1 / depth;
122 matrix[14] = -znear / depth;
134 AnglesToAxis(fd->viewangles, viewaxis);
136 matrix[0] = -viewaxis[1][0];
137 matrix[4] = -viewaxis[1][1];
138 matrix[8] = -viewaxis[1][2];
139 matrix[12] = DotProduct(viewaxis[1], fd->vieworg);
141 matrix[1] = viewaxis[2][0];
142 matrix[5] = viewaxis[2][1];
143 matrix[9] = viewaxis[2][2];
144 matrix[13] = -DotProduct(viewaxis[2], fd->vieworg);
146 matrix[2] = viewaxis[0][0];
147 matrix[6] = viewaxis[0][1];
148 matrix[10] = viewaxis[0][2];
149 matrix[14] = -DotProduct(viewaxis[0], fd->vieworg);
160 inv[0] =
m[5] *
m[10] *
m[15] -
161 m[5] *
m[11] *
m[14] -
162 m[9] *
m[6] *
m[15] +
163 m[9] *
m[7] *
m[14] +
164 m[13] *
m[6] *
m[11] -
165 m[13] *
m[7] *
m[10];
167 inv[1] = -
m[1] *
m[10] *
m[15] +
168 m[1] *
m[11] *
m[14] +
169 m[9] *
m[2] *
m[15] -
170 m[9] *
m[3] *
m[14] -
171 m[13] *
m[2] *
m[11] +
172 m[13] *
m[3] *
m[10];
174 inv[2] =
m[1] *
m[6] *
m[15] -
175 m[1] *
m[7] *
m[14] -
176 m[5] *
m[2] *
m[15] +
177 m[5] *
m[3] *
m[14] +
178 m[13] *
m[2] *
m[7] -
181 inv[3] = -
m[1] *
m[6] *
m[11] +
182 m[1] *
m[7] *
m[10] +
183 m[5] *
m[2] *
m[11] -
184 m[5] *
m[3] *
m[10] -
188 inv[4] = -
m[4] *
m[10] *
m[15] +
189 m[4] *
m[11] *
m[14] +
190 m[8] *
m[6] *
m[15] -
191 m[8] *
m[7] *
m[14] -
192 m[12] *
m[6] *
m[11] +
193 m[12] *
m[7] *
m[10];
195 inv[5] =
m[0] *
m[10] *
m[15] -
196 m[0] *
m[11] *
m[14] -
197 m[8] *
m[2] *
m[15] +
198 m[8] *
m[3] *
m[14] +
199 m[12] *
m[2] *
m[11] -
200 m[12] *
m[3] *
m[10];
202 inv[6] = -
m[0] *
m[6] *
m[15] +
203 m[0] *
m[7] *
m[14] +
204 m[4] *
m[2] *
m[15] -
205 m[4] *
m[3] *
m[14] -
206 m[12] *
m[2] *
m[7] +
209 inv[7] =
m[0] *
m[6] *
m[11] -
210 m[0] *
m[7] *
m[10] -
211 m[4] *
m[2] *
m[11] +
212 m[4] *
m[3] *
m[10] +
216 inv[8] =
m[4] *
m[9] *
m[15] -
217 m[4] *
m[11] *
m[13] -
218 m[8] *
m[5] *
m[15] +
219 m[8] *
m[7] *
m[13] +
220 m[12] *
m[5] *
m[11] -
223 inv[9] = -
m[0] *
m[9] *
m[15] +
224 m[0] *
m[11] *
m[13] +
225 m[8] *
m[1] *
m[15] -
226 m[8] *
m[3] *
m[13] -
227 m[12] *
m[1] *
m[11] +
230 inv[10] =
m[0] *
m[5] *
m[15] -
231 m[0] *
m[7] *
m[13] -
232 m[4] *
m[1] *
m[15] +
233 m[4] *
m[3] *
m[13] +
234 m[12] *
m[1] *
m[7] -
237 inv[11] = -
m[0] *
m[5] *
m[11] +
239 m[4] *
m[1] *
m[11] -
244 inv[12] = -
m[4] *
m[9] *
m[14] +
245 m[4] *
m[10] *
m[13] +
246 m[8] *
m[5] *
m[14] -
247 m[8] *
m[6] *
m[13] -
248 m[12] *
m[5] *
m[10] +
251 inv[13] =
m[0] *
m[9] *
m[14] -
252 m[0] *
m[10] *
m[13] -
253 m[8] *
m[1] *
m[14] +
254 m[8] *
m[2] *
m[13] +
255 m[12] *
m[1] *
m[10] -
258 inv[14] = -
m[0] *
m[5] *
m[14] +
259 m[0] *
m[6] *
m[13] +
260 m[4] *
m[1] *
m[14] -
261 m[4] *
m[2] *
m[13] -
262 m[12] *
m[1] *
m[6] +
265 inv[15] =
m[0] *
m[5] *
m[10] -
267 m[4] *
m[1] *
m[10] +
272 float det =
m[0] * inv[0] +
m[1] * inv[4] +
m[2] * inv[8] +
m[3] * inv[12];
276 for(
int i = 0; i < 16; i++)
277 inv[i] = inv[i] * det;
283 for(
int i = 0; i < 4; i++) {
284 for(
int j = 0; j < 4; j++) {
286 a[0 * 4 + j] * b[i * 4 + 0] +
287 a[1 * 4 + j] * b[i * 4 + 1] +
288 a[2 * 4 + j] * b[i * 4 + 2] +
289 a[3 * 4 + j] * b[i * 4 + 3];
298 for (j = 0; j < 4; j++) {
300 a[0 * 4 + j] * b[0] +
301 a[1 * 4 + j] * b[1] +
302 a[2 * 4 + j] * b[2] +