4 vec_t softwaretransform_rotatematrix[3][4];
5 vec_t softwaretransform_matrix[3][4];
6 vec_t softwaretransform_invmatrix[3][4];
7 int softwaretransform_complexity;
9 vec_t softwaretransform_identitymatrix[3][4] =
16 void softwaretransformidentity(void)
18 memcpy(softwaretransform_rotatematrix, softwaretransform_identitymatrix, sizeof(vec_t[3][4]));
19 memcpy(softwaretransform_matrix , softwaretransform_identitymatrix, sizeof(vec_t[3][4]));
20 memcpy(softwaretransform_invmatrix , softwaretransform_identitymatrix, sizeof(vec_t[3][4]));
21 softwaretransform_complexity = 0;
24 void softwaretransformset (vec3_t origin, vec3_t angles, vec_t scale)
27 invscale = 1.0f / scale;
29 Host_Error("softwaretransformset: 0 scale\n");
31 AngleMatrix(angles, origin, softwaretransform_rotatematrix);
33 softwaretransform_matrix[0][0] = softwaretransform_rotatematrix[0][0] * scale;
34 softwaretransform_matrix[0][1] = softwaretransform_rotatematrix[0][1] * scale;
35 softwaretransform_matrix[0][2] = softwaretransform_rotatematrix[0][2] * scale;
36 softwaretransform_matrix[1][0] = softwaretransform_rotatematrix[1][0] * scale;
37 softwaretransform_matrix[1][1] = softwaretransform_rotatematrix[1][1] * scale;
38 softwaretransform_matrix[1][2] = softwaretransform_rotatematrix[1][2] * scale;
39 softwaretransform_matrix[2][0] = softwaretransform_rotatematrix[2][0] * scale;
40 softwaretransform_matrix[2][1] = softwaretransform_rotatematrix[2][1] * scale;
41 softwaretransform_matrix[2][2] = softwaretransform_rotatematrix[2][2] * scale;
42 softwaretransform_matrix[0][3] = softwaretransform_rotatematrix[0][3];
43 softwaretransform_matrix[1][3] = softwaretransform_rotatematrix[1][3];
44 softwaretransform_matrix[2][3] = softwaretransform_rotatematrix[2][3];
46 softwaretransform_invmatrix[0][0] = softwaretransform_rotatematrix[0][0] * invscale;
47 softwaretransform_invmatrix[0][1] = softwaretransform_rotatematrix[1][0] * invscale;
48 softwaretransform_invmatrix[0][2] = softwaretransform_rotatematrix[2][0] * invscale;
49 softwaretransform_invmatrix[1][0] = softwaretransform_rotatematrix[0][1] * invscale;
50 softwaretransform_invmatrix[1][1] = softwaretransform_rotatematrix[1][1] * invscale;
51 softwaretransform_invmatrix[1][2] = softwaretransform_rotatematrix[2][1] * invscale;
52 softwaretransform_invmatrix[2][0] = softwaretransform_rotatematrix[0][2] * invscale;
53 softwaretransform_invmatrix[2][1] = softwaretransform_rotatematrix[1][2] * invscale;
54 softwaretransform_invmatrix[2][2] = softwaretransform_rotatematrix[2][2] * invscale;
55 softwaretransform_invmatrix[0][3] = softwaretransform_rotatematrix[0][3];
56 softwaretransform_invmatrix[1][3] = softwaretransform_rotatematrix[1][3];
57 softwaretransform_invmatrix[2][3] = softwaretransform_rotatematrix[2][3];
59 // choose transform mode
60 if (softwaretransform_matrix[0][0] != 1 || softwaretransform_matrix[0][1] != 0 || softwaretransform_matrix[0][2] != 0
61 || softwaretransform_matrix[1][0] != 0 || softwaretransform_matrix[1][1] != 1 || softwaretransform_matrix[1][2] != 0
62 || softwaretransform_matrix[2][0] != 0 || softwaretransform_matrix[2][1] != 0 || softwaretransform_matrix[2][2] != 1)
63 softwaretransform_complexity = 2;
64 else if (softwaretransform_matrix[0][3] != 0 || softwaretransform_matrix[1][3] != 0 || softwaretransform_matrix[2][3] != 0)
65 softwaretransform_complexity = 1;
67 softwaretransform_complexity = 0;
70 void softwaretransformforentity (entity_render_t *r)
73 if (r->model->type == mod_brush)
75 angles[0] = r->angles[0];
76 angles[1] = r->angles[1];
77 angles[2] = r->angles[2];
78 softwaretransformset(r->origin, angles, r->scale);
82 angles[0] = -r->angles[0];
83 angles[1] = r->angles[1];
84 angles[2] = r->angles[2];
85 softwaretransformset(r->origin, angles, r->scale);