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.
29 #define MAX_INSTANCE_DEPTH 5
31 struct instance_context {
34 } instance_stack[MAX_INSTANCE_DEPTH];
36 int instance_depth = 0;
38 //instance at specified point with specified orientation
39 //if matrix==NULL, don't modify matrix. This will be like doing an offset
40 void g3_start_instance_matrix(vms_vector *pos,vms_matrix *orient)
43 vms_matrix tempm,tempm2;
45 Assert(instance_depth<MAX_INSTANCE_DEPTH);
47 instance_stack[instance_depth].m = View_matrix;
48 instance_stack[instance_depth].p = View_position;
51 //step 1: subtract object position from view position
53 vm_vec_sub(&tempv,&View_position,pos);
58 //step 2: rotate view vector through object matrix
60 vm_vec_rotate(&View_position,&tempv,orient);
62 //step 3: rotate object matrix through view_matrix (vm = ob * vm)
64 vm_copy_transpose_matrix(&tempm2,orient);
66 vm_matrix_x_matrix(&tempm,&tempm2,&View_matrix);
72 //instance at specified point with specified orientation
73 //if angles==NULL, don't modify matrix. This will be like doing an offset
74 void g3_start_instance_angles(vms_vector *pos,vms_angvec *angles)
79 g3_start_instance_matrix(pos,NULL);
83 vm_angles_2_matrix(&tm,angles);
85 g3_start_instance_matrix(pos,&tm);
90 //pops the old context
91 void g3_done_instance()
95 Assert(instance_depth >= 0);
97 View_position = instance_stack[instance_depth].p;
98 View_matrix = instance_stack[instance_depth].m;