-
Notifications
You must be signed in to change notification settings - Fork 148
/
g_camera.cpp
256 lines (204 loc) · 6.13 KB
/
g_camera.cpp
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
// leave this line at the top for all g_xxxx.cpp files...
#include "g_headers.h"
//g_camera.cpp
#include "g_local.h"
//#include "Q3_Interface.h"
//#include "anims.h"
//#include "b_local.h"
#include "..\cgame\cg_camera.h"
#include "g_functions.h"
/*
#define MAX_CAMERA_GROUP_SUBJECTS 16
void misc_camera_focus_think (gentity_t *self)
{
//Check to see if I should stop?
gi.linkentity(self);
self->nextthink = level.time + FRAMETIME;
}
void misc_camera_focus_use (gentity_t *self, gentity_t *other, gentity_t *activator)
{
G_ActivateBehavior(self,BSET_USE);
//First, find everyone in my cameraGroup, if I have one
//Now find my first path_corner, if I have one
//Start thinking
self->e_ThinkFunc = thinkF_misc_camera_focus_think;
misc_camera_focus_think(self);
self->e_clThinkFunc = clThinkF_CG_MiscCameraFocusThink; // blurgh!...
self->s.eType = ET_THINKER;
self->aimDebounceTime = level.time;
}
*/
/*QUAK-ED misc_camera_focus (0 0 1) (-4 -4 -4) (4 4 4) lerptostart
LERPTOSTART - With interpolate from camera's current angles to this thing's start angle instead of snapping to it, which is the default behavior
The focal point for a camera in a scene
"targetname" - Use it to get it to find it's cameraGroup and start tracking it, also get started on it's path, if any
"cameraGroup" - will find all ents in this group and pick a point in the center of that group.
"speed" angular speed modifier - 100 is normal
*/
void SP_misc_camera_focus (gentity_t *self)
{
if(!self->targetname)
{
gi.Printf(S_COLOR_RED"ERROR: misc_camera_focus with no targetname\n");
G_FreeEntity(self);
return;
}
/*
if(self->speed > 0)
{
self->moveInfo.aspeed = self->speed;
}
else
{
self->moveInfo.aspeed = 100.f;
}
*/
self->speed = 0;
self->script_targetname = G_NewString(self->targetname);
// self->e_UseFunc = useF_misc_camera_focus_use;
}
/*
void misc_camera_track_think (gentity_t *self)
{
vec3_t vec;
float dist;
//Check to see if I should stop?
gi.linkentity(self);
if(self->enemy)
{//We're already heading to a path_corner
VectorSubtract(self->currentOrigin, self->s.origin2, vec);
dist = VectorLengthSquared(vec);
if(dist < 256)//16 squared
{
G_UseTargets(self, self);
self->target = self->enemy->target;
self->enemy = NULL;
}
}
if( !self->enemy)
{
if( self->target && self->target[0] )
{//Find out next path_corner
self->enemy = G_Find(NULL, FOFS(targetname), self->target);
if(self->enemy)
{
if(self->enemy->radius < 0)
{//Don't bother trying to maintain a radius
self->radius = 0;
self->moveInfo.speed = self->speed/10.0f;
}
else if(self->enemy->radius > 0)
{
self->radius = self->enemy->radius;
}
if(self->enemy->speed < 0)
{//go back to our default speed
self->moveInfo.speed = self->speed/10.0f;
}
else if(self->enemy->speed > 0)
{
self->moveInfo.speed = self->enemy->speed/10.0f;
}
}
}
else
{//stop thinking if this is the last one
self->e_ThinkFunc = thinkF_NULL;
self->e_clThinkFunc = clThinkF_NULL;
self->s.eType = ET_GENERAL;
self->nextthink = -1;
}
}
if(self->enemy)
{//clThink will lerp this
VectorCopy(self->enemy->currentOrigin, self->s.origin2);
}
self->nextthink = level.time + FRAMETIME;
}
void misc_camera_track_use (gentity_t *self, gentity_t *other, gentity_t *activator)
{
G_ActivateBehavior(self,BSET_USE);
//Start thinking
self->e_ThinkFunc = thinkF_misc_camera_track_think;
misc_camera_track_think(self);
self->e_clThinkFunc = clThinkF_CG_MiscCameraTrackThink;
self->s.eType = ET_THINKER;
}
*/
/*QUAK-ED misc_camera_track (0 0 1) (-4 -4 -4) (4 4 4)
The track for a camera to stay on
"targetname" - Use it to get it started on it's path
"target" - First point on it's path - if misc_camera_focus is on a path, it will pick the point on it's path closest to the above calced point
use "path_corner"s - path it should stay on- if that path_corner has a speed value, it will use this as it's speed to the next path_corner
"speed" - How quickly to move, 0 by default
"radius" - How far camera should try to stay from it's subject, default is 0 (dist doesn't matter), can pick this up from a path_corner too
*/
void SP_misc_camera_track (gentity_t *self)
{
if(!self->targetname || !self->targetname[0])
{
gi.Printf(S_COLOR_RED"ERROR: misc_camera_track with no targetname\n");
G_FreeEntity(self);
return;
}
self->script_targetname = G_NewString(self->targetname);
//self->moveInfo.speed = self->speed/10;
// self->e_UseFunc = useF_misc_camera_track_use;
}
//-------------------------------------------------
// Bezier camera stuff
//-------------------------------------------------
void cam_point_link( gentity_t *ent )
{
}
void cam_ctrl_point_link( gentity_t *ent )
{
/* gentity_t *target2 = NULL;
target2 = G_Find( NULL, FOFS(targetname), ent->target2 );
if ( !target2 )
{
// Bah, you fool! Target2 not found
Com_Printf( "cam_point_link: target2 specified but not found: %s\n", ent->target2 );
G_FreeEntity( ent );
return;
}
// Store the control point here
VectorCopy( target2->s.origin, ent->pos1 );
//---------------------
if ( ent->target )
{
gentity_t *target = NULL;
target = G_Find( NULL, FOFS(targetname), ent->target );
if ( !target )
{
// Bah, you fool! Target not found
Com_Printf( "cam_point_link: target specified but not found: %s\n", ent->target );
G_FreeEntity( ent );
return;
}
ent->nextTrain = target;
}
*/
}
/*QUAK-ED cam_point (0.25 0 0.5) (-2 -2 -2) (2 2 2)
Under development -- DONT USE ME!!!!!
A camera point used to construct a camera bezier path
Every cam_point MUST be targeted (target2) at one and only one control point
*/
void SP_cam_point( gentity_t *ent )
{
/* if ( !ent->target2 )
{
// Bah, you fool! Target2 not found so we have no idea how to make the curve
Com_Printf( "cam_point_link: target2 was required but not found\n" );
G_FreeEntity( ent );
return;
}
// The thing we are targeting may not be spawned in yet so, wait a bit to try and link to it
ent->e_ThinkFunc = thinkF_cam_ctrl_point_link;
ent->nextthink = level.time + 200;
// Save our position and link us up!
G_SetOrigin( ent, ent->s.origin );
gi.linkentity( ent );
*/
}