2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
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.
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.
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 ===========================================================================
26 #define MAX_POINTFILE 8192
27 static vec3_t s_pointvecs[MAX_POINTFILE];
28 static int s_num_points, s_check_point;
30 void Pointfile_Delete (void)
34 strcpy (name, currentmap);
35 StripExtension (name);
36 strcat (name, ".lin");
41 // advance camera to next point
42 void Pointfile_Next (void)
46 if (s_check_point >= s_num_points-2)
48 Sys_Status ("End of pointfile", 0);
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;
59 Sys_UpdateWindows (W_ALL);
62 // advance camera to previous point
63 void Pointfile_Prev (void)
67 if ( s_check_point == 0)
69 Sys_Status ("Start of pointfile", 0);
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;
80 Sys_UpdateWindows (W_ALL);
83 void Pointfile_Check (void)
89 strcpy (name, currentmap);
90 StripExtension (name);
91 strcat (name, ".lin");
93 f = fopen (name, "r");
97 Sys_Printf ("Reading pointfile %s\n", name);
99 if (!g_qeglobals.d_pointfile_display_list)
100 g_qeglobals.d_pointfile_display_list = glGenLists(1);
103 glNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE);
105 glDisable(GL_TEXTURE_2D);
106 glDisable(GL_TEXTURE_1D);
108 glBegin(GL_LINE_STRIP);
111 if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
113 if (s_num_points < MAX_POINTFILE)
115 VectorCopy (v, s_pointvecs[s_num_points]);
129 void Pointfile_Draw( void )
133 glColor3f( 1.0F, 0.0F, 0.0F );
134 glDisable(GL_TEXTURE_2D);
135 glDisable(GL_TEXTURE_1D);
137 glBegin(GL_LINE_STRIP);
138 for ( i = 0; i < s_num_points; i++ )
140 glVertex3fv( s_pointvecs[i] );
146 void Pointfile_Clear (void)
148 if (!g_qeglobals.d_pointfile_display_list)
151 glDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
152 g_qeglobals.d_pointfile_display_list = 0;
153 Sys_UpdateWindows (W_ALL);