2010-09-09 11:46:38 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
|
|
|
|
#include "CameraView.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "QuakeEd.h"
|
|
|
|
#include "XYView.h"
|
|
|
|
#include "ZView.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
id cameraview_i;
|
2010-09-09 11:46:38 +00:00
|
|
|
extern NSBezierPath *path;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
BOOL timedrawing = 0;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
@implementation CameraView
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
initWithFrame:
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
- initWithFrame:(NSRect)frameRect
|
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int size;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[super initWithFrame: frameRect];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
cameraview_i = self;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
xa = ya = za = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self matrixFromAngles];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
origin[0] = 64;
|
|
|
|
origin[1] = 64;
|
|
|
|
origin[2] = 48;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
move = 16;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
size = _bounds.size.width * _bounds.size.height;
|
2010-09-11 10:03:41 +00:00
|
|
|
zbuffer = malloc (size * 4);
|
|
|
|
imagebuffer = malloc (size * 4);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-23 04:29:12 +00:00
|
|
|
-(void)awakeFromNib
|
|
|
|
{
|
|
|
|
NSBezierPath *path;
|
|
|
|
|
|
|
|
path = zcamera = [NSBezierPath new];
|
|
|
|
[path setLineWidth: 0.3];
|
|
|
|
[path moveToPoint: NSMakePoint (-16, 0)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (16, 8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (16, -8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (-16, -8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (-16, 8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (32, 0)];
|
|
|
|
[path moveToPoint: NSMakePoint (-15, -47)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (29, 0)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (0, 54)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (-29, 0)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (0, -54)];
|
|
|
|
|
|
|
|
path = xycamera = [NSBezierPath new];
|
|
|
|
[path setLineWidth: 0.3];
|
|
|
|
[path moveToPoint: NSMakePoint (-16, 0)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (16, 8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (16, -8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (-16, -8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (-16, 8)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (32, 0)];
|
|
|
|
|
|
|
|
path = xycamera_aim = [NSBezierPath new];
|
|
|
|
[path setLineWidth: 0.3];
|
|
|
|
[path moveToPoint: NSMakePoint (0, 0)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (45, 45)];
|
|
|
|
[path moveToPoint: NSMakePoint (0, 0)];
|
|
|
|
[path relativeLineToPoint: NSMakePoint (45, -45)];
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setXYOrigin:(NSPoint *)pt
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
origin[0] = pt->x;
|
|
|
|
origin[1] = pt->y;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setZOrigin:(float)pt
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
origin[2] = pt;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setOrigin:(vec3_t)org angle:(float)angle
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
VectorCopy (org, origin);
|
|
|
|
ya = angle;
|
|
|
|
[self matrixFromAngles];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-getOrigin:(vec3_t)org
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
VectorCopy (origin, org);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(float)yawAngle
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return ya;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-upFloor:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
sb_floor_dir = 1;
|
|
|
|
sb_floor_dist = 99999;
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i makeAllPerform: @selector (feetToFloor)];
|
|
|
|
if (sb_floor_dist == 99999) {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("already on top floor\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("up floor\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
origin[2] += sb_floor_dist;
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-downFloor:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
sb_floor_dir = -1;
|
|
|
|
sb_floor_dist = -99999;
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i makeAllPerform: @selector (feetToFloor)];
|
|
|
|
if (sb_floor_dist == -99999) {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("already on bottom floor\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("down floor\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
origin[2] += sb_floor_dist;
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
UI TARGETS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
homeView
|
|
|
|
============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-homeView:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
xa = za = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self matrixFromAngles];
|
|
|
|
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("homed view angle\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawMode:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
drawmode =[sender selectedColumn];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateCamera];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setDrawMode:(drawmode_t)mode
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
drawmode = mode;
|
2010-09-11 10:03:41 +00:00
|
|
|
[mode_radio_i selectCellAtRow: 0 column: mode];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateCamera];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
TRANSFORMATION METHODS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-matrixFromAngles
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
if (xa > M_PI * 0.4)
|
|
|
|
xa = M_PI * 0.4;
|
|
|
|
if (xa < -M_PI * 0.4)
|
|
|
|
xa = -M_PI * 0.4;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// vpn
|
2010-09-11 10:03:41 +00:00
|
|
|
matrix[2][0] = cos (xa) * cos (ya);
|
|
|
|
matrix[2][1] = cos (xa) * sin (ya);
|
|
|
|
matrix[2][2] = sin (xa);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// vup
|
|
|
|
matrix[1][0] = cos (xa + M_PI / 2) * cos (ya);
|
|
|
|
matrix[1][1] = cos (xa + M_PI / 2) * sin (ya);
|
|
|
|
matrix[1][2] = sin (xa + M_PI / 2);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// vright
|
|
|
|
CrossProduct (matrix[2], matrix[1], matrix[0]);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-inverseTransform:(vec_t *)invec to:(vec_t *)outvec
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t inverse[3];
|
|
|
|
vec3_t temp;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
for (j = 0; j < 3; j++)
|
2003-03-18 19:48:24 +00:00
|
|
|
inverse[i][j] = matrix[j][i];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
temp[0] = DotProduct (invec, inverse[0]);
|
|
|
|
temp[1] = DotProduct (invec, inverse[1]);
|
|
|
|
temp[2] = DotProduct (invec, inverse[2]);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
VectorAdd (temp, origin, outvec);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
DRAWING METHODS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
typedef struct {
|
|
|
|
vec3_t trans;
|
|
|
|
int clipflags;
|
|
|
|
vec3_t screen; // valid only if clipflags == 0
|
2003-03-18 19:48:24 +00:00
|
|
|
} campt_t;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
#define CLIP_RIGHT 1
|
|
|
|
#define CLIP_LEFT 2
|
|
|
|
#define CLIP_TOP 4
|
|
|
|
#define CLIP_BOTTOM 8
|
|
|
|
#define CLIP_FRONT 16
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
int cam_cur;
|
|
|
|
campt_t campts[2];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t r_matrix[3];
|
|
|
|
vec3_t r_origin;
|
|
|
|
float mid_x, mid_y;
|
|
|
|
float topscale = (240.0 / 3) / 160;
|
|
|
|
float bottomscale = (240.0 * 2 / 3) / 160;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
extern plane_t rfrustum[5];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
MakeCampt (vec3_t in, campt_t * pt)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t temp;
|
|
|
|
float scale;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// transform the points
|
|
|
|
VectorSubtract (in, r_origin, temp);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
pt->trans[0] = DotProduct (temp, r_matrix[0]);
|
|
|
|
pt->trans[1] = DotProduct (temp, r_matrix[1]);
|
|
|
|
pt->trans[2] = DotProduct (temp, r_matrix[2]);
|
|
|
|
|
|
|
|
// check clip flags
|
2003-03-18 19:48:24 +00:00
|
|
|
if (pt->trans[2] < 1)
|
|
|
|
pt->clipflags = CLIP_FRONT;
|
|
|
|
else
|
|
|
|
pt->clipflags = 0;
|
|
|
|
|
|
|
|
if (pt->trans[0] > pt->trans[2])
|
|
|
|
pt->clipflags |= CLIP_RIGHT;
|
|
|
|
else if (-pt->trans[0] > pt->trans[2])
|
|
|
|
pt->clipflags |= CLIP_LEFT;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (pt->trans[1] > pt->trans[2] * topscale)
|
2003-03-18 19:48:24 +00:00
|
|
|
pt->clipflags |= CLIP_TOP;
|
2010-09-11 10:03:41 +00:00
|
|
|
else if (-pt->trans[1] > pt->trans[2] * bottomscale)
|
2003-03-18 19:48:24 +00:00
|
|
|
pt->clipflags |= CLIP_BOTTOM;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (pt->clipflags)
|
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// project
|
2010-09-11 10:03:41 +00:00
|
|
|
scale = mid_x / pt->trans[2];
|
|
|
|
pt->screen[0] = mid_x + pt->trans[0] * scale;
|
|
|
|
pt->screen[1] = mid_y + pt->trans[1] * scale;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
CameraMoveto (vec3_t p)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
campt_t *pt;
|
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
if ([path elementCount] > 2048)
|
2003-03-18 19:48:24 +00:00
|
|
|
lineflush ();
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
pt = &campts[cam_cur];
|
|
|
|
cam_cur ^= 1;
|
2010-09-11 10:03:41 +00:00
|
|
|
MakeCampt (p, pt);
|
2010-09-09 11:46:38 +00:00
|
|
|
if (!pt->clipflags) {
|
|
|
|
// onscreen, so move there immediately
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint point = { pt->screen[0], pt->screen[1] };
|
2010-09-09 11:46:38 +00:00
|
|
|
[path moveToPoint: point];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
ClipLine (vec3_t p1, vec3_t p2, int planenum)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
float d, d2, frac;
|
|
|
|
vec3_t new;
|
|
|
|
plane_t *pl;
|
|
|
|
float scale;
|
|
|
|
NSPoint point;
|
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
if (planenum == 5) {
|
|
|
|
// draw it!
|
2010-09-11 10:03:41 +00:00
|
|
|
scale = mid_x / p1[2];
|
|
|
|
point.x = mid_x + p1[0] * scale;
|
|
|
|
point.y = mid_y + p1[1] * scale;
|
2010-09-09 11:46:38 +00:00
|
|
|
[path moveToPoint: point];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
scale = mid_x / p2[2];
|
|
|
|
point.x = mid_x + p2[0] * scale;
|
|
|
|
point.y = mid_y + p2[1] * scale;
|
2010-09-09 11:46:38 +00:00
|
|
|
[path lineToPoint: point];
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
pl = &rfrustum[planenum];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
d = DotProduct (p1, pl->normal) - pl->dist;
|
2003-03-18 19:48:24 +00:00
|
|
|
d2 = DotProduct (p2, pl->normal) - pl->dist;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (d <= ON_EPSILON && d2 <= ON_EPSILON) { // off screen
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (d >= 0 && d2 >= 0) { // on front
|
|
|
|
ClipLine (p1, p2, planenum + 1);
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
frac = d / (d - d2);
|
|
|
|
new[0] = p1[0] + frac * (p2[0] - p1[0]);
|
|
|
|
new[1] = p1[1] + frac * (p2[1] - p1[1]);
|
|
|
|
new[2] = p1[2] + frac * (p2[2] - p1[2]);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (d > 0)
|
2010-09-11 10:03:41 +00:00
|
|
|
ClipLine (p1, new, planenum + 1);
|
2003-03-18 19:48:24 +00:00
|
|
|
else
|
2010-09-11 10:03:41 +00:00
|
|
|
ClipLine (new, p2, planenum + 1);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
int c_off, c_on, c_clip;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
CameraLineto (vec3_t p)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
campt_t *p1, *p2;
|
|
|
|
int bits;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
p2 = &campts[cam_cur];
|
|
|
|
cam_cur ^= 1;
|
|
|
|
p1 = &campts[cam_cur];
|
|
|
|
MakeCampt (p, p2);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (p1->clipflags & p2->clipflags) {
|
2003-03-18 19:48:24 +00:00
|
|
|
c_off++;
|
2010-09-11 10:03:41 +00:00
|
|
|
return; // entirely off screen
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
bits = p1->clipflags | p2->clipflags;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (!bits) {
|
|
|
|
NSPoint point1 = { p1->screen[0], p1->screen[1] };
|
|
|
|
NSPoint point2 = { p2->screen[0], p2->screen[1] };
|
2003-03-18 19:48:24 +00:00
|
|
|
c_on++;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path moveToPoint: point1];
|
2010-09-09 11:46:38 +00:00
|
|
|
[path lineToPoint: point2];
|
2010-09-11 10:03:41 +00:00
|
|
|
return; // entirely on screen
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
// needs to be clipped
|
|
|
|
c_clip++;
|
|
|
|
|
|
|
|
ClipLine (p1->trans, p2->trans, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
drawSolid
|
|
|
|
=============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawSolid
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
unsigned char *planes[5];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// draw it
|
|
|
|
//
|
|
|
|
VectorCopy (origin, r_origin);
|
|
|
|
VectorCopy (matrix[0], r_matrix[0]);
|
|
|
|
VectorCopy (matrix[1], r_matrix[1]);
|
|
|
|
VectorCopy (matrix[2], r_matrix[2]);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
r_width = _bounds.size.width;
|
|
|
|
r_height = _bounds.size.height;
|
|
|
|
r_picbuffer = imagebuffer;
|
|
|
|
r_zbuffer = zbuffer;
|
|
|
|
|
|
|
|
r_drawflat = (drawmode == dr_flat);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
REN_BeginCamera ();
|
|
|
|
REN_ClearBuffers ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// render the setbrushes
|
2010-09-11 10:03:41 +00:00
|
|
|
//
|
|
|
|
[map_i makeAllPerform: @selector (CameraRenderSelf)];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// display the output
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
[[self window] setBackingType: NSBackingStoreRetained];
|
|
|
|
|
|
|
|
planes[0] = (unsigned char *) imagebuffer;
|
2010-09-11 11:30:01 +00:00
|
|
|
NSDrawBitmap (_bounds, r_width, r_height, 8, 3, 32, r_width * 4, NO, NO,
|
|
|
|
NSCalibratedRGBColorSpace,
|
|
|
|
(const unsigned char **) planes);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[[self window] setBackingType: NSBackingStoreBuffered];
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
drawWire
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawWire:(NSRect)rect
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
// copy current info to globals for the C callbacks
|
2003-03-18 19:48:24 +00:00
|
|
|
mid_x = _bounds.size.width / 2;
|
|
|
|
mid_y = 2 * _bounds.size.height / 3;
|
|
|
|
|
|
|
|
VectorCopy (origin, r_origin);
|
|
|
|
VectorCopy (matrix[0], r_matrix[0]);
|
|
|
|
VectorCopy (matrix[1], r_matrix[1]);
|
|
|
|
VectorCopy (matrix[2], r_matrix[2]);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
r_width = _bounds.size.width;
|
|
|
|
r_height = _bounds.size.height;
|
|
|
|
r_picbuffer = imagebuffer;
|
|
|
|
r_zbuffer = zbuffer;
|
|
|
|
|
|
|
|
REN_BeginCamera ();
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// erase window
|
|
|
|
NSEraseRect (rect);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// draw all entities
|
2010-09-11 10:03:41 +00:00
|
|
|
linestart (0, 0, 0);
|
|
|
|
[map_i makeUnselectedPerform: @selector (CameraDrawSelf)];
|
2003-03-18 19:48:24 +00:00
|
|
|
lineflush ();
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
drawSelf
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) drawRect:(NSRect)rect
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-09 11:46:38 +00:00
|
|
|
float drawtime = 0;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (timedrawing)
|
2010-09-11 10:03:41 +00:00
|
|
|
drawtime = Sys_DoubleTime ();
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-27 10:42:28 +00:00
|
|
|
if (drawmode == dr_texture || drawmode == dr_flat) {
|
|
|
|
[quakeed_i cameraNoRestore: _bounds];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self drawSolid];
|
2010-09-27 10:42:28 +00:00
|
|
|
} else {
|
|
|
|
[quakeed_i cameraNoRestore: rect];
|
|
|
|
[self drawWire: rect];
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (timedrawing) {
|
2010-09-09 11:46:38 +00:00
|
|
|
drawtime = Sys_DoubleTime () - drawtime;
|
2003-03-18 19:48:24 +00:00
|
|
|
printf ("CameraView drawtime: %5.3f\n", drawtime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
XYDrawSelf
|
|
|
|
=============
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) XYDrawSelf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-23 04:29:12 +00:00
|
|
|
NSBezierPath *path;
|
|
|
|
NSAffineTransform *trans;
|
|
|
|
|
|
|
|
[[NSColor blueColor] set];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-23 04:29:12 +00:00
|
|
|
trans = [NSAffineTransform transform];
|
|
|
|
[trans translateXBy: origin[0] yBy: origin[1]];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-23 04:29:12 +00:00
|
|
|
path = [xycamera copy];
|
|
|
|
[path transformUsingAffineTransform: trans];
|
|
|
|
[path stroke];
|
|
|
|
[path release];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-23 04:29:12 +00:00
|
|
|
[trans rotateByRadians: ya];
|
|
|
|
|
|
|
|
path = [xycamera_aim copy];
|
|
|
|
[path transformUsingAffineTransform: trans];
|
|
|
|
[path stroke];
|
|
|
|
[path release];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
ZDrawSelf
|
|
|
|
=============
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) ZDrawSelf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-23 04:29:12 +00:00
|
|
|
NSBezierPath *path;
|
|
|
|
NSAffineTransform *trans;
|
|
|
|
|
|
|
|
[[NSColor blueColor] set];
|
|
|
|
|
|
|
|
trans = [NSAffineTransform transform];
|
|
|
|
[trans translateXBy: 0 yBy: origin[2]];
|
|
|
|
|
|
|
|
path = [zcamera copy];
|
|
|
|
[path transformUsingAffineTransform: trans];
|
|
|
|
[path stroke];
|
|
|
|
[path release];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
XYZ mouse view methods
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
modalMoveLoop
|
|
|
|
================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-modalMoveLoop:(NSPoint *)basept :(vec3_t)movemod :converter
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t originbase;
|
2010-09-11 11:30:01 +00:00
|
|
|
NSEvent *event = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint newpt;
|
|
|
|
vec3_t delta;
|
|
|
|
int i;
|
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("moving camera position\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
VectorCopy (origin, originbase);
|
|
|
|
|
2010-09-26 13:45:26 +00:00
|
|
|
// modal event loop using instance drawing
|
2003-03-18 19:48:24 +00:00
|
|
|
goto drawentry;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
while ([event type] != NSLeftMouseUp &&[event type] != NSRightMouseUp) {
|
2003-03-18 19:48:24 +00:00
|
|
|
// calculate new point
|
2010-09-11 10:03:41 +00:00
|
|
|
newpt =[event locationInWindow];
|
|
|
|
newpt =[converter convertPoint: newpt fromView: NULL];
|
|
|
|
|
|
|
|
delta[0] = newpt.x - basept->x;
|
|
|
|
delta[1] = newpt.y - basept->y;
|
|
|
|
delta[2] = delta[1]; // height change
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
origin[i] = originbase[i] + movemod[i] * delta[i];
|
|
|
|
|
2010-09-11 11:30:01 +00:00
|
|
|
#if 0 // FIXME
|
2003-03-18 19:48:24 +00:00
|
|
|
// if command is down, look towards brush or entity
|
2010-09-11 10:03:41 +00:00
|
|
|
if (event->flags & NS_SHIFTMASK) {
|
2010-09-26 13:45:26 +00:00
|
|
|
NSPoint brushpt;
|
|
|
|
id ent;
|
|
|
|
vec3_t temp;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
ent =[quakemap_i selectedEntity];
|
|
|
|
if (ent) {
|
2003-03-18 19:48:24 +00:00
|
|
|
[ent origin: temp];
|
|
|
|
brushpt.x = temp[0];
|
|
|
|
brushpt.y = temp[1];
|
2010-09-11 10:03:41 +00:00
|
|
|
} else
|
|
|
|
brushpt =[brush_i centerPoint];
|
2003-03-18 19:48:24 +00:00
|
|
|
ya = atan2 (brushpt.y - newpt.y, brushpt.x - newpt.x);
|
|
|
|
[self matrixFromAngles];
|
|
|
|
}
|
|
|
|
#endif
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
drawentry:
|
2003-03-18 19:48:24 +00:00
|
|
|
// instance draw new frame
|
|
|
|
[quakeed_i newinstance];
|
|
|
|
[self display];
|
|
|
|
event = [NSApp nextEventMatchingMask: NSLeftMouseUpMask
|
|
|
|
| NSLeftMouseDraggedMask | NSRightMouseUpMask
|
2010-09-11 10:03:41 +00:00
|
|
|
| NSRightMouseDraggedMask | NSApplicationDefinedMask
|
|
|
|
untilDate: [NSDate distantFuture]
|
|
|
|
inMode: NSEventTrackingRunLoopMode dequeue: YES];
|
|
|
|
if ([event type] == NSKeyDown) {
|
2003-03-18 19:48:24 +00:00
|
|
|
[self _keyDown: event];
|
|
|
|
[self display];
|
|
|
|
goto drawentry;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
XYmouseDown
|
|
|
|
===============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) XYmouseDown:(NSPoint *)pt flags:(int)flags
|
|
|
|
// return YES if brush handled
|
|
|
|
{
|
|
|
|
vec3_t movemod;
|
|
|
|
|
|
|
|
if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16)
|
2003-03-18 19:48:24 +00:00
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (flags & NSAlternateKeyMask) { // up / down drag
|
2003-03-18 19:48:24 +00:00
|
|
|
movemod[0] = 0;
|
|
|
|
movemod[1] = 0;
|
|
|
|
movemod[2] = 1;
|
2010-09-11 10:03:41 +00:00
|
|
|
} else
|
2003-03-18 19:48:24 +00:00
|
|
|
#endif
|
2010-09-11 10:03:41 +00:00
|
|
|
{
|
2003-03-18 19:48:24 +00:00
|
|
|
movemod[0] = 1;
|
|
|
|
movemod[1] = 1;
|
|
|
|
movemod[2] = 0;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self modalMoveLoop: pt : movemod : xyview_i];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
ZmouseDown
|
|
|
|
===============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) ZmouseDown:(NSPoint *)pt flags:(int)flags
|
|
|
|
// return YES if brush handled
|
|
|
|
{
|
|
|
|
vec3_t movemod;
|
|
|
|
|
|
|
|
if (fabs (pt->y - origin[2]) > 16 || pt->x < -8 || pt->x > 8)
|
2003-03-18 19:48:24 +00:00
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
movemod[0] = 0;
|
|
|
|
movemod[1] = 0;
|
|
|
|
movemod[2] = 1;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self modalMoveLoop: pt : movemod : zview_i];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
viewDrag:
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-viewDrag:(NSPoint *)pt
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
float dx, dy;
|
2010-09-11 11:30:01 +00:00
|
|
|
NSEvent *event = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint newpt;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// modal event loop using instance drawing
|
|
|
|
//
|
|
|
|
goto drawentry;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
while ([event type] != NSRightMouseUp) {
|
|
|
|
//
|
2003-03-18 19:48:24 +00:00
|
|
|
// calculate new point
|
2010-09-11 10:03:41 +00:00
|
|
|
//
|
|
|
|
newpt =[event locationInWindow];
|
|
|
|
newpt =[self convertPoint: newpt fromView: NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
dx = newpt.x - pt->x;
|
|
|
|
dy = newpt.y - pt->y;
|
|
|
|
*pt = newpt;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
ya -= dx / _bounds.size.width * M_PI / 2 * 4;
|
|
|
|
xa += dy / _bounds.size.width * M_PI / 2 * 4;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self matrixFromAngles];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
drawentry:
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i newinstance];
|
|
|
|
[self display];
|
2010-09-11 10:03:41 +00:00
|
|
|
event = [NSApp nextEventMatchingMask: NSRightMouseUpMask
|
|
|
|
| NSRightMouseDraggedMask
|
|
|
|
untilDate: [NSDate distantFuture]
|
|
|
|
inMode: NSEventTrackingRunLoopMode dequeue: YES];
|
|
|
|
if ([event type] == NSKeyDown) {
|
|
|
|
[self _keyDown:event];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self display];
|
|
|
|
goto drawentry;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
mouseDown
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-(void) mouseDown:(NSEvent *)theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint pt;
|
|
|
|
int i;
|
|
|
|
vec3_t p1, p2;
|
|
|
|
float forward, right, up;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
|
|
|
|
pt =[self convertPoint: pt fromView: NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
VectorCopy (origin, p1);
|
|
|
|
forward = 160;
|
|
|
|
right = pt.x - 160;
|
2010-09-11 10:03:41 +00:00
|
|
|
up = pt.y - 240 * 2 / 3;
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
p2[i] =
|
|
|
|
forward * matrix[2][i] + up * matrix[1][i] + right * matrix[0][i];
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
p2[i] = p1[i] + 100 * p2[i];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
flags =
|
|
|
|
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
|
|
|
NSAlternateKeyMask | NSCommandKeyMask);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// bare click to select a texture
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == 0) {
|
2003-03-18 19:48:24 +00:00
|
|
|
[map_i getTextureRay: p1 : p2];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// shift click to select / deselect a brush from the world
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == NSShiftKeyMask) {
|
2003-03-18 19:48:24 +00:00
|
|
|
[map_i selectRay: p1 : p2 : NO];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// cmd-shift click to set a target/targetname entity connection
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == (NSShiftKeyMask | NSCommandKeyMask)) {
|
2003-03-18 19:48:24 +00:00
|
|
|
[map_i entityConnect: p1 : p2];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// alt click = set entire brush texture
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == NSAlternateKeyMask) {
|
|
|
|
if (drawmode != dr_texture) {
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Printf ("No texture setting except in texture mode!\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
[map_i setTextureRay: p1 : p2 : YES];
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// ctrl-alt click = set single face texture
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == (NSControlKeyMask | NSAlternateKeyMask)) {
|
|
|
|
if (drawmode != dr_texture) {
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Printf ("No texture setting except in texture mode!\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
[map_i setTextureRay: p1 : p2 : NO];
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
return;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("bad flags for click %x\n", flags);
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
rightMouseDown
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
-(void) rightMouseDown:(NSEvent *)theEvent
|
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint pt;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
pt =[theEvent locationInWindow];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[self convertPoint: pt fromView: NULL];
|
|
|
|
|
|
|
|
flags =
|
|
|
|
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
|
|
|
NSAlternateKeyMask | NSCommandKeyMask);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// click = drag camera
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == 0) {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("looking\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
[self viewDrag: &pt];
|
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("bad flags for click\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
keyDown
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-_keyDown:(NSEvent *)theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-23 08:24:21 +00:00
|
|
|
NSString *chars = [theEvent characters];
|
|
|
|
unichar c = [chars length] == 1 ? [chars characterAtIndex: 0] : '\0';
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-23 08:24:21 +00:00
|
|
|
switch (c) {
|
2010-09-11 10:03:41 +00:00
|
|
|
case 13:
|
|
|
|
return self;
|
|
|
|
|
|
|
|
case 'a':
|
|
|
|
case 'A':
|
|
|
|
xa += M_PI / 8;
|
|
|
|
[self matrixFromAngles];
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
case 'z':
|
|
|
|
case 'Z':
|
|
|
|
xa -= M_PI / 8;
|
|
|
|
[self matrixFromAngles];
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
return self;
|
|
|
|
|
2010-09-23 08:24:21 +00:00
|
|
|
case NSRightArrowFunctionKey:
|
2010-09-11 10:03:41 +00:00
|
|
|
ya -= M_PI * move / (64 * 2);
|
|
|
|
[self matrixFromAngles];
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
2010-09-23 08:24:21 +00:00
|
|
|
case NSLeftArrowFunctionKey:
|
2010-09-11 10:03:41 +00:00
|
|
|
ya += M_PI * move / (64 * 2);
|
|
|
|
[self matrixFromAngles];
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
2010-09-23 08:24:21 +00:00
|
|
|
case NSUpArrowFunctionKey:
|
2010-09-11 10:03:41 +00:00
|
|
|
origin[0] += move * cos (ya);
|
|
|
|
origin[1] += move * sin (ya);
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
2010-09-23 08:24:21 +00:00
|
|
|
case NSDownArrowFunctionKey:
|
2010-09-11 10:03:41 +00:00
|
|
|
origin[0] -= move * cos (ya);
|
|
|
|
origin[1] -= move * sin (ya);
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
origin[0] += move * cos (ya - M_PI_2);
|
|
|
|
origin[1] += move * sin (ya - M_PI_2);
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ',':
|
|
|
|
origin[0] -= move * cos (ya - M_PI_2);
|
|
|
|
origin[1] -= move * sin (ya - M_PI_2);
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
case 'D':
|
|
|
|
origin[2] += move;
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
case 'C':
|
|
|
|
origin[2] -= move;
|
|
|
|
[quakeed_i updateCamera];
|
|
|
|
break;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|