]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/tools/radiant/PointFile.cpp
Various Mac OS X tweaks to get this to build. Probably breaking things.
[icculus/iodoom3.git] / neo / tools / radiant / PointFile.cpp
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.
23
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25
26 ===========================================================================
27 */
28
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31
32 #include "qe3.h"
33
34 #define MAX_POINTFILE   8192
35 static idVec3   s_pointvecs[MAX_POINTFILE];
36 static int              s_num_points, s_check_point;
37
38 void Pointfile_Delete (void)
39 {
40         char    name[1024];
41
42         strcpy (name, currentmap);
43         StripExtension (name);
44         strcat (name, ".lin");
45
46         remove(name);
47 }
48
49 // advance camera to next point
50 void Pointfile_Next (void)
51 {
52         idVec3  dir;
53
54         if (s_check_point >= s_num_points-2)
55         {
56                 Sys_Status ("End of pointfile", 0);
57                 return;
58         }
59         s_check_point++;
60         VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
61         VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
62         VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
63         dir.Normalize();
64         g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
65         g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
66
67         Sys_UpdateWindows (W_ALL);
68 }
69
70 // advance camera to previous point
71 void Pointfile_Prev (void)
72 {
73         idVec3  dir;
74
75         if ( s_check_point == 0)
76         {
77                 Sys_Status ("Start of pointfile", 0);
78                 return;
79         }
80         s_check_point--;
81         VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
82         VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
83         VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
84         dir.Normalize();
85         g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
86         g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
87
88         Sys_UpdateWindows (W_ALL);
89 }
90
91 void WINAPI Pointfile_Check (void)
92 {
93         char    name[1024];
94         FILE    *f;
95         idVec3  v;
96
97         strcpy (name, currentmap);
98         StripExtension (name);
99         strcat (name, ".lin");
100
101         f = fopen (name, "r");
102         if (!f)
103                 return;
104
105         common->Printf ("Reading pointfile %s\n", name);
106
107         if (!g_qeglobals.d_pointfile_display_list)
108                 g_qeglobals.d_pointfile_display_list = qglGenLists(1);
109
110         s_num_points = 0;
111   qglNewList (g_qeglobals.d_pointfile_display_list,  GL_COMPILE);
112         qglColor3f (1, 0, 0);
113         qglDisable(GL_TEXTURE_2D);
114         qglDisable(GL_TEXTURE_1D);
115         qglLineWidth (2);
116         qglBegin(GL_LINE_STRIP);
117         do
118         {
119                 if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
120                         break;
121                 if (s_num_points < MAX_POINTFILE)
122                 {
123                         VectorCopy (v, s_pointvecs[s_num_points]);
124                         s_num_points++;
125                 }
126                 qglVertex3fv( v.ToFloatPtr() );
127         } while (1);
128         qglEnd();
129         qglLineWidth (0.5);
130         qglEndList ();
131
132         s_check_point = 0;
133         fclose (f);
134         //Pointfile_Next ();
135 }
136
137 void Pointfile_Draw( void )
138 {
139         int i;
140
141         qglColor3f( 1.0F, 0.0F, 0.0F );
142         qglDisable(GL_TEXTURE_2D);
143         qglDisable(GL_TEXTURE_1D);
144         qglLineWidth (2);
145         qglBegin(GL_LINE_STRIP);
146         for ( i = 0; i < s_num_points; i++ )
147         {
148                 qglVertex3fv( s_pointvecs[i].ToFloatPtr() );
149         }
150         qglEnd();
151         qglLineWidth( 0.5 );
152 }
153
154 void Pointfile_Clear (void)
155 {
156         if (!g_qeglobals.d_pointfile_display_list)
157                 return;
158
159         qglDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
160         g_qeglobals.d_pointfile_display_list = 0;
161         Sys_UpdateWindows (W_ALL);
162 }
163