doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PointFile.cpp
Go to the documentation of this file.
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 
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 
CMainFrame * g_pParentWnd
Definition: MainFrm.cpp:73
#define F(x, y, z)
Definition: md5.c:103
void WINAPI Sys_UpdateWindows(int nBits)
Definition: MainFrm.cpp:3974
float Normalize(void)
Definition: Vector.h:646
#define qglDisable
Definition: qgl_linked.h:92
#define qglGenLists
Definition: qgl_linked.h:126
void Pointfile_Next(void)
Definition: PointFile.cpp:50
const GLdouble * v
Definition: glext.h:2936
const float * ToFloatPtr(void) const
Definition: Vector.h:719
#define VectorSubtract(a, b, c)
Definition: Vector.h:1995
void WINAPI Pointfile_Check(void)
Definition: PointFile.cpp:91
#define VectorCopy(a, b)
Definition: Vector.h:1999
#define WINAPI
Definition: qgl.h:64
#define qglBegin
Definition: qgl_linked.h:33
void Sys_Status(const char *psz, int part)
Definition: Radiant.cpp:465
camera_t & Camera()
Definition: CamWnd.h:90
Definition: Vector.h:316
#define qglVertex3fv
Definition: qgl_linked.h:350
idAngles angles
Definition: CamWnd.h:49
CXYWnd * GetXYWnd()
Definition: MainFrm.h:120
int i
Definition: process.py:33
void Pointfile_Draw(void)
Definition: PointFile.cpp:137
#define MAX_POINTFILE
Definition: PointFile.cpp:34
#define qglDeleteLists
Definition: qgl_linked.h:87
CCamWnd * GetCamera()
Definition: MainFrm.h:123
void Pointfile_Clear(void)
Definition: PointFile.cpp:154
idCommon * common
Definition: Common.cpp:206
#define qglEndList
Definition: qgl_linked.h:104
#define qglEnd
Definition: qgl_linked.h:103
#define qglColor3f
Definition: qgl_linked.h:50
idVec3 origin
Definition: CamWnd.h:48
virtual void Printf(const char *fmt,...) id_attribute((format(printf
void Pointfile_Prev(void)
Definition: PointFile.cpp:71
tuple f
Definition: idal.py:89
#define qglLineWidth
Definition: qgl_linked.h:184
#define qglNewList
Definition: qgl_linked.h:206
const GLcharARB * name
Definition: glext.h:3629
void StripExtension(char *path)
Definition: cmdlib.cpp:222
char currentmap[1024]
Definition: EditorMap.cpp:37
void Pointfile_Delete(void)
Definition: PointFile.cpp:38
idVec3 & GetOrigin()
Definition: XYWnd.cpp:3840