POINTS.CPP (3957B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena 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 III Arena 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 Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 #include "stdafx.h" 23 24 #include "qe3.h" 25 26 27 #define MAX_POINTFILE 8192 28 static vec3_t s_pointvecs[MAX_POINTFILE]; 29 static int s_num_points, s_check_point; 30 31 void Pointfile_Delete (void) 32 { 33 char name[1024]; 34 35 strcpy (name, currentmap); 36 StripExtension (name); 37 strcat (name, ".lin"); 38 39 remove(name); 40 } 41 42 // advance camera to next point 43 void Pointfile_Next (void) 44 { 45 vec3_t dir; 46 47 if (s_check_point >= s_num_points-2) 48 { 49 Sys_Status ("End of pointfile", 0); 50 return; 51 } 52 s_check_point++; 53 VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin); 54 VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin()); 55 VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir); 56 VectorNormalize (dir); 57 g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159; 58 g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159; 59 60 Sys_UpdateWindows (W_ALL); 61 } 62 63 // advance camera to previous point 64 void Pointfile_Prev (void) 65 { 66 vec3_t dir; 67 68 if ( s_check_point == 0) 69 { 70 Sys_Status ("Start of pointfile", 0); 71 return; 72 } 73 s_check_point--; 74 VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin); 75 VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin()); 76 VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir); 77 VectorNormalize (dir); 78 g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159; 79 g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159; 80 81 Sys_UpdateWindows (W_ALL); 82 } 83 84 void WINAPI Pointfile_Check (void) 85 { 86 char name[1024]; 87 FILE *f; 88 vec3_t v; 89 90 strcpy (name, currentmap); 91 StripExtension (name); 92 strcat (name, ".lin"); 93 94 f = fopen (name, "r"); 95 if (!f) 96 return; 97 98 Sys_Printf ("Reading pointfile %s\n", name); 99 100 if (!g_qeglobals.d_pointfile_display_list) 101 g_qeglobals.d_pointfile_display_list = qglGenLists(1); 102 103 s_num_points = 0; 104 qglNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE); 105 qglColor3f (1, 0, 0); 106 qglDisable(GL_TEXTURE_2D); 107 qglDisable(GL_TEXTURE_1D); 108 qglLineWidth (4); 109 qglBegin(GL_LINE_STRIP); 110 do 111 { 112 if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3) 113 break; 114 if (s_num_points < MAX_POINTFILE) 115 { 116 VectorCopy (v, s_pointvecs[s_num_points]); 117 s_num_points++; 118 } 119 qglVertex3fv (v); 120 } while (1); 121 qglEnd(); 122 qglLineWidth (1); 123 qglEndList (); 124 125 s_check_point = 0; 126 fclose (f); 127 //Pointfile_Next (); 128 } 129 130 void Pointfile_Draw( void ) 131 { 132 int i; 133 134 qglColor3f( 1.0F, 0.0F, 0.0F ); 135 qglDisable(GL_TEXTURE_2D); 136 qglDisable(GL_TEXTURE_1D); 137 qglLineWidth (4); 138 qglBegin(GL_LINE_STRIP); 139 for ( i = 0; i < s_num_points; i++ ) 140 { 141 qglVertex3fv( s_pointvecs[i] ); 142 } 143 qglEnd(); 144 qglLineWidth( 1 ); 145 } 146 147 void Pointfile_Clear (void) 148 { 149 if (!g_qeglobals.d_pointfile_display_list) 150 return; 151 152 qglDeleteLists (g_qeglobals.d_pointfile_display_list, 1); 153 g_qeglobals.d_pointfile_display_list = 0; 154 Sys_UpdateWindows (W_ALL); 155 } 156