1 /* $Id: matrix.c,v 1.5 2004-08-28 23:17:45 schaffner Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Matrix setup & manipulation routines
25 static char rcsid[] = "$Id: matrix.c,v 1.5 2004-08-28 23:17:45 schaffner Exp $";
31 void scale_matrix(void);
33 //set view from x,y,z & p,b,h, zoom. Must call one of g3_set_view_*()
34 void g3_set_view_angles(vms_vector *view_pos,vms_angvec *view_orient,fix zoom)
37 View_position = *view_pos;
39 vm_angles_2_matrix(&View_matrix,view_orient);
42 Win32_set_view_matrix ();
48 //set view from x,y,z, viewer matrix, and zoom. Must call one of g3_set_view_*()
49 void g3_set_view_matrix(vms_vector *view_pos,vms_matrix *view_matrix,fix zoom)
52 View_position = *view_pos;
54 View_matrix = *view_matrix;
57 Win32_set_view_matrix ();
63 //performs aspect scaling on global view matrix
64 void scale_matrix(void)
66 Unscaled_matrix = View_matrix; //so we can use unscaled if we want
68 Matrix_scale = Window_scale;
70 if (View_zoom <= f1_0) //zoom in by scaling z
72 Matrix_scale.z = fixmul(Matrix_scale.z,View_zoom);
74 else { //zoom out by scaling x&y
76 fix s = fixdiv(f1_0,View_zoom);
78 Matrix_scale.x = fixmul(Matrix_scale.x,s);
79 Matrix_scale.y = fixmul(Matrix_scale.y,s);
82 //now scale matrix elements
84 vm_vec_scale(&View_matrix.rvec,Matrix_scale.x);
85 vm_vec_scale(&View_matrix.uvec,Matrix_scale.y);
86 vm_vec_scale(&View_matrix.fvec,Matrix_scale.z);