-
Notifications
You must be signed in to change notification settings - Fork 0
/
points.c
136 lines (112 loc) · 2.91 KB
/
points.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// points.c
#include "qe3.h"
//#define MAX_POINTFILE 4096 //EER1
#define MAX_POINTFILE 8192
static vec3_t s_pointvecs[MAX_POINTFILE];
static int s_num_points, s_check_point;
void Pointfile_Delete (void)
{
char name[1024];
strcpy (name, currentmap);
StripExtension (name);
strcat (name, ".pts");
remove(name);
}
// advance camera to next point
void Pointfile_Next (void)
{
vec3_t dir;
if (s_check_point >= s_num_points-2)
{
Sys_Printf ("End of pointfile\n");
return;
}
s_check_point++;
VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_camera.origin);
VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_xyz.origin);
VectorSubtract (s_pointvecs[s_check_point+1], g_qeglobals.d_camera.origin, dir);
VectorNormalize (dir);
g_qeglobals.d_camera.angles[1] = atan2 (dir[1], dir[0])*180/Q_PI;
g_qeglobals.d_camera.angles[0] = asin (dir[2])*180/Q_PI;
Sys_UpdateWindows (W_ALL);
}
// advance camera to previous point
void Pointfile_Prev (void)
{
vec3_t dir;
if ( s_check_point == 0)
{
Sys_Printf ("Start of pointfile\n");
return;
}
s_check_point--;
VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_camera.origin);
VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_xyz.origin);
VectorSubtract (s_pointvecs[s_check_point+1], g_qeglobals.d_camera.origin, dir);
VectorNormalize (dir);
g_qeglobals.d_camera.angles[1] = atan2 (dir[1], dir[0])*180/Q_PI;
g_qeglobals.d_camera.angles[0] = asin (dir[2])*180/Q_PI;
Sys_UpdateWindows (W_ALL);
}
void Pointfile_Check (void)
{
char name[1024];
FILE *f;
vec3_t v;
strcpy (name, currentmap);
StripExtension (name);
strcat (name, ".pts");
f = fopen (name, "r");
if (!f)
return;
Sys_Printf ("Reading pointfile %s\n", name);
if (!g_qeglobals.d_pointfile_display_list)
g_qeglobals.d_pointfile_display_list = glGenLists(1);
s_num_points = 0;
glNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE);
glColor3f (1, 0, 0);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glLineWidth (4);
glBegin(GL_LINE_STRIP);
do
{
if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
break;
if (s_num_points < MAX_POINTFILE)
{
VectorCopy (v, s_pointvecs[s_num_points]);
s_num_points++;
}
glVertex3fv (v);
} while (1);
glEnd();
glLineWidth (1);
glEndList ();
s_check_point = 0;
fclose (f);
Pointfile_Next ();
}
void Pointfile_Draw( void )
{
int i;
glColor3f( 1.0F, 0.0F, 0.0F );
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glLineWidth (4);
glBegin(GL_LINE_STRIP);
for ( i = 0; i < s_num_points; i++ )
{
glVertex3fv( s_pointvecs[i] );
}
glEnd();
glLineWidth( 1 );
}
void Pointfile_Clear (void)
{
if (!g_qeglobals.d_pointfile_display_list)
return;
glDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
g_qeglobals.d_pointfile_display_list = 0;
Sys_UpdateWindows (W_ALL);
}