1 /* $Id: matrix.c,v 1.4 2002-07-17 21:55:19 bradleyb 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
20 * Revision 1.1 1995/05/05 08:52:11 allender
23 * Revision 1.1 1995/04/17 04:14:34 matt
34 static char rcsid[] = "$Id: matrix.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $";
40 void scale_matrix(void);
42 //set view from x,y,z & p,b,h, zoom. Must call one of g3_set_view_*()
43 void g3_set_view_angles(vms_vector *view_pos,vms_angvec *view_orient,fix zoom)
46 View_position = *view_pos;
48 vm_angles_2_matrix(&View_matrix,view_orient);
51 Win32_set_view_matrix ();
57 //set view from x,y,z, viewer matrix, and zoom. Must call one of g3_set_view_*()
58 void g3_set_view_matrix(vms_vector *view_pos,vms_matrix *view_matrix,fix zoom)
61 View_position = *view_pos;
63 View_matrix = *view_matrix;
66 Win32_set_view_matrix ();
72 //performs aspect scaling on global view matrix
73 void scale_matrix(void)
75 Unscaled_matrix = View_matrix; //so we can use unscaled if we want
77 Matrix_scale = Window_scale;
79 if (View_zoom <= f1_0) //zoom in by scaling z
81 Matrix_scale.z = fixmul(Matrix_scale.z,View_zoom);
83 else { //zoom out by scaling x&y
85 fix s = fixdiv(f1_0,View_zoom);
87 Matrix_scale.x = fixmul(Matrix_scale.x,s);
88 Matrix_scale.y = fixmul(Matrix_scale.y,s);
91 //now scale matrix elements
93 vm_vec_scale(&View_matrix.rvec,Matrix_scale.x);
94 vm_vec_scale(&View_matrix.uvec,Matrix_scale.y);
95 vm_vec_scale(&View_matrix.fvec,Matrix_scale.z);