2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2018-09-02 00:57:29 +00:00
|
|
|
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
|
2014-06-12 08:41:03 +00:00
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
2006-03-20 17:12:09 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Matrix setup & manipulation routines
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "3d.h"
|
|
|
|
#include "globvars.h"
|
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:24 +00:00
|
|
|
|
2021-08-26 03:13:45 +00:00
|
|
|
static void scale_matrix(fix);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//set view from x,y,z, viewer matrix, and zoom. Must call one of g3_set_view_*()
|
2014-10-26 22:01:00 +00:00
|
|
|
void g3_set_view_matrix(const vms_vector &view_pos,const vms_matrix &view_matrix,fix zoom)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2014-10-26 22:01:00 +00:00
|
|
|
View_position = view_pos;
|
|
|
|
View_matrix = view_matrix;
|
2021-08-26 03:13:45 +00:00
|
|
|
scale_matrix(zoom);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//performs aspect scaling on global view matrix
|
2021-08-26 03:13:45 +00:00
|
|
|
static void scale_matrix(const fix View_zoom)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
Unscaled_matrix = View_matrix; //so we can use unscaled if we want
|
|
|
|
|
|
|
|
Matrix_scale = Window_scale;
|
|
|
|
|
|
|
|
if (View_zoom <= f1_0) //zoom in by scaling z
|
|
|
|
|
|
|
|
Matrix_scale.z = fixmul(Matrix_scale.z,View_zoom);
|
|
|
|
|
|
|
|
else { //zoom out by scaling x&y
|
|
|
|
|
|
|
|
fix s = fixdiv(f1_0,View_zoom);
|
|
|
|
|
|
|
|
Matrix_scale.x = fixmul(Matrix_scale.x,s);
|
|
|
|
Matrix_scale.y = fixmul(Matrix_scale.y,s);
|
|
|
|
}
|
|
|
|
|
|
|
|
//now scale matrix elements
|
|
|
|
|
2014-09-28 21:11:05 +00:00
|
|
|
vm_vec_scale(View_matrix.rvec,Matrix_scale.x);
|
|
|
|
vm_vec_scale(View_matrix.uvec,Matrix_scale.y);
|
|
|
|
vm_vec_scale(View_matrix.fvec,Matrix_scale.z);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-12-05 22:57:24 +00:00
|
|
|
}
|