2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
14 * $Source: /cvs/cvsroot/d2x/3d/instance.c,v $
17 * $Date: 2001-01-31 15:17:48 $
21 * $Log: not supported by cvs2svn $
22 * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb
25 * Revision 1.1.1.1 1999/06/14 21:57:45 donut
26 * Import of d1x 1.37 source.
28 * Revision 1.2 1995/06/12 12:36:57 allender
29 * fixed bug where g3_start_instance_angles recursively called itself
31 * Revision 1.1 1995/05/05 08:51:27 allender
34 * Revision 1.1 1995/04/17 06:43:29 matt
45 static char rcsid[] = "$Id: instance.c,v 1.2 2001-01-31 15:17:48 bradleyb Exp $";
57 #define MAX_INSTANCE_DEPTH 5
59 struct instance_context {
62 } instance_stack[MAX_INSTANCE_DEPTH];
64 int instance_depth = 0;
66 //instance at specified point with specified orientation
67 //if matrix==NULL, don't modify matrix. This will be like doing an offset
68 void g3_start_instance_matrix(vms_vector *pos,vms_matrix *orient)
71 vms_matrix tempm,tempm2;
74 Win32_start_instance_matrix (pos, orient);
77 Assert(instance_depth<MAX_INSTANCE_DEPTH);
79 instance_stack[instance_depth].m = View_matrix;
80 instance_stack[instance_depth].p = View_position;
83 //step 1: subtract object position from view position
85 vm_vec_sub(&tempv,&View_position,pos);
90 //step 2: rotate view vector through object matrix
92 vm_vec_rotate(&View_position,&tempv,orient);
94 //step 3: rotate object matrix through view_matrix (vm = ob * vm)
96 vm_copy_transpose_matrix(&tempm2,orient);
98 vm_matrix_x_matrix(&tempm,&tempm2,&View_matrix);
104 //instance at specified point with specified orientation
105 //if angles==NULL, don't modify matrix. This will be like doing an offset
106 void g3_start_instance_angles(vms_vector *pos,vms_angvec *angles)
111 g3_start_instance_matrix(pos,NULL);
115 vm_angles_2_matrix(&tm,angles);
117 g3_start_instance_matrix(pos,&tm);
122 //pops the old context
123 void g3_done_instance()
126 Win32_done_instance ();
131 Assert(instance_depth >= 0);
133 View_position = instance_stack[instance_depth].p;
134 View_matrix = instance_stack[instance_depth].m;