Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
3
 * It is copyright by its individual contributors, as recorded in the
4
 * project's Git history.  See COPYING.txt at the top level for license
5
 * terms and a link to the Git history.
6
 */
7
/*
8
 *
9
 * Matrix setup & manipulation routines
10
 *
11
 */
12
 
13
 
14
#include "3d.h"
15
#include "globvars.h"
16
 
17
namespace dcx {
18
 
19
static void scale_matrix(void);
20
 
21
//set view from x,y,z, viewer matrix, and zoom.  Must call one of g3_set_view_*() 
22
void g3_set_view_matrix(const vms_vector &view_pos,const vms_matrix &view_matrix,fix zoom)
23
{
24
        View_zoom = zoom;
25
        View_position = view_pos;
26
        View_matrix = view_matrix;
27
        scale_matrix();
28
}
29
 
30
//performs aspect scaling on global view matrix
31
static void scale_matrix(void)
32
{
33
        Unscaled_matrix = View_matrix;          //so we can use unscaled if we want
34
 
35
        Matrix_scale = Window_scale;
36
 
37
        if (View_zoom <= f1_0)          //zoom in by scaling z
38
 
39
                Matrix_scale.z =  fixmul(Matrix_scale.z,View_zoom);
40
 
41
        else {                  //zoom out by scaling x&y
42
 
43
                fix s = fixdiv(f1_0,View_zoom);
44
 
45
                Matrix_scale.x = fixmul(Matrix_scale.x,s);
46
                Matrix_scale.y = fixmul(Matrix_scale.y,s);
47
        }
48
 
49
        //now scale matrix elements
50
 
51
        vm_vec_scale(View_matrix.rvec,Matrix_scale.x);
52
        vm_vec_scale(View_matrix.uvec,Matrix_scale.y);
53
        vm_vec_scale(View_matrix.fvec,Matrix_scale.z);
54
 
55
}
56
 
57
}