Debian Codegraph @

tools/quake2/extra/qe4/points.c

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
4
5 This file is part of Quake 2 Tools source code.
6
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22
23 #include "qe3.h"
24
25
26 #define MAX_POINTFILE 8192
27 static vec3_t s_pointvecs[MAX_POINTFILE];
28 static int s_num_points, s_check_point;
29
30 void Pointfile_Delete (void)
31 {
32 char name[1024];
33
34 strcpy (name, currentmap);
35 StripExtension (name);
36 strcat (name, ".lin");
37
38 remove(name);
39 }
40
41 // advance camera to next point
42 void Pointfile_Next (void)
43 {
44 vec3_t dir;
45
46 if (s_check_point >= s_num_points-2)
47 {
48 Sys_Status ("End of pointfile", 0);
49 return;
50 }
51 s_check_point++;
52 VectorCopy (s_pointvecs[s_check_point], camera.origin);
53 VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_xy.origin);
54 VectorSubtract (s_pointvecs[s_check_point+1], camera.origin, dir);
55 VectorNormalize (dir);
56 camera.angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
57 camera.angles[0] = asin (dir[2])*180/3.14159;
58
59 Sys_UpdateWindows (W_ALL);
60 }
61
62 // advance camera to previous point
63 void Pointfile_Prev (void)
64 {
65 vec3_t dir;
66
67 if ( s_check_point == 0)
68 {
69 Sys_Status ("Start of pointfile", 0);
70 return;
71 }
72 s_check_point--;
73 VectorCopy (s_pointvecs[s_check_point], camera.origin);
74 VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_xy.origin);
75 VectorSubtract (s_pointvecs[s_check_point+1], camera.origin, dir);
76 VectorNormalize (dir);
77 camera.angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
78 camera.angles[0] = asin (dir[2])*180/3.14159;
79
80 Sys_UpdateWindows (W_ALL);
81 }
82
83 void Pointfile_Check (void)
84 {
85 char name[1024];
86 FILE *f;
87 vec3_t v;
88
89 strcpy (name, currentmap);
90 StripExtension (name);
91 strcat (name, ".lin");
92
93 f = fopen (name, "r");
94 if (!f)
95 return;
96
97 Sys_Printf ("Reading pointfile %s\n", name);
98
99 if (!g_qeglobals.d_pointfile_display_list)
100 g_qeglobals.d_pointfile_display_list = glGenLists(1);
101
102 s_num_points = 0;
103 glNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE);
104 glColor3f (1, 0, 0);
105 glDisable(GL_TEXTURE_2D);
106 glDisable(GL_TEXTURE_1D);
107 glLineWidth (4);
108 glBegin(GL_LINE_STRIP);
109 do
110 {
111 if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
112 break;
113 if (s_num_points < MAX_POINTFILE)
114 {
115 VectorCopy (v, s_pointvecs[s_num_points]);
116 s_num_points++;
117 }
118 glVertex3fv (v);
119 } while (1);
120 glEnd();
121 glLineWidth (1);
122 glEndList ();
123
124 s_check_point = 0;
125 fclose (f);
126 Pointfile_Next ();
127 }
128
129 void Pointfile_Draw( void )
130 {
131 int i;
132
133 glColor3f( 1.0F, 0.0F, 0.0F );
134 glDisable(GL_TEXTURE_2D);
135 glDisable(GL_TEXTURE_1D);
136 glLineWidth (4);
137 glBegin(GL_LINE_STRIP);
138 for ( i = 0; i < s_num_points; i++ )
139 {
140 glVertex3fv( s_pointvecs[i] );
141 }
142 glEnd();
143 glLineWidth( 1 );
144 }
145
146 void Pointfile_Clear (void)
147 {
148 if (!g_qeglobals.d_pointfile_display_list)
149 return;
150
151 glDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
152 g_qeglobals.d_pointfile_display_list = 0;
153 Sys_UpdateWindows (W_ALL);
154 }
155